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
;
35 NSNetServiceBrowser
*browser
;
37 // for updating the interface
42 // list of broadcast servers
43 NSMutableArray
*serverList
;
44 NSMutableArray
*addressList
;
46 TCaddress
*searchResults
;
47 int searchResultsAmount
;
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
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
;
80 IBOutlet NSMenu
*serverMenu
;
81 IBOutlet NSMenu
*processMenu
;
82 IBOutlet NSMenu
*typeMenu
;
83 IBOutlet NSMenu
*stringSizeMenu
;
84 IBOutlet NSMenu
*integerSizeMenu
;
85 IBOutlet NSMenu
*decimalSizeMenu
;
87 // FOR THE CHANGE SHEET
88 IBOutlet NSWindow
*changeSheet
;
89 IBOutlet NSTextField
*changeTextField
;
90 IBOutlet NSButton
*recurringChangeButton
;
91 IBOutlet NSComboBox
*changeSecondsCombo
;
92 IBOutlet NSButton
*cancelButton
;
93 IBOutlet NSButton
*okButton
;
97 - (void)initialInterfaceSetup
;
99 - (void)updateSearchButton
;
100 - (void)updatePauseButton
;
101 - (void)updateSearchBoxes
;
102 - (void)updateChangeButton
;
104 - (void)setStatusDisconnected
;
105 - (void)setStatusConnected
;
106 - (void)setStatusCheating
;
107 - (void)setStatusSearching
;
108 - (void)setStatusChanging
;
109 - (void)setStatusChangingLater
;
110 - (void)setStatusChangingContinuously
;
111 - (void)setStatusUndoing
;
112 - (void)setStatusRedoing
;
113 - (void)setStatusToLast
;
115 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds
;
116 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds color
:(NSColor
*)color
;
117 - (void)statusTextTimer
:(NSTimer
*)timer
;
119 // UPDATE CHANGE SHEET
123 // CONNECT/DISCONNECT TO SERVER
124 - (void)connectToLocal
;
125 - (void)connectToServer
:(NSData
*)addr name
:(NSString
*)name
;
128 // SEND NETWORK MESSAGE
129 - (void)sendProcessListRequest
;
130 - (void)sendClearSearch
;
131 - (void)sendSearch
:(char const *)data size
:(int)size
;
132 - (void)sendChange
:(char const *)data size
:(int)size
;
133 - (void)sendPauseTarget
;
134 - (void)sendVariableValueRequest
;
135 - (void)sendUndoRequest
;
136 - (void)sendRedoRequest
;
137 - (void)sendSetTargetPID
:(int)pid
;
139 // RECEIVED NETWORK MESSAGE
140 - (void)receivedProcessList
:(NSData
*)data
;
141 - (void)receivedSearchFinished
;
142 - (void)receivedVariableList
:(NSData
*)data
;
143 - (void)receivedChangeFinished
;
144 - (void)receivedError
:(NSData
*)data
;
145 - (void)receivedUndoFinished
;
146 - (void)receivedRedoFinished
;
147 - (void)receivedUndoRedoStatus
:(NSData
*)data
;
148 - (void)receivedAppLaunched
:(NSData
*)data
;
149 - (void)receivedAppQuit
:(NSData
*)data
;
150 - (void)receivedTargetQuit
;
151 - (void)receivedPauseFinished
:(NSData
*)data
;
153 // SEARCHING/CHANGING COMMANDS
157 - (void)changeSheet
:(NSWindow
*)sheet returned
:(int)returned context
:(void *)context
;
159 - (void)changeTimer
:(NSTimer
*)timer
;
161 // CHEAT WINDOW INTERFACE
162 - (IBAction
)typePopup
:(id
)sender
;
164 - (IBAction
)searchButton
:(id
)sender
;
165 - (IBAction
)clearSearchButton
:(id
)sender
;
167 - (IBAction
)changeButton
:(id
)sender
;
169 - (IBAction
)serverMenuItem
:(id
)sender
;
170 - (IBAction
)serverMenuDisconnect
:(id
)sender
;
171 - (IBAction
)serverMenuLocal
:(id
)sender
;
172 - (IBAction
)processMenuItem
:(id
)sender
;
174 - (IBAction
)pauseButton
:(id
)sender
;
176 - (IBAction
)undoMenu
:(id
)sender
;
177 - (IBAction
)redoMenu
:(id
)sender
;
179 // CHANGE SHEET INTERFACE
180 - (IBAction
)cancelButton
:(id
)sender
;
181 - (IBAction
)okButton
:(id
)sender
;
183 - (IBAction
)recurringChangeButton
:(id
)sender
;
187 - (void)destroyResults
;
189 // NOTIFICATION SELECTORS
190 - (void)listenerStarted
:(NSNotification
*)note
;
191 - (void)listenerStopped
:(NSNotification
*)note
;
193 - (void)windowsOnTopChanged
:(NSNotification
*)note
;
196 - (void)handleErrorMessage
:(NSString
*)msg fatal
:(BOOL
)fatal
;