DDraceNetwork Docs
skins7.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_SKINS7_H
4#define GAME_CLIENT_COMPONENTS_SKINS7_H
5
6#include <base/color.h>
7#include <base/vmath.h>
8
10#include <engine/graphics.h>
11
15
16#include <vector>
17
18class CSkins7 : public CComponent
19{
20public:
21 enum
22 {
25
27
30 };
31
33 {
34 public:
36 char m_aName[24];
40
41 bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
42 };
43
44 class CSkin
45 {
46 public:
48 char m_aName[24];
52
53 bool operator<(const CSkin &Other) const { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
54 bool operator==(const CSkin &Other) const { return !str_comp(m_aName, Other.m_aName); }
55 };
56
59 static const char *const ms_apColorComponents[NUM_COLOR_COMPONENTS];
60
63 static int *ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; // use custom color
65
66 int Sizeof() const override { return sizeof(*this); }
67 void OnInit() override;
68
69 const std::vector<CSkin> &GetSkins() const;
70 const std::vector<CSkinPart> &GetSkinParts(int Part) const;
71 const CSkinPart *FindSkinPartOrNullptr(int Part, const char *pName, bool AllowSpecialPart) const;
72 const CSkinPart *FindDefaultSkinPart(int Part) const;
73 const CSkinPart *FindSkinPart(int Part, const char *pName, bool AllowSpecialPart) const;
74 void RandomizeSkin(int Dummy) const;
75
76 ColorRGBA GetColor(int Value, bool UseAlpha) const;
77 ColorRGBA GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const;
78
79 // returns true if everything was valid and nothing changed
80 bool ValidateSkinParts(char *apPartNames[protocol7::NUM_SKINPARTS], int *pUseCustomColors, int *pPartColors, int GameFlags) const;
81
82 bool SaveSkinfile(const char *pName, int Dummy);
83 bool RemoveSkin(const CSkin *pSkin);
84
87
88private:
90
91 std::vector<CSkinPart> m_avSkinParts[protocol7::NUM_SKINPARTS];
93 std::vector<CSkin> m_vSkins;
94
97
98 static int SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser);
99 static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
100
102 void LoadXmasHat();
103 void LoadBotDecoration();
104
105 void AddSkinFromConfigVariables(const char *pName, int Dummy);
106};
107
108#endif
Definition: component.h:20
Definition: skins7.h:33
char m_aName[24]
Definition: skins7.h:36
IGraphics::CTextureHandle m_ColorTexture
Definition: skins7.h:38
bool operator<(const CSkinPart &Other)
Definition: skins7.h:41
int m_Flags
Definition: skins7.h:35
IGraphics::CTextureHandle m_OrgTexture
Definition: skins7.h:37
ColorRGBA m_BloodColor
Definition: skins7.h:39
Definition: skins7.h:45
int m_aUseCustomColors[protocol7::NUM_SKINPARTS]
Definition: skins7.h:50
char m_aName[24]
Definition: skins7.h:48
bool operator<(const CSkin &Other) const
Definition: skins7.h:53
const CSkinPart * m_apParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:49
unsigned m_aPartColors[protocol7::NUM_SKINPARTS]
Definition: skins7.h:51
bool operator==(const CSkin &Other) const
Definition: skins7.h:54
int m_Flags
Definition: skins7.h:47
Definition: skins7.h:19
void RandomizeSkin(int Dummy) const
Definition: skins7.cpp:450
int Sizeof() const override
Definition: skins7.h:66
static char * ms_apSkinNameVariables[NUM_DUMMIES]
Definition: skins7.h:61
const std::vector< CSkin > & GetSkins() const
Definition: skins7.cpp:403
static int SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
Definition: skins7.cpp:37
const CSkinPart * FindDefaultSkinPart(int Part) const
Definition: skins7.cpp:429
static unsigned * ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:64
void AddSkinFromConfigVariables(const char *pName, int Dummy)
Definition: skins7.cpp:366
IGraphics::CTextureHandle m_BotTexture
Definition: skins7.h:96
void LoadBotDecoration()
Definition: skins7.cpp:345
void LoadXmasHat()
Definition: skins7.cpp:324
std::vector< CSkin > m_vSkins
Definition: skins7.h:93
bool ValidateSkinParts(char *apPartNames[protocol7::NUM_SKINPARTS], int *pUseCustomColors, int *pPartColors, int GameFlags) const
Definition: skins7.cpp:522
const CSkinPart * FindSkinPart(int Part, const char *pName, bool AllowSpecialPart) const
Definition: skins7.cpp:440
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
Definition: skins7.cpp:113
static const char *const ms_apColorComponents[NUM_COLOR_COMPONENTS]
Definition: skins7.h:59
IGraphics::CTextureHandle m_XmasHatTexture
Definition: skins7.h:95
IGraphics::CTextureHandle XmasHatTexture() const
Definition: skins7.h:85
void OnInit() override
Definition: skins7.cpp:233
static int * ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:63
CSkinPart m_aPlaceholderSkinParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:92
ColorRGBA GetColor(int Value, bool UseAlpha) const
Definition: skins7.cpp:489
@ SKINFLAG_SPECIAL
Definition: skins7.h:23
@ HAT_NUM
Definition: skins7.h:28
@ SKINFLAG_STANDARD
Definition: skins7.h:24
@ NUM_COLOR_COMPONENTS
Definition: skins7.h:26
@ HAT_OFFSET_SIDE
Definition: skins7.h:29
void InitPlaceholderSkinParts()
Definition: skins7.cpp:312
const std::vector< CSkinPart > & GetSkinParts(int Part) const
Definition: skins7.cpp:408
ColorRGBA GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const
Definition: skins7.cpp:494
std::vector< CSkinPart > m_avSkinParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:91
bool SaveSkinfile(const char *pName, int Dummy)
Definition: skins7.cpp:537
static const char *const ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS]
Definition: skins7.h:58
int m_ScanningPart
Definition: skins7.h:89
static char * ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:62
IGraphics::CTextureHandle BotDecorationTexture() const
Definition: skins7.h:86
const CSkinPart * FindSkinPartOrNullptr(int Part, const char *pName, bool AllowSpecialPart) const
Definition: skins7.cpp:413
bool RemoveSkin(const CSkin *pSkin)
Definition: skins7.cpp:388
static const char *const ms_apSkinPartNames[protocol7::NUM_SKINPARTS]
Definition: skins7.h:57
Definition: color.h:210
Definition: graphics.h:200
@ NUM_DUMMIES
Definition: enums.h:8
int str_comp_nocase(const char *a, const char *b)
Definition: system.cpp:2915
int str_comp(const char *a, const char *b)
Definition: system.cpp:2933
@ NUM_SKINPARTS
Definition: protocol7.h:36
Definition: skin.h:15