diff --git a/base/project.js b/base/project.js index 19a6f688..27f5d63f 100644 --- a/base/project.js +++ b/base/project.js @@ -19,6 +19,14 @@ function add_thread_backend(name) { project.add_define("BACKEND_THREAD_H=\"backends/" + name + "_thread.h\""); } +function get_version_code() { + const now = new Date(); + const year = now.getFullYear().toString().slice(-2); + const month = (now.getMonth() + 1).toString().padStart(2, '0'); + const day = now.getDate().toString().padStart(2, '0'); + return parseInt(year + month + day, 10); +} + // flags: make.js/load_project let flags = globalThis.flags; let dir = flags.name.substr(5).toLowerCase(); // ArmorPaint -> paint @@ -94,6 +102,8 @@ else if (platform == "ios") { project.add_cfiles("sources/backends/data/ios.plist"); project.add_cfiles("sources/backends/ios_file_dialog.m"); project.add_define("IRON_METAL"); + project.target_options.ios.build = get_version_code() + ""; + project.target_options.ios.version = get_version_code() + ""; } else if (platform == "android") { add_sys_backend("android"); @@ -113,19 +123,11 @@ else if (platform == "android") { if (flags.with_audio) { project.add_lib("OpenSLES"); } - project.target_options.android.package = flags.package; project.target_options.android.permissions = ["android.permission.READ_MEDIA_IMAGES", "android.permission.INTERNET"]; project.target_options.android.screenOrientation = ["sensorLandscape"]; project.target_options.android.minSdkVersion = 33; // android 13 project.target_options.android.targetSdkVersion = 36; - function get_version_code() { - const now = new Date(); - const year = now.getFullYear().toString().slice(-2); - const month = (now.getMonth() + 1).toString().padStart(2, '0'); - const day = now.getDate().toString().padStart(2, '0'); - return parseInt(year + month + day, 10); - } project.target_options.android.versionCode = get_version_code(); project.target_options.android.versionName = "1.0 alpha"; } @@ -238,6 +240,9 @@ if (fs_exists(os_cwd() + "/icon.png")) { if (platform == "macos" && fs_exists(os_cwd() + "/icon_macos.png")) { project.icon = "icon_macos.png"; } + else if (platform == "ios" && fs_exists(os_cwd() + "/icon_ios.png")) { + project.icon = "icon_ios.png"; + } else if (platform == "linux") { project.add_assets("../" + dir + "/icon.png", { destination: "{name}", noprocessing: true, noembed: true }); } diff --git a/base/sources/backends/ios_file_dialog.m b/base/sources/backends/ios_file_dialog.m index d67b98b0..dd73ac9e 100644 --- a/base/sources/backends/ios_file_dialog.m +++ b/base/sources/backends/ios_file_dialog.m @@ -2,11 +2,15 @@ #import +static UIDocumentPickerViewController *documentPicker = nil; + void IOSFileDialogOpen() { UIViewController *myViewController = [UIApplication sharedApplication].keyWindow.rootViewController; - UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeOpen]; - documentPicker.delegate = myViewController; - documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; + if (documentPicker == nil) { + documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeOpen]; + documentPicker.delegate = myViewController; + documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; + } [myViewController presentViewController:documentPicker animated:YES completion:nil]; } diff --git a/base/sources/backends/ios_system.m b/base/sources/backends/ios_system.m index e0107c5c..82502001 100644 --- a/base/sources/backends/ios_system.m +++ b/base/sources/backends/ios_system.m @@ -495,13 +495,10 @@ void importFile(NSURL *url) { iron_internal_drop_files_callback(wpath); } -- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url { - // wchar_t *filePath = (wchar_t *)[url.path cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; - // CFURLRef cfurl = (__bridge CFURLRef)url; - // CFURLStartAccessingSecurityScopedResource(cfurl); - // iron_internal_drop_files_callback(filePath); - // CFURLStopAccessingSecurityScopedResource(cfurl); - importFile(url); +- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray *)urls { + for (NSURL *url in urls) { + importFile(url); + } } - (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id)session { @@ -522,7 +519,7 @@ void importFile(NSURL *url) { } - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { - return UIRectEdgeAll; + return UIRectEdgeAll; } @end @@ -544,9 +541,9 @@ void importFile(NSURL *url) { #endif UIWindowScene *windowScene = (UIWindowScene *)scene; - self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; self.window.frame = windowScene.coordinateSpace.bounds; - [self.window setBackgroundColor:[UIColor blackColor]]; + [self.window setBackgroundColor:[UIColor blackColor]]; my_view_controller = [[MyViewController alloc] init]; my_view_controller.view.multipleTouchEnabled = YES; @@ -561,19 +558,19 @@ void importFile(NSURL *url) { } - (void)sceneDidBecomeActive:(UIScene *)scene { - iron_internal_resume_callback(); + iron_internal_resume_callback(); } - (void)sceneWillResignActive:(UIScene *)scene { - iron_internal_pause_callback(); + iron_internal_pause_callback(); } - (void)sceneWillEnterForeground:(UIScene *)scene { - iron_internal_foreground_callback(); + iron_internal_foreground_callback(); } - (void)sceneDidEnterBackground:(UIScene *)scene { - iron_internal_background_callback(); + iron_internal_background_callback(); } @end diff --git a/base/tools/make.js b/base/tools/make.js index 3fd86f62..ecd40868 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -1100,7 +1100,7 @@ class XCodeExporter extends Exporter { frameworks.push(new Framework(lib)); } let target_options = { - bundle: 'org.$(PRODUCT_NAME)', + bundle: 'org.armory3d.' + project.getName().toLowerCase(), version: "1.0", build: "1", organizationName: "Armory3D", @@ -1108,16 +1108,10 @@ class XCodeExporter extends Exporter { }; if (project.target_options && project.target_options.ios) { let userOptions = project.target_options.ios; - if (userOptions.bundle) - target_options.bundle = userOptions.bundle; if (userOptions.version) target_options.version = userOptions.version; if (userOptions.build) target_options.build = userOptions.build; - if (userOptions.organizationName) - target_options.organizationName = userOptions.organizationName; - if (userOptions.developmentTeam) - target_options.developmentTeam = userOptions.developmentTeam; } let projectId = new_path_id("_projectId"); let appFileId = new_path_id("_appFileId"); @@ -2779,6 +2773,7 @@ class Project { this.includes = []; this.target_options = { android: {}, + ios: {} }; this.executable_name = null; this.sources = []; diff --git a/paint/icon_ios.png b/paint/icon_ios.png new file mode 100644 index 00000000..e1efda61 Binary files /dev/null and b/paint/icon_ios.png differ diff --git a/paint/sources/import_asset.ts b/paint/sources/import_asset.ts index 3cbac2b5..c61337b8 100644 --- a/paint/sources/import_asset.ts +++ b/paint/sources/import_asset.ts @@ -8,8 +8,10 @@ let _import_asset_done: ()=>void; function import_asset_run(path: string, drop_x: f32 = -1.0, drop_y: f32 = -1.0, show_box: bool = true, hdr_as_envmap: bool = true, done: ()=>void = null) { if (starts_with(path, "cloud")) { - ///if (arm_android || arm_ios) + ///if arm_android console_toast(tr("Downloading")); + ///else + console_info(tr("Downloading")); ///end _import_asset_drop_x = drop_x; diff --git a/paint/sources/import_envmap.ts b/paint/sources/import_envmap.ts index 912a7fad..f35adc63 100644 --- a/paint/sources/import_envmap.ts +++ b/paint/sources/import_envmap.ts @@ -57,6 +57,7 @@ function import_envmap_run(path: string, image: gpu_texture_t) { scene_world._.radiance = import_envmap_radiance; scene_world._.radiance_mipmaps = import_envmap_mips; context_raw.saved_envmap = image; + context_raw.show_envmap = true; if (context_raw.show_envmap_blur) { scene_world._.envmap = scene_world._.radiance_mipmaps[0]; } diff --git a/paint/sources/ui_base.ts b/paint/sources/ui_base.ts index 3d0fbe1c..b6d04130 100644 --- a/paint/sources/ui_base.ts +++ b/paint/sources/ui_base.ts @@ -105,6 +105,9 @@ function ui_base_init() { scene_world._.envmap = context_raw.show_envmap ? context_raw.saved_envmap : context_raw.empty_envmap; context_raw.ddirty = 1; + let resources: string[] = ["cursor.k", "icons.k"]; + resource_load(resources); + let scale: f32 = config_raw.window_scale; let ops: ui_options_t = { theme: base_theme, @@ -133,9 +136,6 @@ function ui_base_init() { context_raw.gizmo_rotate_y = object_get_child(context_raw.gizmo, ".RotateY"); context_raw.gizmo_rotate_z = object_get_child(context_raw.gizmo, ".RotateZ"); - let resources: string[] = ["cursor.k", "icons.k"]; - resource_load(resources); - project_new(false); if (project_filepath == "") { diff --git a/paint/sources/ui_menubar.ts b/paint/sources/ui_menubar.ts index c9c94d69..4c0e9e18 100644 --- a/paint/sources/ui_menubar.ts +++ b/paint/sources/ui_menubar.ts @@ -345,6 +345,7 @@ function ui_menubar_draw_category_items() { context_raw.ddirty = 2; } + context_raw.show_envmap_handle.selected = context_raw.show_envmap; context_raw.show_envmap = ui_check(context_raw.show_envmap_handle, " " + tr("Envmap")); if (context_raw.show_envmap_handle.changed) { context_load_envmap();