Hide the menubar only when going fullscreen.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#import "main.h"
|
||||
#import "Controller.h"
|
||||
|
||||
@implementation Controller
|
||||
@@ -17,16 +16,12 @@
|
||||
forKey:@"gamepath"]];
|
||||
}
|
||||
|
||||
extern char **environ;
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
gamePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"gamepath"];
|
||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||
gamePath = [[NSUserDefaults standardUserDefaults] stringForKey:@"gamepath"];
|
||||
|
||||
// Ingame requests for native dialogs
|
||||
if ([args containsObject:@"--display-filepicker"])
|
||||
[self launchFilePicker:args];
|
||||
|
||||
|
||||
// Try and launch the game
|
||||
if (![self initMono])
|
||||
{
|
||||
@@ -42,16 +37,21 @@
|
||||
[[NSApplication sharedApplication] terminate:self];
|
||||
}
|
||||
|
||||
// Ingame requests for native dialogs
|
||||
if ([args containsObject:@"--display-filepicker"])
|
||||
[self launchFilePicker:args];
|
||||
|
||||
// Extract a zip file
|
||||
if ([args containsObject:@"--extract-zip"])
|
||||
else if ([args containsObject:@"--extract-zip"])
|
||||
[self extractZip:args];
|
||||
|
||||
// Install ra packages from cd
|
||||
if ([args containsObject:@"--install-ra-packages"])
|
||||
else if ([args containsObject:@"--install-ra-packages"])
|
||||
[self installRAPackages:args];
|
||||
|
||||
else
|
||||
[self launchMod:@"cnc"];
|
||||
|
||||
[self launchMod:@"cnc"];
|
||||
[NSApp terminate: nil];
|
||||
}
|
||||
|
||||
@@ -72,8 +72,10 @@
|
||||
- (void)launchFilePicker:(NSArray *)args
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
hide_menubar_if_necessary();
|
||||
|
||||
|
||||
if ([self shouldHideMenubar])
|
||||
[NSMenu setMenuBarVisible:NO];
|
||||
|
||||
NSOpenPanel *op = [NSOpenPanel openPanel];
|
||||
[op setLevel:CGShieldingWindowLevel()];
|
||||
[op setAllowsMultipleSelection:NO];
|
||||
@@ -88,6 +90,28 @@
|
||||
[NSApp terminate: nil];
|
||||
}
|
||||
|
||||
- (BOOL)shouldHideMenubar
|
||||
{
|
||||
NSTask *task = [[[NSTask alloc] init] autorelease];
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
|
||||
NSMutableArray *taskArgs = [NSMutableArray arrayWithObjects:@"OpenRA.Utility.exe",
|
||||
@"--settings-value",
|
||||
[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath],
|
||||
@"Graphics.Mode", nil];
|
||||
|
||||
[task setCurrentDirectoryPath:gamePath];
|
||||
[task setLaunchPath:monoPath];
|
||||
[task setArguments:taskArgs];
|
||||
[task setStandardOutput:pipe];
|
||||
NSFileHandle *readHandle = [pipe fileHandleForReading];
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
NSString *response = [[[NSString alloc] initWithData:[readHandle readDataToEndOfFile]
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
return ![response isEqualToString:@"Windowed\n"];
|
||||
}
|
||||
|
||||
-(void)launchMod:(NSString *)mod
|
||||
{
|
||||
// Use LaunchServices because neither NSTask or NSWorkspace support Info.plist _and_ arguments pre-10.6
|
||||
@@ -95,12 +119,14 @@
|
||||
// First argument is the directory to run in
|
||||
// Second...Nth arguments are passed to OpenRA.Game.exe
|
||||
// Launcher wrapper sets mono --debug, gl renderer and support dir.
|
||||
NSArray *args = [NSArray arrayWithObjects:@"--launch", gamePath, monoPath,
|
||||
NSArray *args = [NSArray arrayWithObjects:@"--launch",
|
||||
[self shouldHideMenubar] ? @"--hide-menubar" : @"--no-hide-menubar",
|
||||
gamePath,
|
||||
monoPath,
|
||||
[NSString stringWithFormat:@"UtilityPath=%@", [[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]],
|
||||
[NSString stringWithFormat:@"SupportDir=%@",[@"~/Library/Application Support/OpenRA" stringByExpandingTildeInPath]],
|
||||
[NSString stringWithFormat:@"Game.Mods=%@",mod],
|
||||
nil];
|
||||
|
||||
FSRef appRef;
|
||||
CFURLGetFSRef((CFURLRef)[NSURL URLWithString:[[[NSBundle mainBundle] executablePath] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]], &appRef);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user