This commit is contained in:
blank
2021-06-07 15:13:32 +08:00
parent 74d5947e9d
commit 346fc42e67
500 changed files with 77303 additions and 1 deletions

View 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

View 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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View 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

View File

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

View File

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

View File

@@ -0,0 +1,7 @@
#import <MetalKit/MetalKit.h>
#import <AppKit/NSViewController.h>
@interface ViewController : NSViewController
- (instancetype)initWithSize:(NSRect)rect;
@end

View 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

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

View 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);
}