added skin prefix (#1218)

This commit is contained in:
fokkonaut 2018-07-24 17:26:39 +02:00 committed by heinrich5991
parent 2b1df782d3
commit b8b97eb740
35 changed files with 55 additions and 42 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
data/skins/coala_cammo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

BIN
data/skins/coala_pinky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/skins/coala_saddo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
data/skins/coala_toptri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
data/skins/santa_cammo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
data/skins/santa_coala.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
data/skins/santa_pinky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
data/skins/santa_saddo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
data/skins/santa_toptri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View file

@ -365,10 +365,11 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
void CMenus::RenderSettingsTee(CUIRect MainView)
{
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton;
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton, SkinPrefix, SkinPrefixLabel;
bool CheckSettings = false;
static int s_ClVanillaSkinsOnly = g_Config.m_ClVanillaSkinsOnly;
static float s_ClSkinPrefix = 0.0f;
static bool s_InitSkinlist = true;
MainView.HSplitTop(10.0f, 0, &MainView);
@ -406,6 +407,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
MainView.HSplitTop(20.0f, &Label, &MainView);
Label.VSplitLeft(280.0f, &Label, &Dummy);
Label.VSplitLeft(230.0f, &Label, 0);
Dummy.VSplitLeft(250.0f, &Dummy, &SkinPrefix);
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
@ -427,17 +429,16 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
if(DoButton_CheckBox(&g_Config.m_ClKittySkins, Localize("Kitty skins (DDCat)"), g_Config.m_ClKittySkins, &DummyLabel))
{
g_Config.m_ClKittySkins ^= 1;
}
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
if(DoButton_CheckBox(&g_Config.m_ClFatSkins, Localize("Fat skins (DDFat)"), g_Config.m_ClFatSkins, &DummyLabel))
if (DoButton_CheckBox(&g_Config.m_ClFatSkins, Localize("Fat skins (DDFat)"), g_Config.m_ClFatSkins, &DummyLabel))
{
g_Config.m_ClFatSkins ^= 1;
}
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
UI()->DoLabelScaled(&SkinPrefixLabel, Localize("Skin prefix (e.g. kitty, coala, santa)"), 14.0f, -1);
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
DoEditBox(g_Config.m_ClSkinPrefix, &SkinPrefixLabel, g_Config.m_ClSkinPrefix, sizeof(g_Config.m_ClSkinPrefix), 14.0f, &s_ClSkinPrefix);
if(CheckSettings)
{

View file

@ -11,39 +11,45 @@
#include "skins.h"
static const char* s_aaVanillaSkins[] = {"bluekitty.png", "bluestripe.png", "brownbear.png",
"cammo.png", "cammostripes.png", "coala.png", "default.png", "limekitty.png",
"pinky.png", "redbopp.png", "redstripe.png", "saddo.png", "toptri.png",
"twinbop.png", "twintri.png", "warpaint.png", "x_ninja.png"};
static const char *VANILLA_SKINS[] = {"bluekitty", "bluestripe", "brownbear",
"cammo", "cammostripes", "coala", "default", "limekitty",
"pinky", "redbopp", "redstripe", "saddo", "toptri",
"twinbop", "twintri", "warpaint", "x_ninja"};
static bool IsVanillaSkin(const char *pName)
{
for(unsigned int i = 0; i < sizeof(VANILLA_SKINS) / sizeof(VANILLA_SKINS[0]); i++)
{
if(str_comp(pName, VANILLA_SKINS[i]) == 0)
{
return true;
}
}
return false;
}
int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
{
if(g_Config.m_ClVanillaSkinsOnly)
{
bool Found = false;
for(unsigned int i = 0; i < sizeof(s_aaVanillaSkins) / sizeof(s_aaVanillaSkins[0]); i++)
{
if(str_comp(pName, s_aaVanillaSkins[i]) == 0)
{
Found = true;
break;
}
}
if(!Found)
return 0;
}
CSkins *pSelf = (CSkins *)pUser;
int l = str_length(pName);
if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0)
return 0;
char aFilenameWithoutPng[128];
str_copy(aFilenameWithoutPng, pName, sizeof(aFilenameWithoutPng));
aFilenameWithoutPng[str_length(aFilenameWithoutPng) - 4] = 0;
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(aFilenameWithoutPng))
{
return 0;
}
// Don't add duplicate skins (one from user's config directory, other from
// client itself)
for(int i = 0; i < pSelf->Num(); i++)
{
const char* pExName = pSelf->Get(i)->m_aName;
const char *pExName = pSelf->Get(i)->m_aName;
if(str_comp_num(pExName, pName, l-4) == 0 && str_length(pExName) == l-4)
return 0;
}
@ -174,27 +180,32 @@ const CSkins::CSkin *CSkins::Get(int Index)
return &m_aSkins[max(0, Index%m_aSkins.size())];
}
int CSkins::Find(const char *pName)
int CSkins::Find(const char *pName) const
{
char aBuf[24];
if(g_Config.m_ClKittySkins)
if(g_Config.m_ClSkinPrefix[0])
{
for(unsigned int i = 0; i < sizeof(s_aaVanillaSkins) / sizeof(s_aaVanillaSkins[0]); i++)
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s_%s", g_Config.m_ClSkinPrefix, pName);
// If we find something, use it, otherwise fall back to normal
// skins.
int Result = FindImpl(aBuf);
if(Result != -1)
{
// index 0 and 7 are bluekitty and limekitty
if(i != 0 && i != 7 && str_comp_num(pName, s_aaVanillaSkins[i], str_length(s_aaVanillaSkins[i])-4) == 0)
{
str_format(aBuf, sizeof(aBuf), "kitty_%s", pName);
pName = aBuf;
break;
}
return Result;
}
}
return FindImpl(pName);
}
int CSkins::FindImpl(const char *pName) const
{
for(int i = 0; i < m_aSkins.size(); i++)
{
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
{
return i;
}
}
return -1;
}

View file

@ -26,11 +26,12 @@ public:
vec4 GetColorV4(int v);
int Num();
const CSkin *Get(int Index);
int Find(const char *pName);
int Find(const char *pName) const;
private:
sorted_array<CSkin> m_aSkins;
int FindImpl(const char *pName) const;
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
};
#endif

View file

@ -80,7 +80,7 @@ MACRO_CONFIG_INT(ClPlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFL
MACRO_CONFIG_INT(ClPlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
MACRO_CONFIG_INT(ClPlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
MACRO_CONFIG_STR(ClPlayerSkin, player_skin, 24, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin")
MACRO_CONFIG_INT(ClKittySkins, cl_kitty_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable kitty skins instead of vanilla skins")
MACRO_CONFIG_STR(ClSkinPrefix, cl_skin_prefix, 100, "", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Replace the skins by skins with this prefix (e.g. kitty, coala, santa)")
MACRO_CONFIG_INT(ClFatSkins, cl_fat_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable fat skins")
MACRO_CONFIG_INT(UiPage, ui_page, 9, 0, 11, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface page")