Skip to content

Commit

Permalink
Make use of containing ROM folder optional
Browse files Browse the repository at this point in the history
This is mostly useful for distributions where it is not expected for
permission to be granted to the directory a ROM is contained in (e.g.
Flatpak or other Portal API use).

To this end, the `ImGui::Combo` API now uses a list rather that a double
null-terminated string as—combined with trailing commas in C++11—this
allows for entries in this list to be easily added and removed.

Currently, no platform uses this, but this will likely be useful for a
contained release.
  • Loading branch information
TomChapple committed Apr 1, 2024
1 parent 306ad2c commit 4787600
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions platforms/desktop-shared/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,17 @@ static void main_menu(void)

ImGui::Separator();

static const char* const SAVE_FILES_LOCATION_OPTS[] = {
"Save Files In Custom Folder",
#ifndef PREVENT_ROM_FOLDER_USAGE
"Save Files In ROM Folder",
#endif
};
static constexpr int SAVE_FILES_LOCATION_OPTS_COUNT = sizeof(SAVE_FILES_LOCATION_OPTS) / sizeof(const char*);
if (ImGui::BeginMenu("Save File Location"))
{
ImGui::PushItemWidth(220.0f);
if (ImGui::Combo("##savefile_option", &config_emulator.savefiles_dir_option, "Save Files In Custom Folder\0Save Files In ROM Folder\0\0"))
if (ImGui::Combo("##savefile_option", &config_emulator.savefiles_dir_option, SAVE_FILES_LOCATION_OPTS, SAVE_FILES_LOCATION_OPTS_COUNT))
{
emu_savefiles_dir_option = config_emulator.savefiles_dir_option;
}
Expand All @@ -583,10 +590,17 @@ static void main_menu(void)
ImGui::EndMenu();
}

static const char* const SAVE_STATES_LOCATION_OPTS[] = {
"Savestates In Custom Folder",
#ifndef PREVENT_ROM_FOLDER_USAGE
"Savestates In ROM Folder",
#endif
};
static constexpr int SAVE_STATES_LOCATION_OPTS_COUNT = sizeof(SAVE_STATES_LOCATION_OPTS) / sizeof(const char*);
if (ImGui::BeginMenu("Save State Location"))
{
ImGui::PushItemWidth(220.0f);
if (ImGui::Combo("##savestate_option", &config_emulator.savestates_dir_option, "Savestates In Custom Folder\0Savestates In ROM Folder\0\0"))
if (ImGui::Combo("##savestate_option", &config_emulator.savestates_dir_option, SAVE_STATES_LOCATION_OPTS, SAVE_STATES_LOCATION_OPTS_COUNT))
{
emu_savestates_dir_option = config_emulator.savestates_dir_option;
}
Expand Down

0 comments on commit 4787600

Please sign in to comment.