changed skin file format to json

This commit is contained in:
oy 2012-12-22 00:34:49 +01:00
parent d08695b148
commit f5c56c96d5
54 changed files with 631 additions and 548 deletions

View file

@ -0,0 +1,31 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 155,
"sat": 116,
"lgt": 122
},
"tattoo": {
"filename": "stripes",
"custom_colors": "false"
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 11,
"sat": 117,
"lgt": 0
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 29,
"sat": 173,
"lgt": 87
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,23 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 155
body.sat := 116
body.lgt := 122
tattoo.filename := stripes
tattoo.custom_colors := false
hands.filename := standard
hands.custom_colors := true
hands.hue := 11
hands.sat := 117
hands.lgt := 0
feet.filename := standard
feet.custom_colors := true
feet.hue := 29
feet.sat := 173
feet.lgt := 87
eyes.filename := standard
eyes.custom_colors := false

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

35
data/skins/cammo.json Normal file
View file

@ -0,0 +1,35 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 81,
"sat": 101,
"lgt": 70
},
"tattoo": {
"filename": "cammo2",
"custom_colors": "true",
"hue": 76,
"sat": 97,
"lgt": 45,
"alp": 255
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 11,
"sat": 117,
"lgt": 0
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 29,
"sat": 173,
"lgt": 87
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,27 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 81
body.sat := 101
body.lgt := 70
tattoo.filename := cammo2
tattoo.custom_colors := true
tattoo.hue := 76
tattoo.sat := 97
tattoo.lgt := 45
tattoo.alp := 255
hands.filename := standard
hands.custom_colors := true
hands.hue := 11
hands.sat := 117
hands.lgt := 0
feet.filename := standard
feet.custom_colors := true
feet.hue := 29
feet.sat := 173
feet.lgt := 87
eyes.filename := standard
eyes.custom_colors := false

View file

@ -0,0 +1,35 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 81,
"sat": 101,
"lgt": 70
},
"tattoo": {
"filename": "cammostripes",
"custom_colors": "true",
"hue": 29,
"sat": 142,
"lgt": 0,
"alp": 255
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 11,
"sat": 117,
"lgt": 0
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 29,
"sat": 173,
"lgt": 87
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,27 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 81
body.sat := 101
body.lgt := 70
tattoo.filename := cammostripes
tattoo.custom_colors := true
tattoo.hue := 29
tattoo.sat := 142
tattoo.lgt := 0
tattoo.alp := 255
hands.filename := standard
hands.custom_colors := true
hands.hue := 11
hands.sat := 117
hands.lgt := 0
feet.filename := standard
feet.custom_colors := true
feet.hue := 29
feet.sat := 173
feet.lgt := 87
eyes.filename := standard
eyes.custom_colors := false

39
data/skins/coala.json Normal file
View file

@ -0,0 +1,39 @@
{"skin": {
"body": {
"filename": "bear",
"custom_colors": "true",
"hue": 0,
"sat": 0,
"lgt": 184
},
"tattoo": {
"filename": "bear",
"custom_colors": "true",
"hue": 21,
"sat": 12,
"lgt": 226,
"alp": 255
},
"decoration": {
"filename": "hair",
"custom_colors": "false"
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 0,
"sat": 0,
"lgt": 184
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 149,
"sat": 4,
"lgt": 71
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,29 +0,0 @@
body.filename := bear
body.custom_colors := true
body.hue := 0
body.sat := 0
body.lgt := 184
tattoo.filename := bear
tattoo.hue := 21
tattoo.sat := 12
tattoo.lgt := 226
tattoo.alp := 255
decoration.filename := hair
decoration.custom_colors := false
hands.filename := standard
hands.custom_colors := true
hands.hue := 0
hands.sat := 0
hands.lgt := 184
feet.filename := standard
feet.custom_colors := true
feet.hue := 149
feet.sat := 4
feet.lgt := 71
eyes.filename := standard
eyes.custom_colors := false

27
data/skins/default.json Normal file
View file

@ -0,0 +1,27 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 27,
"sat": 111,
"lgt": 116
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 27,
"sat": 117,
"lgt": 158
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 28,
"sat": 135,
"lgt": 62
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,20 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 27
body.sat := 111
body.lgt := 116
hands.filename := standard
hands.custom_colors := true
hands.hue := 27
hands.sat := 117
hands.lgt := 158
feet.filename := standard
feet.custom_colors := true
feet.hue := 28
feet.sat := 135
feet.lgt := 62
eyes.filename := standard
eyes.custom_colors := false

35
data/skins/pinky.json Normal file
View file

@ -0,0 +1,35 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 242,
"sat": 201,
"lgt": 187
},
"tattoo": {
"filename": "whisker",
"custom_colors": "true",
"hue": 243,
"sat": 198,
"lgt": 214,
"alp": 255
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 229,
"sat": 137,
"lgt": 218
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 229,
"sat": 137,
"lgt": 218
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,27 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 242
body.sat := 201
body.lgt := 187
tattoo.filename := whisker
tattoo.custom_colors := true
tattoo.hue := 243
tattoo.sat := 198
tattoo.lgt := 214
tattoo.alp := 255
hands.filename := standard
hands.custom_colors := true
hands.hue := 229
hands.sat := 137
hands.lgt := 218
feet.filename := standard
feet.custom_colors := true
feet.hue := 229
feet.sat := 137
feet.lgt := 218
eyes.filename := standard
eyes.custom_colors := false

42
data/skins/redbopp.json Normal file
View file

@ -0,0 +1,42 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 246,
"sat": 216,
"lgt": 108
},
"tattoo": {
"filename": "donny",
"custom_colors": "true",
"hue": 2,
"sat": 217,
"lgt": 202,
"alp": 255
},
"decoration": {
"filename": "unibop",
"custom_colors": "true",
"hue": 246,
"sat": 216,
"lgt": 108
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 246,
"sat": 216,
"lgt": 108
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 116,
"sat": 85,
"lgt": 233
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,33 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 246
body.sat := 216
body.lgt := 108
tattoo.filename := donny
tattoo.custom_colors := true
tattoo.hue := 2
tattoo.sat := 217
tattoo.lgt := 202
tattoo.alp := 255
decoration.filename := unibop
decoration.custom_colors := true
decoration.hue := 246
decoration.sat := 216
decoration.lgt := 108
hands.filename := standard
hands.custom_colors := true
hands.hue := 246
hands.sat := 216
hands.lgt := 108
feet.filename := standard
feet.custom_colors := true
feet.hue := 116
feet.sat := 85
feet.lgt := 233
eyes.filename := standard
eyes.custom_colors := false

31
data/skins/redstripe.json Normal file
View file

@ -0,0 +1,31 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 248,
"sat": 214,
"lgt": 123
},
"tattoo": {
"filename": "stripe",
"custom_colors": "false"
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 0,
"sat": 0,
"lgt": 184
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 149,
"sat": 4,
"lgt": 71
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,23 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 248
body.sat := 214
body.lgt := 123
tattoo.filename := stripe
tattoo.custom_colors := false
hands.filename := standard
hands.custom_colors := true
hands.hue := 0
hands.sat := 0
hands.lgt := 184
feet.filename := standard
feet.custom_colors := true
feet.hue := 149
feet.sat := 4
feet.lgt := 71
eyes.filename := standard
eyes.custom_colors := false

35
data/skins/saddo.json Normal file
View file

@ -0,0 +1,35 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 109,
"sat": 109,
"lgt": 127
},
"tattoo": {
"filename": "saddo",
"custom_colors": "true",
"hue": 108,
"sat": 54,
"lgt": 68,
"alp": 255
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 55,
"sat": 141,
"lgt": 170
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 88,
"sat": 97,
"lgt": 119
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,27 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 109
body.sat := 109
body.lgt := 127
tattoo.filename := saddo
tattoo.custom_colors := true
tattoo.hue := 108
tattoo.sat := 54
tattoo.lgt := 68
tattoo.alp := 255
hands.filename := standard
hands.custom_colors := true
hands.hue := 55
hands.sat := 141
hands.lgt := 170
feet.filename := standard
feet.custom_colors := true
feet.hue := 88
feet.sat := 97
feet.lgt := 119
eyes.filename := standard
eyes.custom_colors := false

View file

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 725 B

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 638 B

View file

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 838 B

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 867 B

After

Width:  |  Height:  |  Size: 867 B

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 664 B

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 687 B

31
data/skins/toptri.json Normal file
View file

@ -0,0 +1,31 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 93,
"sat": 95,
"lgt": 163
},
"tattoo": {
"filename": "toptri",
"custom_colors": "false"
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 55,
"sat": 141,
"lgt": 170
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 88,
"sat": 97,
"lgt": 119
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,23 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 93
body.sat := 95
body.lgt := 163
tattoo.filename := toptri
tattoo.custom_colors := false
hands.filename := standard
hands.custom_colors := true
hands.hue := 55
hands.sat := 141
hands.lgt := 170
feet.filename := standard
feet.custom_colors := true
feet.hue := 88
feet.sat := 97
feet.lgt := 119
eyes.filename := standard
eyes.custom_colors := false

42
data/skins/twinbop.json Normal file
View file

@ -0,0 +1,42 @@
{"skin": {
"body": {
"filename": "standard",
"custom_colors": "true",
"hue": 233,
"sat": 158,
"lgt": 183
},
"tattoo": {
"filename": "duodonny",
"custom_colors": "true",
"hue": 231,
"sat": 146,
"lgt": 218,
"alp": 255
},
"decoration": {
"filename": "twinbopp",
"custom_colors": "true",
"hue": 233,
"sat": 158,
"lgt": 183
},
"hands": {
"filename": "standard",
"custom_colors": "true",
"hue": 233,
"sat": 158,
"lgt": 183
},
"feet": {
"filename": "standard",
"custom_colors": "true",
"hue": 0,
"sat": 146,
"lgt": 224
},
"eyes": {
"filename": "standard",
"custom_colors": "false"
}}
}

View file

@ -1,33 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 233
body.sat := 158
body.lgt := 183
tattoo.filename := duodonny
tattoo.custom_colors := true
tattoo.hue := 231
tattoo.sat := 146
tattoo.lgt := 218
tattoo.alp := 255
decoration.filename := twinbopp
decoration.custom_colors := true
decoration.hue := 233
decoration.sat := 158
decoration.lgt := 183
hands.filename := standard
hands.custom_colors := true
hands.hue := 233
hands.sat := 158
hands.lgt := 183
feet.filename := standard
feet.custom_colors := true
feet.hue := 0
feet.sat := 146
feet.lgt := 224
eyes.filename := standard
eyes.custom_colors := false

View file

@ -1,27 +0,0 @@
body.filename := standard
body.custom_colors := true
body.hue := 52
body.sat := 156
body.lgt := 124
tattoo.filename := twintri
tattoo.custom_colors := true
tattoo.hue := 40
tattoo.sat := 219
tattoo.lgt := 227
tattoo.alp := 255
hands.filename := standard
hands.custom_colors := true
hands.hue := 0
hands.sat := 0
hands.lgt := 184
feet.filename := standard
feet.custom_colors := true
feet.hue := 149
feet.sat := 4
feet.lgt := 71
eyes.filename := standard
eyes.custom_colors := false

29
data/skins/x_ninja.json Normal file
View file

@ -0,0 +1,29 @@
{"skin": {
"body": {
"filename": "x_ninja",
"custom_colors": "true",
"hue": 0,
"sat": 0,
"lgt": 0
},
"tattoo": {
"filename": "uppy",
"custom_colors": "true",
"hue": 0,
"sat": 0,
"lgt": 255,
"alp": 127
},
"hands": {
"filename": "standard",
"custom_colors": "false"
},
"feet": {
"filename": "standard",
"custom_colors": "false"
},
"eyes": {
"filename": "x_ninja",
"custom_colors": "false"
}}
}

View file

@ -1,21 +0,0 @@
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

View file

@ -16,7 +16,8 @@
void CCountryFlags::LoadCountryflagsIndexfile()
{
// read file data into buffer
IOHANDLE File = Storage()->OpenFile("countryflags/index.json", IOFLAG_READ, IStorage::TYPE_ALL);
const char *pFilename = "countryflags/index.json";
IOHANDLE File = Storage()->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
if(!File)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "couldn't open index file");
@ -35,7 +36,8 @@ void CCountryFlags::LoadCountryflagsIndexfile()
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError);
if(pJsonData == 0)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aError);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, pFilename, aError);
mem_free(pFileData);
return;
}

View file

@ -156,11 +156,11 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID)
if(ClientID >= 0)
{
if(m_pClient->m_aClients[ClientID].m_aUseCustomColors[SKINPART_BODY])
BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_aSkinPartColors[SKINPART_BODY]);
if(m_pClient->m_aClients[ClientID].m_aUseCustomColors[CSkins::SKINPART_BODY])
BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_aSkinPartColors[CSkins::SKINPART_BODY]);
else
{
const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(SKINPART_BODY, m_pClient->m_aClients[ClientID].m_SkinPartIDs[SKINPART_BODY]);
const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(CSkins::SKINPART_BODY, m_pClient->m_aClients[ClientID].m_SkinPartIDs[CSkins::SKINPART_BODY]);
if(s)
BloodColor = s->m_BloodColor;
}

View file

@ -48,7 +48,7 @@ CMenus::CMenus()
m_NeedRestartGraphics = false;
m_NeedRestartSound = false;
m_TeePartSelected = SKINPART_BODY;
m_TeePartSelected = CSkins::SKINPART_BODY;
m_aSaveSkinName[0] = 0;
m_MenuActive = true;
m_UseMouseButtons = true;

View file

@ -202,7 +202,6 @@ class CMenus : public CComponent
char m_aSaveSkinName[24];
void SaveSkinfile();
void WriteLineSkinfile(IOHANDLE File, const char *pLine);
//
bool m_EscapePressed;

View file

@ -67,55 +67,71 @@ int CMenus::DoButton_Customize(const void *pID, IGraphics::CTextureHandle Textur
void CMenus::SaveSkinfile()
{
char aFilename[256];
str_format(aFilename, sizeof(aFilename), "skins/%s.skn", m_aSaveSkinName);
IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "skins/%s.json", m_aSaveSkinName);
IOHANDLE File = Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_SAVE);
if(!File)
return;
static const char *const apParts[6] = {"body", "tattoo", "decoration",
"hands", "feet", "eyes"};
static const char *const apComponents[4] = {"hue", "sat", "lgt", "alp"};
// file start
const char *p = "{\"skin\": {";
io_write(File, p, str_length(p));
int Count = 0;
char aBuf[256];
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int PartIndex = 0; PartIndex < CSkins::NUM_SKINPARTS; PartIndex++)
{
if(!gs_apSkinVariables[p][0])
if(!CSkins::ms_apSkinVariables[PartIndex][0])
continue;
str_format(aBuf, sizeof(aBuf), "%s.filename := %s", apParts[p], gs_apSkinVariables[p]);
WriteLineSkinfile(File, aBuf);
str_format(aBuf, sizeof(aBuf), "%s.custom_colors := %s", apParts[p], *gs_apUCCVariables[p]?"true":"false");
WriteLineSkinfile(File, aBuf);
if(*gs_apUCCVariables[p])
// part start
if(Count == 0)
{
for(int c = 0; c < 3; c++)
p = "\n";
io_write(File, p, str_length(p));
}
else
{
p = ",\n";
io_write(File, p, str_length(p));
}
str_format(aBuf, sizeof(aBuf), "\t\"%s\": {\n", CSkins::ms_apSkinPartNames[PartIndex]);
io_write(File, aBuf, str_length(aBuf));
// part content
str_format(aBuf, sizeof(aBuf), "\t\t\"filename\": \"%s\",\n", CSkins::ms_apSkinVariables[PartIndex]);
io_write(File, aBuf, str_length(aBuf));
str_format(aBuf, sizeof(aBuf), "\t\t\"custom_colors\": \"%s\"", *CSkins::ms_apUCCVariables[PartIndex]?"true":"false");
io_write(File, aBuf, str_length(aBuf));
if(*CSkins::ms_apUCCVariables[PartIndex])
{
for(int c = 0; c < CSkins::NUM_COLOR_COMPONENTS-1; c++)
{
int Val = (*gs_apColorVariables[p] >> (2-c)*8) & 0xff;
str_format(aBuf, sizeof(aBuf), "%s.%s := %d", apParts[p], apComponents[c], Val);
WriteLineSkinfile(File, aBuf);
int Val = (*CSkins::ms_apColorVariables[PartIndex] >> (2-c)*8) & 0xff;
str_format(aBuf, sizeof(aBuf), ",\n\t\t\"%s\": %d", CSkins::ms_apColorComponents[c], Val);
io_write(File, aBuf, str_length(aBuf));
}
if(p == SKINPART_TATTOO)
if(PartIndex == CSkins::SKINPART_TATTOO)
{
int Val = (*gs_apColorVariables[p] >> 24) & 0xff;
str_format(aBuf, sizeof(aBuf), "%s.%s := %d", apParts[p], apComponents[3], Val);
WriteLineSkinfile(File, aBuf);
int Val = (*CSkins::ms_apColorVariables[PartIndex] >> 24) & 0xff;
str_format(aBuf, sizeof(aBuf), ",\n\t\t\"%s\": %d", CSkins::ms_apColorComponents[3], Val);
io_write(File, aBuf, str_length(aBuf));
}
}
if(p != NUM_SKINPARTS-1)
WriteLineSkinfile(File, "");
// part end
p = "\n\t}";
io_write(File, p, str_length(p));
++Count;
}
io_close(File);
}
// file end
p = "}\n}\n";
io_write(File, p, str_length(p));
void CMenus::WriteLineSkinfile(IOHANDLE File, const char *pLine)
{
io_write(File, pLine, str_length(pLine));
io_write_newline(File);
io_close(File);
}
void CMenus::RenderHSLPicker(CUIRect MainView)
@ -137,17 +153,17 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
float ButtonHeight = 20.0f;
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
static int s_CustomColors = 0;
if(DoButton_CheckBox(&s_CustomColors, Localize("Custom colors"), *gs_apUCCVariables[m_TeePartSelected], &Button))
*gs_apUCCVariables[m_TeePartSelected] ^= 1;
if(DoButton_CheckBox(&s_CustomColors, Localize("Custom colors"), *CSkins::ms_apUCCVariables[m_TeePartSelected], &Button))
*CSkins::ms_apUCCVariables[m_TeePartSelected] ^= 1;
if(!(*gs_apUCCVariables[m_TeePartSelected]))
if(!(*CSkins::ms_apUCCVariables[m_TeePartSelected]))
return;
MainView.HSplitTop(Spacing, 0, &MainView);
bool Modified = false;
bool UseAlpha = m_TeePartSelected == SKINPART_TATTOO;
int Color = *gs_apColorVariables[m_TeePartSelected];
bool UseAlpha = m_TeePartSelected == CSkins::SKINPART_TATTOO;
int Color = *CSkins::ms_apColorVariables[m_TeePartSelected];
int Hue, Sat, Lgt, Alp;
Hue = (Color>>16)&0xff;
@ -250,7 +266,7 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
{
int Val = v*2;
vec3 rgb;
float Dark = DARKEST_COLOR_LGT/255.0f;
float Dark = CSkins::DARKEST_COLOR_LGT/255.0f;
if(i == 0)
rgb = HslToRgb(vec3(Val/255.0f, 1.0f, 0.5f));
else if(i == 1)
@ -301,10 +317,10 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
if(Modified)
{
int NewVal = (Hue << 16) + (Sat << 8) + Lgt;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
if(m_TeePartSelected == p)
*gs_apColorVariables[p] = NewVal;
*CSkins::ms_apColorVariables[p] = NewVal;
}
if(UseAlpha)
g_Config.m_PlayerColorTattoo = (Alp << 24) + NewVal;
@ -345,12 +361,12 @@ void CMenus::RenderSkinSelection(CUIRect MainView)
if(Item.m_Visible)
{
CTeeRenderInfo Info;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
if(s->m_aUseCustomColors[p])
{
Info.m_aTextures[p] = s->m_apParts[p]->m_ColorTexture;
Info.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(s->m_aPartColors[p], p==SKINPART_TATTOO);
Info.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(s->m_aPartColors[p], p==CSkins::SKINPART_TATTOO);
}
else
{
@ -372,11 +388,11 @@ void CMenus::RenderSkinSelection(CUIRect MainView)
{
const CSkins::CSkin *s = s_paSkinList[NewSelected];
mem_copy(g_Config.m_PlayerSkin, s->m_aName, sizeof(g_Config.m_PlayerSkin));
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
mem_copy(gs_apSkinVariables[p], s->m_apParts[p]->m_aName, 24);
*gs_apUCCVariables[p] = s->m_aUseCustomColors[p];
*gs_apColorVariables[p] = s->m_aPartColors[p];
mem_copy(CSkins::ms_apSkinVariables[p], s->m_apParts[p]->m_aName, 24);
*CSkins::ms_apUCCVariables[p] = s->m_aUseCustomColors[p];
*CSkins::ms_apColorVariables[p] = s->m_aPartColors[p];
}
}
}
@ -390,7 +406,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
static float s_ScrollValue = 0.0f;
if(s_InitSkinPartList)
{
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
s_paList[p].clear();
for(int i = 0; i < m_pClient->m_pSkins->NumSkinPart(p); ++i)
@ -404,11 +420,8 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
s_InitSkinPartList = false;
}
const char *const apTitles[6] = {Localize("Bodies"), Localize("Tattoos"), Localize("Decoration"),
Localize("Hands"), Localize("Feet"), Localize("Eyes")};
static int OldSelected = -1;
UiDoListboxHeader(&MainView, apTitles[m_TeePartSelected], 20.0f, 2.0f);
UiDoListboxHeader(&MainView, CSkins::ms_apSkinPartNames[m_TeePartSelected], 20.0f, 2.0f);
UiDoListboxStart(&s_InitSkinPartList, 50.0f, 0, s_paList[m_TeePartSelected].size(), 5, OldSelected, s_ScrollValue);
for(int i = 0; i < s_paList[m_TeePartSelected].size(); ++i)
@ -416,24 +429,24 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
const CSkins::CSkinPart *s = s_paList[m_TeePartSelected][i];
if(s == 0)
continue;
if(!str_comp(s->m_aName, gs_apSkinVariables[m_TeePartSelected]))
if(!str_comp(s->m_aName, CSkins::ms_apSkinVariables[m_TeePartSelected]))
OldSelected = i;
CListboxItem Item = UiDoListboxNextItem(&s_paList[m_TeePartSelected][i], OldSelected == i);
if(Item.m_Visible)
{
CTeeRenderInfo Info;
for(int j = 0; j < NUM_SKINPARTS; j++)
for(int j = 0; j < CSkins::NUM_SKINPARTS; j++)
{
int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, gs_apSkinVariables[j], false);
int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, CSkins::ms_apSkinVariables[j], false);
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(j, SkinPart);
if(*gs_apUCCVariables[j])
if(*CSkins::ms_apUCCVariables[j])
{
if(m_TeePartSelected == j)
Info.m_aTextures[j] = s->m_ColorTexture;
else
Info.m_aTextures[j] = pSkinPart->m_ColorTexture;
Info.m_aColors[j] = m_pClient->m_pSkins->GetColorV4(*gs_apColorVariables[j], j==SKINPART_TATTOO);
Info.m_aColors[j] = m_pClient->m_pSkins->GetColorV4(*CSkins::ms_apColorVariables[j], j==CSkins::SKINPART_TATTOO);
}
else
{
@ -456,7 +469,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
if(NewSelected != OldSelected)
{
const CSkins::CSkinPart *s = s_paList[m_TeePartSelected][NewSelected];
mem_copy(gs_apSkinVariables[m_TeePartSelected], s->m_aName, 24);
mem_copy(CSkins::ms_apSkinVariables[m_TeePartSelected], s->m_aName, 24);
}
}
OldSelected = NewSelected;
@ -478,7 +491,8 @@ public:
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<CLanguage> *pLanguages)
{
// read file data into buffer
IOHANDLE File = pStorage->OpenFile("languages/index.json", IOFLAG_READ, IStorage::TYPE_ALL);
const char *pFilename = "languages/index.json";
IOHANDLE File = pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
if(!File)
{
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "couldn't open index file");
@ -497,7 +511,8 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError);
if(pJsonData == 0)
{
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localizations", aError);
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, pFilename, aError);
mem_free(pFileData);
return;
}
@ -850,9 +865,6 @@ void CMenus::RenderSettingsTeeCustom(CUIRect MainView)
UI()->DoLabel(&Label, Localize("Customize"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
// skin part selection
const char *const apParts[6] = {Localize("Body"), Localize("Tattoo"), Localize("Decoration"),
Localize("Hands"), Localize("Feet"), Localize("Eyes")};
MainView.HSplitTop(SpacingH, 0, &MainView);
MainView.HSplitTop(ButtonHeight, &Patterns, &MainView);
RenderTools()->DrawUIRect(&Patterns, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
@ -860,10 +872,10 @@ void CMenus::RenderSettingsTeeCustom(CUIRect MainView)
float ButtonWidth = (Patterns.w/6.0f)-(SpacingW*5.0)/6.0f;
static int s_aPatternButtons[6] = {0};
for(int i = 0; i < NUM_SKINPARTS; i++)
for(int i = 0; i < CSkins::NUM_SKINPARTS; i++)
{
Patterns.VSplitLeft(ButtonWidth, &Button, &Patterns);
if(DoButton_MenuTabTop(&s_aPatternButtons[i], apParts[i], m_TeePartSelected==i, &Button))
if(DoButton_MenuTabTop(&s_aPatternButtons[i], CSkins::ms_apSkinPartNames[i], m_TeePartSelected==i, &Button))
{
m_TeePartSelected = i;
}
@ -931,14 +943,14 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
CTeeRenderInfo OwnSkinInfo;
OwnSkinInfo.m_Size = 50.0f;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, gs_apSkinVariables[p], false);
int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, CSkins::ms_apSkinVariables[p], false);
const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(p, SkinPart);
if(*gs_apUCCVariables[p])
if(*CSkins::ms_apUCCVariables[p])
{
OwnSkinInfo.m_aTextures[p] = pSkinPart->m_ColorTexture;
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(*gs_apColorVariables[p], p==SKINPART_TATTOO);
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(*CSkins::ms_apColorVariables[p], p==CSkins::SKINPART_TATTOO);
}
else
{
@ -961,19 +973,19 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
RenderTools()->DrawUIRect(&Left, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
int TeamColor = m_pClient->m_pSkins->GetTeamColor(*gs_apUCCVariables[p], *gs_apColorVariables[p], TEAM_RED, p);
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(TeamColor, p==SKINPART_TATTOO);
int TeamColor = m_pClient->m_pSkins->GetTeamColor(*CSkins::ms_apUCCVariables[p], *CSkins::ms_apColorVariables[p], TEAM_RED, p);
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(TeamColor, p==CSkins::SKINPART_TATTOO);
}
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Left.x+Left.w/2.0f, Left.y+Left.h/2.0f+2.0f));
RenderTools()->DrawUIRect(&Right, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
int TeamColor = m_pClient->m_pSkins->GetTeamColor(*gs_apUCCVariables[p], *gs_apColorVariables[p], TEAM_BLUE, p);
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(TeamColor, p==SKINPART_TATTOO);
int TeamColor = m_pClient->m_pSkins->GetTeamColor(*CSkins::ms_apUCCVariables[p], *CSkins::ms_apColorVariables[p], TEAM_BLUE, p);
OwnSkinInfo.m_aColors[p] = m_pClient->m_pSkins->GetColorV4(TeamColor, p==CSkins::SKINPART_TATTOO);
}
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Right.x+Right.w/2.0f, Right.y+Right.h/2.0f+2.0f));
}

View file

@ -46,9 +46,9 @@ void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float
HandPos += DirY * PostRotOffset.y;
//Graphics()->TextureSet(data->m_aImages[IMAGE_CHAR_DEFAULT].id);
Graphics()->TextureSet(pInfo->m_aTextures[SKINPART_HANDS]);
Graphics()->TextureSet(pInfo->m_aTextures[CSkins::SKINPART_HANDS]);
Graphics()->QuadsBegin();
vec4 Color = pInfo->m_aColors[SKINPART_HANDS];
vec4 Color = pInfo->m_aColors[CSkins::SKINPART_HANDS];
Graphics()->SetColor(Color.r, Color.g, Color.b, Color.a);
// two passes
@ -467,7 +467,7 @@ void CPlayers::RenderPlayer(
{
vec2 GhostPosition = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), Client()->IntraGameTick());
CTeeRenderInfo Ghost = RenderInfo;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
Ghost.m_aColors[p].a *= 0.5f;
RenderTools()->RenderTee(&State, &Ghost, Player.m_Emote, Direction, GhostPosition); // render ghost
}
@ -532,18 +532,18 @@ void CPlayers::OnRender()
if(Skin != -1)
{
const CSkins::CSkin *pNinja = m_pClient->m_pSkins->Get(Skin);
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
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);
m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(ColorVal, p==CSkins::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);
m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(pNinja->m_aPartColors[p], p==CSkins::SKINPART_TATTOO);
}
else
{

View file

@ -5,23 +5,24 @@
#include <base/system.h>
#include <base/math.h>
#include <engine/shared/config.h>
#include <engine/graphics.h>
#include <engine/storage.h>
#include <engine/external/json-parser/json.h>
#include <engine/shared/config.h>
#include <engine/shared/linereader.h>
#include "skins.h"
char *const gs_apSkinVariables[NUM_SKINPARTS] = {g_Config.m_PlayerSkinBody, g_Config.m_PlayerSkinTattoo, g_Config.m_PlayerSkinDecoration,
const char * const CSkins::ms_apSkinPartNames[NUM_SKINPARTS] = {"body", "tattoo", "decoration", "hands", "feet", "eyes"};
const char * const CSkins::ms_apColorComponents[NUM_COLOR_COMPONENTS] = {"hue", "sat", "lgt", "alp"};
char *const CSkins::ms_apSkinVariables[NUM_SKINPARTS] = {g_Config.m_PlayerSkinBody, g_Config.m_PlayerSkinTattoo, g_Config.m_PlayerSkinDecoration,
g_Config.m_PlayerSkinHands, g_Config.m_PlayerSkinFeet, g_Config.m_PlayerSkinEyes};
int *const gs_apUCCVariables[NUM_SKINPARTS] = {&g_Config.m_PlayerUseCustomColorBody, &g_Config.m_PlayerUseCustomColorTattoo, &g_Config.m_PlayerUseCustomColorDecoration,
int *const CSkins::ms_apUCCVariables[NUM_SKINPARTS] = {&g_Config.m_PlayerUseCustomColorBody, &g_Config.m_PlayerUseCustomColorTattoo, &g_Config.m_PlayerUseCustomColorDecoration,
&g_Config.m_PlayerUseCustomColorHands, &g_Config.m_PlayerUseCustomColorFeet, &g_Config.m_PlayerUseCustomColorEyes};
int *const gs_apColorVariables[NUM_SKINPARTS] = {&g_Config.m_PlayerColorBody, &g_Config.m_PlayerColorTattoo, &g_Config.m_PlayerColorDecoration,
int *const CSkins::ms_apColorVariables[NUM_SKINPARTS] = {&g_Config.m_PlayerColorBody, &g_Config.m_PlayerColorTattoo, &g_Config.m_PlayerColorDecoration,
&g_Config.m_PlayerColorHands, &g_Config.m_PlayerColorFeet, &g_Config.m_PlayerColorEyes};
static const char *const gs_apFolders[NUM_SKINPARTS] = {"bodies", "tattoos", "decoration",
"hands", "feet", "eyes"};
int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
{
@ -31,12 +32,12 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
return 0;
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "skins/%s/%s", gs_apFolders[pSelf->m_ScanningPart], pName);
str_format(aBuf, sizeof(aBuf), "skins/%s/%s", CSkins::ms_apSkinPartNames[pSelf->m_ScanningPart], pName);
CImageInfo Info;
if(!pSelf->Graphics()->LoadPNG(&Info, aBuf, DirType))
{
str_format(aBuf, sizeof(aBuf), "failed to load skin from %s", pName);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
str_format(aBuf, sizeof(aBuf), "failed to load skin part '%s'", pName);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "skins", aBuf);
return 0;
}
@ -93,7 +94,7 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
if(g_Config.m_Debug)
{
str_format(aBuf, sizeof(aBuf), "load skin part %s", Part.m_aName);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "skins", aBuf);
}
pSelf->m_aaSkinParts[pSelf->m_ScanningPart].add(Part);
@ -102,108 +103,103 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
{
CSkins *pSelf = (CSkins *)pUser;
int l = str_length(pName);
if(l < 4 || IsDir || str_comp(pName+l-4, ".skn") != 0)
if(l < 5 || IsDir || str_comp(pName+l-5, ".json") != 0)
return 0;
CSkins *pSelf = (CSkins *)pUser;
// read file data into buffer
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;
int FileSize = (int)io_length(File);
char *pFileData = (char *)mem_alloc(FileSize+1, 1);
io_read(File, pFileData, FileSize);
pFileData[FileSize] = 0;
io_close(File);
// init
CSkin Skin = pSelf->m_DummySkin;
bool SpecialSkin = pName[0] == 'x' && pName[1] == '_';
CLineReader LineReader;
LineReader.Init(File);
while(1)
// parse json data
json_settings JsonSettings;
mem_zero(&JsonSettings, sizeof(JsonSettings));
char aError[256];
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError);
if(pJsonData == 0)
{
char *pLine = LineReader.Get();
if(!pLine)
break;
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, aBuf, aError);
mem_free(pFileData);
return 0;
}
char aBuffer[1024];
str_copy(aBuffer, pLine, sizeof(aBuffer));
char *pStr = aBuffer;
pStr = str_skip_whitespaces(pStr);
char *pVariable = pStr;
pStr = str_skip_to_whitespace(pStr);
if(!pStr[0])
continue;
pStr[0] = 0;
pStr++;
pStr = str_skip_whitespaces(pStr);
if(pStr[0] != ':' || pStr[1] != '=')
continue;
pStr += 2;
if(!pStr[0])
continue;
pStr = str_skip_whitespaces(pStr);
char *pValue = pStr;
static const char *const apParts[6] = {"body.", "tattoo.", "decoration.",
"hands.", "feet.", "eyes."};
int Part = -1;
for(int p = 0; p < NUM_SKINPARTS; p++)
// extract data
const json_value &rStart = (*pJsonData)["skin"];
if(rStart.type == json_object)
{
for(int PartIndex = 0; PartIndex < NUM_SKINPARTS; ++PartIndex)
{
if(str_comp_num(pVariable, apParts[p], str_length(apParts[p])) == 0)
Part = p;
}
if(Part < 0)
continue;
pVariable += str_length(apParts[Part]);
if(str_comp(pVariable, "filename") == 0)
{
int SkinPart = pSelf->FindSkinPart(Part, pValue, SpecialSkin);
if(SkinPart < 0)
const json_value &rPart = rStart[(const char *)ms_apSkinPartNames[PartIndex]];
if(rPart.type != json_object)
continue;
Skin.m_apParts[Part] = pSelf->GetSkinPart(Part, SkinPart);
}
else if(str_comp(pVariable, "custom_colors") == 0)
{
if(str_comp(pValue, "true") == 0)
Skin.m_aUseCustomColors[Part] = 1;
else if(str_comp(pValue, "false") == 0)
Skin.m_aUseCustomColors[Part] = 0;
}
else
{
static const char *const apComponents[4] = {"hue", "sat", "lgt", "alp"};
int Component = -1;
for(int i = 0; i < 4; i++)
// filename
const json_value &rFilename = rPart["filename"];
if(rFilename.type == json_string)
{
if(str_comp(pVariable, apComponents[i]) == 0)
Component = i;
int SkinPart = pSelf->FindSkinPart(PartIndex, (const char *)rFilename, SpecialSkin);
if(SkinPart > -1)
Skin.m_apParts[PartIndex] = pSelf->GetSkinPart(PartIndex, SkinPart);
}
if(Component < 0)
// use custom colors
bool UseCustomColors = false;
const json_value &rColour = rPart["custom_colors"];
if(rColour.type == json_string)
{
UseCustomColors = str_comp((const char *)rColour, "true") == 0;
}
Skin.m_aUseCustomColors[PartIndex] = UseCustomColors;
// color components
if(!UseCustomColors)
continue;
if(Part != SKINPART_TATTOO && Component == 3)
continue;
int OldVal = Skin.m_aPartColors[Part];
int Val = str_toint(pValue);
if(Component == 0)
Skin.m_aPartColors[Part] = (OldVal&0xFF00FFFF) | (Val << 16);
else if(Component == 1)
Skin.m_aPartColors[Part] = (OldVal&0xFFFF00FF) | (Val << 8);
else if(Component == 2)
Skin.m_aPartColors[Part] = (OldVal&0xFFFFFF00) | Val;
else if(Component == 3)
Skin.m_aPartColors[Part] = (OldVal&0x00FFFFFF) | (Val << 24);
for(int i = 0; i < NUM_COLOR_COMPONENTS; i++)
{
if(PartIndex != SKINPART_TATTOO && i == 3)
continue;
const json_value &rComponent = rPart[(const char *)ms_apColorComponents[i]];
if(rComponent.type == json_integer)
{
switch(i)
{
case 0: Skin.m_aPartColors[PartIndex] = (Skin.m_aPartColors[PartIndex]&0xFF00FFFF) | (rComponent.u.integer << 16); break;
case 1: Skin.m_aPartColors[PartIndex] = (Skin.m_aPartColors[PartIndex]&0xFFFF00FF) | (rComponent.u.integer << 8); break;
case 2: Skin.m_aPartColors[PartIndex] = (Skin.m_aPartColors[PartIndex]&0xFFFFFF00) | rComponent.u.integer; break;
case 3: Skin.m_aPartColors[PartIndex] = (Skin.m_aPartColors[PartIndex]&0x00FFFFFF) | (rComponent.u.integer << 24); break;
}
}
}
}
}
io_close(File);
// clean up
json_value_free(pJsonData);
mem_free(pFileData);
// 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-4));
if(g_Config.m_Debug)
{
str_format(aBuf, sizeof(aBuf), "load skin %s", Skin.m_aName);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "skins", aBuf);
}
pSelf->m_aSkins.add(Skin);
@ -228,7 +224,7 @@ void CSkins::OnInit()
// load skin parts
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "skins/%s", gs_apFolders[p]);
str_format(aBuf, sizeof(aBuf), "skins/%s", ms_apSkinPartNames[p]);
m_ScanningPart = p;
Storage()->ListDirectory(IStorage::TYPE_ALL, aBuf, SkinPartScan, this);

View file

@ -6,29 +6,26 @@
#include <base/tl/sorted_array.h>
#include <game/client/component.h>
enum
{
DARKEST_COLOR_LGT=61
};
enum
{
SKINPART_BODY=0,
SKINPART_TATTOO,
SKINPART_DECORATION,
SKINPART_HANDS,
SKINPART_FEET,
SKINPART_EYES,
NUM_SKINPARTS
};
class CSkins : public CComponent
{
public:
enum
{
SKINTYPE_STANDARD,
SKINTYPE_STANDARD=0,
SKINTYPE_SPECIAL,
SKINPART_BODY=0,
SKINPART_TATTOO,
SKINPART_DECORATION,
SKINPART_HANDS,
SKINPART_FEET,
SKINPART_EYES,
NUM_SKINPARTS,
DARKEST_COLOR_LGT=61,
NUM_COLOR_COMPONENTS=4
};
struct CSkinPart
@ -54,6 +51,14 @@ public:
bool operator<(const CSkin &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
};
static const char * const ms_apSkinPartNames[NUM_SKINPARTS];
static const char * const ms_apColorComponents[NUM_COLOR_COMPONENTS];
static char * const ms_apSkinVariables[NUM_SKINPARTS];
static int * const ms_apUCCVariables[NUM_SKINPARTS]; // use custom color
static int * const ms_apColorVariables[NUM_SKINPARTS];
//
void OnInit();
int Num();
@ -62,7 +67,6 @@ public:
int Find(const char *pName, bool AllowSpecialSkin);
const CSkinPart *GetSkinPart(int Part, int Index);
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;
@ -78,8 +82,4 @@ private:
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
};
extern char *const gs_apSkinVariables[NUM_SKINPARTS];
extern int *const gs_apUCCVariables[NUM_SKINPARTS]; // use custom color
extern int *const gs_apColorVariables[NUM_SKINPARTS];
#endif

View file

@ -965,7 +965,7 @@ void CGameClient::OnNewSnapshot()
IntsToStr(pInfo->m_aClan, 3, pClient->m_aClan);
pClient->m_Country = pInfo->m_Country;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
IntsToStr(pInfo->m_aaSkinPartNames[p], 6, pClient->m_aaSkinPartNames[p]);
pClient->m_aUseCustomColors[p] = pInfo->m_aUseCustomColors[p];
@ -1324,12 +1324,12 @@ void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool U
{
m_SkinInfo.m_Size = 64;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
int ID = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p], false);
if(ID < 0)
{
if(p == SKINPART_TATTOO || p == SKINPART_DECORATION)
if(p == CSkins::SKINPART_TATTOO || p == CSkins::SKINPART_DECORATION)
ID = pGameClient->m_pSkins->FindSkinPart(p, "", false);
else
ID = pGameClient->m_pSkins->FindSkinPart(p, "standard", false);
@ -1346,7 +1346,7 @@ void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool U
if(m_aUseCustomColors[p])
{
m_SkinInfo.m_aTextures[p] = pSkinPart->m_ColorTexture;
m_SkinInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(m_aSkinPartColors[p], p==SKINPART_TATTOO);
m_SkinInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(m_aSkinPartColors[p], p==CSkins::SKINPART_TATTOO);
}
else
{
@ -1361,11 +1361,11 @@ void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool U
// force team colors
if(pGameClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS)
{
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
m_RenderInfo.m_aTextures[p] = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p])->m_ColorTexture;
int ColorVal = pGameClient->m_pSkins->GetTeamColor(m_aUseCustomColors[p], m_aSkinPartColors[p], m_Team, p);
m_RenderInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(ColorVal, p==SKINPART_TATTOO);
m_RenderInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(ColorVal, p==CSkins::SKINPART_TATTOO);
}
}
}
@ -1382,7 +1382,7 @@ void CGameClient::CClientData::Reset(CGameClient *pGameClient)
m_Active = false;
m_ChatIgnore = false;
m_Friend = false;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
m_SkinPartIDs[p] = 0;
m_SkinInfo.m_aTextures[p] = pGameClient->m_pSkins->GetSkinPart(p, 0)->m_ColorTexture;
@ -1428,11 +1428,11 @@ void CGameClient::SendStartInfo()
Msg.m_pName = g_Config.m_PlayerName;
Msg.m_pClan = g_Config.m_PlayerClan;
Msg.m_Country = g_Config.m_PlayerCountry;
for(int p = 0; p < NUM_SKINPARTS; p++)
for(int p = 0; p < CSkins::NUM_SKINPARTS; p++)
{
Msg.m_apSkinPartNames[p] = gs_apSkinVariables[p];
Msg.m_aUseCustomColors[p] = *gs_apUCCVariables[p];
Msg.m_aSkinPartColors[p] = *gs_apColorVariables[p];
Msg.m_apSkinPartNames[p] = CSkins::ms_apSkinVariables[p];
Msg.m_aUseCustomColors[p] = *CSkins::ms_apUCCVariables[p];
Msg.m_aSkinPartColors[p] = *CSkins::ms_apColorVariables[p];
}
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
}

View file

@ -77,7 +77,8 @@ bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, ICon
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError);
if(pJsonData == 0)
{
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localizations", aError);
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, pFilename, aError);
mem_free(pFileData);
return false;
}

View file

@ -227,7 +227,8 @@ void CEditorImage::LoadAutoMapper()
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, aError);
if(pJsonData == 0)
{
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", aError);
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, aBuf, aError);
mem_free(pFileData);
return;
}