Don't show joystics tab/dialog if there are no joysticks

This commit is contained in:
Ilari Liusvaara 2013-08-05 12:30:38 +03:00
parent e436cabd72
commit 7da4621285
2 changed files with 22 additions and 2 deletions

View file

@ -123,19 +123,29 @@ namespace
SetSizer(top_s);
if(singletab) {
//If this throws, let it throw through.
settings_tab* t = singletab->create(this);
top_s->Add(t, 1, wxGROW);
t->set_notify([this]() { this->on_notify(); });
tabs.push_back(t);
} else {
int created = 0;
tabset = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
for(auto i : settings_tab_factory::factories()) {
settings_tab* t = i->create(tabset);
settings_tab* t;
try {
t = i->create(tabset);
} catch(...) {
continue;
}
tabset->AddPage(t, towxstring(i->get_name()));
t->set_notify([this]() { this->on_notify(); });
tabs.push_back(t);
created++;
}
top_s->Add(tabset, 1, wxGROW);
if(!created)
throw std::runtime_error("Nothing to configure here, move along");
}
wxBoxSizer* pbutton_s = new wxBoxSizer(wxHORIZONTAL);
@ -187,8 +197,16 @@ void display_settings_dialog(wxWindow* parent, settings_tab_factory* singletab)
{
modal_pause_holder hld;
wxDialog* editor;
try {
try {
editor = dlg = new wxeditor_esettings2(parent, singletab);
} catch(std::exception& e) {
std::string title = "Configure";
if(singletab)
title = "Configure " + singletab->get_name();
show_message_ok(parent, title, e.what(), wxICON_EXCLAMATION);
return;
}
editor->ShowModal();
} catch(...) {
}

View file

@ -273,6 +273,8 @@ namespace
joystick_config_window(wxWindow* parent)
: settings_tab(parent)
{
if(!lsnes_gamepads.gamepads())
throw std::runtime_error("No joysticks available");
wxSizer* top1_s = new wxBoxSizer(wxVERTICAL);
SetSizer(top1_s);
std::map<std::string, unsigned> jsnum;