mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-23 08:00:17 +00:00
mac: get the launcher building with SDL2
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
861ff0362f
commit
94121600ea
@ -34,20 +34,17 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
|
|
||||||
+(void) initialize {
|
+(void) initialize {
|
||||||
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
|
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
[defaults setObject:@"" forKey:FQPrefCommandLineKey];
|
[defaults setObject:@"" forKey:FQPrefCommandLineKey];
|
||||||
[defaults setObject:[NSNumber numberWithBool:YES] forKey:FQPrefFullscreenKey];
|
[defaults setObject:[NSNumber numberWithBool:YES] forKey:FQPrefFullscreenKey];
|
||||||
[defaults setObject:[NSNumber numberWithInt:0] forKey:FQPrefScreenModeKey];
|
[defaults setObject:[NSNumber numberWithInt:0] forKey:FQPrefScreenModeKey];
|
||||||
|
|
||||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
int i,j;
|
int i, nummodes, err;
|
||||||
int flags;
|
SDL_DisplayMode mode;
|
||||||
int bpps[3] = {32, 24, 16};
|
|
||||||
SDL_PixelFormat format;
|
|
||||||
SDL_Rect **modes;
|
|
||||||
ScreenInfo *info;
|
ScreenInfo *info;
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
@ -59,26 +56,18 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
flags = SDL_OPENGL | SDL_FULLSCREEN;
|
|
||||||
format.palette = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
format.BitsPerPixel = bpps[i];
|
|
||||||
modes = SDL_ListModes(&format, flags);
|
|
||||||
|
|
||||||
if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
|
nummodes = SDL_GetNumDisplayModes(0);
|
||||||
continue;
|
for (i = 0; i < nummodes; i++) {
|
||||||
|
err = SDL_GetDisplayMode(0, i, &mode);
|
||||||
for (j = 0; modes[j]; j++) {
|
if (err)
|
||||||
info = [[ScreenInfo alloc] initWithWidth:modes[j]->w height:modes[j]->h bpp:bpps[i]];
|
continue;
|
||||||
[screenModes addObject:info];
|
info = [[ScreenInfo alloc] initWithWidth:mode.w height:mode.h bpp:SDL_BITSPERPIXEL(mode.format)];
|
||||||
[info release];
|
[screenModes addObject:info];
|
||||||
}
|
[info release];
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
arguments = [[QuakeArguments alloc] initWithArguments:gArgv + 1 count:gArgc - 1];
|
arguments = [[QuakeArguments alloc] initWithArguments:gArgv + 1 count:gArgc - 1];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -95,10 +84,10 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
} else {
|
} else {
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
[paramTextField setStringValue:[defaults stringForKey:FQPrefCommandLineKey]];
|
[paramTextField setStringValue:[defaults stringForKey:FQPrefCommandLineKey]];
|
||||||
|
|
||||||
BOOL fullscreen = [defaults boolForKey:FQPrefFullscreenKey];
|
BOOL fullscreen = [defaults boolForKey:FQPrefFullscreenKey];
|
||||||
[fullscreenCheckBox setState:fullscreen ? NSOnState : NSOffState];
|
[fullscreenCheckBox setState:fullscreen ? NSOnState : NSOffState];
|
||||||
|
|
||||||
int screenModeIndex = [defaults integerForKey:FQPrefScreenModeKey];
|
int screenModeIndex = [defaults integerForKey:FQPrefScreenModeKey];
|
||||||
[screenModePopUp selectItemAtIndex:screenModeIndex];
|
[screenModePopUp selectItemAtIndex:screenModeIndex];
|
||||||
}
|
}
|
||||||
@ -121,11 +110,10 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
|
|
||||||
- (IBAction)launchQuake:(id)sender {
|
- (IBAction)launchQuake:(id)sender {
|
||||||
[arguments parseArguments:[paramTextField stringValue]];
|
[arguments parseArguments:[paramTextField stringValue]];
|
||||||
|
|
||||||
int index = [screenModePopUp indexOfSelectedItem];
|
int index = [screenModePopUp indexOfSelectedItem];
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
ScreenInfo *info = [screenModes objectAtIndex:index];
|
ScreenInfo *info = [screenModes objectAtIndex:index];
|
||||||
|
|
||||||
int width = [info width];
|
int width = [info width];
|
||||||
int height = [info height];
|
int height = [info height];
|
||||||
int bpp = [info bpp];
|
int bpp = [info bpp];
|
||||||
@ -134,7 +122,7 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
[arguments addArgument:@"-height" withValue:[NSString stringWithFormat:@"%d", height]];
|
[arguments addArgument:@"-height" withValue:[NSString stringWithFormat:@"%d", height]];
|
||||||
[arguments addArgument:@"-bpp" withValue:[NSString stringWithFormat:@"%d", bpp]];
|
[arguments addArgument:@"-bpp" withValue:[NSString stringWithFormat:@"%d", bpp]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[arguments removeArgument:@"-fullscreen"];
|
[arguments removeArgument:@"-fullscreen"];
|
||||||
[arguments removeArgument:@"-window"];
|
[arguments removeArgument:@"-window"];
|
||||||
BOOL fullscreen = [fullscreenCheckBox state] == NSOnState;
|
BOOL fullscreen = [fullscreenCheckBox state] == NSOnState;
|
||||||
@ -144,17 +132,17 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
[arguments addArgument:@"-window"];
|
[arguments addArgument:@"-window"];
|
||||||
|
|
||||||
NSString *path = [NSString stringWithCString:gArgv[0] encoding:NSASCIIStringEncoding];
|
NSString *path = [NSString stringWithCString:gArgv[0] encoding:NSASCIIStringEncoding];
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
path = [path stringByDeletingLastPathComponent];
|
path = [path stringByDeletingLastPathComponent];
|
||||||
|
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
[fileManager changeCurrentDirectoryPath:path];
|
[fileManager changeCurrentDirectoryPath:path];
|
||||||
|
|
||||||
int argc = [arguments count] + 1;
|
int argc = [arguments count] + 1;
|
||||||
char *argv[argc];
|
char *argv[argc];
|
||||||
|
|
||||||
argv[0] = gArgv[0];
|
argv[0] = gArgv[0];
|
||||||
[arguments setArguments:argv + 1];
|
[arguments setArguments:argv + 1];
|
||||||
|
|
||||||
@ -167,7 +155,7 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
[defaults setObject:[NSNumber numberWithInt:index] forKey:FQPrefScreenModeKey];
|
[defaults setObject:[NSNumber numberWithInt:index] forKey:FQPrefScreenModeKey];
|
||||||
[defaults synchronize];
|
[defaults synchronize];
|
||||||
|
|
||||||
int status = SDL_main (argc, argv);
|
int status = SDL_main(argc, argv);
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,5 +168,4 @@ NSString *FQPrefScreenModeKey = @"ScreenMode";
|
|||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#import "SDLMain.h"
|
#import "SDLMain.h"
|
||||||
#import <sys/param.h> /* for MAXPATHLEN */
|
#import <sys/param.h> /* for MAXPATHLEN */
|
||||||
#import <unistd.h>
|
#import <unistd.h>
|
||||||
#import "SDLApplication.h"
|
|
||||||
|
|
||||||
int gArgc;
|
int gArgc;
|
||||||
char **gArgv;
|
char **gArgv;
|
||||||
@ -57,13 +56,12 @@ BOOL gCalledAppMainline = FALSE;
|
|||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
#ifdef main
|
#ifdef main
|
||||||
# undef main
|
# undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Main entry point to executable - should *not* be SDL_main! */
|
/* Main entry point to executable - should *not* be SDL_main! */
|
||||||
int main (int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* Copy the arguments into a global variable */
|
/* Copy the arguments into a global variable */
|
||||||
/* This is passed if we are launched by double-clicking */
|
/* This is passed if we are launched by double-clicking */
|
||||||
@ -72,7 +70,7 @@ int main (int argc, char **argv)
|
|||||||
gArgv[0] = argv[0];
|
gArgv[0] = argv[0];
|
||||||
gArgv[1] = NULL;
|
gArgv[1] = NULL;
|
||||||
gArgc = 1;
|
gArgc = 1;
|
||||||
gFinderLaunch = YES;
|
gFinderLaunch = TRUE;
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
gArgc = argc;
|
gArgc = argc;
|
||||||
@ -82,6 +80,6 @@ int main (int argc, char **argv)
|
|||||||
gFinderLaunch = NO;
|
gFinderLaunch = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSApplicationMain (argc, (const char**) argv);
|
NSApplicationMain(argc, (const char**)argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user