backend-infra-engineer: Pre-0.2.2 2024 Q4 snapshot
This commit is contained in:
6
src/ios/Media.xcassets/Contents.json
Normal file
6
src/ios/Media.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
14
src/ios/Media.xcassets/yaze.appiconset/Contents.json
Normal file
14
src/ios/Media.xcassets/yaze.appiconset/Contents.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "yaze.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
src/ios/Media.xcassets/yaze.appiconset/yaze.png
Normal file
BIN
src/ios/Media.xcassets/yaze.appiconset/yaze.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
120
src/ios/iOS/Info-iOS.plist
Normal file
120
src/ios/iOS/Info-iOS.plist
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>SFC ROM</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Default</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>org.halext.sfc</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>SMC ROM</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Default</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>halext.sfc</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>yaze-ios</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
<string>metal</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<false/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string></string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>Super Nintendo ROMs</string>
|
||||
<key>UTTypeIconFiles</key>
|
||||
<array/>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>org.halext.sfc</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>sfc</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>Super Nintendo ROMs</string>
|
||||
<key>UTTypeIconFiles</key>
|
||||
<array/>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>org.halext.sfc</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>sfc</string>
|
||||
</array>
|
||||
<key>public.mime-type</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
27
src/ios/iOS/LaunchScreen.storyboard
Normal file
27
src/ios/iOS/LaunchScreen.storyboard
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
|
||||
<color key="backgroundColor" red="0.27843137254901962" green="0.36078431372549019" blue="0.50196078431372548" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
394
src/ios/main.mm
Normal file
394
src/ios/main.mm
Normal file
@@ -0,0 +1,394 @@
|
||||
// yaze iOS Application
|
||||
// Uses SDL2 and ImGui
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
|
||||
|
||||
#include "app/core/controller.h"
|
||||
#include "app/core/platform/app_delegate.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
#include "app/core/platform/view_controller.h"
|
||||
#include "imgui/backends/imgui_impl_metal.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppViewController
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@implementation AppViewController
|
||||
|
||||
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
|
||||
bundle:(nullable NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
|
||||
_device = MTLCreateSystemDefaultDevice();
|
||||
_commandQueue = [_device newCommandQueue];
|
||||
|
||||
if (!self.device) {
|
||||
NSLog(@"Metal is not supported");
|
||||
abort();
|
||||
}
|
||||
|
||||
_controller = new yaze::app::core::Controller();
|
||||
|
||||
SDL_SetMainReady();
|
||||
SDL_iOSSetEventPump(SDL_TRUE);
|
||||
int argc = NSProcessInfo.processInfo.arguments.count;
|
||||
char **argv = new char *[argc];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
NSString *arg = NSProcessInfo.processInfo.arguments[i];
|
||||
const char *cString = [arg UTF8String];
|
||||
argv[i] = new char[strlen(cString) + 1];
|
||||
strcpy(argv[i], cString);
|
||||
}
|
||||
|
||||
std::string rom_filename = "";
|
||||
if (argc > 1) {
|
||||
rom_filename = argv[1];
|
||||
}
|
||||
SDL_iOSSetEventPump(SDL_FALSE);
|
||||
|
||||
// Enable native IME.
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
if (!_controller->CreateWindow().ok()) {
|
||||
printf("Error creating window: %s\n", SDL_GetError());
|
||||
abort();
|
||||
}
|
||||
if (!_controller->CreateRenderer().ok()) {
|
||||
printf("Error creating renderer: %s\n", SDL_GetError());
|
||||
abort();
|
||||
}
|
||||
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
(void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
yaze::app::gui::ColorsYaze();
|
||||
|
||||
ImGui_ImplSDL2_InitForSDLRenderer(_controller->window(), _controller->renderer());
|
||||
ImGui_ImplSDLRenderer2_Init(_controller->renderer());
|
||||
|
||||
if (!_controller->LoadFontFamilies().ok()) {
|
||||
abort();
|
||||
}
|
||||
_controller->SetupScreen(rom_filename);
|
||||
_controller->set_active(true);
|
||||
|
||||
_hoverGestureRecognizer =
|
||||
[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(HoverGesture:)];
|
||||
[self.view addGestureRecognizer:_hoverGestureRecognizer];
|
||||
|
||||
_pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(HandlePinch:)];
|
||||
[self.view addGestureRecognizer:_pinchRecognizer];
|
||||
|
||||
_longPressRecognizer =
|
||||
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
|
||||
[self.view addGestureRecognizer:_longPressRecognizer];
|
||||
|
||||
_swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(HandleSwipe:)];
|
||||
_swipeRecognizer.direction =
|
||||
UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft;
|
||||
[self.view addGestureRecognizer:_swipeRecognizer];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (MTKView *)mtkView {
|
||||
return (MTKView *)self.view;
|
||||
}
|
||||
|
||||
- (void)loadView {
|
||||
self.view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, 1200, 720)];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.mtkView.device = self.device;
|
||||
self.mtkView.delegate = self;
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
ImGui_ImplOSX_Init(self.view);
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)drawInMTKView:(MTKView *)view {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.DisplaySize.x = view.bounds.size.width;
|
||||
io.DisplaySize.y = view.bounds.size.height;
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
CGFloat framebufferScale =
|
||||
view.window.screen.backingScaleFactor ?: NSScreen.mainScreen.backingScaleFactor;
|
||||
#else
|
||||
CGFloat framebufferScale = view.window.screen.scale ?: UIScreen.mainScreen.scale;
|
||||
#endif
|
||||
io.DisplayFramebufferScale = ImVec2(framebufferScale, framebufferScale);
|
||||
|
||||
ImGui_ImplSDLRenderer2_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
#if TARGET_OS_OSX
|
||||
ImGui_ImplOSX_NewFrame(view);
|
||||
#endif
|
||||
|
||||
ImGui::NewFrame();
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
ImVec2 dimensions(io.DisplaySize.x, io.DisplaySize.y);
|
||||
ImGui::SetNextWindowSize(dimensions, ImGuiCond_Always);
|
||||
if (ImGui::Begin("##YazeMain", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_MenuBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus)) {
|
||||
auto controller_status = _controller->OnLoad();
|
||||
if (!controller_status.ok()) {
|
||||
abort();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
_controller->DoRender();
|
||||
}
|
||||
|
||||
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Input processing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
|
||||
- (void)viewWillAppear {
|
||||
[super viewWillAppear];
|
||||
self.view.window.delegate = self;
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification {
|
||||
ImGui_ImplMetal_Shutdown();
|
||||
ImGui_ImplOSX_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// This touch mapping is super cheesy/hacky. We treat any touch on the screen
|
||||
// as if it were a depressed left mouse button, and we don't bother handling
|
||||
// multitouch correctly at all. This causes the "cursor" to behave very erratically
|
||||
// when there are multiple active touches. But for demo purposes, single-touch
|
||||
// interaction actually works surprisingly well.
|
||||
- (void)UpdateIOWithTouchEvent:(UIEvent *)event {
|
||||
UITouch *anyTouch = event.allTouches.anyObject;
|
||||
CGPoint touchLocation = [anyTouch locationInView:self.view];
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
||||
io.AddMousePosEvent(touchLocation.x, touchLocation.y);
|
||||
|
||||
BOOL hasActiveTouch = NO;
|
||||
for (UITouch *touch in event.allTouches) {
|
||||
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) {
|
||||
hasActiveTouch = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
io.AddMouseButtonEvent(0, hasActiveTouch);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self UpdateIOWithTouchEvent:event];
|
||||
}
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self UpdateIOWithTouchEvent:event];
|
||||
}
|
||||
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self UpdateIOWithTouchEvent:event];
|
||||
}
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self UpdateIOWithTouchEvent:event];
|
||||
}
|
||||
|
||||
- (void)HoverGesture:(UIHoverGestureRecognizer *)gesture {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
||||
// Cast to UIGestureRecognizer to UIGestureRecognizer to get locationInView
|
||||
UIGestureRecognizer *gestureRecognizer = (UIGestureRecognizer *)gesture;
|
||||
if (gesture.zOffset < 0.50) {
|
||||
io.AddMousePosEvent([gestureRecognizer locationInView:self.view].x,
|
||||
[gestureRecognizer locationInView:self.view].y);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)HandlePinch:(UIPinchGestureRecognizer *)gesture {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
||||
io.AddMouseWheelEvent(0.0f, gesture.scale);
|
||||
}
|
||||
|
||||
- (void)HandleSwipe:(UISwipeGestureRecognizer *)gesture {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
||||
if (gesture.direction == UISwipeGestureRecognizerDirectionRight) {
|
||||
io.AddMouseWheelEvent(1.0f, 0.0f); // Swipe Right
|
||||
} else if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) {
|
||||
io.AddMouseWheelEvent(-1.0f, 0.0f); // Swipe Left
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);
|
||||
io.AddMouseButtonEvent(1, gesture.state == UIGestureRecognizerStateBegan);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppDelegate
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
@property(nonatomic, strong) NSWindow *window;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
NSViewController *rootViewController = [[AppViewController alloc] initWithNibName:nil
|
||||
bundle:nil];
|
||||
self.window = [[NSWindow alloc]
|
||||
initWithContentRect:NSZeroRect
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||
NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
self.window.contentViewController = rootViewController;
|
||||
[self.window center];
|
||||
[self.window makeKeyAndOrderFront:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
|
||||
UIViewController *rootViewController = [[AppViewController alloc] init];
|
||||
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
||||
self.window.rootViewController = rootViewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
ImGui_ImplSDLRenderer2_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
- (void)PresentDocumentPickerWithCompletionHandler:
|
||||
(void (^)(NSString *selectedFile))completionHandler {
|
||||
self.completionHandler = completionHandler;
|
||||
|
||||
NSArray *documentTypes = @[ [UTType typeWithIdentifier:@"org.halext.sfc"] ];
|
||||
UIViewController *rootViewController = self.window.rootViewController;
|
||||
_documentPicker =
|
||||
[[UIDocumentPickerViewController alloc] initForOpeningContentTypes:documentTypes];
|
||||
_documentPicker.delegate = self;
|
||||
_documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
|
||||
[rootViewController presentViewController:_documentPicker animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller
|
||||
didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
|
||||
NSURL *selectedFileURL = [urls firstObject];
|
||||
|
||||
if (self.completionHandler) {
|
||||
if (selectedFileURL) {
|
||||
self.completionHandler(selectedFileURL.path);
|
||||
std::string fileName = std::string([selectedFileURL.path UTF8String]);
|
||||
|
||||
// Extract the data from the file
|
||||
[selectedFileURL startAccessingSecurityScopedResource];
|
||||
|
||||
auto data = [NSData dataWithContentsOfURL:selectedFileURL];
|
||||
// Cast NSData* to uint8_t*
|
||||
uchar *bytes = (uchar *)[data bytes];
|
||||
// Size of the data
|
||||
size_t size = [data length];
|
||||
|
||||
PRINT_IF_ERROR(yaze::app::SharedRom::shared_rom_->LoadFromPointer(bytes, size));
|
||||
std::string filename = std::string([selectedFileURL.path UTF8String]);
|
||||
yaze::app::SharedRom::shared_rom_->set_filename(filename);
|
||||
[selectedFileURL stopAccessingSecurityScopedResource];
|
||||
|
||||
} else {
|
||||
self.completionHandler(@"");
|
||||
}
|
||||
}
|
||||
self.completionHandler = nil;
|
||||
[controller dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
|
||||
if (self.completionHandler) {
|
||||
self.completionHandler(@"");
|
||||
}
|
||||
self.completionHandler = nil;
|
||||
[controller dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Application main() function
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
int main(int argc, const char *argv[]) { return NSApplicationMain(argc, argv); }
|
||||
#else
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
6321
src/ios/yaze.xcodeproj/project.pbxproj
Normal file
6321
src/ios/yaze.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
7
src/ios/yaze.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
src/ios/yaze.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:/Users/scawful/Code/yaze/src/ios/yaze.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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/>
|
||||
</plist>
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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>top-level-items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>children</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>children</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destination</key>
|
||||
<dict>
|
||||
<key>rebasable-url</key>
|
||||
<dict>
|
||||
<key>base</key>
|
||||
<string>workspace</string>
|
||||
<key>payload</key>
|
||||
<dict>
|
||||
<key>relative-path</key>
|
||||
<string>iOS/LaunchScreen.storyboard</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>DVTDocumentLocation</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>bookmark</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destination</key>
|
||||
<dict>
|
||||
<key>rebasable-url</key>
|
||||
<dict>
|
||||
<key>base</key>
|
||||
<string>workspace</string>
|
||||
<key>payload</key>
|
||||
<dict>
|
||||
<key>relative-path</key>
|
||||
<string>iOS/Info-iOS.plist</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>DVTDocumentLocation</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>bookmark</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>title</key>
|
||||
<string>iOS</string>
|
||||
<key>type</key>
|
||||
<string>group</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>children</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destination</key>
|
||||
<dict>
|
||||
<key>rebasable-url</key>
|
||||
<dict>
|
||||
<key>base</key>
|
||||
<string>workspace</string>
|
||||
<key>payload</key>
|
||||
<dict>
|
||||
<key>relative-path</key>
|
||||
<string>macOS/MainMenu.storyboard</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>DVTDocumentLocation</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>bookmark</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destination</key>
|
||||
<dict>
|
||||
<key>rebasable-url</key>
|
||||
<dict>
|
||||
<key>base</key>
|
||||
<string>workspace</string>
|
||||
<key>payload</key>
|
||||
<dict>
|
||||
<key>relative-path</key>
|
||||
<string>macOS/Info-macOS.plist</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>DVTDocumentLocation</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>bookmark</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>title</key>
|
||||
<string>macOS</string>
|
||||
<key>type</key>
|
||||
<string>group</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destination</key>
|
||||
<dict>
|
||||
<key>rebasable-url</key>
|
||||
<dict>
|
||||
<key>base</key>
|
||||
<string>workspace</string>
|
||||
<key>payload</key>
|
||||
<dict>
|
||||
<key>relative-path</key>
|
||||
<string>main.mm</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>DVTDocumentLocation</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>bookmark</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>title</key>
|
||||
<string>yaze-ios</string>
|
||||
<key>type</key>
|
||||
<string>group</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
src/ios/yaze.xcodeproj/project.xcworkspace/xcuserdata/scawful.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
src/ios/yaze.xcodeproj/project.xcworkspace/xcuserdata/scawful.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
<?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>BuildLocationStyle</key>
|
||||
<string>UseAppPreferences</string>
|
||||
<key>CustomBuildLocationType</key>
|
||||
<string>RelativeToDerivedData</string>
|
||||
<key>DerivedDataLocationStyle</key>
|
||||
<string>Default</string>
|
||||
<key>ShowSharedSchemesAutomaticallyEnabled</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
uuid = "7EE5EA39-AD11-4288-9891-6AD47470A4DD"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
</Bucket>
|
||||
@@ -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>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>example_apple_metal_ios.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>example_apple_metal_macos.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>imgui_apple_metal_ios.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>imgui_apple_metal_macos.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>yaze_ios.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
<key>yaze_macos.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>7</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user