Skip to content

Commit da326c0

Browse files
feat: add geode::dirs::getResourceDir() and {gd_resource_dir} setting variable (#1285)
1 parent 6175c25 commit da326c0

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

loader/include/Geode/loader/Dirs.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ namespace geode::dirs {
6161
* This directory is not deleted even when Geode is uninstalled
6262
*/
6363
GEODE_DLL std::filesystem::path getModPersistentDir();
64+
/**
65+
* Directory where Geometry Dash's resources are stored
66+
* On Android, the resources are stored in the APK, so this just returns "assets"
67+
*/
68+
GEODE_DLL std::filesystem::path getResourcesDir();
6469
}

loader/src/loader/SettingV3.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@ Result<std::shared_ptr<FileSettingV3>> FileSettingV3::parse(std::string const& k
973973
fmt::arg("gd_save_dir", dirs::getSaveDir()),
974974
fmt::arg("mod_config_dir", dirs::getModConfigDir() / modID),
975975
fmt::arg("mod_save_dir", dirs::getModsSaveDir() / modID),
976-
fmt::arg("temp_dir", dirs::getTempDir())
976+
fmt::arg("temp_dir", dirs::getTempDir()),
977+
fmt::arg("gd_resources_dir", dirs::getResourcesDir())
977978
));
978979
}
979980
catch(fmt::format_error const& e) {

loader/src/platform/android/util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ std::filesystem::path dirs::getModRuntimeDir() {
119119
return std::filesystem::path(cachedResult) / "geode" / "unzipped";
120120
}
121121

122+
std::filesystem::path dirs::getResourcesDir() {
123+
return "assets";
124+
}
125+
122126
void utils::web::openLinkInBrowser(std::string const& url) {
123127
CCApplication::sharedApplication()->openURL(url.c_str());
124128
}

loader/src/platform/ios/util.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ void shutdown() {
351351
return getBaseDir() / "save";
352352
}
353353

354+
std::filesystem::path dirs::getResourcesDir() {
355+
return [[[NSBundle mainBundle] resourcePath] UTF8String];
356+
}
357+
354358
bool geode::utils::permission::getPermissionStatus(Permission permission) {
355359
switch (permission) {
356360
case Permission::RecordAudio:

loader/src/platform/mac/util.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ +(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickO
246246
return dirs::getGeodeDir() / "unzipped";
247247
}
248248

249+
std::filesystem::path dirs::getResourcesDir() {
250+
return dirs::getGameDir() / "Resources";
251+
}
252+
249253
void geode::utils::game::exit() {
250254
if (CCApplication::sharedApplication() &&
251255
(GameManager::get()->m_playLayer || GameManager::get()->m_levelEditorLayer)) {

loader/src/platform/windows/util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ std::filesystem::path dirs::getModRuntimeDir() {
201201
return dirs::getGeodeDir() / "unzipped";
202202
}
203203

204+
std::filesystem::path dirs::getResourcesDir() {
205+
return dirs::getGameDir() / "Resources";
206+
}
207+
204208
void geode::utils::game::exit(bool saveData) {
205209
// TODO: mat
206210
#if 0

0 commit comments

Comments
 (0)