summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-12-30 20:15:56 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-12-30 20:15:56 +0000
commitd4da70307ee50ee5d16715942f5cf218f76b3040 (patch)
treef2f7d93af4d100af040f71d4f25ba934363cfa6b
parent46e82c8e70678600bc55eea5b3c442ecafd8b147 (diff)
downloadpcsxr-d4da70307ee50ee5d16715942f5cf218f76b3040.tar.gz
Better checking if we are launched from the Finder if we are on Mavericks. Code adapted from the 1.2 fork of SDL.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@88202 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--macosx/English.lproj/zh-Hans.lproj/Localizable.strings10
-rwxr-xr-xmacosx/PcsxrController.h1
-rwxr-xr-xmacosx/PcsxrController.m63
-rwxr-xr-xmacosx/main.m45
4 files changed, 84 insertions, 35 deletions
diff --git a/macosx/English.lproj/zh-Hans.lproj/Localizable.strings b/macosx/English.lproj/zh-Hans.lproj/Localizable.strings
index 28bccab5..9d63853d 100644
--- a/macosx/English.lproj/zh-Hans.lproj/Localizable.strings
+++ b/macosx/English.lproj/zh-Hans.lproj/Localizable.strings
@@ -6,6 +6,8 @@
Copyright 2011 __MyCompanyName__. All rights reserved.
*/
+//Commented out strings are those that need to be translated
+
//libpcsxrcore strings
"Error Opening CDR Plugin" = "打开CDR插件时发生错误";
"Error Opening SPU Plugin" = "打开SPU插件时发生错误";
@@ -103,6 +105,14 @@
//not-so-general buttons
//"Show Folder" = "Show Folder";
+//BIOS file opener
+"PlayStation BIOS File" = "PlayStation BIOS 映像";
+//"The file \"%@\" seems to be a BIOS file. Do you want PCSX-R to copy it to the proper location?" = "The file “%1$@\” seems to be a BIOS file. Do you want PCSX-R to copy it to the proper location?";
+//"BIOS_Copy" = "Copy";
+//"BIOS_Move" = "Move";
+//"BIOS Already Exists" = "BIOS Already Exists";
+//"There already exists a BIOS file at \"%1$@\": not copying the file at \"%2$@\".\n\nIf you do want to use the BIOS file at \"%2$@\", delete the BIOS at \"%1$@\"." = "There already exists a BIOS file at “%1$@”: not copying the file at “%2$@”.\n\nIf you do want to use the BIOS file at “%2$@”, delete the BIOS at “%1$@”.";
+
//Mem card flags
"MemCard_Deleted" = "删除";
"MemCard_Free" = "可用";
diff --git a/macosx/PcsxrController.h b/macosx/PcsxrController.h
index cb2a902f..3c9e6c27 100755
--- a/macosx/PcsxrController.h
+++ b/macosx/PcsxrController.h
@@ -9,6 +9,7 @@
@class CheatController;
void ShowHelpAndExit(FILE* output, int exitCode);
+extern BOOL wasFinderLaunch;
@interface PcsxrController : NSObject <NSApplicationDelegate>
{
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m
index f44c0976..ca920806 100755
--- a/macosx/PcsxrController.m
+++ b/macosx/PcsxrController.m
@@ -17,24 +17,29 @@
#include "cdrom.h"
#include "ExtendedKeys.h"
-NSDictionary *prefStringKeys;
-NSDictionary *prefByteKeys;
-NSDictionary *prefURLKeys;
-NSMutableArray *biosList;
-NSString *saveStatePath;
+NSDictionary *prefStringKeys = nil;
+NSDictionary *prefByteKeys = nil;
+NSDictionary *prefURLKeys = nil;
+NSMutableArray *biosList = nil;
+NSString *saveStatePath = nil;
+BOOL wasFinderLaunch = NO;
+
#define HELPSTR "\n" \
-"At least one of these must be passed:\n"\
-"\t--iso path \tlaunch with selected ISO\n" \
-"\t--cdrom \tlaunch with a CD-ROM\n" \
-"\t--bios \tlaunch into the BIOS\n\n" \
+"At least one of these must be passed:\n" \
+"\t--iso path launch with selected ISO\n" \
+"\t--cdrom launch with a CD-ROM\n" \
+"\t--bios launch into the BIOS\n" \
+"\n" \
"Additional options:\n" \
-"\t--exitAtClose \tcloses PCSX-R at when the emulation has ended\n" \
-"\t--mcd1 path \tsets the fist memory card to path\n" \
-"\t--mcd2 path \tsets the second memory card to path\n" \
-"\t--freeze path \tloads freeze state from path\n\n" \
+"\t--exitAtClose closes PCSX-R at when the emulation has ended\n" \
+"\t--mcd1 path sets the fist memory card to path\n" \
+"\t--mcd2 path sets the second memory card to path\n" \
+"\t--freeze path loads freeze state from path\n" \
+"\n" \
"Help:\n" \
-"\t--help \tshows this message\n\n" \
+"\t--help shows this message\n" \
+"\n" \
void ShowHelpAndExit(FILE* output, int exitCode)
@@ -446,36 +451,36 @@ otherblock();\
- (void)awakeFromNib
{
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(emuWindowDidClose:)
- name:@"emuWindowDidClose" object:nil];
-
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(emuWindowDidClose:)
+ name:@"emuWindowDidClose" object:nil];
+
pluginList = [[PluginList alloc] init];
if (![pluginList configured] /*!Config.Gpu[0] || !Config.Spu[0] || !Config.Pad1[0] || !Config.Cdr[0]*/) {
// configure plugins
[self preferences:nil];
-
+
NSRunCriticalAlertPanel(NSLocalizedString(@"Missing plugins!", nil),
- NSLocalizedString(@"Pcsxr is missing one or more critical plugins. You will need to install these in order to play games.", nil),
- nil, nil, nil);
+ NSLocalizedString(@"Pcsxr is missing one or more critical plugins. You will need to install these in order to play games.", nil),
+ nil, nil, nil);
}
-
+
if (![PcsxrController biosAvailable]) {
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *supportURL = [manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
NSURL *biosURL = [[supportURL URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"Bios"];
NSInteger retVal = NSRunInformationalAlertPanel(NSLocalizedString(@"Missing BIOS!", nil),
- NSLocalizedString(@"Pcsxr wasn't able to locate any Playstation BIOS ROM files. This means that it will run in BIOS simulation mode which is less stable and compatible than using a real Playstation BIOS.\nIf you have a BIOS available, please copy it to\n%@", nil),
- NSLocalizedString(@"Okay", @"OK"), NSLocalizedString(@"Show Folder", @"Show Folder"), nil, [[biosURL path] stringByAbbreviatingWithTildeInPath]);
+ NSLocalizedString(@"Pcsxr wasn't able to locate any Playstation BIOS ROM files. This means that it will run in BIOS simulation mode which is less stable and compatible than using a real Playstation BIOS.\nIf you have a BIOS available, please copy it to\n%@", nil),
+ NSLocalizedString(@"Okay", @"OK"), NSLocalizedString(@"Show Folder", @"Show Folder"), nil, [[biosURL path] stringByAbbreviatingWithTildeInPath]);
if (retVal == NSAlertAlternateReturn) {
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[biosURL]];
}
}
-
+
self.sleepInBackground = [[NSUserDefaults standardUserDefaults] boolForKey:@"PauseInBackground"];
NSArray *progArgs = [[NSProcessInfo processInfo] arguments];
- if ([progArgs count] > 1 && ![progArgs[1] hasPrefix:@"-psn"]) {
+ if ([progArgs count] > 1 && !wasFinderLaunch) {
self.skipFiles = [NSMutableArray array];
BOOL isLaunchable = NO;
@@ -551,7 +556,7 @@ otherblock();\
}];
[larg addToDictionary:argDict];
};
-
+
BOOL hasFileTestBlock = NO;
for (__block int i = 1; i < [progArgs count]; i++) {
@@ -573,7 +578,7 @@ otherblock();\
hasFileTestBlock = YES;
}
- //DO NOT END these MACROS WITH A SIMICOLON! it will break the if-else if process
+ //DO NOT END these MACROS WITH A SIMICOLON! It will break the if-else if process
HandleArg(kPCSXRArgumentISO, YES, isoBlock)
HandleArgElse(kPCSXRArgumentCDROM, YES, cdromBlock)
HandleArgElse(kPCSXRArgumentBIOS, YES, biosBlock)
@@ -586,7 +591,7 @@ otherblock();\
}
}
#ifdef DEBUG
- if ([unknownOptions count]) {
+ if ([unknownOptions count]) {
NSString *unknownString = [unknownOptions componentsJoinedByString:@" "];
NSLog(@"The following options weren't recognized by PCSX-R: %@. This may be due to extra arguments passed by the OS or debugger.", unknownString);
diff --git a/macosx/main.m b/macosx/main.m
index 7d37a57b..ff44be8f 100755
--- a/macosx/main.m
+++ b/macosx/main.m
@@ -16,6 +16,10 @@
#include <IOKit/pwr_mgt/IOPMLib.h>
#import "hotkeys.h"
+#ifndef NSFoundationVersionNumber10_8_4
+#define NSFoundationVersionNumber10_8_4 945.18
+#endif
+
static inline void RunOnMainThreadSync(dispatch_block_t block)
{
if ([NSThread isMainThread]) {
@@ -31,14 +35,43 @@ static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
void PADhandleKey(int key);
+static inline BOOL IsRootCwd()
+{
+ char buf[MAXPATHLEN];
+ char *cwd = getcwd(buf, sizeof(buf));
+ return (cwd && (strcmp(cwd, "/") == 0));
+}
+
+static inline BOOL IsTenPointNineOrLater()
+{
+ int curFoundNum = floor(NSFoundationVersionNumber), tenPointEightFoundNum = floor(NSFoundationVersionNumber10_8_4);
+ return curFoundNum > tenPointEightFoundNum;
+}
+
+static BOOL IsFinderLaunch(const int argc, const char **argv)
+{
+ BOOL isNewerOS = IsTenPointNineOrLater();
+ /* -psn_XXX is passed if we are launched from Finder in 10.8 and earlier */
+ if ( (!isNewerOS) && (argc >= 2) && (strncmp(argv[1], "-psn", 4) == 0) ) {
+ return YES;
+ } else if ((isNewerOS) && (argc == 1) && IsRootCwd()) {
+ /* we might still be launched from the Finder; on 10.9+, you might not
+ get the -psn command line anymore. Check version, if there's no
+ command line, and if our current working directory is "/". */
+ return YES;
+ }
+ return NO; /* not a Finder launch. */
+}
+
int main(int argc, const char *argv[])
{
- if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
+ if (argc >= 2 && IsFinderLaunch(argc, argv)) {
+ wasFinderLaunch = YES;
char parentdir[MAXPATHLEN];
char *c;
- strlcpy ( parentdir, argv[0], sizeof(parentdir) );
- c = (char*) parentdir;
+ strlcpy(parentdir, argv[0], sizeof(parentdir));
+ c = (char*)parentdir;
while (*c != '\0') /* go to end */
c++;
@@ -48,8 +81,8 @@ int main(int argc, const char *argv[])
*c++ = '\0'; /* cut off last part (binary name) */
- assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
- assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
+ assert(chdir(parentdir) == 0); /* chdir to the binary app's parent */
+ assert(chdir("../../../") == 0); /* chdir to the .app's parent */
} else {
for (int i = 1; i < argc; i++) {
//All the other option will be handled in the app delegate's awakeFromNib
@@ -83,7 +116,7 @@ int SysInit()
//We use the log extension so that OS X's console app can open it by default.
NSURL *logFileURL = [logFolderURL URLByAppendingPathComponent:@"emuLog.log"];
- emuLog = fopen([[logFileURL path] fileSystemRepresentation],"wb");
+ emuLog = fopen([[logFileURL path] fileSystemRepresentation], "wb");
#else
emuLog = stdout;
#endif