Fixes in the config interfaces handling of disabled options.

- Don't show dialog or menu if selected list is NULL or empty.
- Don't create list for lowlevel sound options if disabled in config.h.
This commit is contained in:
Volker Ruppert 2021-03-05 16:52:26 +00:00
parent 2f2752dd74
commit e8709d58e4
4 changed files with 61 additions and 38 deletions

View File

@ -1569,11 +1569,11 @@ void bx_init_options()
// sound subtree // sound subtree
bx_list_c *sound = new bx_list_c(root_param, "sound", "Sound Configuration"); bx_list_c *sound = new bx_list_c(root_param, "sound", "Sound Configuration");
sound->set_options(sound->USE_TAB_WINDOW | sound->SHOW_PARENT); sound->set_options(sound->USE_TAB_WINDOW | sound->SHOW_PARENT);
#if BX_SUPPORT_SOUNDLOW
bx_list_c *soundlow = new bx_list_c(sound, "lowlevel", "Lowlevel Sound Configuration"); bx_list_c *soundlow = new bx_list_c(sound, "lowlevel", "Lowlevel Sound Configuration");
soundlow->set_options(soundlow->SHOW_PARENT | soundlow->SERIES_ASK); soundlow->set_options(soundlow->SHOW_PARENT | soundlow->SERIES_ASK);
soundlow->set_enabled(BX_SUPPORT_SOUNDLOW); soundlow->set_enabled(BX_SUPPORT_SOUNDLOW);
#if BX_SUPPORT_SOUNDLOW
bx_soundmod_ctl.init(); bx_soundmod_ctl.init();
bx_param_enum_c *driver = new bx_param_enum_c(soundlow, bx_param_enum_c *driver = new bx_param_enum_c(soundlow,
"waveoutdrv", "waveoutdrv",

View File

@ -380,28 +380,36 @@ void build_runtime_options_prompt(const char *format, char *buf, int size)
int do_menu(const char *pname) int do_menu(const char *pname)
{ {
bx_list_c *menu = (bx_list_c *)SIM->get_param(pname, NULL); bx_list_c *menu = (bx_list_c *)SIM->get_param(pname, NULL);
while (1) { if (menu != NULL) {
menu->set_choice(0); if (menu->get_size() > 0) {
int status = menu->text_ask(); while (1) {
if (status < 0) return status; menu->set_choice(0);
if (menu->get_choice() < 1) int status = menu->text_ask();
return menu->get_choice(); if (status < 0) return status;
else { if (menu->get_choice() < 1)
int index = menu->get_choice() - 1; // choosing 1 means list[0] return menu->get_choice();
bx_param_c *chosen = menu->get(index); else {
assert(chosen != NULL); int index = menu->get_choice() - 1; // choosing 1 means list[0]
if (chosen->get_enabled()) { bx_param_c *chosen = menu->get(index);
if (SIM->get_init_done() && !chosen->get_runtime_param()) { assert(chosen != NULL);
bx_printf("\nWARNING: parameter not available at runtime!\n"); if (chosen->get_enabled()) {
} else if (chosen->get_type() == BXT_LIST) { if (SIM->get_init_done() && !chosen->get_runtime_param()) {
char chosen_pname[80]; bx_printf("\nWARNING: parameter not available at runtime!\n");
chosen->get_param_path(chosen_pname, 80); } else if (chosen->get_type() == BXT_LIST) {
do_menu(chosen_pname); char chosen_pname[80];
} else { chosen->get_param_path(chosen_pname, 80);
chosen->text_ask(); do_menu(chosen_pname);
} else {
chosen->text_ask();
}
}
} }
} }
} else {
bx_printf("\nERROR: nothing to configure in this section!\n");
} }
} else {
bx_printf("\nERROR: nothing to configure in this section!\n");
} }
} }

View File

@ -555,8 +555,13 @@ static BOOL CALLBACK MainMenuDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
pname = start_options[i].param; pname = start_options[i].param;
} }
if (pname[0] != '#') { if (pname[0] != '#') {
if (((bx_list_c*)SIM->get_param(pname))->get_size() > 0) { bx_list_c *list = (bx_list_c*)SIM->get_param(pname);
win32ParamDialog(hDlg, pname); if (list != NULL) {
if (list->get_size() > 0) {
win32ParamDialog(hDlg, pname);
} else {
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
}
} else { } else {
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION); MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
} }

View File

@ -656,16 +656,16 @@ void MyFrame::OnEditBoot(wxCommandEvent& WXUNUSED(event))
if (firstcd != NULL) { if (firstcd != NULL) {
bootDevices++; bootDevices++;
} }
if (bootDevices == 0) { if (bootDevices > 0) {
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("boot_params");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.AddParam(list);
dlg.ShowModal();
} else {
wxMessageBox(wxT("All the possible boot devices are disabled right now!\nYou must enable the first floppy drive, a hard drive, or a CD-ROM."), wxMessageBox(wxT("All the possible boot devices are disabled right now!\nYou must enable the first floppy drive, a hard drive, or a CD-ROM."),
wxT("None enabled"), wxOK | wxICON_ERROR, this); wxT("None enabled"), wxOK | wxICON_ERROR, this);
return;
} }
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("boot_params");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.AddParam(list);
dlg.ShowModal();
} }
void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event))
@ -680,21 +680,31 @@ void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnEditNet(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditNet(wxCommandEvent& WXUNUSED(event))
{ {
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("network"); bx_list_c *list = (bx_list_c*) SIM->get_param("network");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8)); if (list != NULL) {
dlg.AddParam(list); ParamDialog dlg(this, -1);
dlg.ShowModal(); dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.AddParam(list);
dlg.ShowModal();
} else {
wxMessageBox(wxT("Nothing to configure in this section!"),
wxT("Not enabled"), wxOK | wxICON_ERROR, this);
}
} }
void MyFrame::OnEditSound(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditSound(wxCommandEvent& WXUNUSED(event))
{ {
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("sound"); bx_list_c *list = (bx_list_c*) SIM->get_param("sound");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8)); if (list->get_size() > 0) {
dlg.AddParam(list); ParamDialog dlg(this, -1);
dlg.SetRuntimeFlag(sim_thread != NULL); dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.ShowModal(); dlg.AddParam(list);
dlg.SetRuntimeFlag(sim_thread != NULL);
dlg.ShowModal();
} else {
wxMessageBox(wxT("Nothing to configure in this section!"),
wxT("Not enabled"), wxOK | wxICON_ERROR, this);
}
} }
void MyFrame::OnEditOther(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditOther(wxCommandEvent& WXUNUSED(event))