/** * @brief GUI override was toggled. * * @param wid Window id. * @param name of widget. */ static void info_toggleGuiOverride( unsigned int wid, char *name ) { player.guiOverride = window_checkboxState( wid, name ); /* Go back to the default one. */ if (player.guiOverride == 0) toolkit_setList( wid, "lstGUI", gui_pick() ); }
/** * @brief Loads a GUI. * * @param wdw Window triggering function. * @param str Unused. */ static void setgui_load( unsigned int wdw, char *str ) { (void)str; char *gui; int wid; wid = window_get( _("Select GUI") ); gui = toolkit_getList( wid, "lstGUI" ); if (strcmp(gui,_("None")) == 0) return; if (player.guiOverride == 0) { if (dialogue_YesNo( _("GUI Override is not set."), _("Enable GUI Override and change GUI to '%s'?"), gui )) { player.guiOverride = 1; window_checkboxSet( wid, "chkOverride", player.guiOverride ); } else { return; } } /* Set the GUI. */ if (player.gui != NULL) free( player.gui ); player.gui = strdup( gui ); /* Close menus before loading for proper rendering. */ setgui_close(wdw, NULL); /* Load the GUI. */ gui_load( gui_pick() ); }
/** * @brief Allows the player to set a different GUI. * * @param wid Window id. * @param name of widget. */ static void info_setGui( unsigned int wid, char* str ) { (void)str; int i; char **guis; int nguis; char **gui_copy; /* Get the available GUIs. */ guis = player_guiList( &nguis ); /* In case there are none. */ if (guis == NULL) { WARN("No GUI available."); dialogue_alert( "There are no GUI available, this means something went wrong somewhere. Inform the Naev maintainer." ); return; } /* window */ wid = window_create( "Select GUI", -1, -1, SETGUI_WIDTH, SETGUI_HEIGHT ); window_setCancel( wid, setgui_close ); /* Copy GUI. */ gui_copy = malloc( sizeof(char*) * nguis ); for (i=0; i<nguis; i++) gui_copy[i] = strdup( guis[i] ); /* List */ window_addList( wid, 20, -50, SETGUI_WIDTH-BUTTON_WIDTH/2 - 60, SETGUI_HEIGHT-110, "lstGUI", gui_copy, nguis, 0, NULL ); toolkit_setList( wid, "lstGUI", gui_pick() ); /* buttons */ window_addButton( wid, -20, 20, BUTTON_WIDTH/2, BUTTON_HEIGHT, "btnBack", "Cancel", setgui_close ); window_addButton( wid, -20, 30 + BUTTON_HEIGHT, BUTTON_WIDTH/2, BUTTON_HEIGHT, "btnLoad", "Load", setgui_load ); /* Checkboxes */ window_addCheckbox( wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "chkOverride", "Override GUI", info_toggleGuiOverride, player.guiOverride ); info_toggleGuiOverride( wid, "chkOverride" ); /* default action */ window_setAccept( wid, setgui_load ); }
/** * @brief Loads a GUI. * * @param wdw Window triggering function. * @param str Unused. */ static void setgui_load( unsigned int wdw, char *str ) { (void)str; char *gui; int wid; wid = window_get( "Select GUI" ); gui = toolkit_getList( wid, "lstGUI" ); if (strcmp(gui,"None") == 0) return; /* Set the GUI. */ if (player.gui != NULL) free( player.gui ); player.gui = strdup( gui ); /* Close menus before loading for proper rendering. */ setgui_close(wdw, NULL); /* Load the GUI. */ gui_load( gui_pick() ); }