Fixed config loaded and emulation restarted as soon as you click on an entry in the list.
This commit is contained in:
parent
98887f2665
commit
4112a26952
1 changed files with 283 additions and 278 deletions
|
@ -21,7 +21,7 @@
|
|||
#include "gui.h"
|
||||
#include "gui_handling.h"
|
||||
|
||||
static char last_active_config[MAX_DPATH] = {'\0'};
|
||||
static char last_active_config[MAX_DPATH] = { '\0' };
|
||||
static int ensureVisible = -1;
|
||||
|
||||
static gcn::Button* cmdLoad;
|
||||
|
@ -56,20 +56,20 @@ bool LoadConfigByName(const char *name)
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SetLastActiveConfig(const char* filename)
|
||||
{
|
||||
void SetLastActiveConfig(const char* filename)
|
||||
{
|
||||
extractFileName(filename, last_active_config);
|
||||
removeFileExtension(last_active_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ConfigsListModel : public gcn::ListModel
|
||||
{
|
||||
class ConfigsListModel : public gcn::ListModel
|
||||
{
|
||||
vector<string> configs;
|
||||
|
||||
public:
|
||||
public:
|
||||
ConfigsListModel()
|
||||
= default;
|
||||
|
||||
|
@ -101,14 +101,14 @@ bool LoadConfigByName(const char *name)
|
|||
configs.emplace_back(tmp);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
static ConfigsListModel* configsList;
|
||||
static ConfigsListModel* configsList;
|
||||
|
||||
|
||||
class ConfigButtonActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
class ConfigButtonActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent) override
|
||||
{
|
||||
int i;
|
||||
|
@ -172,48 +172,52 @@ bool LoadConfigByName(const char *name)
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
static ConfigButtonActionListener* configButtonActionListener;
|
||||
static ConfigButtonActionListener* configButtonActionListener;
|
||||
|
||||
|
||||
class ConfigsListActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
class ConfigsListActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent) override
|
||||
{
|
||||
const int selected_item = lstConfigs->getSelected();
|
||||
if (txtName->getText() != ConfigFilesList[selected_item]->Name)
|
||||
{
|
||||
//-----------------------------------------------
|
||||
// Selected same config again -> load and start it
|
||||
//-----------------------------------------------
|
||||
if (emulating)
|
||||
{
|
||||
uae_restart(0, ConfigFilesList[selected_item]->FullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, 0, 0);
|
||||
strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_DPATH);
|
||||
DisableResume();
|
||||
RefreshAllPanels();
|
||||
uae_reset(0, 1);
|
||||
}
|
||||
gui_running = false;
|
||||
}
|
||||
else
|
||||
if (txtName->getText() != ConfigFilesList[selected_item]->Name || txtDesc->getText() != ConfigFilesList[selected_item]->Description)
|
||||
{
|
||||
txtName->setText(ConfigFilesList[selected_item]->Name);
|
||||
txtDesc->setText(ConfigFilesList[selected_item]->Description);
|
||||
//-----------------------------------------------
|
||||
// Selected same config again -> load and start it
|
||||
//-----------------------------------------------
|
||||
//if (emulating)
|
||||
//{
|
||||
// uae_restart(0, ConfigFilesList[selected_item]->FullPath);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// target_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, 0, 0);
|
||||
// //strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_DPATH);
|
||||
// txtName->setText(ConfigFilesList[selected_item]->Name);
|
||||
// txtDesc->setText(ConfigFilesList[selected_item]->Description);
|
||||
// DisableResume();
|
||||
// RefreshAllPanels();
|
||||
//uae_reset(0, 1);
|
||||
//}
|
||||
//gui_running = false;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// txtName->setText(ConfigFilesList[selected_item]->Name);
|
||||
// txtDesc->setText(ConfigFilesList[selected_item]->Description);
|
||||
//}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
static ConfigsListActionListener* configsListActionListener;
|
||||
static ConfigsListActionListener* configsListActionListener;
|
||||
|
||||
void InitPanelConfig(const struct _ConfigCategory& category)
|
||||
{
|
||||
void InitPanelConfig(const struct _ConfigCategory& category)
|
||||
{
|
||||
configButtonActionListener = new ConfigButtonActionListener();
|
||||
|
||||
cmdLoad = new gcn::Button("Load");
|
||||
|
@ -267,6 +271,7 @@ bool LoadConfigByName(const char *name)
|
|||
|
||||
lstConfigs = new gcn::UaeListBox(configsList);
|
||||
lstConfigs->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER - 22, 232);
|
||||
lstConfigs->setBaseColor(gui_baseCol);
|
||||
lstConfigs->setBackgroundColor(colTextboxBackground);
|
||||
lstConfigs->setWrappingEnabled(true);
|
||||
lstConfigs->setId("ConfigList");
|
||||
|
@ -295,10 +300,10 @@ bool LoadConfigByName(const char *name)
|
|||
txtDesc->setText(changed_prefs.description);
|
||||
ensureVisible = -1;
|
||||
RefreshPanelConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void ExitPanelConfig()
|
||||
{
|
||||
void ExitPanelConfig()
|
||||
{
|
||||
delete lstConfigs;
|
||||
delete scrAreaConfigs;
|
||||
delete configsListActionListener;
|
||||
|
@ -314,19 +319,19 @@ bool LoadConfigByName(const char *name)
|
|||
delete txtName;
|
||||
delete lblDesc;
|
||||
delete txtDesc;
|
||||
}
|
||||
}
|
||||
|
||||
static void MakeCurrentVisible()
|
||||
{
|
||||
static void MakeCurrentVisible()
|
||||
{
|
||||
if (ensureVisible >= 0)
|
||||
{
|
||||
scrAreaConfigs->setVerticalScrollAmount(ensureVisible * 19);
|
||||
ensureVisible = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshPanelConfig()
|
||||
{
|
||||
void RefreshPanelConfig()
|
||||
{
|
||||
ReadConfigFileList();
|
||||
configsList->InitConfigsList();
|
||||
|
||||
|
@ -345,10 +350,10 @@ bool LoadConfigByName(const char *name)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool HelpPanelConfig(std::vector<std::string> &helptext)
|
||||
{
|
||||
bool HelpPanelConfig(std::vector<std::string> &helptext)
|
||||
{
|
||||
helptext.clear();
|
||||
helptext.emplace_back("To load a configuration, select the entry in the list and then click on \"Load\".");
|
||||
helptext.emplace_back("If you doubleclick on an entry in the list, the emulation starts with this configuration.");
|
||||
|
@ -358,4 +363,4 @@ bool LoadConfigByName(const char *name)
|
|||
helptext.emplace_back("");
|
||||
helptext.emplace_back("\"Delete\" will delete the selected configuration.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue