/** * @brief Init skins into the GUI */ static void CL_InitSkin_f (void) { /* create option for singleplayer skins */ if (UI_GetOption(OPTION_SINGLEPLAYER_SKINS) == nullptr) { uiNode_t* skins = nullptr; int idx = 0; const actorSkin_t* skin; while ((skin = CL_GetActorSkinByIDS(idx++))) { if (!skin->singleplayer) continue; UI_AddOption(&skins, skin->id, skin->name, va("%d", skin->idx)); } UI_RegisterOption(OPTION_SINGLEPLAYER_SKINS, skins); } /* create option for multiplayer skins */ if (UI_GetOption(OPTION_MULTIPLAYER_SKINS) == nullptr) { uiNode_t* skins = nullptr; int idx = 0; const actorSkin_t* skin; while ((skin = CL_GetActorSkinByIDS(idx++))) { if (!skin->multiplayer) continue; UI_AddOption(&skins, skin->id, skin->name, va("%d", skin->idx)); } UI_RegisterOption(OPTION_MULTIPLAYER_SKINS, skins); } }
/** * @brief Return the first option of the node * @todo check versionId and update cached data, and fire events */ uiNode_t* UI_AbstractOptionGetFirstOption (uiNode_t * node) { if (node->firstChild && node->firstChild->behaviour == ui_optionBehaviour) { return node->firstChild; } else { const int v = UI_GetDataVersion(EXTRADATA(node).dataId); if (v != EXTRADATA(node).versionId) { int count = 0; uiNode_t *option = UI_GetOption(EXTRADATA(node).dataId); while (option) { if (!option->invis) count++; option = option->next; } EXTRADATA(node).count = count; EXTRADATA(node).versionId = v; } return UI_GetOption(EXTRADATA(node).dataId); } }
static void CL_TeamDefInitMenu (void) { uiNode_t* option = UI_GetOption(OPTION_TEAMDEFS); if (option != nullptr) return; for (int i = 0; i < csi.numTeamDefs; i++) { const teamDef_t* td = &csi.teamDef[i]; if (td->team != TEAM_CIVILIAN) UI_AddOption(&option, td->id, va("_%s", td->name), td->id); } UI_RegisterOption(OPTION_TEAMDEFS, option); }
/** * @brief Hide the ufo selection or show it with the ufos given in the parameter * @param ufos if @c NULL, the ufo selection panel will be hidden, otherwise it * will be shown with the given list entries as content. */ static inline void GAME_SK_HideUFOs (const linkedList_t *ufos) { const qboolean hide = (ufos == NULL); if (hide) { UI_ExecuteConfunc("skirmish_hide_ufos true"); Cvar_Set("rm_ufo", ""); } else { const char *rma = Com_GetRandomMapAssemblyNameForCraft((const char *)ufos->data); Cvar_Set("rm_ufo", rma); UI_UpdateInvisOptions(UI_GetOption(OPTION_UFOS), ufos); UI_ExecuteConfunc("skirmish_hide_ufos false"); } }
/** * @brief Hide the dropship selection or show it with the dropship given in the parameter * @param dropships if @c NULL, the dropship selection panel will be hidden, otherwise it * will be shown with the given list entries as content. */ static inline void GAME_SK_HideDropships (const linkedList_t *dropships) { const qboolean hide = (dropships == NULL); if (hide) { UI_ExecuteConfunc("skirmish_hide_dropships true"); Cvar_Set("rm_drop", ""); } else { const char *rma = Com_GetRandomMapAssemblyNameForCraft((const char *)dropships->data); Cvar_Set("rm_drop", rma); UI_UpdateInvisOptions(UI_GetOption(OPTION_DROPSHIPS), dropships); UI_ExecuteConfunc("skirmish_hide_dropships false"); } }
static void CL_VideoInitMenu (void) { uiNode_t* option = UI_GetOption(OPTION_VIDEO_RESOLUTIONS); if (option != nullptr) { return; } const int length = VID_GetModeNums(); for (int i = 0; i < length; i++) { vidmode_t vidmode; if (VID_GetModeInfo(i, &vidmode)) UI_AddOption(&option, va("r%ix%i", vidmode.width, vidmode.height), va("%i x %i", vidmode.width, vidmode.height), va("%i", i)); } UI_RegisterOption(OPTION_VIDEO_RESOLUTIONS, option); }
/** * @brief Return the first option of the node * @todo check versionId and update cached data, and fire events */ static uiNode_t* UI_OptionTreeNodeGetFirstOption (uiNode_t * node) { if (node->firstChild) { /** @todo FIXME it MUST be an option behaviour */ assert(node->firstChild->behaviour == ui_optionBehaviour); return node->firstChild; } else { const int v = UI_GetDataVersion(EXTRADATA(node).dataId); uiNode_t *option = UI_GetOption(EXTRADATA(node).dataId); if (v != EXTRADATA(node).versionId) { EXTRADATA(node).versionId = v; UI_OptionTreeNodeUpdateCache(node); } return option; } }
static void CL_SetRatioFilter_f (void) { uiNode_t* firstOption = UI_GetOption(OPTION_VIDEO_RESOLUTIONS); uiNode_t* option = firstOption; float requestedRation = atof(Cmd_Argv(1)); bool all = false; bool custom = false; const float delta = 0.01; if (Cmd_Argc() != 2) { Com_Printf("Usage: %s <all|floatration>\n", Cmd_Argv(0)); return; } if (Q_streq(Cmd_Argv(1), "all")) all = true; else if (Q_streq(Cmd_Argv(1), "custom")) custom = true; else requestedRation = atof(Cmd_Argv(1)); while (option) { int width; int height; bool visible = false; const int result = sscanf(OPTIONEXTRADATA(option).label, "%i x %i", &width, &height); if (result != 2) Com_Error(ERR_FATAL, "CL_SetRatioFilter_f: Impossible to decode resolution label.\n"); const float ratio = (float)width / (float)height; if (all) visible = true; else if (custom) /** @todo We should check the ratio list and remove matched resolutions, here it is a hack */ visible = ratio > 2 || (ratio > 1.7 && ratio < 1.76); else visible = ratio - delta < requestedRation && ratio + delta > requestedRation; option->invis = !visible; option = option->next; } /* the content change */ UI_RegisterOption(OPTION_VIDEO_RESOLUTIONS, firstOption); }