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 <chrono>
17#include <vector>
18
19class CSkins7 : public CComponent
20{
21public:
22 enum
23 {
26
28
31 };
32
34 {
35 public:
37 char m_aName[24];
41
42 bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
43 };
44
45 class CSkin
46 {
47 public:
49 char m_aName[24];
53
54 bool operator<(const CSkin &Other) const { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
55 bool operator==(const CSkin &Other) const { return !str_comp(m_aName, Other.m_aName); }
56 };
57
60 static const char *const ms_apColorComponents[NUM_COLOR_COMPONENTS];
61
64 static int *ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; // use custom color
66
67 int Sizeof() const override { return sizeof(*this); }
68 void OnInit() override;
69
70 std::chrono::nanoseconds LastRefreshTime() const { return m_LastRefreshTime; }
71
72 const std::vector<CSkin> &GetSkins() const;
73 const std::vector<CSkinPart> &GetSkinParts(int Part) const;
74 const CSkinPart *FindSkinPartOrNullptr(int Part, const char *pName, bool AllowSpecialPart) const;
75 const CSkinPart *FindDefaultSkinPart(int Part) const;
76 const CSkinPart *FindSkinPart(int Part, const char *pName, bool AllowSpecialPart) const;
77 void RandomizeSkin(int Dummy) const;
78
79 ColorRGBA GetColor(int Value, bool UseAlpha) const;
80 ColorRGBA GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const;
81
82 // returns true if everything was valid and nothing changed
83 bool ValidateSkinParts(char *apPartNames[protocol7::NUM_SKINPARTS], int *pUseCustomColors, int *pPartColors, int GameFlags) const;
84
85 bool SaveSkinfile(const char *pName, int Dummy);
86 bool RemoveSkin(const CSkin *pSkin);
87
90
91private:
93 std::chrono::nanoseconds m_LastRefreshTime;
94
95 std::vector<CSkinPart> m_avSkinParts[protocol7::NUM_SKINPARTS];
97 std::vector<CSkin> m_vSkins;
98
101
102 static int SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser);
103 static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
104
106 void LoadXmasHat();
107 void LoadBotDecoration();
108
109 void AddSkinFromConfigVariables(const char *pName, int Dummy);
110};
111
112#endif
Definition: component.h:20
Definition: skins7.h:34
char m_aName[24]
Definition: skins7.h:37
IGraphics::CTextureHandle m_ColorTexture
Definition: skins7.h:39
bool operator<(const CSkinPart &Other)
Definition: skins7.h:42
int m_Flags
Definition: skins7.h:36
IGraphics::CTextureHandle m_OrgTexture
Definition: skins7.h:38
ColorRGBA m_BloodColor
Definition: skins7.h:40
Definition: skins7.h:46
int m_aUseCustomColors[protocol7::NUM_SKINPARTS]
Definition: skins7.h:51
char m_aName[24]
Definition: skins7.h:49
bool operator<(const CSkin &Other) const
Definition: skins7.h:54
const CSkinPart * m_apParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:50
unsigned m_aPartColors[protocol7::NUM_SKINPARTS]
Definition: skins7.h:52
bool operator==(const CSkin &Other) const
Definition: skins7.h:55
int m_Flags
Definition: skins7.h:48
Definition: skins7.h:20
void RandomizeSkin(int Dummy) const
Definition: skins7.cpp:452
int Sizeof() const override
Definition: skins7.h:67
static char * ms_apSkinNameVariables[NUM_DUMMIES]
Definition: skins7.h:62
const std::vector< CSkin > & GetSkins() const
Definition: skins7.cpp:405
static int SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser)
Definition: skins7.cpp:37
std::chrono::nanoseconds m_LastRefreshTime
Definition: skins7.h:93
const CSkinPart * FindDefaultSkinPart(int Part) const
Definition: skins7.cpp:431
static unsigned * ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:65
void AddSkinFromConfigVariables(const char *pName, int Dummy)
Definition: skins7.cpp:368
IGraphics::CTextureHandle m_BotTexture
Definition: skins7.h:100
void LoadBotDecoration()
Definition: skins7.cpp:347
void LoadXmasHat()
Definition: skins7.cpp:326
std::vector< CSkin > m_vSkins
Definition: skins7.h:97
bool ValidateSkinParts(char *apPartNames[protocol7::NUM_SKINPARTS], int *pUseCustomColors, int *pPartColors, int GameFlags) const
Definition: skins7.cpp:524
const CSkinPart * FindSkinPart(int Part, const char *pName, bool AllowSpecialPart) const
Definition: skins7.cpp:442
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:60
IGraphics::CTextureHandle m_XmasHatTexture
Definition: skins7.h:99
IGraphics::CTextureHandle XmasHatTexture() const
Definition: skins7.h:88
void OnInit() override
Definition: skins7.cpp:233
static int * ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:64
CSkinPart m_aPlaceholderSkinParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:96
ColorRGBA GetColor(int Value, bool UseAlpha) const
Definition: skins7.cpp:491
@ SKINFLAG_SPECIAL
Definition: skins7.h:24
@ HAT_NUM
Definition: skins7.h:29
@ SKINFLAG_STANDARD
Definition: skins7.h:25
@ NUM_COLOR_COMPONENTS
Definition: skins7.h:27
@ HAT_OFFSET_SIDE
Definition: skins7.h:30
void InitPlaceholderSkinParts()
Definition: skins7.cpp:314
const std::vector< CSkinPart > & GetSkinParts(int Part) const
Definition: skins7.cpp:410
ColorRGBA GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const
Definition: skins7.cpp:496
std::vector< CSkinPart > m_avSkinParts[protocol7::NUM_SKINPARTS]
Definition: skins7.h:95
std::chrono::nanoseconds LastRefreshTime() const
Definition: skins7.h:70
bool SaveSkinfile(const char *pName, int Dummy)
Definition: skins7.cpp:539
static const char *const ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS]
Definition: skins7.h:59
int m_ScanningPart
Definition: skins7.h:92
static char * ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]
Definition: skins7.h:63
IGraphics::CTextureHandle BotDecorationTexture() const
Definition: skins7.h:89
const CSkinPart * FindSkinPartOrNullptr(int Part, const char *pName, bool AllowSpecialPart) const
Definition: skins7.cpp:415
bool RemoveSkin(const CSkin *pSkin)
Definition: skins7.cpp:390
static const char *const ms_apSkinPartNames[protocol7::NUM_SKINPARTS]
Definition: skins7.h:58
Definition: color.h:210
Definition: graphics.h:201
@ NUM_DUMMIES
Definition: enums.h:8
int str_comp_nocase(const char *a, const char *b)
Definition: system.cpp:2956
int str_comp(const char *a, const char *b)
Definition: system.cpp:2974
@ NUM_SKINPARTS
Definition: protocol7.h:36
Definition: skin.h:15