- implemented optional plugin control dialog (TODO: do the same for wx)

This commit is contained in:
Volker Ruppert 2012-02-17 17:23:57 +00:00
parent e30e6a9808
commit 6079d4b2c0
3 changed files with 94 additions and 4 deletions

View File

@ -492,14 +492,81 @@ void LogOptionsDialog(HWND hwnd)
DialogBox(NULL, MAKEINTRESOURCE(LOGOPT_DLG), hwnd, (DLGPROC)LogOptDlgProc);
}
static BOOL CALLBACK PluginCtrlDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int count, i;
long code;
bx_list_c *plugin_ctrl;
char plugname[20], message[80];
switch (msg) {
case WM_INITDIALOG:
plugin_ctrl = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL);
count = plugin_ctrl->get_size();
for (i = 0; i < count; i++) {
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_ADDSTRING, 0, (LPARAM)plugin_ctrl->get(i)->get_name());
}
EnableWindow(GetDlgItem(hDlg, IDLOAD), FALSE);
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
return TRUE;
case WM_CLOSE:
EndDialog(hDlg, 0);
break;
case WM_COMMAND:
code = HIWORD(wParam);
switch (LOWORD(wParam)) {
case IDPLUGLIST:
if (code == LBN_SELCHANGE) {
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), TRUE);
}
break;
case IDEDIT:
if (code == EN_CHANGE) {
i = GetWindowTextLength(GetDlgItem(hDlg, IDEDIT));
EnableWindow(GetDlgItem(hDlg, IDLOAD), i > 0);
}
break;
case IDLOAD:
GetDlgItemText(hDlg, IDEDIT, plugname, 18);
if (SIM->opt_plugin_ctrl(plugname, 1)) {
wsprintf(message, "Plugin '%s' loaded", plugname);
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_ADDSTRING, 0, (LPARAM)plugname);
}
break;
case IDUNLOAD:
i = SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_GETCURSEL, 0, 0);
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_GETTEXT, i, (LPARAM)plugname);
if (SIM->opt_plugin_ctrl(plugname, 0)) {
wsprintf(message, "Plugin '%s' unloaded", plugname);
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
SendMessage(GetDlgItem(hDlg, IDPLUGLIST), LB_DELETESTRING, i, 0);
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
}
break;
case IDOK:
EndDialog(hDlg, 1);
break;
}
break;
}
return FALSE;
}
void PluginCtrlDialog(HWND hwnd)
{
DialogBox(NULL, MAKEINTRESOURCE(PLUGIN_CTRL_DLG), hwnd, (DLGPROC)PluginCtrlDlgProc);
}
typedef struct {
const char *label;
const char *param;
} edit_opts_t;
edit_opts_t start_options[] = {
{"Plugin Control", "#plugins"},
{"Logfile", "log"},
{"Log Options", "*"},
{"Log Options", "#logopts"},
{"CPU", "cpu"},
#if BX_CPU_LEVEL >= 4
{"CPUID", "cpuid"},
@ -524,7 +591,7 @@ edit_opts_t runtime_options[] = {
{"CD-ROM", BXPN_MENU_RUNTIME_CDROM},
{"USB", BXPN_MENU_RUNTIME_USB},
{"Misc", BXPN_MENU_RUNTIME_MISC},
{"Log Options", "*"},
{"Log Options", "#logopts"},
{NULL, NULL}
};
static BOOL CALLBACK MainMenuDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@ -606,14 +673,20 @@ static BOOL CALLBACK MainMenuDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
} else {
pname = start_options[i].param;
}
if (lstrcmp(pname, "*")) {
if (pname[0] != '#') {
if (((bx_list_c*)SIM->get_param(pname))->get_size() > 0) {
win32ParamDialog(hDlg, pname);
} else {
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
}
} else {
LogOptionsDialog(hDlg);
if (!lstrcmp(pname, "#logopts")) {
LogOptionsDialog(hDlg);
} else if (!lstrcmp(pname, "#plugins")) {
PluginCtrlDialog(hDlg);
} else {
MessageBox(hDlg, "Unknown keyword", "Warning", MB_ICONEXCLAMATION);
}
}
break;
case IDRESETCFG:

View File

@ -24,6 +24,11 @@
#define IDLOGEVT5 1235
#define IDADVLOGOPT 1240
#define IDAPPLY 1250
#define PLUGIN_CTRL_DLG 1300
#define IDPLUGLIST 1310
#define IDEDIT 1320
#define IDLOAD 1330
#define IDUNLOAD 1340
#define ASK_DLG 2000
#define IDASKTX1 2010
#define IDASKDEV 2020

View File

@ -95,6 +95,18 @@ BEGIN
PUSHBUTTON "Apply", IDAPPLY, 155, 155, 50, 14
END
PLUGIN_CTRL_DLG DIALOG 100, 120, 180, 135
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Optional Plugin Control"
FONT 8, "Helv"
BEGIN
LISTBOX IDPLUGLIST, 15, 15, 85, 100, WS_VSCROLL | WS_TABSTOP
EDITTEXT IDEDIT, 110, 15, 60, 14
PUSHBUTTON "Load", IDLOAD, 110, 35, 50, 14
PUSHBUTTON "Unload", IDUNLOAD, 110, 55, 50, 14
DEFPUSHBUTTON "OK", IDOK, 65, 115, 50, 14
END
PARAM_DLG DIALOG 30, 30, 200, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Param"