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,8 +323,7 @@ void CMenus::RenderSkinSelection(CUIRect MainView)
|
||||||
{
|
{
|
||||||
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
||||||
// no special skins
|
// no special skins
|
||||||
if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
|
if(s->m_Type == CSkins::SKINTYPE_STANDARD)
|
||||||
continue;
|
|
||||||
s_paSkinList.add(s);
|
s_paSkinList.add(s);
|
||||||
}
|
}
|
||||||
s_InitSkinlist = false;
|
s_InitSkinlist = false;
|
||||||
|
@ -398,8 +397,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
|
||||||
{
|
{
|
||||||
const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(p, i);
|
const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(p, i);
|
||||||
// no special skins
|
// no special skins
|
||||||
if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
|
if(s->m_Type == CSkins::SKINTYPE_STANDARD)
|
||||||
continue;
|
|
||||||
s_paList[p].add(s);
|
s_paList[p].add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +425,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
|
||||||
CTeeRenderInfo Info;
|
CTeeRenderInfo Info;
|
||||||
for(int j = 0; j < NUM_SKINPARTS; j++)
|
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);
|
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(j, SkinPart);
|
||||||
if(*gs_apUCCVariables[j])
|
if(*gs_apUCCVariables[j])
|
||||||
{
|
{
|
||||||
|
@ -952,7 +950,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
||||||
OwnSkinInfo.m_Size = 50.0f;
|
OwnSkinInfo.m_Size = 50.0f;
|
||||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
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);
|
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(p, SkinPart);
|
||||||
if(*gs_apUCCVariables[p])
|
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)
|
if(m_pClient->m_Snap.m_aCharacters[i].m_Cur.m_Weapon == WEAPON_NINJA)
|
||||||
{
|
{
|
||||||
// change the skin for the player to the 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)
|
if(Skin != -1)
|
||||||
{
|
{
|
||||||
const CSkins::CSkin *pNinja = m_pClient->m_pSkins->Get(Skin);
|
const CSkins::CSkin *pNinja = m_pClient->m_pSkins->Get(Skin);
|
||||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||||
{
|
{
|
||||||
if(IsTeamplay)
|
/*if(IsTeamplay)
|
||||||
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture;
|
m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture;
|
||||||
else
|
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_aTextures[p] = pNinja->m_apParts[p]->m_OrgTexture;
|
||||||
m_aRenderInfo[i].m_aColors[p] = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
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);
|
mem_free(Info.m_pData);
|
||||||
|
|
||||||
// set skin part data
|
// 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));
|
str_copy(Part.m_aName, pName, min((int)sizeof(Part.m_aName),l-3));
|
||||||
if(g_Config.m_Debug)
|
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)
|
if(l < 4 || IsDir || str_comp(pName+l-4, ".skn") != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CSkin Skin = pSelf->m_DummySkin;
|
|
||||||
|
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
str_format(aBuf, sizeof(aBuf), "skins/%s", pName);
|
str_format(aBuf, sizeof(aBuf), "skins/%s", pName);
|
||||||
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_READ, IStorage::TYPE_ALL);
|
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_READ, IStorage::TYPE_ALL);
|
||||||
if(!File)
|
if(!File)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
CSkin Skin = pSelf->m_DummySkin;
|
||||||
|
bool SpecialSkin = pName[0] == 'x' & pName[1] == '_';
|
||||||
CLineReader LineReader;
|
CLineReader LineReader;
|
||||||
LineReader.Init(File);
|
LineReader.Init(File);
|
||||||
|
|
||||||
|
@ -153,7 +157,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
pVariable += str_length(apParts[Part]);
|
pVariable += str_length(apParts[Part]);
|
||||||
if(str_comp(pVariable, "filename") == 0)
|
if(str_comp(pVariable, "filename") == 0)
|
||||||
{
|
{
|
||||||
int SkinPart = pSelf->FindSkinPart(Part, pValue);
|
int SkinPart = pSelf->FindSkinPart(Part, pValue, SpecialSkin);
|
||||||
if(SkinPart < 0)
|
if(SkinPart < 0)
|
||||||
continue;
|
continue;
|
||||||
Skin.m_apParts[Part] = pSelf->GetSkinPart(Part, SkinPart);
|
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);
|
io_close(File);
|
||||||
|
|
||||||
// set skin data
|
// 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));
|
str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3));
|
||||||
if(g_Config.m_Debug)
|
if(g_Config.m_Debug)
|
||||||
{
|
{
|
||||||
|
@ -231,6 +236,7 @@ void CSkins::OnInit()
|
||||||
if(!m_aaSkinParts[p].size())
|
if(!m_aaSkinParts[p].size())
|
||||||
{
|
{
|
||||||
CSkinPart DummySkinPart;
|
CSkinPart DummySkinPart;
|
||||||
|
DummySkinPart.m_Type = SKINTYPE_STANDARD;
|
||||||
str_copy(DummySkinPart.m_aName, "dummy", sizeof(DummySkinPart.m_aName));
|
str_copy(DummySkinPart.m_aName, "dummy", sizeof(DummySkinPart.m_aName));
|
||||||
DummySkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f);
|
DummySkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f);
|
||||||
m_aaSkinParts[p].add(DummySkinPart);
|
m_aaSkinParts[p].add(DummySkinPart);
|
||||||
|
@ -238,14 +244,15 @@ void CSkins::OnInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// create dummy skin
|
// create dummy skin
|
||||||
|
m_DummySkin.m_Type = SKINTYPE_STANDARD;
|
||||||
str_copy(m_DummySkin.m_aName, "dummy", sizeof(m_DummySkin.m_aName));
|
str_copy(m_DummySkin.m_aName, "dummy", sizeof(m_DummySkin.m_aName));
|
||||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||||
{
|
{
|
||||||
int Default;
|
int Default;
|
||||||
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
|
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
|
||||||
Default = FindSkinPart(p, "");
|
Default = FindSkinPart(p, "", false);
|
||||||
else
|
else
|
||||||
Default = FindSkinPart(p, "standard");
|
Default = FindSkinPart(p, "standard", false);
|
||||||
if(Default < 0)
|
if(Default < 0)
|
||||||
Default = 0;
|
Default = 0;
|
||||||
m_DummySkin.m_apParts[p] = GetSkinPart(p, Default);
|
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())];
|
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++)
|
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 i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -293,11 +300,11 @@ const CSkins::CSkinPart *CSkins::GetSkinPart(int Part, int Index)
|
||||||
return &m_aaSkinParts[Part][max(0, Index%Size)];
|
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++)
|
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 i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -25,18 +25,27 @@ enum
|
||||||
class CSkins : public CComponent
|
class CSkins : public CComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SKINTYPE_STANDARD,
|
||||||
|
SKINTYPE_SPECIAL,
|
||||||
|
};
|
||||||
|
|
||||||
struct CSkinPart
|
struct CSkinPart
|
||||||
{
|
{
|
||||||
|
int m_Type;
|
||||||
char m_aName[24];
|
char m_aName[24];
|
||||||
IGraphics::CTextureHandle m_OrgTexture;
|
IGraphics::CTextureHandle m_OrgTexture;
|
||||||
IGraphics::CTextureHandle m_ColorTexture;
|
IGraphics::CTextureHandle m_ColorTexture;
|
||||||
vec3 m_BloodColor;
|
vec3 m_BloodColor;
|
||||||
|
|
||||||
|
|
||||||
bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
|
bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CSkin
|
struct CSkin
|
||||||
{
|
{
|
||||||
|
int m_Type;
|
||||||
char m_aName[24];
|
char m_aName[24];
|
||||||
const CSkinPart *m_apParts[NUM_SKINPARTS];
|
const CSkinPart *m_apParts[NUM_SKINPARTS];
|
||||||
int m_aPartColors[NUM_SKINPARTS];
|
int m_aPartColors[NUM_SKINPARTS];
|
||||||
|
@ -50,9 +59,10 @@ public:
|
||||||
int Num();
|
int Num();
|
||||||
int NumSkinPart(int Part);
|
int NumSkinPart(int Part);
|
||||||
const CSkin *Get(int Index);
|
const CSkin *Get(int Index);
|
||||||
int Find(const char *pName);
|
int Find(const char *pName, bool AllowSpecialSkin);
|
||||||
const CSkinPart *GetSkinPart(int Part, int Index);
|
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;
|
vec3 GetColorV3(int v) const;
|
||||||
vec4 GetColorV4(int v, bool UseAlpha) 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++)
|
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||||
{
|
{
|
||||||
if(m_aaSkinPartNames[p][0] == 'x' && m_aaSkinPartNames[p][1] == '_')
|
int ID = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p], false);
|
||||||
str_copy(m_aaSkinPartNames[p], "default", 24);
|
if(ID < 0)
|
||||||
|
|
||||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p]);
|
|
||||||
if(m_SkinPartIDs[p] < 0)
|
|
||||||
{
|
{
|
||||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->Find("default");
|
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
|
||||||
if(m_SkinPartIDs[p] < 0)
|
ID = pGameClient->m_pSkins->FindSkinPart(p, "", false);
|
||||||
|
else
|
||||||
|
ID = pGameClient->m_pSkins->FindSkinPart(p, "standard", false);
|
||||||
|
|
||||||
|
if(ID < 0)
|
||||||
m_SkinPartIDs[p] = 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]);
|
const CSkins::CSkinPart *pSkinPart = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p]);
|
||||||
if(m_aUseCustomColors[p])
|
if(m_aUseCustomColors[p])
|
||||||
|
|
Loading…
Reference in a new issue