diff --git a/template/multi-platform-js-runtime/framework/Classes/Runtime.cpp b/template/multi-platform-js-runtime/framework/Classes/Runtime.cpp index 8cfc42a845..74963c7751 100644 --- a/template/multi-platform-js-runtime/framework/Classes/Runtime.cpp +++ b/template/multi-platform-js-runtime/framework/Classes/Runtime.cpp @@ -231,6 +231,11 @@ void startScript() ScriptingCore::getInstance()->runScript("cocos2d-jsb.js"); } +void ReloadScript() +{ + +} + class ConnectWaiter: public Object { public: diff --git a/template/multi-platform-js-runtime/framework/Classes/Runtime.h b/template/multi-platform-js-runtime/framework/Classes/Runtime.h index a43d63d585..dd074c4865 100644 --- a/template/multi-platform-js-runtime/framework/Classes/Runtime.h +++ b/template/multi-platform-js-runtime/framework/Classes/Runtime.h @@ -33,6 +33,8 @@ using namespace std; void StartRuntime(); +void ReloadScript(); + // SimulatorConfig typedef struct _SimulatorScreenSize { string title; diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/template/multi-platform-js-runtime/framework/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 4ee86583ef..1eba8ad60f 100644 --- a/template/multi-platform-js-runtime/framework/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -86,7 +86,6 @@ 509D4AC817EBB2AB00697056 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 509D4AB817EBB2AB00697056 /* main.m */; }; 509D4AC917EBB2AB00697056 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 509D4ABB17EBB2AB00697056 /* RootViewController.mm */; }; 509D4ACF17EBB2BE00697056 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 509D4ACB17EBB2BE00697056 /* Icon.icns */; }; - 509D4AD117EBB2BE00697056 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 509D4ACD17EBB2BE00697056 /* main.cpp */; }; 509D4AE717EBB81800697056 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AE617EBB81800697056 /* OpenGL.framework */; }; 509D4AE917EBB82000697056 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AE817EBB82000697056 /* AppKit.framework */; }; 509D4AEB17EBB82600697056 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AEA17EBB82600697056 /* IOKit.framework */; }; @@ -102,6 +101,9 @@ C026DCC718928A1A00B3EDE8 /* Runtime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C026DCC518928A1A00B3EDE8 /* Runtime.cpp */; }; C026DCC918928A2400B3EDE8 /* Runtime_ios-mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C026DCC818928A2400B3EDE8 /* Runtime_ios-mac.mm */; }; C026DCCA18928A2400B3EDE8 /* Runtime_ios-mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C026DCC818928A2400B3EDE8 /* Runtime_ios-mac.mm */; }; + C03C8B4B18A770DD00723415 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C03C8B4818A770DD00723415 /* main.m */; }; + C03C8B4C18A770DD00723415 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C03C8B4918A770DD00723415 /* MainMenu.xib */; }; + C0C2F37418AA0C66003976DA /* SimulatorApp.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C2F37318AA0C66003976DA /* SimulatorApp.mm */; }; D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D454520B156E22BD00887EB5 /* libz.dylib */; }; D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; D6B061241803AB9F0077942B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B061231803AB9F0077942B /* CoreMotion.framework */; }; @@ -329,7 +331,6 @@ 509D4ABB17EBB2AB00697056 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RootViewController.mm; path = ios/RootViewController.mm; sourceTree = ""; }; 509D4ACB17EBB2BE00697056 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 509D4ACC17EBB2BE00697056 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 509D4ACD17EBB2BE00697056 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 509D4ACE17EBB2BE00697056 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 509D4AE617EBB81800697056 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 509D4AE817EBB82000697056 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; @@ -346,6 +347,10 @@ C014EAEB188EA65400753BDC /* Runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Runtime.h; sourceTree = ""; }; C026DCC518928A1A00B3EDE8 /* Runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Runtime.cpp; sourceTree = ""; }; C026DCC818928A2400B3EDE8 /* Runtime_ios-mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "Runtime_ios-mac.mm"; sourceTree = SOURCE_ROOT; }; + C03C8B4818A770DD00723415 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + C03C8B4918A770DD00723415 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; + C0C2F37218AA0C66003976DA /* SimulatorApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatorApp.h; sourceTree = ""; }; + C0C2F37318AA0C66003976DA /* SimulatorApp.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimulatorApp.mm; sourceTree = ""; }; D454520B156E22BD00887EB5 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; D4545215156E28EF00887EB5 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -477,9 +482,12 @@ 509D4ACA17EBB2BE00697056 /* mac */ = { isa = PBXGroup; children = ( + C0C2F37218AA0C66003976DA /* SimulatorApp.h */, + C0C2F37318AA0C66003976DA /* SimulatorApp.mm */, + C03C8B4818A770DD00723415 /* main.m */, + C03C8B4918A770DD00723415 /* MainMenu.xib */, 509D4ACB17EBB2BE00697056 /* Icon.icns */, 509D4ACC17EBB2BE00697056 /* Info.plist */, - 509D4ACD17EBB2BE00697056 /* main.cpp */, 509D4ACE17EBB2BE00697056 /* Prefix.pch */, ); path = mac; @@ -574,8 +582,8 @@ buildConfigurationList = 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "HelloJavascript Mac" */; buildPhases = ( 509D4A8017EBB24E00697056 /* Sources */, - 509D4A8217EBB24E00697056 /* Frameworks */, 509D4A9317EBB24E00697056 /* Resources */, + 509D4A8217EBB24E00697056 /* Frameworks */, ); buildRules = ( ); @@ -767,6 +775,7 @@ 1A676843180E9CE90076BC67 /* jsb_cocosbuilder.js in Resources */, 1A676844180E9CE90076BC67 /* jsb_debugger.js in Resources */, 1A676845180E9CE90076BC67 /* jsb_deprecated.js in Resources */, + C03C8B4C18A770DD00723415 /* MainMenu.xib in Resources */, 1A676846180E9CE90076BC67 /* jsb_opengl_constants.js in Resources */, 1A676847180E9CE90076BC67 /* jsb_opengl.js in Resources */, 1A676848180E9CE90076BC67 /* jsb_sys.js in Resources */, @@ -827,10 +836,11 @@ buildActionMask = 2147483647; files = ( C026DCC718928A1A00B3EDE8 /* Runtime.cpp in Sources */, - 509D4AD117EBB2BE00697056 /* main.cpp in Sources */, 509D4A8117EBB24E00697056 /* AppDelegate.cpp in Sources */, + C0C2F37418AA0C66003976DA /* SimulatorApp.mm in Sources */, C026DCCA18928A2400B3EDE8 /* Runtime_ios-mac.mm in Sources */, 013F8DBD1887C10F008B7106 /* cocos2d-jsb.js in Sources */, + C03C8B4B18A770DD00723415 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -914,6 +924,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = mac/Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( + GLFW_EXPOSE_NATIVE_COCOA, + GLFW_EXPOSE_NATIVE_NSGL, CC_TARGET_OS_MAC, "$(inherited)", ); diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/ios/RootViewController.mm b/template/multi-platform-js-runtime/framework/proj.ios_mac/ios/RootViewController.mm index af421369f2..dfbe298774 100644 --- a/template/multi-platform-js-runtime/framework/proj.ios_mac/ios/RootViewController.mm +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/ios/RootViewController.mm @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010 Ricardo Quesada + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #import "RootViewController.h" #import "cocos2d.h" #import "CCEAGLView.h" diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/MainMenu.xib b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/MainMenu.xib new file mode 100644 index 0000000000..ded673e061 --- /dev/null +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/MainMenu.xib @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.h b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.h new file mode 100644 index 0000000000..94bd6040d8 --- /dev/null +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.h @@ -0,0 +1,50 @@ +/**************************************************************************** + Copyright (c) 2010 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + + +#include +#include "AppDelegate.h" + +@interface AppController : NSObject +{ + NSWindow *window; + NSMenu *menu; + NSFileHandle *fileHandle; + //console pipe + NSPipe *pipe; + NSFileHandle *pipeReadHandle; +} + +@property (nonatomic, assign) IBOutlet NSMenu* menu; + + + +- (IBAction) onFileClose:(id)sender; +- (IBAction) onScreenPortait:(id)sender; +- (IBAction) onScreenLandscape:(id)sender; +- (IBAction) onScreenZoomOut:(id)sender; +- (IBAction) onReloadScript:(id)sender; + + +@end diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.mm b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.mm new file mode 100644 index 0000000000..0a5aba24a3 --- /dev/null +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/SimulatorApp.mm @@ -0,0 +1,271 @@ +/**************************************************************************** + Copyright (c) 2010 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import "SimulatorApp.h" + + +#include +#include +#include +#include +#include + +#include "AppDelegate.h" +#include "glfw3.h" +#include "glfw3native.h" +#include "Runtime.h" + +#include "cocos2d.h" + +using namespace cocos2d; + +bool g_landscape=false; +CCSize g_screenSize; +GLView* g_eglView=NULL; + +using namespace std; +using namespace cocos2d; + +@implementation AppController + +@synthesize menu; + +-(void) dealloc +{ + CCDirector::sharedDirector()->end(); + [super dealloc]; +} + +#pragma mark - +#pragma delegates + +- (void) applicationDidFinishLaunching:(NSNotification *)aNotification +{ + + AppDelegate app; + [self createSimulator:[NSString stringWithUTF8String:"HelloJavascript"] viewWidth:960 viewHeight:640 factor:1.0]; + int ret = Application::getInstance()->run(); + +} + + +#pragma mark - +#pragma mark functions + +- (void) createSimulator:(NSString*)viewName viewWidth:(float)width viewHeight:(float)height factor:(float)frameZoomFactor +{ + if (g_eglView) + { + return; + } + + g_eglView = GLView::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor); + auto director = Director::getInstance(); + director->setOpenGLView(g_eglView); + g_landscape = false; + g_screenSize.width = width; + g_screenSize.height = height; + if (width > height) + { + g_landscape = true; + } + + window = glfwGetCocoaWindow(g_eglView->getWindow()); + window.delegate = self; + [NSApp setDelegate: self]; + + [self createViewMenu]; + [self updateMenu]; + [window center]; + + [window becomeFirstResponder]; + [window makeKeyAndOrderFront:self]; + [window setAcceptsMouseMovedEvents:NO]; +} + + +- (void) createViewMenu +{ + + NSMenu *submenu = [[[window menu] itemWithTitle:@"View"] submenu]; + + for (int i = SimulatorConfig::getInstance()->getScreenSizeCount() - 1; i >= 0; --i) + { + SimulatorScreenSize size = SimulatorConfig::getInstance()->getScreenSize(i); + NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:size.title.c_str() encoding:NSUTF8StringEncoding] + action:@selector(onViewChangeFrameSize:) + keyEquivalent:@""] autorelease]; + [item setTag:i]; + [submenu insertItem:item atIndex:0]; + } +} + + +- (void) updateMenu +{ + + NSMenu *menuScreen = [[[window menu] itemWithTitle:@"View"] submenu]; + NSMenuItem *itemPortait = [menuScreen itemWithTitle:@"Portait"]; + NSMenuItem *itemLandscape = [menuScreen itemWithTitle:@"Landscape"]; + if (g_landscape) + { + [itemPortait setState:NSOffState]; + [itemLandscape setState:NSOnState]; + } + else + { + [itemPortait setState:NSOnState]; + [itemLandscape setState:NSOffState]; + } + + int scale = 100; + + NSMenuItem *itemZoom100 = [menuScreen itemWithTitle:@"Actual (100%)"]; + NSMenuItem *itemZoom75 = [menuScreen itemWithTitle:@"Zoom Out (75%)"]; + NSMenuItem *itemZoom50 = [menuScreen itemWithTitle:@"Zoom Out (50%)"]; + NSMenuItem *itemZoom25 = [menuScreen itemWithTitle:@"Zoom Out (25%)"]; + [itemZoom100 setState:NSOffState]; + [itemZoom75 setState:NSOffState]; + [itemZoom50 setState:NSOffState]; + [itemZoom25 setState:NSOffState]; + if (scale == 100) + { + [itemZoom100 setState:NSOnState]; + } + else if (scale == 75) + { + [itemZoom75 setState:NSOnState]; + } + else if (scale == 50) + { + [itemZoom50 setState:NSOnState]; + } + else if (scale == 25) + { + [itemZoom25 setState:NSOnState]; + } + + int width = g_screenSize.width; + int height = g_screenSize.height; + if (height > width) + { + int w = width; + width = height; + height = w; + } + + int count = SimulatorConfig::getInstance()->getScreenSizeCount(); + for (int i = 0; i < count; ++i) + { + bool bSel = false; + SimulatorScreenSize size = SimulatorConfig::getInstance()->getScreenSize(i); + if (size.width == width && size.height == height) + { + bSel = true; + } + NSMenuItem *itemView = [menuScreen itemWithTitle:[NSString stringWithUTF8String:size.title.c_str()]]; + [itemView setState:(bSel? NSOnState : NSOffState)]; + } + + + //[window setTitle:[NSString stringWithFormat:@"quick-x-player (%0.0f%%)", projectConfig.getFrameScale() * 100]]; +} + + +- (void) updateView +{ + if (g_landscape) + { + glfwSetWindowSize(g_eglView->getWindow(),g_screenSize.width,g_screenSize.height); + } + else + { + glfwSetWindowSize(g_eglView->getWindow(),g_screenSize.height,g_screenSize.width); + } + [self updateMenu]; +} + +- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication +{ + return YES; +} + +- (BOOL) applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag +{ + return NO; +} + +- (void) windowWillClose:(NSNotification *)notification +{ + [[NSRunningApplication currentApplication] terminate]; +} + + +- (IBAction) onFileClose:(id)sender +{ + [[NSApplication sharedApplication] terminate:self]; +} + + +- (IBAction) onScreenPortait:(id)sender +{ + g_landscape = false; + [self updateView]; + +} + +- (IBAction) onScreenLandscape:(id)sender +{ + g_landscape = true; + [self updateView]; +} + +- (IBAction) onReloadScript:(id)sender +{ + ReloadScript(); +} + + +- (IBAction) onViewChangeFrameSize:(id)sender +{ + NSInteger index = [sender tag]; + if (index >= 0 && index < SimulatorConfig::getInstance()->getScreenSizeCount()) + { + SimulatorScreenSize size = SimulatorConfig::getInstance()->getScreenSize(index); + g_screenSize.width = size.width; + g_screenSize.height = size.height; + [self updateView]; + } +} + + +- (IBAction) onScreenZoomOut:(id)sender +{ + if ([sender state] == NSOnState) return; + float scale = (float)[sender tag] / 100.0f; + [self setZoom:scale]; +} + + +@end diff --git a/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/main.m b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/main.m new file mode 100644 index 0000000000..658f0c14ee --- /dev/null +++ b/template/multi-platform-js-runtime/framework/proj.ios_mac/mac/main.m @@ -0,0 +1,7 @@ + +#import + +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **)argv); +} diff --git a/template/multi-platform-js-runtime/framework/proj.win32/SimulatorWindow.cpp b/template/multi-platform-js-runtime/framework/proj.win32/SimulatorWindow.cpp index 0b407d4522..aa1851e52a 100644 --- a/template/multi-platform-js-runtime/framework/proj.win32/SimulatorWindow.cpp +++ b/template/multi-platform-js-runtime/framework/proj.win32/SimulatorWindow.cpp @@ -164,6 +164,7 @@ LRESULT CALLBACK SNewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar switch (wmId) { case ID_FILE_EXIT: + exit(0); break; case ID_VIEW_PORTRAIT: @@ -171,6 +172,10 @@ LRESULT CALLBACK SNewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar onViewChangeOrientation(wmId); break; + case ID_CONTROL_RELOAD: + ReloadScript(); + break; + case ID_HELP_ABOUT: onHelpAbout(); diff --git a/template/multi-platform-js-runtime/framework/proj.win32/game.rc b/template/multi-platform-js-runtime/framework/proj.win32/game.rc index 4e18d2ff7c..940b5e7256 100644 --- a/template/multi-platform-js-runtime/framework/proj.win32/game.rc +++ b/template/multi-platform-js-runtime/framework/proj.win32/game.rc @@ -60,7 +60,10 @@ BEGIN MENUITEM SEPARATOR MENUITEM "&Custom", ID_VIEW_CUSTOM END - MENUITEM "&Reset", 0 + POPUP "&Control" + BEGIN + MENUITEM "Reload", ID_CONTROL_RELOAD + END POPUP "&Help" BEGIN MENUITEM "&About ...", ID_HELP_ABOUT diff --git a/template/multi-platform-js-runtime/framework/proj.win32/resource.h b/template/multi-platform-js-runtime/framework/proj.win32/resource.h index c4b393119e..cffaa92fea 100644 --- a/template/multi-platform-js-runtime/framework/proj.win32/resource.h +++ b/template/multi-platform-js-runtime/framework/proj.win32/resource.h @@ -21,13 +21,15 @@ #define ID_Menu 32780 #define ID_Menu32781 32781 #define ID_TEST_RESET 32782 +#define ID_CONTROL 32783 +#define ID_CONTROL_RELOAD 32784 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 204 -#define _APS_NEXT_COMMAND_VALUE 32783 +#define _APS_NEXT_COMMAND_VALUE 32785 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif