Skip to content

Commit

Permalink
Android: Fix 'Flare' directory not being automatically created
Browse files Browse the repository at this point in the history
Closes flareteam#1870

Also added a dialog message that can direct the player to the wiki page
that has instructions for installing the game data.
  • Loading branch information
dorkster committed Nov 12, 2023
1 parent 65fc25e commit 4b1f4ed
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Engine fixes:
* Fix power.target_neighbor not using the starting_pos as the origin point.
* Fixed crash in Power tooltips when base_damage was not defined.
* Fix incorrect power level being shown in the action bar tooltips for upgraded powers.
* Android: Fix 'Flare' directory not being automatically created.
* Android: Added a dialog to direct the player to the wiki page for installing if no game data is found.

Game updates:
* Limited the number of "unique" items that can drop from a boss to 1 per kill.
Expand Down
37 changes: 33 additions & 4 deletions src/PlatformAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Platform platform;
namespace PlatformAndroid {
std::string getPackageName();
int isExitEvent(void *userdata, SDL_Event* event);
void dialogInstallHint();
};

std::string PlatformAndroid::getPackageName()
Expand Down Expand Up @@ -72,6 +73,30 @@ int PlatformAndroid::isExitEvent(void* userdata, SDL_Event* event) {
return 1;
}

void PlatformAndroid::dialogInstallHint() {
const SDL_MessageBoxButtonData buttons[] = {
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT|SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "No" },
{ 0, 1, "Yes" },
};
const SDL_MessageBoxData messageboxdata = {
SDL_MESSAGEBOX_INFORMATION,
NULL,
"Flare",
"Flare game data needs to be installed. Visit the wiki page for download & instructions?",
static_cast<int>(SDL_arraysize(buttons)),
buttons,
NULL
};
int buttonid = 0;
SDL_ShowMessageBox(&messageboxdata, &buttonid);
if (buttonid == 0) {
// do nothing
}
else if (buttonid == 1) {
SDL_OpenURL("https://github.com/flareteam/flare-engine/wiki/Android-port");
}
}

Platform::Platform()
: has_exit_button(true)
, is_mobile_device(true)
Expand Down Expand Up @@ -172,14 +197,18 @@ void Platform::setPaths() {
}
}

// unable to create /Flare directory, use app directory instead
if (!Filesystem::pathExists(settings->path_user)) {
Filesystem::createDir(settings->path_user);

if (Filesystem::pathExists(settings->path_user)) {
// path_user created outside app directory; create path_conf inside it
Filesystem::createDir(settings->path_conf);
}
else {
// unable to create /Flare directory, use app directory instead
settings->path_user = settings->path_data + "/userdata";
settings->path_conf = settings->path_data + "/config";
}

Filesystem::createDir(settings->path_user);
Filesystem::createDir(settings->path_conf);
Filesystem::createDir(settings->path_user + "/mods");
Filesystem::createDir(settings->path_user + "/saves");

Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/

#include <SDL.h>

Version VersionInfo::ENGINE(1, 14, 30);
Version VersionInfo::ENGINE(1, 14, 31);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ static void init(const CmdLineArgs& cmd_line_args) {
Utils::logError("A copy of the default mod is in the \"mods\" directory of the flare-engine repo.");
Utils::logError("The repo is located at: https://github.com/flareteam/flare-engine");
Utils::logError("Try again after copying the default mod to one of the above directories. Exiting.");
Utils::logErrorDialog("main: Could not find the 'default' mod in the following locations:\n\n%smods/\n%smods/", settings->path_user.c_str(), settings->path_data.c_str());
Utils::logErrorDialog("main: Could not find the 'default' mod in the following locations:\n\n%smods/\n\n%smods/", settings->path_user.c_str(), settings->path_data.c_str());
#if __ANDROID__
PlatformAndroid::dialogInstallHint();
#endif
Utils::Exit(1);
}

Expand Down

0 comments on commit 4b1f4ed

Please sign in to comment.