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
bx_list_c *sound = new bx_list_c(root_param, "sound", "Sound Configuration");
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");
soundlow->set_options(soundlow->SHOW_PARENT | soundlow->SERIES_ASK);
soundlow->set_enabled(BX_SUPPORT_SOUNDLOW);
#if BX_SUPPORT_SOUNDLOW
bx_soundmod_ctl.init();
bx_param_enum_c *driver = new bx_param_enum_c(soundlow,
"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)
{
bx_list_c *menu = (bx_list_c *)SIM->get_param(pname, NULL);
while (1) {
menu->set_choice(0);
int status = menu->text_ask();
if (status < 0) return status;
if (menu->get_choice() < 1)
return menu->get_choice();
else {
int index = menu->get_choice() - 1; // choosing 1 means list[0]
bx_param_c *chosen = menu->get(index);
assert(chosen != NULL);
if (chosen->get_enabled()) {
if (SIM->get_init_done() && !chosen->get_runtime_param()) {
bx_printf("\nWARNING: parameter not available at runtime!\n");
} else if (chosen->get_type() == BXT_LIST) {
char chosen_pname[80];
chosen->get_param_path(chosen_pname, 80);
do_menu(chosen_pname);
} else {
chosen->text_ask();
if (menu != NULL) {
if (menu->get_size() > 0) {
while (1) {
menu->set_choice(0);
int status = menu->text_ask();
if (status < 0) return status;
if (menu->get_choice() < 1)
return menu->get_choice();
else {
int index = menu->get_choice() - 1; // choosing 1 means list[0]
bx_param_c *chosen = menu->get(index);
assert(chosen != NULL);
if (chosen->get_enabled()) {
if (SIM->get_init_done() && !chosen->get_runtime_param()) {
bx_printf("\nWARNING: parameter not available at runtime!\n");
} else if (chosen->get_type() == BXT_LIST) {
char chosen_pname[80];
chosen->get_param_path(chosen_pname, 80);
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;
}
if (pname[0] != '#') {
if (((bx_list_c*)SIM->get_param(pname))->get_size() > 0) {
win32ParamDialog(hDlg, pname);
bx_list_c *list = (bx_list_c*)SIM->get_param(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 {
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) {
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."),
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))
@ -680,21 +680,31 @@ void MyFrame::OnEditSerialParallel(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnEditNet(wxCommandEvent& WXUNUSED(event))
{
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("network");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.AddParam(list);
dlg.ShowModal();
if (list != NULL) {
ParamDialog dlg(this, -1);
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))
{
ParamDialog dlg(this, -1);
bx_list_c *list = (bx_list_c*) SIM->get_param("sound");
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
dlg.AddParam(list);
dlg.SetRuntimeFlag(sim_thread != NULL);
dlg.ShowModal();
if (list->get_size() > 0) {
ParamDialog dlg(this, -1);
dlg.SetTitle(wxString(list->get_title(), wxConvUTF8));
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))