mirror of https://github.com/OpenRCT2/OpenRCT2.git
Added searching for OpenRCT2 data in OS X app bundle resources folder
This commit is contained in:
parent
ea6fa2c82a
commit
d91a82f6ea
|
@ -112,6 +112,29 @@ void platform_posix_sub_user_data_path(char *buffer, const char *homedir, const
|
|||
strncat(buffer, separator, MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default directory fallback is:
|
||||
* - (command line argument)
|
||||
* - <exePath>/data
|
||||
* - /var/lib/openrct2
|
||||
* - /usr/share/openrct2
|
||||
*/
|
||||
void platform_posix_sub_resolve_openrct_data_path(utf8 *out) {
|
||||
static const utf8 *searchLocations[] = {
|
||||
"/var/lib/openrct2",
|
||||
"/usr/share/openrct2",
|
||||
};
|
||||
for (size_t i = 0; i < countof(searchLocations); i++)
|
||||
{
|
||||
if (platform_directory_exists(searchLocations[i]))
|
||||
{
|
||||
out[0] = '\0';
|
||||
safe_strncpy(out, searchLocations[i], MAX_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
utf8 *platform_open_directory_browser(utf8 *title)
|
||||
{
|
||||
STUB();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
@import AppKit;
|
||||
@import Foundation;
|
||||
#include <mach-o/dyld.h>
|
||||
#include "platform.h"
|
||||
#include "../util/util.h"
|
||||
|
@ -75,6 +76,29 @@ void platform_posix_sub_user_data_path(char *buffer, const char *homedir, const
|
|||
strncat(buffer, separator, MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default directory fallback is:
|
||||
* - (command line argument)
|
||||
* - <exePath>/data
|
||||
* - <Resources Folder>
|
||||
*/
|
||||
void platform_posix_sub_resolve_openrct_data_path(utf8 *out) {
|
||||
@autoreleasepool
|
||||
{
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
if (bundle)
|
||||
{
|
||||
const utf8 *resources = bundle.resourcePath.UTF8String;
|
||||
if (platform_directory_exists(resources))
|
||||
{
|
||||
out[0] = '\0';
|
||||
safe_strncpy(out, resources, MAX_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void platform_show_messagebox(char *message)
|
||||
{
|
||||
@autoreleasepool
|
||||
|
|
|
@ -574,9 +574,12 @@ void platform_get_openrct_data_path(utf8 *outPath)
|
|||
safe_strncpy(outPath, _openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
|
||||
}
|
||||
|
||||
void platform_posix_sub_resolve_openrct_data_path(utf8 *out);
|
||||
|
||||
/**
|
||||
* Default directory fallback is:
|
||||
* - (command line argument)
|
||||
* - <exePath>/data
|
||||
* - <platform dependent>
|
||||
*/
|
||||
void platform_resolve_openrct_data_path()
|
||||
|
@ -599,22 +602,14 @@ void platform_resolve_openrct_data_path()
|
|||
|
||||
strncat(buffer, separator, MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
|
||||
strncat(buffer, "data", MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
|
||||
const utf8 *searchLocations[] = {
|
||||
buffer,
|
||||
#ifdef __linux__
|
||||
"/var/lib/openrct2",
|
||||
"/usr/share/openrct2",
|
||||
#endif // __linux__
|
||||
};
|
||||
for (size_t i = 0; i < countof(searchLocations); i++)
|
||||
if (platform_directory_exists(buffer))
|
||||
{
|
||||
if (platform_directory_exists(searchLocations[i]))
|
||||
{
|
||||
_openrctDataDirectoryPath[0] = '\0';
|
||||
safe_strncpy(_openrctDataDirectoryPath, searchLocations[i], sizeof(_openrctDataDirectoryPath));
|
||||
return;
|
||||
}
|
||||
_openrctDataDirectoryPath[0] = '\0';
|
||||
safe_strncpy(_openrctDataDirectoryPath, buffer, MAX_PATH);
|
||||
return;
|
||||
}
|
||||
|
||||
platform_posix_sub_resolve_openrct_data_path(_openrctDataDirectoryPath);
|
||||
}
|
||||
|
||||
void platform_get_user_directory(utf8 *outPath, const utf8 *subDirectory)
|
||||
|
|
Loading…
Reference in New Issue