mirror of
https://github.com/blanking003/cx-cocos.git
synced 2025-11-09 07:45:33 +00:00
init
This commit is contained in:
15
cx3-demo/project/cxdemo.ios/mac/AppController.h
Normal file
15
cx3-demo/project/cxdemo.ios/mac/AppController.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface AppController : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) ViewController* viewController;
|
||||
|
||||
+ (AppController *)ins;
|
||||
- (void) removeLaunchImage;
|
||||
|
||||
@end
|
||||
|
||||
96
cx3-demo/project/cxdemo.ios/mac/AppController.mm
Normal file
96
cx3-demo/project/cxdemo.ios/mac/AppController.mm
Normal file
@@ -0,0 +1,96 @@
|
||||
#import "AppController.h"
|
||||
#import "Game.h"
|
||||
#include <string>
|
||||
|
||||
@interface AppController ()
|
||||
{
|
||||
NSWindow* _window;
|
||||
Game* _game;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppController
|
||||
|
||||
static AppController* s_sharedAppController;
|
||||
+ (AppController*)ins
|
||||
{
|
||||
return s_sharedAppController;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
s_sharedAppController = self;
|
||||
|
||||
// NSRect rect = NSMakeRect(200, 200, 390, 844); //iphone12 pro
|
||||
NSRect rect = NSMakeRect(200, 200, 375, 667); //iphone6s
|
||||
_window = [[NSWindow alloc] initWithContentRect:rect
|
||||
styleMask:NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
if (!_window) {
|
||||
NSLog(@"Failed to allocated the window.");
|
||||
return;
|
||||
}
|
||||
|
||||
_window.title = @"";
|
||||
|
||||
self.viewController = [[ViewController alloc] initWithSize: rect];
|
||||
_window.contentViewController = self.viewController;
|
||||
_window.contentView = self.viewController.view;
|
||||
[_window.contentView setWantsBestResolutionOpenGLSurface:YES];
|
||||
[_window makeKeyAndOrderFront:nil];
|
||||
|
||||
_game = new Game(rect.size.width, rect.size.height);
|
||||
_game->init();
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(windowWillMiniaturizeNotification)name:NSWindowWillMiniaturizeNotification
|
||||
object:_window];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(windowDidDeminiaturizeNotification)name:NSWindowDidDeminiaturizeNotification
|
||||
object:_window];
|
||||
|
||||
NSImageView *backgroundView = [[NSImageView alloc] initWithFrame: NSMakeRect(0, 0, rect.size.width, rect.size.height)];
|
||||
backgroundView.imageAlignment = NSImageAlignCenter;
|
||||
backgroundView.imageScaling = NSImageScaleNone;
|
||||
backgroundView.image = [NSImage imageNamed:@"LaunchImage.png"];
|
||||
[self.viewController.view addSubview:backgroundView];
|
||||
|
||||
}
|
||||
|
||||
- (void) removeLaunchImage
|
||||
{
|
||||
for (NSView* subview in self.viewController.view.subviews)
|
||||
{
|
||||
if ([subview isKindOfClass:[NSImageView class]])
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillMiniaturizeNotification
|
||||
{
|
||||
_game->onPause();
|
||||
}
|
||||
|
||||
- (void)windowDidDeminiaturizeNotification
|
||||
{
|
||||
_game->onResume();
|
||||
}
|
||||
|
||||
- (NSWindow*)getWindow
|
||||
{
|
||||
return _window;
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
||||
delete _game;
|
||||
//FIXME: will crash if relase it here.
|
||||
// [_window release];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
39
cx3-demo/project/cxdemo.ios/mac/Info.plist
Normal file
39
cx3-demo/project/cxdemo.ios/mac/Info.plist
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2019 minggo. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSSupportsAutomaticTermination</key>
|
||||
<true/>
|
||||
<key>NSSupportsSuddenTermination</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
cx3-demo/project/cxdemo.ios/mac/LaunchImage.png
Normal file
BIN
cx3-demo/project/cxdemo.ios/mac/LaunchImage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 286 B |
7
cx3-demo/project/cxdemo.ios/mac/Prefix.pch
Normal file
7
cx3-demo/project/cxdemo.ios/mac/Prefix.pch
Normal file
@@ -0,0 +1,7 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
// Configuration settings file format documentation can be found at:
|
||||
// https://help.apple.com/xcode/#/dev745c5c974
|
||||
|
||||
#include "/Users/minggo/sourcecode/creator/3d/editor-3d/resources/3d/cocos2d-x-lite/cocos/platform/mac/CCModuleConfigMac.debug.xcconfig"
|
||||
@@ -0,0 +1,4 @@
|
||||
// Configuration settings file format documentation can be found at:
|
||||
// https://help.apple.com/xcode/#/dev745c5c974
|
||||
|
||||
#include "/Users/minggo/sourcecode/creator/3d/editor-3d/resources/3d/cocos2d-x-lite/cocos/platform/mac/CCModuleConfigMac.release.xcconfig"
|
||||
7
cx3-demo/project/cxdemo.ios/mac/ViewController.h
Normal file
7
cx3-demo/project/cxdemo.ios/mac/ViewController.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#import <MetalKit/MetalKit.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
|
||||
@interface ViewController : NSViewController
|
||||
- (instancetype)initWithSize:(NSRect)rect;
|
||||
@end
|
||||
|
||||
17
cx3-demo/project/cxdemo.ios/mac/ViewController.mm
Normal file
17
cx3-demo/project/cxdemo.ios/mac/ViewController.mm
Normal file
@@ -0,0 +1,17 @@
|
||||
#import "ViewController.h"
|
||||
#import "platform/mac/View.h"
|
||||
|
||||
@implementation ViewController
|
||||
{
|
||||
View* _view;
|
||||
}
|
||||
|
||||
- (instancetype)initWithSize:(NSRect)rect {
|
||||
if (self = [super init]) {
|
||||
_view = [[View alloc] initWithFrame:rect];
|
||||
self.view = _view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
10
cx3-demo/project/cxdemo.ios/mac/gfx_tests.entitlements
Normal file
10
cx3-demo/project/cxdemo.ios/mac/gfx_tests.entitlements
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
9
cx3-demo/project/cxdemo.ios/mac/main.m
Normal file
9
cx3-demo/project/cxdemo.ios/mac/main.m
Normal file
@@ -0,0 +1,9 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "AppController.h"
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
id delegate = [[AppController alloc] init];
|
||||
NSApplication.sharedApplication.delegate = delegate;
|
||||
return NSApplicationMain(argc, argv);
|
||||
}
|
||||
Reference in New Issue
Block a user