mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Implement #7930: automatically create custom user content folders
This commit is contained in:
committed by
Michael Steenbeek
parent
303dd66e5d
commit
f1d5989bc3
@@ -76,6 +76,7 @@ The following people are not part of the development team, but have been contrib
|
||||
* Nicolas Hawrysh (xp4xbox) - Various (ride) sprite improvements.
|
||||
* Albert Morgese (Fusxfaranto) - Shop auto-rotation, unicode uppercasing.
|
||||
* Olivier Wervers (oli414) - Remove unused objects command, various bugfixes
|
||||
* Christian Schubert (Osmodium) - Ensuring custom user content folders.
|
||||
|
||||
## Bug fixes
|
||||
* (halfbro)
|
||||
|
||||
@@ -359,6 +359,8 @@ namespace OpenRCT2
|
||||
_uiContext->CreateWindow();
|
||||
}
|
||||
|
||||
EnsureUserContentDirectoriesExist();
|
||||
|
||||
// TODO Ideally we want to delay this until we show the title so that we can
|
||||
// still open the game window and draw a progress screen for the creation
|
||||
// of the object cache.
|
||||
@@ -947,6 +949,35 @@ namespace OpenRCT2
|
||||
_uiContext->Update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the custom user content folders are present
|
||||
*/
|
||||
void EnsureUserContentDirectoriesExist()
|
||||
{
|
||||
EnsureDirectoriesExist(
|
||||
DIRBASE::USER,
|
||||
{
|
||||
DIRID::OBJECT,
|
||||
DIRID::SAVE,
|
||||
DIRID::SCENARIO,
|
||||
DIRID::TRACK,
|
||||
DIRID::LANDSCAPE,
|
||||
DIRID::HEIGHTMAP,
|
||||
DIRID::THEME,
|
||||
DIRID::SEQUENCE,
|
||||
});
|
||||
}
|
||||
|
||||
void EnsureDirectoriesExist(const DIRBASE dirBase, const std::initializer_list<DIRID>& dirIds)
|
||||
{
|
||||
for (const auto& dirId : dirIds)
|
||||
{
|
||||
auto path = _env->GetDirectoryPath(dirBase, dirId);
|
||||
if (!platform_ensure_directory_exists(path.c_str()))
|
||||
log_error("Unable to create directory '%s'.", path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy saved games and landscapes to user directory
|
||||
*/
|
||||
|
||||
@@ -209,6 +209,7 @@ const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] =
|
||||
"shaders", // SHADER
|
||||
"themes", // THEME
|
||||
"track", // TRACK
|
||||
"heightmap", // HEIGHTMAP
|
||||
};
|
||||
|
||||
const char * PlatformEnvironment::FileNames[] =
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace OpenRCT2
|
||||
SHADER, // Contains OpenGL shaders.
|
||||
THEME, // Contains interface themes.
|
||||
TRACK, // Contains track designs.
|
||||
HEIGHTMAP, // Contains heightmap data.
|
||||
};
|
||||
|
||||
enum class PATHID
|
||||
|
||||
Reference in New Issue
Block a user