Skip to content

Commit

Permalink
Fix minor GUI bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 28, 2025
1 parent e196564 commit fba2be7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 74 deletions.
5 changes: 4 additions & 1 deletion platforms/shared/desktop/gui_filedialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "gui_debug_memory.h"
#include "gui_debug_disassembler.h"
#include "gui_debug_trace_logger.h"
#include "gui_menus.h"
#include "application.h"
#include "config.h"
#include "emu.h"
Expand Down Expand Up @@ -163,7 +164,9 @@ void gui_file_dialog_choose_savestate_path(void)
nfdresult_t result = NFD_PickFolderU8_With(&outPath, &args);
if (result == NFD_OKAY)
{
strncpy(gui_savestates_path, outPath, sizeof(gui_savestates_path));
config_emulator.savestates_path.assign(outPath);
update_savestates_data();
NFD_FreePath(outPath);
}
else if (result != NFD_CANCEL)
Expand All @@ -182,8 +185,8 @@ void gui_file_dialog_choose_screenshot_path(void)
nfdresult_t result = NFD_PickFolderU8_With(&outPath, &args);
if (result == NFD_OKAY)
{
strncpy(gui_screenshots_path, outPath, sizeof(gui_screenshots_path));
config_emulator.screenshots_path.assign(outPath);
update_savestates_data();
NFD_FreePath(outPath);
}
else if (result != NFD_CANCEL)
Expand Down
135 changes: 63 additions & 72 deletions platforms/shared/desktop/gui_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include "renderer.h"
#include "../../../src/geargrafx.h"

static char savefiles_path[4096] = "";
static char savestates_path[4096] = "";
static char screenshots_path[4096] = "";
static bool open_rom = false;
static bool open_ram = false;
static bool save_ram = false;
Expand All @@ -57,9 +54,9 @@ static void draw_savestate_slot_info(int slot);

void gui_init_menus(void)
{
strcpy(savefiles_path, config_emulator.savefiles_path.c_str());
strcpy(savestates_path, config_emulator.savestates_path.c_str());
strcpy(screenshots_path, config_emulator.screenshots_path.c_str());
strcpy(gui_savefiles_path, config_emulator.savefiles_path.c_str());
strcpy(gui_savestates_path, config_emulator.savestates_path.c_str());
strcpy(gui_screenshots_path, config_emulator.screenshots_path.c_str());
gui_shortcut_open_rom = false;
}

Expand Down Expand Up @@ -231,94 +228,88 @@ static void menu_emulator(void)
{
gui_in_use = true;

if (ImGui::BeginMenu("Directories"))
if (ImGui::BeginMenu("Save States Dir"))
{
if (ImGui::BeginMenu("Save States"))
ImGui::PushItemWidth(220.0f);
if (ImGui::Combo("##savestate_option", &config_emulator.savestates_dir_option, "Default Location\0Same as ROM\0Custom Location\0\0"))
{
ImGui::PushItemWidth(220.0f);
if (ImGui::Combo("##savestate_option", &config_emulator.savestates_dir_option, "Default Location\0Same as ROM\0Custom Location\0\0"))
update_savestates_data();
}

switch ((Directory_Location)config_emulator.savestates_dir_option)
{
case Directory_Location_Default:
{
update_savestates_data();
ImGui::Text("%s", config_root_path);
break;
}

switch ((Directory_Location)config_emulator.savestates_dir_option)
case Directory_Location_ROM:
{
case Directory_Location_Default:
{
ImGui::Text("%s", config_root_path);
break;
}
case Directory_Location_ROM:
if (emu_get_core()->GetCartridge()->IsReady())
ImGui::Text("%s", emu_get_core()->GetCartridge()->GetFileDirectory());
break;
}
case Directory_Location_Custom:
{
if (ImGui::MenuItem("Choose..."))
{
if (emu_get_core()->GetCartridge()->IsReady())
ImGui::Text("%s", emu_get_core()->GetCartridge()->GetFileDirectory());
break;
choose_savestates_path = true;
}
case Directory_Location_Custom:

ImGui::PushItemWidth(450);
if (ImGui::InputText("##savestate_path", gui_savestates_path, IM_ARRAYSIZE(gui_savestates_path), ImGuiInputTextFlags_AutoSelectAll))
{
if (ImGui::MenuItem("Choose..."))
{
choose_savestates_path = true;
}

ImGui::PushItemWidth(450);
if (ImGui::InputText("##savestate_path", savestates_path, IM_ARRAYSIZE(savestates_path), ImGuiInputTextFlags_AutoSelectAll))
{
config_emulator.savestates_path.assign(savestates_path);
update_savestates_data();
}
ImGui::PopItemWidth();
break;
config_emulator.savestates_path.assign(gui_savestates_path);
update_savestates_data();
}
ImGui::PopItemWidth();
break;
}

ImGui::EndMenu();
}

// if (ImGui::BeginMenu("RAM Saves"))
// {
// ImGui::EndMenu();
// }
ImGui::EndMenu();
}

if (ImGui::BeginMenu("Screenshots"))
{
ImGui::PushItemWidth(220.0f);
ImGui::Combo("##screenshots_option", &config_emulator.screenshots_dir_option, "Default Location\0Same as ROM\0Custom Location\0\0");
// if (ImGui::BeginMenu("RAM Saves Dir"))
// {
// ImGui::EndMenu();
// }

if (ImGui::BeginMenu("Screenshots Dir"))
{
ImGui::PushItemWidth(220.0f);
ImGui::Combo("##screenshots_option", &config_emulator.screenshots_dir_option, "Default Location\0Same as ROM\0Custom Location\0\0");

switch ((Directory_Location)config_emulator.screenshots_dir_option)
switch ((Directory_Location)config_emulator.screenshots_dir_option)
{
case Directory_Location_Default:
{
case Directory_Location_Default:
{
ImGui::Text("%s", config_root_path);
break;
}
case Directory_Location_ROM:
ImGui::Text("%s", config_root_path);
break;
}
case Directory_Location_ROM:
{
if (emu_get_core()->GetCartridge()->IsReady())
ImGui::Text("%s", emu_get_core()->GetCartridge()->GetFileDirectory());
break;
}
case Directory_Location_Custom:
{
if (ImGui::MenuItem("Choose..."))
{
if (emu_get_core()->GetCartridge()->IsReady())
ImGui::Text("%s", emu_get_core()->GetCartridge()->GetFileDirectory());
break;
choose_screenshots_path = true;
}
case Directory_Location_Custom:

ImGui::PushItemWidth(450);
if (ImGui::InputText("##screenshots_path", gui_screenshots_path, IM_ARRAYSIZE(gui_screenshots_path), ImGuiInputTextFlags_AutoSelectAll))
{
if (ImGui::MenuItem("Choose..."))
{
choose_screenshots_path = true;
}

ImGui::PushItemWidth(450);
if (ImGui::InputText("##screenshots_path", screenshots_path, IM_ARRAYSIZE(screenshots_path), ImGuiInputTextFlags_AutoSelectAll))
{
config_emulator.screenshots_path.assign(screenshots_path);
}
ImGui::PopItemWidth();
break;
config_emulator.screenshots_path.assign(gui_screenshots_path);
}
ImGui::PopItemWidth();
break;
}

ImGui::EndMenu();
}


ImGui::EndMenu();
}

Expand Down
4 changes: 4 additions & 0 deletions platforms/shared/desktop/gui_menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#define EXTERN extern
#endif

EXTERN char gui_savefiles_path[4096];
EXTERN char gui_savestates_path[4096];
EXTERN char gui_screenshots_path[4096];

EXTERN void gui_init_menus(void);
EXTERN void gui_main_menu(void);

Expand Down
1 change: 0 additions & 1 deletion platforms/shared/desktop/gui_popups.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
EXTERN void gui_popup_modal_keyboard();
EXTERN void gui_popup_modal_gamepad(int pad);
EXTERN void gui_popup_modal_about(void);
EXTERN void gui_popup_modal_bios(void);
EXTERN void gui_show_info(void);
EXTERN void gui_show_fps(void);

Expand Down

0 comments on commit fba2be7

Please sign in to comment.