mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 05:39:58 +00:00
Merge pull request #113455 from bruvzg/ios_p
[iOS] Fix use of `godot_path`.
This commit is contained in:
commit
ec3f304ccc
5 changed files with 13 additions and 17 deletions
|
|
@ -718,7 +718,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
|
|||
// We need to test both possibilities as extensions for Linux binaries are optional
|
||||
// (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
|
||||
|
||||
#ifdef MACOS_ENABLED
|
||||
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
|
||||
if (!found) {
|
||||
// Attempt to load PCK from macOS .app bundle resources.
|
||||
found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_basename + ".pck"), false, 0, true) || _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().path_join(exec_filename + ".pck"), false, 0, true);
|
||||
|
|
@ -777,7 +777,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef MACOS_ENABLED
|
||||
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
|
||||
// Attempt to load project file from macOS .app bundle resources.
|
||||
resource_path = OS::get_singleton()->get_bundle_resource_dir();
|
||||
if (!resource_path.is_empty()) {
|
||||
|
|
|
|||
|
|
@ -52,19 +52,6 @@ void change_to_launch_dir(char **p_args) {
|
|||
}
|
||||
}
|
||||
|
||||
int add_path(int p_argc, char **p_args) {
|
||||
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
|
||||
if (!str) {
|
||||
return p_argc;
|
||||
}
|
||||
|
||||
p_args[p_argc++] = (char *)"--path";
|
||||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
p_args[p_argc] = nullptr;
|
||||
|
||||
return p_argc;
|
||||
}
|
||||
|
||||
int add_cmdline(int p_argc, char **p_args) {
|
||||
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
|
||||
if (!arr) {
|
||||
|
|
@ -89,7 +76,6 @@ int process_args(int p_argc, char **p_args, char **r_args) {
|
|||
r_args[i] = p_args[i];
|
||||
}
|
||||
r_args[p_argc] = nullptr;
|
||||
p_argc = add_path(p_argc, r_args);
|
||||
p_argc = add_cmdline(p_argc, r_args);
|
||||
return p_argc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public:
|
|||
virtual String get_cache_path() const override;
|
||||
virtual String get_temp_path() const override;
|
||||
virtual String get_resource_dir() const override;
|
||||
virtual String get_bundle_resource_dir() const override;
|
||||
|
||||
virtual String get_locale() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -412,6 +412,15 @@ String OS_AppleEmbedded::get_resource_dir() const {
|
|||
#endif
|
||||
}
|
||||
|
||||
String OS_AppleEmbedded::get_bundle_resource_dir() const {
|
||||
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
|
||||
if (!str) {
|
||||
return OS_Unix::get_bundle_resource_dir();
|
||||
} else {
|
||||
return String::utf8([str cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
}
|
||||
}
|
||||
|
||||
String OS_AppleEmbedded::get_locale() const {
|
||||
NSString *preferredLanguage = [NSLocale preferredLanguages].firstObject;
|
||||
|
||||
|
|
|
|||
|
|
@ -996,7 +996,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
|
||||
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
|
||||
String old_cwd = OS::get_singleton()->get_cwd();
|
||||
#ifdef MACOS_ENABLED
|
||||
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
|
||||
String new_cwd = OS::get_singleton()->get_bundle_resource_dir();
|
||||
if (new_cwd.is_empty() || !new_cwd.is_absolute_path()) {
|
||||
new_cwd = OS::get_singleton()->get_executable_path().get_base_dir();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue