/** * @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 Translate the skin id to skin name * @param[in] id The id of the skin * @return Translated skin name */ static const char* CL_GetTeamSkinName (unsigned int id) { const actorSkin_t *skin = CL_GetActorSkinByIDS(id); if (skin == NULL) Com_Error(ERR_DROP, "CL_GetTeamSkinName: Unknown skin id %i", id); return skin->name; }
/** * @brief Fix actorskin idx according to game mode */ static int CL_FixActorSkinIDX (int idx) { const actorSkin_t* skin = CL_GetActorSkinByIDS(idx); /** @todo we should check somewhere there is at least 1 skin */ if (skin == nullptr) { idx = 0; } else { if (GAME_IsSingleplayer() && !skin->singleplayer) idx = 0; else if (GAME_IsMultiplayer() && !skin->multiplayer) idx = 0; } return idx; }