X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=DocInterfaceActions.m;h=b2e120868eb1c99ba5693694456ab48aeaf1976d;hb=refs%2Fheads%2Fyishen;hp=f53ddf3e512aa6a0d612aeb899166c99a49aeae3;hpb=d27548f80fe411fda2ee69c74a24eab4292267e9;p=chaz%2Fthecheat diff --git a/DocInterfaceActions.m b/DocInterfaceActions.m index f53ddf3..b2e1208 100644 --- a/DocInterfaceActions.m +++ b/DocInterfaceActions.m @@ -1,10 +1,14 @@ -// -// DocumentActions.m -// The Cheat -// -// Created by Chaz McGarvey on 12/26/04. -// Copyright 2004 Chaz McGarvey. All rights reserved. -// + +/* + * The Cheat - The legendary universal game trainer for Mac OS X. + * http://www.brokenzipper.com/trac/wiki/TheCheat + * + * Copyright (c) 2003-2011, Charles McGarvey et al. + * + * Distributable under the terms and conditions of the 2-clause BSD + * license; see the file COPYING for the legal text of the license. + */ + #import "CheatDocument.h" @@ -48,7 +52,8 @@ - (IBAction)ibSetRemoteCheater:(id)sender { - ChazLog( @"Selected %@", sender ); + int timeout=5; + ChazLog( @"Selected %@", sender ); if ( ![self shouldConnectWithServer:sender] ) { return; @@ -58,7 +63,7 @@ _resolvingService = [[sender representedObject] retain]; [_resolvingService setDelegate:self]; - [_resolvingService resolve]; + [_resolvingService resolveWithTimeout:timeout]; } - (void)netServiceDidResolveAddress:(NSNetService *)sender @@ -169,6 +174,7 @@ return; } + [_cheatData process]; if ( [_searchData hasSearchedOnce] ) { NSBeginInformationalAlertSheet( @"Confirm target change.", @"OK", @"Cancel", nil, ibWindow, self, NULL, @selector(_confirmTargetChange:returnCode:context:), [[sender representedObject] retain], @@ -234,6 +240,7 @@ // do the search if ( [_searchData valueUsed] == TCGivenValue ) { variable = [[Variable alloc] initWithType:[_searchData variableType] integerSign:[_searchData integerSign]]; + [variable setProcess:_process]; [variable setStringValue:[ibSearchValueField stringValue]]; if ( [variable isValueValid] && [variable valueSize] > 0 ) { _status = TCSearchingStatus; @@ -241,8 +248,9 @@ [ibStatusBar setIndeterminate:NO]; [_searchData setSearchValue:variable]; + [_cheater searchForVariable:variable comparison:[_searchData searchOperator]]; + //[_cheater searchForVariable:[_searchData searchValue] comparison:[_searchData searchOperator]]; [variable release]; - [_cheater searchForVariable:[_searchData searchValue] comparison:[_searchData searchOperator]]; } else { NSBeginAlertSheet( @"Invalid Input", @"OK", nil, nil, ibWindow, nil, NULL, NULL, NULL, @@ -285,25 +293,11 @@ [self switchToCheatMode]; int rowIndex = [_cheatData variableCount]-1; - if ( MacOSXVersion() >= 0x1030 ) { - [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndex:rowIndex] byExtendingSelection:NO]; - } - else { - [ibCheatVariableTable selectRow:rowIndex byExtendingSelection:NO]; - } + [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndex:rowIndex] byExtendingSelection:NO]; // start editing the last added variable if ( [[NSUserDefaults standardUserDefaults] boolForKey:TCAutoStartEditingVarsPref] ) { if ( top > 1 ) { - // edit multiple - if ( MacOSXVersion() >= 0x1030 ) { - [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(rowIndex-top+1,top-1)] - byExtendingSelection:YES]; - } - else { - for ( i = 1; i < top; i++ ) { - [ibCheatVariableTable selectRow:rowIndex-i byExtendingSelection:YES]; - } - } + [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(rowIndex-top+1,top-1)] byExtendingSelection:YES]; [ibCheatVariableTable scrollRowToVisible:rowIndex]; [self ibRunEditVariablesSheet:nil]; } @@ -435,9 +429,8 @@ var = [_cheatData variableAtIndex:row]; - // update fields + // update field [ibNewValueField setStringValue:[var stringValue]]; - [ibVariableEnableButton setState:[var isEnabled]]; // display sheet [NSApp beginSheet:ibEditVariablesSheet modalForWindow:ibWindow modalDelegate:nil didEndSelector:NULL contextInfo:nil]; @@ -446,7 +439,6 @@ - (IBAction)ibEndEditVariablesSheet:(id)sender { NSString *newValue = [ibNewValueField stringValue]; - BOOL enabled = [ibVariableEnableButton state]; NSArray *rows; int i, top; @@ -463,12 +455,12 @@ rows = [ibCheatVariableTable selectedRows]; top = [rows count]; - for ( i = 0; i < top; i++ ) { - Variable *var = [_cheatData variableAtIndex:[[rows objectAtIndex:i] unsignedIntValue]]; - if ( newValue ) { + // change all selected variables with the new value + if ( newValue ) { + for ( i = 0; i < top; i++ ) { + Variable *var = [_cheatData variableAtIndex:[[rows objectAtIndex:i] unsignedIntValue]]; [var setStringValue:newValue]; } - [var setEnabled:enabled]; } [ibCheatVariableTable reloadData]; @@ -531,7 +523,6 @@ - (IBAction)ibAddCheatVariable:(id)sender { ChazLog( @"ibAddCheatVariable:" ); - Variable *var = [[Variable alloc] initWithType:[sender tag]]; // add the new variable to the doc data [_cheatData addVariable:var]; @@ -543,12 +534,7 @@ [self switchToCheatMode]; int row = [_cheatData variableCount]-1; - if ( MacOSXVersion() >= 0x1030 ) { - [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; - } - else { - [ibCheatVariableTable selectRow:row byExtendingSelection:NO]; - } + [ibCheatVariableTable selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; // start editing new variable if ( [[NSUserDefaults standardUserDefaults] boolForKey:TCAutoStartEditingVarsPref] ) { [ibCheatVariableTable editColumn:[ibCheatVariableTable columnWithIdentifier:@"address"] row:row withEvent:nil select:YES];