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
;
47 // to allow for connecting on new document
50 // for the status field
51 NSString
*savedStatusText
;
52 NSColor
*savedStatusColor
;
53 NSTimer
*statusTextTimer
;
55 // for updating the interface
56 int undoCount
, redoCount
;
59 // for changing variables every x seconds
61 NSArray
*changeSelectedItems
;
64 IBOutlet NSWindow
*cheatWindow
;
65 IBOutlet NSPopUpButton
*serverPopup
;
66 IBOutlet NSButton
*pauseButton
;
67 IBOutlet NSPopUpButton
*processPopup
;
68 IBOutlet NSPopUpButton
*typePopup
;
69 IBOutlet NSPopUpButton
*sizePopup
;
70 IBOutlet NSTextField
*searchTextField
;
71 IBOutlet NSMatrix
*searchRadioMatrix
;
72 IBOutlet NSButton
*searchButton
;
73 IBOutlet NSButton
*clearSearchButton
;
74 IBOutlet NSButton
*changeButton
;
75 IBOutlet NSTableView
*addressTable
;
76 IBOutlet NSTextField
*statusText
;
77 IBOutlet NSProgressIndicator
*statusBar
;
78 IBOutlet NSTextField
*descriptionText
;
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
;
103 - (void)updateDescriptionText
;
105 - (void)setStatusDisconnected
;
106 - (void)setStatusConnected
;
107 - (void)setStatusCheating
;
108 - (void)setStatusSearching
;
109 - (void)setStatusChanging
;
110 - (void)setStatusChangingLater
;
111 - (void)setStatusChangingContinuously
;
112 - (void)setStatusUndoing
;
113 - (void)setStatusRedoing
;
114 - (void)setStatusToLast
;
116 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds
;
117 - (void)setStatusText
:(NSString
*)msg duration
:(NSTimeInterval
)seconds color
:(NSColor
*)color
;
118 - (void)statusTextTimer
:(NSTimer
*)timer
;
120 // UPDATE CHANGE SHEET
124 // CONNECT/DISCONNECT TO SERVER
125 - (void)connectToLocal
;
126 - (void)connectToServer
:(NSData
*)addr name
:(NSString
*)name
;
129 // SEND NETWORK MESSAGE
130 - (void)sendProcessListRequest
;
131 - (void)sendClearSearch
;
132 - (void)sendSearch
:(char const *)data size
:(int)size
;
133 - (void)sendChange
:(char const *)data size
:(int)size
;
134 - (void)sendPauseTarget
;
135 - (void)sendVariableValueRequest
;
136 - (void)sendUndoRequest
;
137 - (void)sendRedoRequest
;
138 - (void)sendSetTargetPID
:(int)pid
;
140 // RECEIVED NETWORK MESSAGE
141 - (void)receivedProcessList
:(NSData
*)data
;
142 - (void)receivedSearchFinished
;
143 - (void)receivedVariableList
:(NSData
*)data
;
144 - (void)receivedChangeFinished
;
145 - (void)receivedError
:(NSData
*)data
;
146 - (void)receivedUndoFinished
;
147 - (void)receivedRedoFinished
;
148 - (void)receivedUndoRedoStatus
:(NSData
*)data
;
149 - (void)receivedAppLaunched
:(NSData
*)data
;
150 - (void)receivedAppQuit
:(NSData
*)data
;
151 - (void)receivedTargetQuit
;
152 - (void)receivedPauseFinished
:(NSData
*)data
;
154 // SEARCHING/CHANGING COMMANDS
158 - (void)changeSheet
:(NSWindow
*)sheet returned
:(int)returned context
:(void *)context
;
160 - (void)changeTimer
:(NSTimer
*)timer
;
162 // CHEAT WINDOW INTERFACE
163 - (IBAction
)typePopup
:(id
)sender
;
164 - (IBAction
)sizePopup
:(id
)sender
;
166 - (IBAction
)searchButton
:(id
)sender
;
167 - (IBAction
)clearSearchButton
:(id
)sender
;
169 - (IBAction
)changeButton
:(id
)sender
;
171 - (IBAction
)serverMenuItem
:(id
)sender
;
172 - (IBAction
)serverMenuDisconnect
:(id
)sender
;
173 - (IBAction
)serverMenuLocal
:(id
)sender
;
174 - (IBAction
)processMenuItem
:(id
)sender
;
176 - (IBAction
)pauseButton
:(id
)sender
;
178 - (IBAction
)undoMenu
:(id
)sender
;
179 - (IBAction
)redoMenu
:(id
)sender
;
181 // CHANGE SHEET INTERFACE
182 - (IBAction
)cancelButton
:(id
)sender
;
183 - (IBAction
)okButton
:(id
)sender
;
185 - (IBAction
)recurringChangeButton
:(id
)sender
;
189 - (void)destroyResults
;
191 // NOTIFICATION SELECTORS
192 - (void)listenerStarted
:(NSNotification
*)note
;
193 - (void)listenerStopped
:(NSNotification
*)note
;
195 - (void)windowsOnTopChanged
:(NSNotification
*)note
;
198 - (void)handleErrorMessage
:(NSString
*)msg fatal
:(BOOL
)fatal
;