diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-03-03 00:39:53 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-03-03 00:39:53 +0000 |
| commit | e68904da2ee403030e454bad73cd8dcfe6d3715c (patch) | |
| tree | 048ba3bb5bdf0b6a956826caaa0c9e5dfb0681ba /macosx/CheatController.m | |
| parent | f9a250d60e621b63cc77d432f42ae700ff3e249b (diff) | |
| download | pcsxr-e68904da2ee403030e454bad73cd8dcfe6d3715c.tar.gz | |
Apply patch 13980, with fixes to get it working properly. This allows a cheat interface for OS X.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@83306 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/CheatController.m')
| -rw-r--r-- | macosx/CheatController.m | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/macosx/CheatController.m b/macosx/CheatController.m new file mode 100644 index 00000000..81fe9544 --- /dev/null +++ b/macosx/CheatController.m @@ -0,0 +1,91 @@ +// +// CheatController.m +// Pcsxr +// + +#import <Cocoa/Cocoa.h> +#include "psxcommon.h" +#include "cheat.h" +#import "CheatController.h" +#import "ARCBridge.h" + +@implementation CheatController + +- (id)init +{ + self = [self initWithWindowNibName:@"CheatWindow"]; + return self; +} + +- (void)refresh +{ + [cheatView reloadData]; +} + +- (NSInteger)numberOfRowsInTableView:(NSTableView *)view +{ + return NumCheats; +} + +- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)idx +{ + if (idx >= NumCheats) + return nil; + NSString *ident = [col identifier]; + if ([ident isEqualToString:@"COL_NAME"]) { + return [NSString stringWithCString:Cheats[idx].Descr encoding:NSUTF8StringEncoding]; + } + if ([ident isEqualToString:@"COL_ENABLE"]) { + return [NSNumber numberWithInt: Cheats[idx].Enabled ? NSOnState : NSOffState]; + } + NSLog(@"Unknown column identifier: %@", ident); + return nil; +} + +- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)col row:(NSInteger)row +{ + if (row >= NumCheats) + return; + NSString *ident = [col identifier]; + if ([ident isEqualToString:@"COL_ENABLE"]) { + Cheats[row].Enabled = [object integerValue] == NSOnState; + } +} + +- (IBAction)LoadCheats:(id)sender +{ + NSOpenPanel *openDlg = RETAINOBJ([NSOpenPanel openPanel]); + [openDlg setCanChooseFiles:YES]; + [openDlg setCanChooseDirectories:NO]; + + if ([openDlg runModal] == NSFileHandlingPanelOKButton) { + NSArray *files = [openDlg URLs]; + LoadCheats((const char *)[[[files objectAtIndex:0] path] fileSystemRepresentation]); + [self refresh]; + } + RELEASEOBJ(openDlg); +} + +- (IBAction)SaveCheats:(id)sender +{ + NSSavePanel *saveDlg = RETAINOBJ([NSSavePanel savePanel]); + [saveDlg setPrompt:NSLocalizedString(@"Save Cheats", nil)]; + if ([saveDlg runModal] == NSFileHandlingPanelOKButton) { + NSURL *url = [saveDlg URL]; + SaveCheats((const char *)[[url path] fileSystemRepresentation]); + } + RELEASEOBJ(saveDlg); +} + +- (IBAction)clear:(id)sender +{ + ClearAllCheats(); + [self refresh]; +} + +- (IBAction)close:(id)sender +{ + [[self window] close]; +} + +@end |
