2 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 // Created: Sun Sep 07 2003
8 // Copyright: 2003 Chaz McGarvey. All rights reserved.
9 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 #import <Cocoa/Cocoa.h>
15 #import "ClientDelegate.h"
17 #import "MenuExtras.h"
19 #include "cheat_types.h"
20 #include "cheat_globals.h"
21 #include "cheat_net.h"
24 @interface MyDocument
: NSDocument
< ClientDelegate
>
26 // allows for easy interface updating
27 TCstatus status
, lastStatus
;
29 // dealing with connecting
30 BOOL waitingToConnect
;
31 NSConnection
*connection
;
32 NSData
*connectionAddress
;
33 NSString
*connectionName
;
36 // for updating the interface
42 NSMutableArray
*addressList
;
44 TCaddress
*searchResults
;
45 int searchResultsAmount
;
46 int maxSearchResultsAmount
;
48 // to allow for connecting on new document
51 // for the status field
52 NSString
*savedStatusText
;
53 NSColor
*savedStatusColor
;
54 NSTimer
*statusTextTimer
;
56 // for updating the interface
57 int undoCount
, redoCount
;
60 // for changing variables every x seconds
62 NSArray
*changeSelectedItems
;
65 IBOutlet NSWindow
*cheatWindow
;
66 IBOutlet NSPopUpButton
*serverPopup
;
67 IBOutlet NSButton
*pauseButton
;
68 IBOutlet NSPopUpButton
*processPopup
;
69 IBOutlet NSPopUpButton
*typePopup
;
70 IBOutlet NSPopUpButton
*sizePopup
;
71 IBOutlet NSTextField
*searchTextField
;
72 IBOutlet NSMatrix
*searchRadioMatrix
;
73 IBOutlet NSButton
*searchButton
;
74 IBOutlet NSButton
*clearSearchButton
;
75 IBOutlet NSButton
*changeButton
;
76 IBOutlet NSTableView
*addressTable
;
77 IBOutlet NSTextField
*statusText
;
78 IBOutlet NSProgressIndicator
*statusBar
;
79 IBOutlet NSTextField
*descriptionText
;
81 IBOutlet NSMenu
*serverMenu
;
82 IBOutlet NSMenu
*processMenu
;
83 IBOutlet NSMenu
*typeMenu
;
84 IBOutlet NSMenu
*stringSizeMenu
;
85 IBOutlet NSMenu
*integerSizeMenu
;
86 IBOutlet NSMenu
*decimalSizeMenu
;
88 // FOR THE CHANGE SHEET
89 IBOutlet NSWindow
*changeSheet
;
90 IBOutlet NSTextField
*changeTextField
;
91 IBOutlet NSButton
*recurringChangeButton
;
92 IBOutlet NSComboBox
*changeSecondsCombo
;
93 IBOutlet NSButton
*cancelButton
;
94 IBOutlet NSButton
*okButton
;
98 - (void)initialInterfaceSetup
;
100 - (void)updateSearchButton
;
101 - (void)updatePauseButton
;
102 - (void)updateSearchBoxes
;
103 - (void)updateChangeButton
;
104 - (void)updateDescriptionText
;
106 - (void)setStatusDisconnected
;
107 - (void)setStatusConnected
;
108 - (void)setStatusCheating
;
109 - (void)setStatusSearching
;
110 - (void)setStatusChanging
;
111 - (void)setStatusChangingLater
;
112 - (void)setStatusChangingContinuously
;
113 - (void)setStatusUndoing
;
114 - (void)setStatusRedoing
;
115 - (void)setStatusToLast
;
117 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds
;
118 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds color
:(NSColor
*)color
;
119 - (void)statusTextTimer
:(NSTimer
*)timer
;
121 // UPDATE CHANGE SHEET
125 // CONNECT/DISCONNECT TO SERVER
126 - (void)connectToLocal
;
127 - (void)connectToServer
:(NSData
*)addr name
:(NSString
*)name
;
130 // SEND NETWORK MESSAGE
131 - (void)sendProcessListRequest
;
132 - (void)sendClearSearch
;
133 - (void)sendSearch
:(char const *)data size
:(int)size
;
134 - (void)sendChange
:(char const *)data size
:(int)size
;
135 - (void)sendPauseTarget
;
136 - (void)sendVariableValueRequest
;
137 - (void)sendUndoRequest
;
138 - (void)sendRedoRequest
;
139 - (void)sendSetTargetPID
:(int)pid
;
141 // RECEIVED NETWORK MESSAGE
142 - (void)receivedProcessList
:(NSData
*)data
;
143 - (void)receivedSearchFinished
;
144 - (void)receivedVariableList
:(NSData
*)data
;
145 - (void)receivedChangeFinished
;
146 - (void)receivedError
:(NSData
*)data
;
147 - (void)receivedUndoFinished
;
148 - (void)receivedRedoFinished
;
149 - (void)receivedUndoRedoStatus
:(NSData
*)data
;
150 - (void)receivedAppLaunched
:(NSData
*)data
;
151 - (void)receivedAppQuit
:(NSData
*)data
;
152 - (void)receivedTargetQuit
;
153 - (void)receivedPauseFinished
:(NSData
*)data
;
155 // SEARCHING/CHANGING COMMANDS
159 - (void)changeSheet
:(NSWindow
*)sheet returned
:(int)returned context
:(void *)context
;
161 - (void)changeTimer
:(NSTimer
*)timer
;
163 // CHEAT WINDOW INTERFACE
164 - (IBAction
)typePopup
:(id
)sender
;
165 - (IBAction
)sizePopup
:(id
)sender
;
167 - (IBAction
)searchButton
:(id
)sender
;
168 - (IBAction
)clearSearchButton
:(id
)sender
;
170 - (IBAction
)changeButton
:(id
)sender
;
172 - (IBAction
)serverMenuItem
:(id
)sender
;
173 - (IBAction
)serverMenuDisconnect
:(id
)sender
;
174 - (IBAction
)serverMenuLocal
:(id
)sender
;
175 - (IBAction
)processMenuItem
:(id
)sender
;
177 - (IBAction
)pauseButton
:(id
)sender
;
179 - (IBAction
)undoMenu
:(id
)sender
;
180 - (IBAction
)redoMenu
:(id
)sender
;
182 // CHANGE SHEET INTERFACE
183 - (IBAction
)cancelButton
:(id
)sender
;
184 - (IBAction
)okButton
:(id
)sender
;
186 - (IBAction
)recurringChangeButton
:(id
)sender
;
190 - (void)destroyResults
;
192 // NOTIFICATION SELECTORS
193 - (void)listenerStarted
:(NSNotification
*)note
;
194 - (void)listenerStopped
:(NSNotification
*)note
;
196 - (void)windowsOnTopChanged
:(NSNotification
*)note
;
199 - (void)handleErrorMessage
:(NSString
*)msg fatal
:(BOOL
)fatal
;