mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-12-18 10:37:53 +01:00
Added WD and Linux-specific /usr/* to game data search paths.
Improved data not found error message. Ref #100.
This commit is contained in:
parent
389122182e
commit
3400ea4576
4 changed files with 38 additions and 9 deletions
|
@ -118,7 +118,7 @@ int pb::uninit()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void pb::SelectDatFile(std::array<char*, 2> dataSearchPaths)
|
||||
void pb::SelectDatFile(const std::vector<const char*>& dataSearchPaths)
|
||||
{
|
||||
DatFileName.clear();
|
||||
FullTiltDemoMode = FullTiltMode = false;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
static int init();
|
||||
static int uninit();
|
||||
static void SelectDatFile(std::array<char*, 2> dataSearchPaths);
|
||||
static void SelectDatFile(const std::vector<const char*>& dataSearchPaths);
|
||||
static void reset_table();
|
||||
static void firsttime_setup();
|
||||
static void mode_change(int mode);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <string>
|
||||
#include <thread>
|
||||
#include <map>
|
||||
#include <array>
|
||||
//#include <array>
|
||||
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include "SDL.h"
|
||||
|
@ -94,4 +94,15 @@ inline FILE* fopenu(const char* path, const char* opt)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Platform specific data paths not found in SDL
|
||||
constexpr const char* PlatformDataPaths[2] =
|
||||
{
|
||||
#ifdef _WIN32
|
||||
nullptr
|
||||
#else
|
||||
"/usr/local/share/SpaceCadetPinball/",
|
||||
"/usr/share/SpaceCadetPinball/"
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //PCH_H
|
||||
|
|
|
@ -114,14 +114,23 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||
auto iniPath = std::string(prefPath) + "imgui_pb.ini";
|
||||
io.IniFilename = iniPath.c_str();
|
||||
|
||||
// First step: just load the options, second: run updates depending on FullTiltMode
|
||||
// First step: just load the options
|
||||
options::InitPrimary();
|
||||
|
||||
// Data search order: WD, executable path, user pref path, platform specific paths.
|
||||
auto basePath = SDL_GetBasePath();
|
||||
pb::SelectDatFile(std::array<char*, 2>
|
||||
std::vector<const char*> searchPaths
|
||||
{
|
||||
{
|
||||
"",
|
||||
basePath,
|
||||
prefPath
|
||||
});
|
||||
}
|
||||
};
|
||||
searchPaths.insert(searchPaths.end(), std::begin(PlatformDataPaths), std::end(PlatformDataPaths));
|
||||
pb::SelectDatFile(searchPaths);
|
||||
|
||||
// Second step: run updates depending on FullTiltMode
|
||||
options::InitSecondary();
|
||||
|
||||
if (!Sound::Init(Options.SoundChannels, Options.Sounds))
|
||||
|
@ -132,8 +141,17 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||
|
||||
if (pb::init())
|
||||
{
|
||||
std::string message = "The .dat file is missing.\n"
|
||||
"Make sure that the game data is present in any of the following locations:\n";
|
||||
for (auto path : searchPaths)
|
||||
{
|
||||
if (path)
|
||||
{
|
||||
message = message + (path[0] ? path : "working directory") + "\n";
|
||||
}
|
||||
}
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not load game data",
|
||||
"The .dat file is missing", window);
|
||||
message.c_str(), window);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue