summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-01 16:50:36 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-01 16:50:36 +0000
commit3c7ad73309303a8899d18c6d9da3f41a0a54da6d (patch)
tree7af9a187734bb7c8b35cd03d7ebf1a6bca26932b
parent7419d226fe6f60a0e8cc850ba646b9388b7c1763 (diff)
downloadpcsxr-3c7ad73309303a8899d18c6d9da3f41a0a54da6d.tar.gz
Some work on OS X's cheat interface.
Use .cht as the file extension for cheats. Create a file handler for cheat files. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86364 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--macosx/CheatController.h2
-rw-r--r--macosx/CheatController.m10
-rw-r--r--macosx/Info.plist32
-rw-r--r--macosx/Pcsxr.xcodeproj/project.pbxproj10
-rw-r--r--macosx/PcsxrCheatHandler.h14
-rw-r--r--macosx/PcsxrCheatHandler.m38
-rwxr-xr-xmacosx/PcsxrController.h1
-rwxr-xr-xmacosx/PcsxrController.m4
-rwxr-xr-xmacosx/hotkeys.m2
9 files changed, 107 insertions, 6 deletions
diff --git a/macosx/CheatController.h b/macosx/CheatController.h
index ab61c6d0..5ddbc1d8 100644
--- a/macosx/CheatController.h
+++ b/macosx/CheatController.h
@@ -10,6 +10,8 @@
IBOutlet NSTableView *cheatView;
}
+- (void)refresh;
+
-(IBAction)SaveCheats:(id)sender;
-(IBAction)LoadCheats:(id)sender;
-(IBAction)clear:(id)sender;
diff --git a/macosx/CheatController.m b/macosx/CheatController.m
index 79a66b26..c011c0c7 100644
--- a/macosx/CheatController.m
+++ b/macosx/CheatController.m
@@ -8,6 +8,7 @@
#include "cheat.h"
#import "CheatController.h"
#import "ARCBridge.h"
+#import "PcsxrCheatHandler.h"
@implementation CheatController
@@ -32,9 +33,9 @@
return nil;
NSString *ident = [col identifier];
if ([ident isEqualToString:@"COL_NAME"]) {
- return [NSString stringWithCString:Cheats[idx].Descr encoding:NSUTF8StringEncoding];
+ return @(Cheats[idx].Descr);
} else if ([ident isEqualToString:@"COL_ENABLE"]) {
- return [NSNumber numberWithInt: Cheats[idx].Enabled ? NSOnState : NSOffState];
+ return @( Cheats[idx].Enabled ? NSOnState : NSOffState);
}
NSLog(@"Unknown column identifier: %@", ident);
return nil;
@@ -58,6 +59,8 @@
NSOpenPanel *openDlg = RETAINOBJ([NSOpenPanel openPanel]);
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
+ [openDlg setAllowsMultipleSelection:YES];
+ [openDlg setAllowedFileTypes:[PcsxrCheatHandler supportedUTIs]];
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
NSArray *files = [openDlg URLs];
@@ -72,6 +75,9 @@
- (IBAction)SaveCheats:(id)sender
{
NSSavePanel *saveDlg = RETAINOBJ([NSSavePanel savePanel]);
+ [saveDlg setAllowedFileTypes:[PcsxrCheatHandler supportedUTIs]];
+ [saveDlg setCanSelectHiddenExtension:YES];
+ [saveDlg setCanCreateDirectories:YES];
[saveDlg setPrompt:NSLocalizedString(@"Save Cheats", nil)];
if ([saveDlg runModal] == NSFileHandlingPanelOKButton) {
NSURL *url = [saveDlg URL];
diff --git a/macosx/Info.plist b/macosx/Info.plist
index 1a34da67..9ad12f1a 100644
--- a/macosx/Info.plist
+++ b/macosx/Info.plist
@@ -119,6 +119,20 @@
<string>public.iso-image</string>
</array>
</dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>cht</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>Playstation Cheat</string>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>LSItemContentTypes</key>
+ <array>
+ <string>com.codeplex.pcsxr.cheat</string>
+ </array>
+ </dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
@@ -237,6 +251,24 @@
</array>
</dict>
</dict>
+ <dict>
+ <key>UTTypeConformsTo</key>
+ <array>
+ <string>public.text</string>
+ <string>public.data</string>
+ </array>
+ <key>UTTypeDescription</key>
+ <string>PCSXR Cheat</string>
+ <key>UTTypeIdentifier</key>
+ <string>com.codeplex.pcsxr.cheat</string>
+ <key>UTTypeTagSpecification</key>
+ <dict>
+ <key>public.filename-extension</key>
+ <array>
+ <string>cht</string>
+ </array>
+ </dict>
+ </dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
diff --git a/macosx/Pcsxr.xcodeproj/project.pbxproj b/macosx/Pcsxr.xcodeproj/project.pbxproj
index 90b764d9..97e81136 100644
--- a/macosx/Pcsxr.xcodeproj/project.pbxproj
+++ b/macosx/Pcsxr.xcodeproj/project.pbxproj
@@ -198,6 +198,7 @@
551A77E61786A4C20052D185 /* libTinySDL.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 551A77C01786A2890052D185 /* libTinySDL.dylib */; };
551A77E71786A4DD0052D185 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 551A76AC178693C60052D185 /* Carbon.framework */; };
5529EA11169CBE3400BAA2A5 /* RecentItemsMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 5550D2721683C923006C56B5 /* RecentItemsMenu.m */; };
+ 5581463917AABCD100862DBF /* PcsxrCheatHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 5581463817AABCD100862DBF /* PcsxrCheatHandler.m */; };
559366CA12B694DF004ACC1E /* iR3000A-64.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C112B694DF004ACC1E /* iR3000A-64.c */; };
559366CB12B694DF004ACC1E /* ix86-64.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C212B694DF004ACC1E /* ix86-64.c */; };
559366CD12B694DF004ACC1E /* ix86_cpudetect.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C512B694DF004ACC1E /* ix86_cpudetect.c */; };
@@ -705,6 +706,8 @@
5539965D178BB1B100859644 /* OSXPlugLocalization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSXPlugLocalization.h; sourceTree = "<group>"; };
5550D2711683C923006C56B5 /* RecentItemsMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RecentItemsMenu.h; sourceTree = "<group>"; };
5550D2721683C923006C56B5 /* RecentItemsMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RecentItemsMenu.m; sourceTree = "<group>"; usesTabs = 1; };
+ 5581463717AABCD100862DBF /* PcsxrCheatHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PcsxrCheatHandler.h; sourceTree = "<group>"; };
+ 5581463817AABCD100862DBF /* PcsxrCheatHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PcsxrCheatHandler.m; sourceTree = "<group>"; };
55858D2817864D140068B8FC /* Pcsxr.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Pcsxr.xcconfig; sourceTree = "<group>"; };
55858D2A17864DC80068B8FC /* Pcsxr-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Pcsxr-Debug.xcconfig"; sourceTree = "<group>"; };
55858D2B17864DC90068B8FC /* Pcsxr-Instrument.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Pcsxr-Instrument.xcconfig"; sourceTree = "<group>"; };
@@ -1724,6 +1727,8 @@
55BBA69814953887003B2CEC /* PcsxrDiscHandler.m */,
55BBA69A14958399003B2CEC /* PcsxrFreezeStateHandler.h */,
55BBA69B1495839A003B2CEC /* PcsxrFreezeStateHandler.m */,
+ 5581463717AABCD100862DBF /* PcsxrCheatHandler.h */,
+ 5581463817AABCD100862DBF /* PcsxrCheatHandler.m */,
);
name = "File Handlers";
sourceTree = "<group>";
@@ -1731,8 +1736,6 @@
557649B71786AF92007C4457 /* Plug-in handling */ = {
isa = PBXGroup;
children = (
- 2B4DE98D05FF9307003EFEF0 /* PluginController.h */,
- 2B4DE98E05FF9307003EFEF0 /* PluginController.m */,
2BBB1126051DC00500B84448 /* PluginList.h */,
2BBB1127051DC00500B84448 /* PluginList.m */,
2BA44360052DB2EA00E21DDD /* PcsxrPlugin.h */,
@@ -1744,6 +1747,8 @@
557649B81786AFB7007C4457 /* Controllers */ = {
isa = PBXGroup;
children = (
+ 2B4DE98D05FF9307003EFEF0 /* PluginController.h */,
+ 2B4DE98E05FF9307003EFEF0 /* PluginController.m */,
2B75FD3C051C56D200D12034 /* PcsxrController.h */,
2B75FD3D051C56D200D12034 /* PcsxrController.m */,
2B75FD4A051C8A7400D12034 /* ConfigurationController.h */,
@@ -2254,6 +2259,7 @@
55EC05FB1788B1230053AC23 /* PcsxrMemCardArray.m in Sources */,
55EC05FE178916E80053AC23 /* MemBadgeView.m in Sources */,
55E0ACE0178B69620005C945 /* LaunchArg.m in Sources */,
+ 5581463917AABCD100862DBF /* PcsxrCheatHandler.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/macosx/PcsxrCheatHandler.h b/macosx/PcsxrCheatHandler.h
new file mode 100644
index 00000000..1dc4fc8e
--- /dev/null
+++ b/macosx/PcsxrCheatHandler.h
@@ -0,0 +1,14 @@
+//
+// PcsxrCheatHandler.h
+// Pcsxr
+//
+// Created by C.W. Betts on 8/1/13.
+//
+//
+
+#import <Foundation/Foundation.h>
+#import "PcsxrFileHandle.h"
+
+@interface PcsxrCheatHandler : NSObject <PcsxrFileHandle>
+
+@end
diff --git a/macosx/PcsxrCheatHandler.m b/macosx/PcsxrCheatHandler.m
new file mode 100644
index 00000000..547b7244
--- /dev/null
+++ b/macosx/PcsxrCheatHandler.m
@@ -0,0 +1,38 @@
+//
+// PcsxrCheatHandler.m
+// Pcsxr
+//
+// Created by C.W. Betts on 8/1/13.
+//
+//
+
+#import "PcsxrCheatHandler.h"
+#import "ARCBridge.h"
+#import "CheatController.h"
+#import "PcsxrController.h"
+#include "psxcommon.h"
+#include "cheat.h"
+
+@implementation PcsxrCheatHandler
+
++ (NSArray *)supportedUTIs
+{
+ static NSArray *utisupport;
+ if (utisupport == nil) {
+ utisupport = @[@"com.codeplex.pcsxr.cheat"];
+ RETAINOBJNORETURN(utisupport);
+ }
+ return utisupport;
+}
+
+- (BOOL)handleFile:(NSString *)theFile
+{
+ LoadCheats([theFile fileSystemRepresentation]);
+
+ if ([(PcsxrController*)[NSApp delegate] cheatController]) {
+ [[(PcsxrController*)[NSApp delegate] cheatController] refresh];
+ }
+ return YES;
+}
+
+@end
diff --git a/macosx/PcsxrController.h b/macosx/PcsxrController.h
index 3510d18b..0e27f075 100755
--- a/macosx/PcsxrController.h
+++ b/macosx/PcsxrController.h
@@ -30,6 +30,7 @@ void ShowHelpAndExit(FILE* output, int exitCode);
NSMutableArray *skipFiles;
}
@property (readonly) RecentItemsMenu *recentItems;
+@property (readonly) CheatController *cheatController;
@property (readonly) BOOL endAtEmuClose;
- (IBAction)ejectCD:(id)sender;
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m
index fc12a98f..f9d8bd38 100755
--- a/macosx/PcsxrController.m
+++ b/macosx/PcsxrController.m
@@ -7,6 +7,7 @@
#import "PcsxrPluginHandler.h"
#import "PcsxrDiscHandler.h"
#import "PcsxrFreezeStateHandler.h"
+#import "PcsxrCheatHandler.h"
#import "LaunchArg.h"
#include "psxcommon.h"
#include "plugins.h"
@@ -56,6 +57,7 @@ void ShowHelpAndExit(FILE* output, int exitCode)
@synthesize recentItems;
@synthesize skipFiles;
+@synthesize cheatController;
- (BOOL)endAtEmuClose
{
@@ -835,7 +837,7 @@ otherblock();\
}
static NSArray *handlers = nil;
if (handlers == nil) {
- handlers = @[[PcsxrPluginHandler class], [PcsxrMemCardHandler class], [PcsxrFreezeStateHandler class], [PcsxrDiscHandler class]];
+ handlers = @[[PcsxrPluginHandler class], [PcsxrMemCardHandler class], [PcsxrFreezeStateHandler class], [PcsxrDiscHandler class], [PcsxrCheatHandler class]];
RETAINOBJNORETURN(handlers);
}
BOOL isHandled = NO;
diff --git a/macosx/hotkeys.m b/macosx/hotkeys.m
index 9ae83047..066ecc1d 100755
--- a/macosx/hotkeys.m
+++ b/macosx/hotkeys.m
@@ -88,7 +88,7 @@ BOOL handleHotkey(NSString* keyCode) {
void setupHotkey(int hk, NSString *label, NSDictionary *binding) {
if(binding != nil)
- [hotkeys setObject:[NSNumber numberWithInt:hk] forKey:[binding objectForKey:@"keyCode"]];
+ [hotkeys setObject:@(hk) forKey:[binding objectForKey:@"keyCode"]];
}
void setupHotkeys() {