From e68904da2ee403030e454bad73cd8dcfe6d3715c Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Sun, 3 Mar 2013 00:39:53 +0000 Subject: 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 --- macosx/CheatController.h | 21 + macosx/CheatController.m | 91 ++++ macosx/English.lproj/CheatWindow.xib | 789 +++++++++++++++++++++++++++++++++ macosx/English.lproj/PCSXR.xib | 56 ++- macosx/Pcsxr.xcodeproj/project.pbxproj | 19 + macosx/PcsxrController.h | 4 + macosx/PcsxrController.m | 26 +- 7 files changed, 986 insertions(+), 20 deletions(-) create mode 100644 macosx/CheatController.h create mode 100644 macosx/CheatController.m create mode 100644 macosx/English.lproj/CheatWindow.xib diff --git a/macosx/CheatController.h b/macosx/CheatController.h new file mode 100644 index 00000000..671f028d --- /dev/null +++ b/macosx/CheatController.h @@ -0,0 +1,21 @@ +// +// CheatController.h +// Pcsxr +// + +#import + +@interface CheatController : NSWindowController +{ + IBOutlet NSTableView *cheatView; +} + +-(IBAction)SaveCheats:(id)sender; +-(IBAction)LoadCheats:(id)sender; +-(IBAction)clear:(id)sender; +-(IBAction)close:(id)sender; + +-(NSInteger)numberOfRowsInTableView:(NSTableView *)view; +-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)idx; +-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; +@end 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 +#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 diff --git a/macosx/English.lproj/CheatWindow.xib b/macosx/English.lproj/CheatWindow.xib new file mode 100644 index 00000000..227fea32 --- /dev/null +++ b/macosx/English.lproj/CheatWindow.xib @@ -0,0 +1,789 @@ + + + + 1070 + 12C60 + 3084 + 1187.34 + 625.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 3084 + + + YES + NSButton + NSButtonCell + NSCustomObject + NSScrollView + NSScroller + NSTableColumn + NSTableHeaderView + NSTableView + NSTextFieldCell + NSView + NSWindowTemplate + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + CheatController + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{196, 153}, {649, 357}} + 1618477056 + Cheats + NSWindow + + + + + 256 + + YES + + + 268 + {{145, 10}, {129, 32}} + + + + YES + + 67108864 + 134217728 + Save Cheats… + + LucidaGrande + 13 + 1044 + + + -2038284288 + 129 + + + 200 + 25 + + NO + + + + 268 + {{14, 10}, {131, 32}} + + + + YES + + 67108864 + 134217728 + Load Cheats… + + + -2038284288 + 129 + + + 200 + 25 + + NO + + + + 268 + + YES + + + 2304 + + YES + + + 256 + {607, 266} + + + + YES + NO + YES + + + 256 + {607, 17} + + + + + + + + -2147483392 + {{224, 0}, {16, 17}} + + + + YES + + COL_ENABLE + 48.40234375 + 40 + 1000 + + 75497536 + 2048 + Enabled + + LucidaGrande + 11 + 3100 + + + 3 + MC4zMzMzMzI5ODU2AA + + + 6 + System + headerTextColor + + 3 + MAA + + + + + 67108864 + 0 + + + + 1211912448 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + 3 + YES + YES + + + + COL_NAME + 552.51953125 + 40 + 1000 + + 75497536 + 2048 + Name + + + + + + 337641536 + 2048 + Text Cell + + + + 6 + System + controlBackgroundColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + 3 + YES + + + + 3 + 2 + + 3 + MQA + + + 6 + System + gridColor + + 3 + MC41AA + + + 17 + 1388314624 + + + 4 + 15 + 0 + NO + 0 + 1 + + + {{1, 17}, {607, 266}} + + + + + + 4 + + + + -2147483392 + {{224, 17}, {15, 102}} + + + + NO + + _doScroller: + 0.93927125506072873 + + + + -2147483392 + {{1, 249}, {607, 15}} + + + + NO + 1 + + _doScroller: + 0.98699186991869914 + + + + 2304 + + YES + + + {{1, 0}, {607, 17}} + + + + + + 4 + + + {{20, 53}, {609, 284}} + + + + 133682 + + + + + QSAAAEEgAABBmAAAQZgAAA + 0.25 + 4 + 1 + + + + 268 + {{539, 10}, {96, 32}} + + + + YES + + 67108864 + 134217728 + Close + + + -2038284288 + 129 + + + 200 + 25 + + NO + + + + 268 + {{462, 10}, {73, 32}} + + + + _NS:9 + YES + + 67108864 + 134217728 + Clear + + _NS:9 + + -2038284288 + 129 + + + 200 + 25 + + NO + + + {649, 357} + + + + + {{0, 0}, {1920, 1058}} + {10000000000000, 10000000000000} + YES + + + + + YES + + + cheatView + + + + 105 + + + + window + + + + 106 + + + + clear: + + + + 109 + + + + close: + + + + 110 + + + + LoadCheats: + + + + 111 + + + + SaveCheats: + + + + 112 + + + + delegate + + + + 108 + + + + dataSource + + + + 107 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + + + + + 4 + + + YES + + + + + + 5 + + + + + 6 + + + YES + + + + + + 7 + + + + + 23 + + + YES + + + + + + + + + 24 + + + + + 25 + + + + + 26 + + + YES + + + + + + + 27 + + + + + 28 + + + YES + + + + + + 29 + + + YES + + + + + + 31 + + + + + 32 + + + + + 33 + + + YES + + + + + + 34 + + + + + 78 + + + YES + + + + + + 79 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 2.IBPluginDependency + 23.IBPluginDependency + 24.IBPluginDependency + 25.IBPluginDependency + 26.IBPluginDependency + 27.IBPluginDependency + 28.IBPluginDependency + 29.IBPluginDependency + 31.IBPluginDependency + 32.IBPluginDependency + 33.IBPluginDependency + 34.IBPluginDependency + 4.IBPluginDependency + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + 78.IBPluginDependency + 79.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{649, 658}, {649, 357}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 112 + + + + YES + + CheatController + NSWindowController + + YES + + YES + LoadCheats: + SaveCheats: + clear: + close: + + + YES + id + id + id + id + + + + YES + + YES + LoadCheats: + SaveCheats: + clear: + close: + + + YES + + LoadCheats: + id + + + SaveCheats: + id + + + clear: + id + + + close: + id + + + + + cheatView + NSTableView + + + cheatView + + cheatView + NSTableView + + + + IBProjectSource + ./Classes/CheatController.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + NSSwitch + {15, 15} + + + diff --git a/macosx/English.lproj/PCSXR.xib b/macosx/English.lproj/PCSXR.xib index dc243086..63ed7ebd 100644 --- a/macosx/English.lproj/PCSXR.xib +++ b/macosx/English.lproj/PCSXR.xib @@ -3,12 +3,12 @@ 1070 12C60 - 2844 + 3084 1187.34 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 2844 + 3084 NSCustomObject @@ -285,6 +285,15 @@ + + + Cheats + c + 1572864 + 2147483647 + + + YES @@ -592,16 +601,7 @@ submenuAction: Menu - - - - Item - - 2147483647 - - - - + @@ -863,6 +863,14 @@ 364 + + + showCheatsWindow: + + + + 373 + pcsxr @@ -1068,6 +1076,7 @@ + @@ -1310,15 +1319,13 @@ 370 - - - + 371 - + @@ -1395,7 +1402,7 @@ - 371 + 373 @@ -1403,6 +1410,7 @@ PcsxrController NSObject + id id id id @@ -1414,8 +1422,13 @@ id id id + id + + cheats: + id + defrost: id @@ -1460,12 +1473,21 @@ runIso: id + + showCheatsWindow: + id + + NSWindow NSWindow RecentItemsMenu + + cheatWindow + NSWindow + preferenceWindow NSWindow diff --git a/macosx/Pcsxr.xcodeproj/project.pbxproj b/macosx/Pcsxr.xcodeproj/project.pbxproj index 7b74caeb..08bef439 100644 --- a/macosx/Pcsxr.xcodeproj/project.pbxproj +++ b/macosx/Pcsxr.xcodeproj/project.pbxproj @@ -79,6 +79,8 @@ 71F4C5AF0FDED12800529849 /* spu.c in Sources */ = {isa = PBXBuildFile; fileRef = 71F4C5860FDED12800529849 /* spu.c */; }; 71F4C5B90FDED16D00529849 /* iR3000A.c in Sources */ = {isa = PBXBuildFile; fileRef = 71F4C5B50FDED16D00529849 /* iR3000A.c */; }; 71F4C5BA0FDED16D00529849 /* ix86.c in Sources */ = {isa = PBXBuildFile; fileRef = 71F4C5B60FDED16D00529849 /* ix86.c */; }; + D422E66E16DC48D000526DCF /* CheatWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = D422E66C16DC48D000526DCF /* CheatWindow.xib */; }; + D422E67A16DC495800526DCF /* CheatController.m in Sources */ = {isa = PBXBuildFile; fileRef = D422E67916DC495800526DCF /* CheatController.m */; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ @@ -354,6 +356,9 @@ 71F4C5B70FDED16D00529849 /* ix86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ix86.h; sourceTree = ""; }; 71F703A611B3A673007DD5C5 /* sjisfont.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = sjisfont.h; sourceTree = ""; }; 71F93F6311FB8E9D007A5A7C /* DFCdrom.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = DFCdrom.xcodeproj; path = plugins/DFCdrom/DFCdrom.xcodeproj; sourceTree = ""; }; + D422E66D16DC48D000526DCF /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/CheatWindow.xib; sourceTree = ""; }; + D422E67816DC495800526DCF /* CheatController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheatController.h; sourceTree = ""; }; + D422E67916DC495800526DCF /* CheatController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheatController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -427,6 +432,7 @@ 2BA178AD0514CE260026D74D /* Resources */ = { isa = PBXGroup; children = ( + D422E66C16DC48D000526DCF /* CheatWindow.xib */, 02FE55E616765F9400205CF2 /* KeyNames.plist */, 2BBB1786051E0D9700B84448 /* Credits.rtf */, 28F0C3C4146521A700A90285 /* Configuration.xib */, @@ -478,6 +484,8 @@ 2BA44361052DB2EA00E21DDD /* PcsxrPlugin.m */, 55A9021E147D7C380037E18F /* PcsxrMemCardController.h */, 55A9021F147D7C380037E18F /* PcsxrMemCardController.m */, + D422E67816DC495800526DCF /* CheatController.h */, + D422E67916DC495800526DCF /* CheatController.m */, 55A90227147D89380037E18F /* PcsxrMemoryObject.h */, 55A90228147D89380037E18F /* PcsxrMemoryObject.m */, 55BBA690149454DE003B2CEC /* PcsxrFileHandle.h */, @@ -791,6 +799,7 @@ 55A90223147D7C7A0037E18F /* MemCardManager.xib in Resources */, 55C7A214148B2B3800C22ABC /* PcsxrMemCardDocument.xib in Resources */, 02FE55E816765F9400205CF2 /* KeyNames.plist in Resources */, + D422E66E16DC48D000526DCF /* CheatWindow.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -850,6 +859,7 @@ 0280B7AD16764CC5007B8001 /* HotkeyController.m in Sources */, 02717968167884C9004AED62 /* hotkeys.m in Sources */, 5529EA11169CBE3400BAA2A5 /* RecentItemsMenu.m in Sources */, + D422E67A16DC495800526DCF /* CheatController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -967,6 +977,15 @@ path = ..; sourceTree = ""; }; + D422E66C16DC48D000526DCF /* CheatWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + D422E66D16DC48D000526DCF /* English */, + ); + name = CheatWindow.xib; + path = ..; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/macosx/PcsxrController.h b/macosx/PcsxrController.h index a6bed84f..1b78dbcf 100755 --- a/macosx/PcsxrController.h +++ b/macosx/PcsxrController.h @@ -6,13 +6,16 @@ #import "RecentItemsMenu.h" @class ConfigurationController; +@class CheatController; @interface PcsxrController : NSObject { ConfigurationController *preferencesController; + CheatController *cheatController; PluginList *pluginList; IBOutlet NSWindow *preferenceWindow; + IBOutlet NSWindow *cheatWindow; IBOutlet RecentItemsMenu *recentItems; BOOL sleepInBackground; @@ -22,6 +25,7 @@ - (IBAction)ejectCD:(id)sender; - (IBAction)pause:(id)sender; +- (IBAction)showCheatsWindow:(id)sender; - (IBAction)preferences:(id)sender; - (IBAction)reset:(id)sender; - (IBAction)runCD:(id)sender; diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index 8ba710c4..387cd029 100755 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -1,6 +1,7 @@ #import #import "PcsxrController.h" #import "ConfigurationController.h" +#import "CheatController.h" #import "EmuThread.h" #import "PcsxrMemCardHandler.h" #import "PcsxrPluginHandler.h" @@ -86,6 +87,21 @@ NSString *saveStatePath; } } +- (IBAction)showCheatsWindow:(id)sender +{ + /* load the nib if it hasn't yet */ + if (cheatWindow == nil) { + if (cheatController == nil) { + cheatController = [[CheatController alloc] initWithWindowNibName:@"CheatWindow"]; + } + cheatWindow = [cheatController window]; + } + + /* show the window */ + //[cheatWindow makeKeyAndOrderFront:sender]; + [cheatController showWindow:sender]; +} + - (IBAction)preferences:(id)sender { /* load the nib if it hasn't yet */ @@ -97,8 +113,8 @@ NSString *saveStatePath; } /* show the window */ - [preferenceWindow makeKeyAndOrderFront:self]; - [preferencesController showWindow:self]; + //[preferenceWindow makeKeyAndOrderFront:sender]; + [preferencesController showWindow:sender]; } - (IBAction)reset:(id)sender @@ -216,6 +232,10 @@ NSString *saveStatePath; if ([preferencesController isMemoryCardWindowVisible] == YES) return NO; } + + if (cheatWindow != nil) + if ([cheatWindow isVisible]) + return NO; if ([menuItem action] == @selector(runBios:) && strcmp(Config.Bios, "HLE") == 0) return NO; @@ -238,7 +258,7 @@ NSString *saveStatePath; [menuItem setState:(sleepInBackground ? NSOnState : NSOffState)]; return YES; } - + return YES; } -- cgit v1.2.3