add mac Simulator

This commit is contained in:
chuanweizhang2013 2014-02-11 18:07:20 +08:00
parent c0d3ce2b75
commit fcc78f39a1
11 changed files with 529 additions and 7 deletions

View File

@ -231,6 +231,11 @@ void startScript()
ScriptingCore::getInstance()->runScript("cocos2d-jsb.js");
}
void ReloadScript()
{
}
class ConnectWaiter: public Object
{
public:

View File

@ -33,6 +33,8 @@ using namespace std;
void StartRuntime();
void ReloadScript();
// SimulatorConfig
typedef struct _SimulatorScreenSize {
string title;

View File

@ -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 = "<group>"; };
509D4ACB17EBB2BE00697056 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
509D4ACC17EBB2BE00697056 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
509D4ACD17EBB2BE00697056 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
509D4ACE17EBB2BE00697056 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
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 = "<group>"; };
C026DCC518928A1A00B3EDE8 /* Runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Runtime.cpp; sourceTree = "<group>"; };
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 = "<group>"; };
C03C8B4918A770DD00723415 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
C0C2F37218AA0C66003976DA /* SimulatorApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatorApp.h; sourceTree = "<group>"; };
C0C2F37318AA0C66003976DA /* SimulatorApp.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimulatorApp.mm; sourceTree = "<group>"; };
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 = "<group>"; };
D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -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)",
);

View File

@ -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"

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1060" defaultVersion="1090" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AppController">
<connections>
<outlet property="delegate" destination="536" id="537"/>
<outlet property="menu" destination="29" id="650"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
<menuItem title="Cocos-player" id="GS6-Lb-ftA">
<menu key="submenu" title="Cocos-player" systemMenu="apple" id="YN2-V8-ty0">
<items>
<menuItem title="About Cocos-player" id="HhF-Es-coQ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="tSA-7z-LPk"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="OzD-Nm-tPt">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Services" id="TOj-vg-cDm">
<menu key="submenu" title="Services" systemMenu="services" id="e98-We-UX5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="muN-Hw-eeZ">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Hide Cocos-player" keyEquivalent="h" id="sH6-na-PTL">
<connections>
<action selector="hide:" target="-3" id="SGN-0p-7lH"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="XG8-CE-veT">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-3" id="iJd-Ba-eXG"/>
</connections>
</menuItem>
<menuItem title="Show All" id="IqD-3v-zQT">
<connections>
<action selector="unhideAllApplications:" target="-3" id="DR8-By-ymv"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="GU5-eI-OTq">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Quit Cocos-player" keyEquivalent="q" id="7Z7-ot-jqY">
<connections>
<action selector="terminate:" target="-3" id="DyL-yF-GYq"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="File" id="83">
<menu key="submenu" title="File" id="81">
<items>
<menuItem title="Close" keyEquivalent="w" id="611">
<connections>
<action selector="onFileClose:" target="-1" id="661"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="295" userLabel="Menu Item - View">
<menu key="submenu" title="View" id="296" userLabel="Menu - View">
<items>
<menuItem isSeparatorItem="YES" id="579"/>
<menuItem title="Portait" state="on" id="592">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="onScreenPortait:" target="-1" id="667"/>
</connections>
</menuItem>
<menuItem title="Landscape" id="593">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="onScreenLandscape:" target="-1" id="647"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="594"/>
<menuItem title="Actual (100%)" state="on" tag="100" keyEquivalent="0" id="595">
<connections>
<action selector="onScreenZoomOut:" target="-1" id="yUj-fN-Rh7"/>
</connections>
</menuItem>
<menuItem title="Zoom Out (75%)" tag="75" keyEquivalent="6" id="pqR-xy-5ip">
<connections>
<action selector="onScreenZoomOut:" target="-1" id="yps-LZ-egB"/>
</connections>
</menuItem>
<menuItem title="Zoom Out (50%)" tag="50" keyEquivalent="5" id="596">
<connections>
<action selector="onScreenZoomOut:" target="-1" id="654"/>
</connections>
</menuItem>
<menuItem title="Zoom Out (25%)" tag="25" keyEquivalent="4" id="QB8-6D-hAr">
<connections>
<action selector="onScreenZoomOut:" target="-1" id="DSu-if-D2T"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Control" id="Heh-SD-KHE">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Control" id="ysx-9J-ekz">
<items>
<menuItem title="Reload" id="hfu-OP-8X3">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="onReloadScript:" target="-1" id="ar6-Pq-fmZ"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="490">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="491"/>
</menuItem>
</items>
</menu>
<customObject id="420" customClass="NSFontManager"/>
<customObject id="536" customClass="AppController">
<connections>
<outlet property="menu" destination="29" id="550"/>
</connections>
</customObject>
</objects>
</document>

View File

@ -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 <string>
#include "AppDelegate.h"
@interface AppController : NSObject <NSApplicationDelegate, NSWindowDelegate>
{
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

View File

@ -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 <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <string>
#include <vector>
#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

View File

@ -0,0 +1,7 @@
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}

View File

@ -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();

View File

@ -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

View File

@ -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