Display library plugins list is now created dynamicly at startup instead of the
hardcoded one. In plugins mode now all plugins with PLUGTYPE_GUI can be used. Added similar code for the case plugins are disabled. The macros PLUG_get_plugins_count() and PLUG_get_plugin_name() can be used in both cases.
This commit is contained in:
parent
333afe3e4a
commit
535856833c
@ -43,6 +43,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
const char **display_library_list;
|
||||
int bochsrc_include_level = 0;
|
||||
|
||||
#define LOG_THIS genlog->
|
||||
@ -227,22 +228,12 @@ void bx_init_usb_options(const char *usb_name, const char *pname, int maxports)
|
||||
void bx_plugin_ctrl_init()
|
||||
{
|
||||
bx_list_c *base = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL);
|
||||
#if !BX_PLUGINS
|
||||
int i = 0;
|
||||
while (strcmp(bx_builtin_plugins[i].name, "NULL")) {
|
||||
if (bx_builtin_plugins[i].type == PLUGTYPE_OPTIONAL) {
|
||||
new bx_param_bool_c(base, bx_builtin_plugins[i].name, "", "", 0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
#else
|
||||
const char *name;
|
||||
int count = bx_get_plugins_count(PLUGTYPE_OPTIONAL);
|
||||
int count = PLUG_get_plugins_count(PLUGTYPE_OPTIONAL);
|
||||
for (int i = 0; i < count; i++) {
|
||||
name = bx_get_plugin_name(PLUGTYPE_OPTIONAL, i);
|
||||
name = PLUG_get_plugin_name(PLUGTYPE_OPTIONAL, i);
|
||||
new bx_param_bool_c(base, name, "", "", 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_plugin_ctrl_reset(bool init_done)
|
||||
@ -275,6 +266,28 @@ bool bx_opt_plugin_available(const char *plugname)
|
||||
return (((bx_list_c*)SIM->get_param(BXPN_PLUGIN_CTRL))->get_by_name(plugname) != NULL);
|
||||
}
|
||||
|
||||
void bx_init_displaylib_list()
|
||||
{
|
||||
Bit8u i, count = 0;
|
||||
|
||||
count = PLUG_get_plugins_count(PLUGTYPE_GUI);
|
||||
display_library_list = (const char**) malloc((count + 1) * sizeof(char*));
|
||||
for (i = 0; i < count; i++) {
|
||||
display_library_list[i] = PLUG_get_plugin_name(PLUGTYPE_GUI, i);
|
||||
}
|
||||
display_library_list[count] = NULL;
|
||||
// move default display library to the top of the list
|
||||
if (strcmp(display_library_list[0], BX_DEFAULT_DISPLAY_LIBRARY)) {
|
||||
for (i = 1; i < count; i++) {
|
||||
if (!strcmp(display_library_list[i], BX_DEFAULT_DISPLAY_LIBRARY)) {
|
||||
display_library_list[i] = display_library_list[0];
|
||||
display_library_list[0] = BX_DEFAULT_DISPLAY_LIBRARY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bx_init_options()
|
||||
{
|
||||
int i;
|
||||
@ -902,49 +915,7 @@ void bx_init_options()
|
||||
// display subtree
|
||||
bx_list_c *display = new bx_list_c(root_param, "display", "Bochs Display & Interface Options");
|
||||
|
||||
// this is a list of gui libraries that are known to be available at
|
||||
// compile time. The one that is listed first will be the default,
|
||||
// which is used unless the user overrides it on the command line or
|
||||
// in a configuration file.
|
||||
static const char *display_library_list[] = {
|
||||
#if BX_WITH_X11
|
||||
"x",
|
||||
#endif
|
||||
#if BX_WITH_WIN32
|
||||
"win32",
|
||||
#endif
|
||||
#if BX_WITH_CARBON
|
||||
"carbon",
|
||||
#endif
|
||||
#if BX_WITH_MACOS
|
||||
"macos",
|
||||
#endif
|
||||
#if BX_WITH_AMIGAOS
|
||||
"amigaos",
|
||||
#endif
|
||||
#if BX_WITH_SDL
|
||||
"sdl",
|
||||
#endif
|
||||
#if BX_WITH_SDL2
|
||||
"sdl2",
|
||||
#endif
|
||||
#if BX_WITH_TERM
|
||||
"term",
|
||||
#endif
|
||||
#if BX_WITH_RFB
|
||||
"rfb",
|
||||
#endif
|
||||
#if BX_WITH_VNCSRV
|
||||
"vncsrv",
|
||||
#endif
|
||||
#if BX_WITH_WX
|
||||
"wx",
|
||||
#endif
|
||||
#if BX_WITH_NOGUI
|
||||
"nogui",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
bx_init_displaylib_list();
|
||||
bx_param_enum_c *sel_displaylib = new bx_param_enum_c(display,
|
||||
"display_library", "VGA Display Library",
|
||||
"Select VGA Display Library",
|
||||
|
@ -1091,6 +1091,35 @@ plugin_t bx_builtin_plugins[] = {
|
||||
{"NULL", PLUGTYPE_GUI, NULL, 0}
|
||||
};
|
||||
|
||||
Bit8u bx_get_plugins_count_np(plugintype_t type)
|
||||
{
|
||||
int i = 0;
|
||||
Bit8u count = 0;
|
||||
|
||||
while (strcmp(bx_builtin_plugins[i].name, "NULL")) {
|
||||
if (type == bx_builtin_plugins[i].type)
|
||||
count++;
|
||||
i++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
const char* bx_get_plugin_name_np(plugintype_t type, Bit8u index)
|
||||
{
|
||||
int i = 0;
|
||||
Bit8u count = 0;
|
||||
|
||||
while (strcmp(bx_builtin_plugins[i].name, "NULL")) {
|
||||
if (type == bx_builtin_plugins[i].type) {
|
||||
if (count == index)
|
||||
return bx_builtin_plugins[i].name;
|
||||
count++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int bx_load_plugin_np(const char *name, plugintype_t type)
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -113,10 +113,13 @@ extern "C" {
|
||||
// When plugins are off, PLUG_load_plugin will call the plugin_entry function
|
||||
// directly.
|
||||
#define PLUG_load_plugin(name,type) {lib##name##_plugin_entry(NULL,type,1);}
|
||||
#define PLUG_unload_plugin(name) {lib##name##_plugin_entry(NULL,type,0);}
|
||||
// Builtin plugins macros
|
||||
#define PLUG_get_plugins_count(a) bx_get_plugins_count_np(a)
|
||||
#define PLUG_get_plugin_name(a,b) bx_get_plugin_name_np(a,b)
|
||||
#define PLUG_load_gui_plugin(name) bx_load_plugin_np(name,PLUGTYPE_GUI)
|
||||
#define PLUG_load_opt_plugin(name) bx_load_plugin_np(name,PLUGTYPE_OPTIONAL)
|
||||
#define PLUG_load_vga_plugin(name) bx_load_plugin_np(name,PLUGTYPE_VGA)
|
||||
#define PLUG_unload_plugin(name) {lib##name##_plugin_entry(NULL,type,0);}
|
||||
#define PLUG_unload_opt_plugin(name) bx_unload_opt_plugin(name,1)
|
||||
|
||||
#define DEV_register_ioread_handler(b,c,d,e,f) bx_devices.register_io_read_handler(b,c,d,e,f)
|
||||
@ -350,6 +353,8 @@ extern void bx_plugins_after_restore_state(void);
|
||||
#if !BX_PLUGINS
|
||||
extern plugin_t bx_builtin_plugins[];
|
||||
|
||||
Bit8u bx_get_plugins_count_np(plugintype_t type);
|
||||
const char* bx_get_plugin_name_np(plugintype_t type, Bit8u index);
|
||||
int bx_load_plugin_np(const char *name, plugintype_t type);
|
||||
int bx_unload_opt_plugin(const char *name, bool devflag);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user