mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
fixed ninja skin and skin part selection on missing part
This commit is contained in:
parent
1b6698a181
commit
8b8eb50961
BIN
data/skins/eyes/x_ninja.png
Normal file
BIN
data/skins/eyes/x_ninja.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
21
data/skins/x_ninja.skn
Normal file
21
data/skins/x_ninja.skn
Normal file
|
@ -0,0 +1,21 @@
|
|||
body.filename := x_ninja
|
||||
body.custom_colors := true
|
||||
body.hue := 0
|
||||
body.sat := 0
|
||||
body.lgt := 0
|
||||
|
||||
tattoo.filename := uppy
|
||||
tattoo.custom_colors := true
|
||||
tattoo.hue := 0
|
||||
tattoo.sat := 0
|
||||
tattoo.lgt := 255
|
||||
tattoo.alp := 127
|
||||
|
||||
hands.filename := standard
|
||||
hands.custom_colors := false
|
||||
|
||||
feet.filename := standard
|
||||
feet.custom_colors := false
|
||||
|
||||
eyes.filename := x_ninja
|
||||
eyes.custom_colors := false
|
|
@ -323,9 +323,8 @@ void CMenus::RenderSkinSelection(CUIRect MainView)
|
|||
{
|
||||
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
||||
// no special skins
|
||||
if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
|
||||
continue;
|
||||
s_paSkinList.add(s);
|
||||
if(s->m_Type == CSkins::SKINTYPE_STANDARD)
|
||||
s_paSkinList.add(s);
|
||||
}
|
||||
s_InitSkinlist = false;
|
||||
}
|
||||
|
@ -398,9 +397,8 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
|
|||
{
|
||||
const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(p, i);
|
||||
// no special skins
|
||||
if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
|
||||
continue;
|
||||
s_paList[p].add(s);
|
||||
if(s->m_Type == CSkins::SKINTYPE_STANDARD)
|
||||
s_paList[p].add(s);
|
||||
}
|
||||
}
|
||||
s_InitSkinPartList = false;
|
||||
|
@ -427,7 +425,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
|
|||
CTeeRenderInfo Info;
|
||||
for(int j = 0; j < NUM_SKINPARTS; j++)
|
||||
{
|
||||
int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, gs_apSkinVariables[j]);
|
||||
int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, gs_apSkinVariables[j], false);
|
||||
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(j, SkinPart);
|
||||
if(*gs_apUCCVariables[j])
|
||||
{
|
||||
|
@ -952,7 +950,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
OwnSkinInfo.m_Size = 50.0f;
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, gs_apSkinVariables[p]);
|
||||
int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, gs_apSkinVariables[p], false);
|
||||
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(p, SkinPart);
|
||||
if(*gs_apUCCVariables[p])
|
||||
{
|
||||
|
|
|
@ -528,15 +528,31 @@ void CPlayers::OnRender()
|
|||
if(m_pClient->m_Snap.m_aCharacters[i].m_Cur.m_Weapon == WEAPON_NINJA)
|
||||
{
|
||||
// change the skin for the player to the ninja
|
||||
int Skin = m_pClient->m_pSkins->Find("x_ninja");
|
||||
int Skin = m_pClient->m_pSkins->Find("x_ninja", true);
|
||||
if(Skin != -1)
|
||||
{
|
||||
const CSkins::CSkin *pNinja = m_pClient->m_pSkins->Get(Skin);
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
if(IsTeamplay)
|
||||
/*if(IsTeamplay)
|
||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture;
|
||||
else
|
||||
{
|
||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_OrgTexture;
|
||||
m_aRenderInfo[i].m_aColors[p] = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}*/
|
||||
if(IsTeamplay)
|
||||
{
|
||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture;
|
||||
int ColorVal = m_pClient->m_pSkins->GetTeamColor(true, pNinja->m_aPartColors[p], m_pClient->m_aClients[i].m_Team, p);
|
||||
m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(ColorVal, p==SKINPART_TATTOO);
|
||||
}
|
||||
else if(pNinja->m_aUseCustomColors[p])
|
||||
{
|
||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture;
|
||||
m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(pNinja->m_aPartColors[p], p==SKINPART_TATTOO);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_OrgTexture;
|
||||
m_aRenderInfo[i].m_aColors[p] = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -86,6 +86,9 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
mem_free(Info.m_pData);
|
||||
|
||||
// set skin part data
|
||||
Part.m_Type = SKINTYPE_STANDARD;
|
||||
if(pName[0] == 'x' && pName[1] == '_')
|
||||
Part.m_Type = SKINTYPE_SPECIAL;
|
||||
str_copy(Part.m_aName, pName, min((int)sizeof(Part.m_aName),l-3));
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
|
@ -104,13 +107,14 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
if(l < 4 || IsDir || str_comp(pName+l-4, ".skn") != 0)
|
||||
return 0;
|
||||
|
||||
CSkin Skin = pSelf->m_DummySkin;
|
||||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "skins/%s", pName);
|
||||
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_READ, IStorage::TYPE_ALL);
|
||||
if(!File)
|
||||
return 0;
|
||||
|
||||
CSkin Skin = pSelf->m_DummySkin;
|
||||
bool SpecialSkin = pName[0] == 'x' & pName[1] == '_';
|
||||
CLineReader LineReader;
|
||||
LineReader.Init(File);
|
||||
|
||||
|
@ -153,7 +157,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
pVariable += str_length(apParts[Part]);
|
||||
if(str_comp(pVariable, "filename") == 0)
|
||||
{
|
||||
int SkinPart = pSelf->FindSkinPart(Part, pValue);
|
||||
int SkinPart = pSelf->FindSkinPart(Part, pValue, SpecialSkin);
|
||||
if(SkinPart < 0)
|
||||
continue;
|
||||
Skin.m_apParts[Part] = pSelf->GetSkinPart(Part, SkinPart);
|
||||
|
@ -194,6 +198,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
io_close(File);
|
||||
|
||||
// set skin data
|
||||
Skin.m_Type = SpecialSkin ? SKINTYPE_SPECIAL : SKINTYPE_STANDARD;
|
||||
str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3));
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
|
@ -231,6 +236,7 @@ void CSkins::OnInit()
|
|||
if(!m_aaSkinParts[p].size())
|
||||
{
|
||||
CSkinPart DummySkinPart;
|
||||
DummySkinPart.m_Type = SKINTYPE_STANDARD;
|
||||
str_copy(DummySkinPart.m_aName, "dummy", sizeof(DummySkinPart.m_aName));
|
||||
DummySkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f);
|
||||
m_aaSkinParts[p].add(DummySkinPart);
|
||||
|
@ -238,14 +244,15 @@ void CSkins::OnInit()
|
|||
}
|
||||
|
||||
// create dummy skin
|
||||
m_DummySkin.m_Type = SKINTYPE_STANDARD;
|
||||
str_copy(m_DummySkin.m_aName, "dummy", sizeof(m_DummySkin.m_aName));
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
int Default;
|
||||
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
|
||||
Default = FindSkinPart(p, "");
|
||||
Default = FindSkinPart(p, "", false);
|
||||
else
|
||||
Default = FindSkinPart(p, "standard");
|
||||
Default = FindSkinPart(p, "standard", false);
|
||||
if(Default < 0)
|
||||
Default = 0;
|
||||
m_DummySkin.m_apParts[p] = GetSkinPart(p, Default);
|
||||
|
@ -277,11 +284,11 @@ 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, bool AllowSpecialSkin)
|
||||
{
|
||||
for(int i = 0; i < m_aSkins.size(); i++)
|
||||
{
|
||||
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
|
||||
if(str_comp(m_aSkins[i].m_aName, pName) == 0 && (m_aSkins[i].m_Type != SKINTYPE_SPECIAL || AllowSpecialSkin))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -293,11 +300,11 @@ const CSkins::CSkinPart *CSkins::GetSkinPart(int Part, int Index)
|
|||
return &m_aaSkinParts[Part][max(0, Index%Size)];
|
||||
}
|
||||
|
||||
int CSkins::FindSkinPart(int Part, const char *pName)
|
||||
int CSkins::FindSkinPart(int Part, const char *pName, bool AllowSpecialPart)
|
||||
{
|
||||
for(int i = 0; i < m_aaSkinParts[Part].size(); i++)
|
||||
{
|
||||
if(str_comp(m_aaSkinParts[Part][i].m_aName, pName) == 0)
|
||||
if(str_comp(m_aaSkinParts[Part][i].m_aName, pName) == 0 && (m_aaSkinParts[Part][i].m_Type != SKINTYPE_SPECIAL || AllowSpecialPart))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -25,18 +25,27 @@ enum
|
|||
class CSkins : public CComponent
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
SKINTYPE_STANDARD,
|
||||
SKINTYPE_SPECIAL,
|
||||
};
|
||||
|
||||
struct CSkinPart
|
||||
{
|
||||
int m_Type;
|
||||
char m_aName[24];
|
||||
IGraphics::CTextureHandle m_OrgTexture;
|
||||
IGraphics::CTextureHandle m_ColorTexture;
|
||||
vec3 m_BloodColor;
|
||||
|
||||
|
||||
bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
|
||||
};
|
||||
|
||||
struct CSkin
|
||||
{
|
||||
int m_Type;
|
||||
char m_aName[24];
|
||||
const CSkinPart *m_apParts[NUM_SKINPARTS];
|
||||
int m_aPartColors[NUM_SKINPARTS];
|
||||
|
@ -50,9 +59,10 @@ public:
|
|||
int Num();
|
||||
int NumSkinPart(int Part);
|
||||
const CSkin *Get(int Index);
|
||||
int Find(const char *pName);
|
||||
int Find(const char *pName, bool AllowSpecialSkin);
|
||||
const CSkinPart *GetSkinPart(int Part, int Index);
|
||||
int FindSkinPart(int Part, const char *pName);
|
||||
int FindSkinPart(int Part, const char *pName, bool AllowSpecialPart);
|
||||
const CSkin *GetDummySkin() const { return &m_DummySkin; }
|
||||
|
||||
vec3 GetColorV3(int v) const;
|
||||
vec4 GetColorV4(int v, bool UseAlpha) const;
|
||||
|
|
|
@ -1326,16 +1326,21 @@ void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool U
|
|||
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
if(m_aaSkinPartNames[p][0] == 'x' && m_aaSkinPartNames[p][1] == '_')
|
||||
str_copy(m_aaSkinPartNames[p], "default", 24);
|
||||
|
||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p]);
|
||||
if(m_SkinPartIDs[p] < 0)
|
||||
int ID = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p], false);
|
||||
if(ID < 0)
|
||||
{
|
||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->Find("default");
|
||||
if(m_SkinPartIDs[p] < 0)
|
||||
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
|
||||
ID = pGameClient->m_pSkins->FindSkinPart(p, "", false);
|
||||
else
|
||||
ID = pGameClient->m_pSkins->FindSkinPart(p, "standard", false);
|
||||
|
||||
if(ID < 0)
|
||||
m_SkinPartIDs[p] = 0;
|
||||
else
|
||||
m_SkinPartIDs[p] = ID;
|
||||
}
|
||||
else
|
||||
m_SkinPartIDs[p] = ID;
|
||||
|
||||
const CSkins::CSkinPart *pSkinPart = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p]);
|
||||
if(m_aUseCustomColors[p])
|
||||
|
|
Loading…
Reference in a new issue