Skip to content

Commit

Permalink
bugfix: improve double-click -> load config and start emulation (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed May 10, 2024
1 parent cb4d82c commit 90506bf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/osdep/gui/PanelConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ class ConfigButtonActionListener : public gcn::ActionListener

static ConfigButtonActionListener* configButtonActionListener;

static Uint32 last_click_time = 0;
class ConfigsListActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent) override
{
const int selected_item = lstConfigs->getSelected();
if (selected_item == -1) return;

const Uint32 current_time = SDL_GetTicks();

if (txtName->getText() != ConfigFilesList[selected_item]->Name || txtDesc->getText() != ConfigFilesList[
selected_item]->Description)
{
Expand All @@ -138,22 +140,24 @@ class ConfigsListActionListener : public gcn::ActionListener
txtName->setText(ConfigFilesList[selected_item]->Name);
txtDesc->setText(ConfigFilesList[selected_item]->Description);
}
else

//-----------------------------------------------
// Double click on selected config -> Load it and start emulation
// ----------------------------------------------
if (current_time - last_click_time < 1000)
{
//-----------------------------------------------
// Second click on selected config -> Load it and start emulation
// ----------------------------------------------
if (emulating)
{
disable_resume();
}
target_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, CONFIG_TYPE_DEFAULT, 0);
strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_DPATH);
refresh_all_panels();

uae_reset(1, 1);
gui_running = false;
}
last_click_time = current_time;
}
};

Expand Down

0 comments on commit 90506bf

Please sign in to comment.