From c24ec04646945cbc6db234cfcd0adac3320c9d86 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Sun, 13 Apr 2014 18:10:45 +0200 Subject: [PATCH] Simplifies going fullscreen a lot! --- BoxCar2D.xcodeproj/project.pbxproj | 12 ---- GLEssentials/Car.cpp | 2 +- GLEssentials/OSX/FullscreenWindow.h | 12 ---- GLEssentials/OSX/FullscreenWindow.m | 41 ----------- GLEssentials/OSX/MainMenu.xib | 2 +- GLEssentials/OSX/WindowController.h | 16 ----- GLEssentials/OSX/WindowController.m | 108 ---------------------------- 7 files changed, 2 insertions(+), 191 deletions(-) delete mode 100644 GLEssentials/OSX/FullscreenWindow.h delete mode 100644 GLEssentials/OSX/FullscreenWindow.m delete mode 100644 GLEssentials/OSX/WindowController.h delete mode 100644 GLEssentials/OSX/WindowController.m diff --git a/BoxCar2D.xcodeproj/project.pbxproj b/BoxCar2D.xcodeproj/project.pbxproj index cd8dbe8..b208739 100644 --- a/BoxCar2D.xcodeproj/project.pbxproj +++ b/BoxCar2D.xcodeproj/project.pbxproj @@ -24,9 +24,7 @@ 4280D43318E8321100E4CDFB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4280D41A18E8311400E4CDFB /* AppDelegate.m */; }; 4280D43418E8321100E4CDFB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4280D42018E8311400E4CDFB /* ViewController.m */; }; 4280D43818E839C100E4CDFB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4280D43718E839C100E4CDFB /* Images.xcassets */; }; - 4295A2CA18CB4E5100A58D8F /* FullscreenWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 4295A2C318CB4E5100A58D8F /* FullscreenWindow.m */; }; 4295A2CB18CB4E5100A58D8F /* GLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4295A2C518CB4E5100A58D8F /* GLView.m */; }; - 4295A2CC18CB4E5100A58D8F /* WindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4295A2C718CB4E5100A58D8F /* WindowController.m */; }; 4295A2E018CB68A400A58D8F /* Game.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4295A2DF18CB68A400A58D8F /* Game.mm */; }; 4295A2EB18CBB0F700A58D8F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4295A2EA18CBB0F700A58D8F /* main.m */; }; 4295A2F318CBB22800A58D8F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4295A2F218CBB22800A58D8F /* MainMenu.xib */; }; @@ -61,12 +59,8 @@ 4280D41F18E8311400E4CDFB /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewController.h; path = GLEssentials/iOS/ViewController.h; sourceTree = SOURCE_ROOT; }; 4280D42018E8311400E4CDFB /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewController.m; path = GLEssentials/iOS/ViewController.m; sourceTree = SOURCE_ROOT; }; 4280D43718E839C100E4CDFB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = GLEssentials/Images.xcassets; sourceTree = ""; }; - 4295A2C218CB4E5100A58D8F /* FullscreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FullscreenWindow.h; path = GLEssentials/OSX/FullscreenWindow.h; sourceTree = ""; }; - 4295A2C318CB4E5100A58D8F /* FullscreenWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FullscreenWindow.m; path = GLEssentials/OSX/FullscreenWindow.m; sourceTree = ""; }; 4295A2C418CB4E5100A58D8F /* GLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GLView.h; path = GLEssentials/OSX/GLView.h; sourceTree = ""; }; 4295A2C518CB4E5100A58D8F /* GLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GLView.m; path = GLEssentials/OSX/GLView.m; sourceTree = ""; }; - 4295A2C618CB4E5100A58D8F /* WindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WindowController.h; path = GLEssentials/OSX/WindowController.h; sourceTree = ""; }; - 4295A2C718CB4E5100A58D8F /* WindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WindowController.m; path = GLEssentials/OSX/WindowController.m; sourceTree = ""; }; 4295A2DE18CB68A400A58D8F /* Game.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Game.h; path = GLEssentials/Game.h; sourceTree = ""; }; 4295A2DF18CB68A400A58D8F /* Game.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Game.mm; path = GLEssentials/Game.mm; sourceTree = ""; }; 4295A2EA18CBB0F700A58D8F /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = GLEssentials/OSX/main.m; sourceTree = ""; }; @@ -183,12 +177,8 @@ 4295A2F018CBB1D200A58D8F /* BoxCar2D-Info.plist */, 4295A2EA18CBB0F700A58D8F /* main.m */, 4295A2F218CBB22800A58D8F /* MainMenu.xib */, - 4295A2C218CB4E5100A58D8F /* FullscreenWindow.h */, - 4295A2C318CB4E5100A58D8F /* FullscreenWindow.m */, 4295A2C418CB4E5100A58D8F /* GLView.h */, 4295A2C518CB4E5100A58D8F /* GLView.m */, - 4295A2C618CB4E5100A58D8F /* WindowController.h */, - 4295A2C718CB4E5100A58D8F /* WindowController.m */, ); name = OSX; sourceTree = ""; @@ -373,10 +363,8 @@ files = ( 42409A2218EAD10900B43925 /* Car.cpp in Sources */, 4295A2EB18CBB0F700A58D8F /* main.m in Sources */, - 4295A2CA18CB4E5100A58D8F /* FullscreenWindow.m in Sources */, 4295A2CB18CB4E5100A58D8F /* GLView.m in Sources */, 42409A2418EAD10900B43925 /* Drawer.cpp in Sources */, - 4295A2CC18CB4E5100A58D8F /* WindowController.m in Sources */, 42409A2618EAD10900B43925 /* Path.cpp in Sources */, 4295A2E018CB68A400A58D8F /* Game.mm in Sources */, ); diff --git a/GLEssentials/Car.cpp b/GLEssentials/Car.cpp index 8a26609..c3f5141 100644 --- a/GLEssentials/Car.cpp +++ b/GLEssentials/Car.cpp @@ -155,7 +155,6 @@ struct CarBuilder { //stickJoint.enableLimit = true; stickJoint.enableMotor = true; stickJoint.maxMotorTorque = 1000; - stickJoint.motorSpeed = get_rand(-1, 2); } b2Body * createWheel(WheelGenome const & g){ @@ -197,6 +196,7 @@ struct CarBuilder { stickJoint.lowerAngle = startAngle - sg.limit; stickJoint.upperAngle = startAngle + sg.limit; stickJoint.referenceAngle = startAngle; + stickJoint.motorSpeed = get_rand(-1, 2); world.CreateJoint(&stickJoint); } diff --git a/GLEssentials/OSX/FullscreenWindow.h b/GLEssentials/OSX/FullscreenWindow.h deleted file mode 100644 index 4c52a78..0000000 --- a/GLEssentials/OSX/FullscreenWindow.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// -// OSX GLEssentials -// -// Copied from the Apple GLEssentials -// -// - -@import Cocoa; - -@interface FullscreenWindow : NSWindow -@end diff --git a/GLEssentials/OSX/FullscreenWindow.m b/GLEssentials/OSX/FullscreenWindow.m deleted file mode 100644 index 25807e3..0000000 --- a/GLEssentials/OSX/FullscreenWindow.m +++ /dev/null @@ -1,41 +0,0 @@ -// -// -// OSX GLEssentials -// -// Copied from the Apple GLEssentials -// -// - -#import "FullscreenWindow.h" - -@implementation FullscreenWindow - -- (id)init { - // Create a screen-sized window on the display you want to take over - // Initialize the window making it size of the screen and borderless - NSRect screenRect = [[NSScreen mainScreen] frame]; - if(self = [super initWithContentRect:screenRect - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:YES]){ - - self.level = NSMainMenuWindowLevel + 1; // Set the window level to be above the menu bar to cover everything else - self.opaque = YES; // Set opaque - self.hidesOnDeactivate = YES; // Hide this when user switches to another window (or app) - } - - return self; -} - -- (BOOL)canBecomeKeyWindow { - // Return yes so that this borderless window can receive input - return YES; -} - -- (void)keyDown:(NSEvent *)event { - // Implement keyDown since controller will not get [ESC] key event which - // the controller uses to kill fullscreen - [self.windowController keyDown:event]; -} - -@end diff --git a/GLEssentials/OSX/MainMenu.xib b/GLEssentials/OSX/MainMenu.xib index b9a9281..db49f34 100644 --- a/GLEssentials/OSX/MainMenu.xib +++ b/GLEssentials/OSX/MainMenu.xib @@ -79,6 +79,7 @@ + @@ -91,7 +92,6 @@ - diff --git a/GLEssentials/OSX/WindowController.h b/GLEssentials/OSX/WindowController.h deleted file mode 100644 index b20f556..0000000 --- a/GLEssentials/OSX/WindowController.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// -// OSX GLEssentials -// -// Copied from the Apple GLEssentials -// -// - -@import Cocoa; - -@class GLView; -@interface WindowController : NSWindowController { - IBOutlet GLView *view; -} - -@end diff --git a/GLEssentials/OSX/WindowController.m b/GLEssentials/OSX/WindowController.m deleted file mode 100644 index 3b5f5c7..0000000 --- a/GLEssentials/OSX/WindowController.m +++ /dev/null @@ -1,108 +0,0 @@ -// -// -// OSX GLEssentials -// -// Copied from the Apple GLEssentials -// -// - -#import "WindowController.h" -#import "FullscreenWindow.h" -#import "GLView.h" - -@interface WindowController () { - FullscreenWindow *fullscreenWindow; // Fullscreen window - NSWindow* standardWindow; // Non-Fullscreen window (also the initial window) -} - -@end - - -@implementation WindowController - -- (id)initWithWindow:(NSWindow *) window{ - if (self = [super initWithWindow:window]){ - fullscreenWindow = nil; - } - - return self; -} - -- (void)goFullscreen{ - if(fullscreenWindow){ - return; - } - - // Allocate a new fullscreen window - fullscreenWindow = [[FullscreenWindow alloc] init]; - - // Resize the view to screensize - view.frame = fullscreenWindow.frame; - - // Set the view in the fullscreen window - fullscreenWindow.contentView = view; - - // keep a referene to the old window - standardWindow = self.window; - - // Hide non-fullscreen window so it doesn't show up when switching out - // of this app (i.e. with CMD-TAB) - [standardWindow orderOut:self]; - - // Set controller to the fullscreen window so that all input will go to - // this controller (self) - self.window = fullscreenWindow; - - // Show the window and make it the key window for input - [fullscreenWindow makeKeyAndOrderFront:self]; - -} - -- (void)goWindow{ - if(!fullscreenWindow){ - return; - } - - // Resize the view to the window size - view.frame = standardWindow.frame; - - // Set controller to the standard window so that all input will go to - // this controller (self) - self.window = standardWindow; - - // Set the content of the orginal window to the view - self.window.contentView = view; - - // Show the window and make it the key window for input - [[self window] makeKeyAndOrderFront:self]; - - // release fullscreenWindow - fullscreenWindow = nil; -} - - -- (void)keyDown:(NSEvent *)event{ - unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0]; - - switch (c){ - // Handle [ESC] key - case 27: - if(fullscreenWindow){ - [self goWindow]; - } - return; - // Have f key toggle fullscreen - case 'f': - if(fullscreenWindow){ - [self goWindow]; - } else { - [self goFullscreen]; - } - return; - } - - // Allow other character to be handled (or not and beep) - [super keyDown:event]; -} - -@end