2 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // File: SessionController.h
6 // Created: Sun Sep 07 2003
8 // Copyright: 2003 Chaz McGarvey. All rights reserved.
9 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 #import <Cocoa/Cocoa.h>
16 #import "ClientDelegate.h"
18 #import "MenuExtras.h"
20 #include "cheat_types.h"
21 #include "cheat_globals.h"
22 #include "cheat_net.h"
25 @interface SessionController
: NSWindowController
< ClientDelegate
>
27 // allows for easy interface updating
28 TCstatus status
, lastStatus
;
30 // dealing with connecting
31 BOOL waitingToConnect
;
32 NSConnection
*connection
;
33 NSData
*connectionAddress
;
34 NSString
*connectionName
;
37 // for updating the interface
43 NSMutableArray
*addressList
;
45 TCaddress
*searchResults
;
46 int searchResultsAmount
;
47 int searchResultsAmountDisplayed
;
49 // to allow for connecting on new document
52 // for the status field
53 NSString
*savedStatusText
;
54 NSColor
*savedStatusColor
;
55 NSTimer
*statusTextTimer
;
57 // for updating the interface
58 int undoCount
, redoCount
;
61 // for changing variables every x seconds
63 NSArray
*changeSelectedItems
;
66 IBOutlet NSWindow
*cheatWindow
;
67 IBOutlet NSPopUpButton
*serverPopup
;
68 IBOutlet NSButton
*pauseButton
;
69 IBOutlet NSPopUpButton
*processPopup
;
70 IBOutlet NSPopUpButton
*typePopup
;
71 IBOutlet NSPopUpButton
*sizePopup
;
72 IBOutlet NSTextField
*searchTextField
;
73 IBOutlet NSMatrix
*searchRadioMatrix
;
74 IBOutlet NSButton
*searchButton
;
75 IBOutlet NSButton
*clearSearchButton
;
76 IBOutlet NSButton
*changeButton
;
77 IBOutlet NSTableView
*addressTable
;
78 IBOutlet CMStatusView
*statusText
;
79 IBOutlet NSProgressIndicator
*statusBar
;
80 IBOutlet NSTextField
*descriptionText
;
82 IBOutlet NSMenu
*serverMenu
;
83 IBOutlet NSMenu
*processMenu
;
84 IBOutlet NSMenu
*typeMenu
;
85 IBOutlet NSMenu
*stringSizeMenu
;
86 IBOutlet NSMenu
*integerSizeMenu
;
87 IBOutlet NSMenu
*decimalSizeMenu
;
89 // FOR THE CHANGE SHEET
90 IBOutlet NSWindow
*changeSheet
;
91 IBOutlet NSTextField
*changeTextField
;
92 IBOutlet NSButton
*recurringChangeButton
;
93 IBOutlet NSComboBox
*changeSecondsCombo
;
94 IBOutlet NSButton
*cancelButton
;
95 IBOutlet NSButton
*okButton
;
99 - (void)initialInterfaceSetup
;
101 - (void)updateSearchButton
;
102 - (void)updatePauseButton
;
103 - (void)updateSearchBoxes
;
104 - (void)updateChangeButton
;
105 - (void)updateDescriptionText
;
107 - (void)setStatusDisconnected
;
108 - (void)setStatusConnected
;
109 - (void)setStatusCheating
;
110 - (void)setStatusSearching
;
111 - (void)setStatusChanging
;
112 - (void)setStatusChangingLater
;
113 - (void)setStatusChangingContinuously
;
114 - (void)setStatusUndoing
;
115 - (void)setStatusRedoing
;
116 //- (void)setStatusToLast;
118 //- (void)setStatusText:(NSString *)msg duration:(NSTimeInterval)seconds;
119 //- (void)setStatusText:(NSString *)msg duration:(NSTimeInterval)seconds color:(NSColor *)color;
120 //- (void)statusTextTimer:(NSTimer *)timer;
122 // UPDATE CHANGE SHEET
126 // CONNECT/DISCONNECT TO SERVER
127 - (void)connectToLocal
;
128 - (void)connectToServer
:(NSData
*)addr name
:(NSString
*)name
;
131 // SEND NETWORK MESSAGE
132 - (void)sendProcessListRequest
;
133 - (void)sendClearSearch
;
134 - (void)sendSearch
:(char const *)data size
:(int)size
;
135 - (void)sendChange
:(char const *)data size
:(int)size
;
136 - (void)sendPauseTarget
;
137 - (void)sendVariableValueRequest
;
138 - (void)sendUndoRequest
;
139 - (void)sendRedoRequest
;
140 - (void)sendSetTargetPID
:(int)pid
;
142 // RECEIVED NETWORK MESSAGE
143 - (void)receivedProcessList
:(NSData
*)data
;
144 - (void)receivedSearchFinished
;
145 - (void)receivedVariableList
:(NSData
*)data
;
146 - (void)receivedChangeFinished
;
147 - (void)receivedError
:(NSData
*)data
;
148 - (void)receivedUndoFinished
;
149 - (void)receivedRedoFinished
;
150 - (void)receivedUndoRedoStatus
:(NSData
*)data
;
151 - (void)receivedAppLaunched
:(NSData
*)data
;
152 - (void)receivedAppQuit
:(NSData
*)data
;
153 - (void)receivedTargetQuit
;
154 - (void)receivedPauseFinished
:(NSData
*)data
;
156 // SEARCHING/CHANGING COMMANDS
160 - (void)changeSheet
:(NSWindow
*)sheet returned
:(int)returned context
:(void *)context
;
162 - (void)changeTimer
:(NSTimer
*)timer
;
164 // CHEAT WINDOW INTERFACE
165 - (IBAction
)typePopup
:(id
)sender
;
166 - (IBAction
)sizePopup
:(id
)sender
;
168 - (IBAction
)searchButton
:(id
)sender
;
169 - (IBAction
)clearSearchButton
:(id
)sender
;
171 - (IBAction
)changeButton
:(id
)sender
;
173 - (IBAction
)serverMenuItem
:(id
)sender
;
174 - (IBAction
)serverMenuDisconnect
:(id
)sender
;
175 - (IBAction
)serverMenuLocal
:(id
)sender
;
176 - (IBAction
)processMenuItem
:(id
)sender
;
178 - (IBAction
)pauseButton
:(id
)sender
;
180 - (IBAction
)undoMenu
:(id
)sender
;
181 - (IBAction
)redoMenu
:(id
)sender
;
183 // CHANGE SHEET INTERFACE
184 - (IBAction
)cancelButton
:(id
)sender
;
185 - (IBAction
)okButton
:(id
)sender
;
187 - (IBAction
)recurringChangeButton
:(id
)sender
;
191 - (void)destroyResults
;
193 // NOTIFICATION SELECTORS
194 - (void)listenerStarted
:(NSNotification
*)note
;
195 - (void)listenerStopped
:(NSNotification
*)note
;
197 - (void)windowsOnTopChanged
:(NSNotification
*)note
;
200 - (void)handleErrorMessage
:(NSString
*)msg fatal
:(BOOL
)fatal
;