2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #import <Cocoa/Cocoa.h>
23 #include "cheat_global.h"
25 #import "VariableTable.h"
27 #import "MenuExtras.h"
28 #import "StatusTextField.h"
31 #import "SearchData.h"
33 #import "LocalCheater.h"
34 #import "RemoteCheater.h"
37 #import "AppController.h"
40 typedef unsigned TCDocumentMode
;
47 typedef unsigned TCDocumentStatus
;
50 TCSearchingStatus
= 1,
56 @interface CheatDocument
: NSDocument
59 IBOutlet NSWindow
*ibWindow
;
60 IBOutlet NSPopUpButton
*ibServerPopup
;
61 IBOutlet NSPopUpButton
*ibProcessPopup
;
62 IBOutlet NSView
*ibPlaceView
;
63 IBOutlet StatusTextField
*ibStatusText
;
64 IBOutlet NSProgressIndicator
*ibStatusBar
;
66 // SEARCH MODE INTERFACE
67 IBOutlet NSView
*ibSearchContentView
;
68 IBOutlet NSPopUpButton
*ibSearchTypePopup
;
69 IBOutlet NSMatrix
*ibSearchIntegerSignMatrix
;
70 IBOutlet NSPopUpButton
*ibSearchOperatorPopup
;
71 IBOutlet NSMatrix
*ibSearchValueUsedMatrix
;
72 IBOutlet NSTextField
*ibSearchValueField
;
73 IBOutlet VariableTable
*ibSearchVariableTable
;
74 IBOutlet NSButton
*ibSearchClearButton
;
75 IBOutlet NSButton
*ibSearchButton
;
76 IBOutlet NSButton
*ibSearchVariableButton
;
78 // CHEAT MODE INTERFACE
79 IBOutlet NSView
*ibCheatContentView
;
80 IBOutlet NSTextField
*ibCheatInfoText
;
81 IBOutlet BetterTableView
*ibCheatVariableTable
;
82 IBOutlet NSButton
*ibCheatRepeatButton
;
83 IBOutlet NSTextField
*ibCheatRepeatAuxText
;
84 IBOutlet NSTextField
*ibCheatRepeatField
;
85 IBOutlet NSButton
*ibCheatButton
;
87 // PROPERTIES INTERFACE
88 IBOutlet NSWindow
*ibPropertiesSheet
;
89 IBOutlet NSTextField
*ibWindowTitleField
;
90 IBOutlet NSTextField
*ibCheatInfoField
;
93 IBOutlet NSWindow
*ibPasswordSheet
;
94 IBOutlet NSTextField
*ibPasswordField
;
96 // CUSTOM SERVER INTERFACE
97 IBOutlet NSWindow
*ibCustomServerSheet
;
98 IBOutlet NSTextField
*ibServerField
;
99 IBOutlet NSTextField
*ibPortField
;
101 // EDIT VARIABLES INTERFACE
102 IBOutlet NSWindow
*ibEditVariablesSheet
;
103 IBOutlet NSTextField
*ibNewValueField
;
105 NSResponder
*_lastResponder
;
107 // ### IMPORTANT STUFF ###
108 BOOL _connectsOnOpen
; // set whether connects automatically on open
109 TCDocumentMode _mode
; // 'search' or 'cheat' mode
110 FadeView
*_fadeView
; // facilitates the fade animation
112 TCDocumentStatus _status
; // what the user is doing
113 BOOL _isCancelingTask
; // is what the user doing being cancelled
114 BOOL _isTargetPaused
; // is the currently selected process paused
116 id _serverObject
; // the object represented by the current server
117 Process
*_process
; // the currently selected process
119 CheatData
*_cheatData
; // container for the document data
120 SearchData
*_searchData
; // container for the search data
122 Cheater
*_cheater
; // the local or remote object to handle the cheating
124 // rendezvous support
125 NSNetService
*_resolvingService
;
128 // #############################################################################
129 #pragma mark Service Finding
130 // #############################################################################
132 + (NSArray
*)cheatServices
;
134 // #############################################################################
135 #pragma mark Changing Mode
136 // #############################################################################
138 // used to set the mode before the nib is loaded.
139 // do not use after that.
140 - (void)setMode
:(TCDocumentMode
)mode
;
142 // use this after the nib is loaded.
143 - (void)switchToCheatMode
;
144 - (void)switchToSearchMode
;
146 // #############################################################################
147 #pragma mark Accessors
148 // #############################################################################
150 - (NSString
*)defaultStatusString
;
151 - (BOOL
)isLoadedFromFile
;
153 - (void)addServer
:(NSMenuItem
*)item
;
154 - (void)removeServerWithObject
:(id
)serverObject
;
156 // #############################################################################
157 #pragma mark Interface
158 // #############################################################################
160 - (void)updateInterface
;
161 - (void)setDocumentChanged
;
163 - (void)setActualResults
:(unsigned)count
;
165 // #############################################################################
167 // #############################################################################
169 + (void)setGlobalTarget
:(Process
*)target
;
170 + (Process
*)globalTarget
;
172 - (void)showError
:(NSString
*)error
;
174 // this doesn't update the interface
175 // so explicitly call updateInterface after use.
176 - (BOOL
)shouldConnectWithServer
:(NSMenuItem
*)item
;
177 - (void)selectConnectedCheater
;
178 - (void)connectWithServer
:(NSMenuItem
*)item
;
179 - (void)disconnectFromCheater
;
181 - (void)setConnectOnOpen
:(BOOL
)flag
;
182 - (void)connectWithURL
:(NSString
*)url
;
184 - (void)watchVariables
;
190 // #############################################################################
192 @interface
CheatDocument ( DocInterfaceActions
)
194 - (IBAction
)ibSetLocalCheater
:(id
)sender
;
195 - (IBAction
)ibSetRemoteCheater
:(id
)sender
;
196 - (IBAction
)ibSetCustomCheater
:(id
)sender
;
197 - (IBAction
)ibSetNoCheater
:(id
)sender
;
199 - (IBAction
)ibSetProcess
:(id
)sender
;
201 - (IBAction
)ibSetVariableType
:(id
)sender
;
202 - (IBAction
)ibSetIntegerSign
:(id
)sender
;
203 - (IBAction
)ibSetOperator
:(id
)sender
;
204 - (IBAction
)ibSetValueUsed
:(id
)sender
;
206 - (IBAction
)ibClearSearch
:(id
)sender
;
207 - (IBAction
)ibSearch
:(id
)sender
;
208 - (IBAction
)ibAddSearchVariable
:(id
)sender
;
210 - (IBAction
)ibSetCheatRepeats
:(id
)sender
;
211 - (IBAction
)ibSetRepeatInterval
:(id
)sender
;
212 - (IBAction
)ibCheat
:(id
)sender
;
214 - (IBAction
)ibRunPropertiesSheet
:(id
)sender
;
215 - (IBAction
)ibEndPropertiesSheet
:(id
)sender
;
217 - (IBAction
)ibRunPasswordSheet
:(id
)sender
;
218 - (IBAction
)ibEndPasswordSheet
:(id
)sender
;
220 - (IBAction
)ibRunCustomServerSheet
:(id
)sender
;
221 - (IBAction
)ibEndCustomServerSheet
:(id
)sender
;
223 - (IBAction
)ibRunEditVariablesSheet
:(id
)sender
;
224 - (IBAction
)ibEndEditVariablesSheet
:(id
)sender
;
226 - (IBAction
)ibPauseTarget
:(id
)sender
;
227 - (IBAction
)ibResumeTarget
:(id
)sender
;
229 - (IBAction
)ibCancelSearch
:(id
)sender
;
230 - (IBAction
)ibStopCheat
:(id
)sender
;
232 - (IBAction
)ibDumpMemory
:(id
)sender
;
233 - (IBAction
)ibCancelDump
:(id
)sender
;
235 - (IBAction
)ibAddCheatVariable
:(id
)sender
;
236 - (IBAction
)ibSetVariableEnabled
:(id
)sender
;
238 - (IBAction
)ibToggleSearchCheat
:(id
)sender
;
240 - (IBAction
)ibUndo
:(id
)sender
;
241 - (IBAction
)ibRedo
:(id
)sender
;
246 // #############################################################################
248 @interface
CheatDocument ( DocCheaterDelegate
) < CheaterDelegate
>