OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PlayerInfoCore Class Reference

#include <C4InfoCore.h>

Inheritance diagram for C4PlayerInfoCore:
[legend]
Collaboration diagram for C4PlayerInfoCore:
[legend]

Public Member Functions

 C4PlayerInfoCore ()
 
void Default (C4RankSystem *pRanks=nullptr)
 
void Promote (int32_t iRank, C4RankSystem &rRanks)
 
bool Load (C4Group &hGroup)
 
bool Save (C4Group &hGroup)
 
bool CheckPromotion (C4RankSystem &rRanks)
 
void CompileFunc (StdCompiler *pComp)
 

Static Public Member Functions

static DWORD GetPrefColorValue (int32_t iPrefColor)
 

Public Attributes

char PrefName [C4MaxName+1]
 
char Comment [C4MaxComment+1]
 
int32_t Rank
 
char RankName [C4MaxName+1]
 
int32_t TotalScore
 
int32_t Rounds
 
int32_t RoundsWon
 
int32_t RoundsLost
 
int32_t TotalPlayingTime
 
C4RoundResult LastRound
 
C4ValueMapData ExtraData
 
char LeagueName [C4MaxName+1]
 
StdCopyStrBuf PrefControl
 
int32_t PrefMouse
 
int32_t PrefColor
 
uint32_t PrefColorDw
 
uint32_t PrefColor2Dw
 
int32_t PrefClonkSkin
 
int32_t OldPrefControl
 
int32_t OldPrefControlStyle
 
int32_t OldPrefAutoContextMenu
 
C4ScenarioParameters Achievements
 

Detailed Description

Definition at line 79 of file C4InfoCore.h.

Constructor & Destructor Documentation

C4PlayerInfoCore::C4PlayerInfoCore ( )

Definition at line 35 of file C4InfoCore.cpp.

References Default().

36 {
37  Default();
38 }
void Default(C4RankSystem *pRanks=nullptr)
Definition: C4InfoCore.cpp:40

Here is the call graph for this function:

Member Function Documentation

bool C4PlayerInfoCore::CheckPromotion ( C4RankSystem rRanks)

Definition at line 124 of file C4InfoCore.cpp.

References C4RankSystem::Experience(), Promote(), Rank, and TotalScore.

125 {
126  if (TotalScore>=rRanks.Experience(Rank+1))
127  {
128  Promote(Rank+1,rRanks);
129  return true;
130  }
131  return false;
132 }
int32_t TotalScore
Definition: C4InfoCore.h:89
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:118
int Experience(int iRank)

Here is the call graph for this function:

void C4PlayerInfoCore::CompileFunc ( StdCompiler pComp)

Definition at line 134 of file C4InfoCore.cpp.

References Achievements, Comment, C4ValueMapData::Denumerate(), C4ValueNumbers::Denumerate(), ExtraData, StdCompiler::isDeserializer(), LastRound, LeagueName, LoadResStr(), mkNamingAdapt(), mkParAdapt(), StdCompiler::Name(), StdCompiler::NameEnd(), OldPrefAutoContextMenu, OldPrefControl, OldPrefControlStyle, PrefClonkSkin, PrefColor, PrefColor2Dw, PrefColorDw, PrefControl, PrefMouse, PrefName, Rank, RankName, Rounds, RoundsLost, RoundsWon, toC4CStr, TotalPlayingTime, TotalScore, and StdCompiler::Value().

135 {
136  C4ValueNumbers numbers;
137  pComp->Name("Player");
138  pComp->Value(mkNamingAdapt(toC4CStr(PrefName),"Name", "Neuling"));
139  pComp->Value(mkNamingAdapt(toC4CStr(Comment), "Comment", ""));
140  pComp->Value(mkNamingAdapt(Rank, "Rank", 0));
141  pComp->Value(mkNamingAdapt(toC4CStr(RankName),"RankName", LoadResStr("IDS_MSG_RANK"))); // TODO: check if this would be desirable
142  pComp->Value(mkNamingAdapt(TotalScore, "Score", 0));
143  pComp->Value(mkNamingAdapt(Rounds, "Rounds", 0));
144  pComp->Value(mkNamingAdapt(RoundsWon, "RoundsWon", 0));
145  pComp->Value(mkNamingAdapt(RoundsLost, "RoundsLost", 0));
146  pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0));
147  pComp->Value(mkNamingAdapt(mkParAdapt(ExtraData, &numbers), "ExtraData", C4ValueMapData()));
148  pComp->Value(mkNamingAdapt(numbers, "ExtraDataValues"));
149  if (pComp->isDeserializer())
150  {
151  numbers.Denumerate();
152  ExtraData.Denumerate(&numbers);
153  }
154  pComp->Value(mkNamingAdapt(toC4CStr(LeagueName),"LeagueName", ""));
155  pComp->NameEnd();
156 
157  pComp->Name("Preferences");
158  pComp->Value(mkNamingAdapt(PrefColor, "Color", 0));
159  pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu));
160  pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u));
161  pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1));
162  pComp->Value(mkNamingAdapt(OldPrefControl, "Control", 1));
163  pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0));
164  pComp->Value(mkNamingAdapt(OldPrefAutoContextMenu, "AutoContextMenu", -1)); // compiling default is -1 (if this is detected, AutoContextMenus will be defaulted by control style)
165  pComp->Value(mkNamingAdapt(PrefControl, "ControlSet", StdStrBuf()));
166  pComp->Value(mkNamingAdapt(PrefClonkSkin, "ClonkSkin", 0));
167  pComp->NameEnd();
168 
169  pComp->Value(mkNamingAdapt(LastRound, "LastRound"));
170 
171  pComp->Value(mkNamingAdapt(Achievements, "Achievements"));
172 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:104
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:105
void Denumerate()
Definition: C4Value.cpp:281
int32_t TotalPlayingTime
Definition: C4InfoCore.h:91
int32_t RoundsWon
Definition: C4InfoCore.h:90
int32_t OldPrefControl
Definition: C4InfoCore.h:103
void Denumerate(C4ValueNumbers *)
Definition: C4ValueMap.cpp:254
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:85
int32_t PrefClonkSkin
Definition: C4InfoCore.h:100
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:94
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:96
virtual bool Name(const char *szName)
Definition: StdCompiler.h:77
#define toC4CStr(szString)
Definition: StdAdaptors.h:24
int32_t PrefMouse
Definition: C4InfoCore.h:97
C4ValueMapData ExtraData
Definition: C4InfoCore.h:93
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t RoundsLost
Definition: C4InfoCore.h:90
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:86
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:88
int32_t PrefColor
Definition: C4InfoCore.h:98
void Value(const T &rStruct)
Definition: StdCompiler.h:161
uint32_t PrefColorDw
Definition: C4InfoCore.h:99
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:99
virtual bool isDeserializer()
Definition: StdCompiler.h:53
int32_t TotalScore
Definition: C4InfoCore.h:89
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458
int32_t Rounds
Definition: C4InfoCore.h:90
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:108
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:78
C4RoundResult LastRound
Definition: C4InfoCore.h:92

Here is the call graph for this function:

void C4PlayerInfoCore::Default ( C4RankSystem pRanks = nullptr)

Definition at line 40 of file C4InfoCore.cpp.

References StdStrBuf::Clear(), Comment, C4RoundResult::Default(), ExtraData, StdStrBuf::getData(), C4RankSystem::GetRankName(), LastRound, LeagueName, OldPrefAutoContextMenu, OldPrefControl, OldPrefControlStyle, PrefClonkSkin, PrefColor, PrefColor2Dw, PrefColorDw, PrefControl, PrefMouse, PrefName, Rank, RankName, C4ValueMapData::Reset(), Rounds, RoundsLost, RoundsWon, SCopy(), TotalPlayingTime, and TotalScore.

Referenced by C4PlayerInfoCore(), and C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg().

41 {
42  *Comment='\0';
43  *RankName='\0';
44  TotalScore=0;
47  *LeagueName='\0';
51  Rank=0;
52  SCopy("Neuling",PrefName);
53  if (pRanks) SCopy(pRanks->GetRankName(Rank,false).getData(),RankName);
54  else SCopy("Rang",RankName);
55  PrefClonkSkin=0;
56  PrefColor=0;
57  PrefColorDw=0xff;
58  PrefColor2Dw=0;
60  PrefMouse=1;
64  ExtraData.Reset();
65 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:104
const char * getData() const
Definition: StdBuf.h:442
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:105
int32_t TotalPlayingTime
Definition: C4InfoCore.h:91
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
int32_t RoundsWon
Definition: C4InfoCore.h:90
int32_t OldPrefControl
Definition: C4InfoCore.h:103
void Clear()
Definition: StdBuf.h:466
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:85
int32_t PrefClonkSkin
Definition: C4InfoCore.h:100
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:94
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:96
int32_t PrefMouse
Definition: C4InfoCore.h:97
C4ValueMapData ExtraData
Definition: C4InfoCore.h:93
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
int32_t RoundsLost
Definition: C4InfoCore.h:90
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:86
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:88
int32_t PrefColor
Definition: C4InfoCore.h:98
uint32_t PrefColorDw
Definition: C4InfoCore.h:99
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:99
int32_t TotalScore
Definition: C4InfoCore.h:89
int32_t Rounds
Definition: C4InfoCore.h:90
C4RoundResult LastRound
Definition: C4InfoCore.h:92

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD C4PlayerInfoCore::GetPrefColorValue ( int32_t  iPrefColor)
static

Definition at line 67 of file C4InfoCore.cpp.

Referenced by C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), Load(), C4StartupPlrPropertiesDlg::OnClrChangeLeft(), and C4StartupPlrPropertiesDlg::OnClrChangeRight().

68 {
69  DWORD valRGB[12] = { 0xFF0000E8, 0xFFF40000, 0xFF00C800, 0xFFFCF41C,
70  0xFFC48444, 0xFF784830, 0xFFA04400, 0xFFF08050,
71  0xFF848484, 0xFFFFFFFF, 0xFF0094F8, 0xFFBC00C0
72  };
73  if (Inside<int32_t>(iPrefColor, 0, 11))
74  return valRGB[iPrefColor];
75  return 0xFFAAAAAA;
76 }
uint32_t DWORD

Here is the caller graph for this function:

bool C4PlayerInfoCore::Load ( C4Group hGroup)

Definition at line 78 of file C4InfoCore.cpp.

References StdStrBuf::Append(), C4CFN_PlayerInfoCore, DirSep, StdStrBuf::getData(), C4Group::GetFullName(), GetPrefColorValue(), C4Group::LoadEntryString(), OldPrefAutoContextMenu, OldPrefControlStyle, PrefColor, PrefColor2Dw, PrefColorDw, PrefName, and C4Markup::StripMarkup().

Referenced by C4MainMenu::ActivateNewPlayer(), C4Player::Load(), C4PlayerInfo::LoadFromLocalFile(), and C4Player::Strip().

79 {
80  // New version
81  StdStrBuf Source;
82  if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,&Source))
83  {
84  // Compile
85  StdStrBuf GrpName = hGroup.GetFullName(); GrpName.Append(DirSep C4CFN_PlayerInfoCore);
86  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, GrpName.getData()))
87  return false;
88  // Pref for AutoContextMenus is still undecided: default by player's control style
89  if (OldPrefAutoContextMenu == -1)
91  // Determine true color from indexed pref color
92  if (!PrefColorDw)
94  // Validate colors
95  PrefColorDw &= 0xffffff;
96  PrefColor2Dw &= 0xffffff;
97  // Validate name
99  // Success
100  return true;
101  }
102 
103  // Old version no longer supported - sorry
104  return false;
105 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:104
const char * getData() const
Definition: StdBuf.h:442
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:105
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:85
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:67
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
#define C4CFN_PlayerInfoCore
Definition: C4Components.h:45
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
int32_t PrefColor
Definition: C4InfoCore.h:98
uint32_t PrefColorDw
Definition: C4InfoCore.h:99
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:99
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932
#define DirSep
static bool StripMarkup(char *szText)
Definition: C4Markup.cpp:113

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PlayerInfoCore::Promote ( int32_t  iRank,
C4RankSystem rRanks 
)

Definition at line 118 of file C4InfoCore.cpp.

References C4MaxName, StdStrBuf::getData(), C4RankSystem::GetRankName(), Rank, RankName, and SCopy().

Referenced by CheckPromotion().

119 {
120  Rank=iRank;
122 }
const char * getData() const
Definition: StdBuf.h:442
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:88
const unsigned int C4MaxName

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerInfoCore::Save ( C4Group hGroup)

Definition at line 107 of file C4InfoCore.cpp.

References C4Group::Add(), StdStrBuf::Append(), C4CFN_PlayerInfoCore, C4Group::Delete(), DirSep, StdStrBuf::getData(), and C4Group::GetFullName().

Referenced by C4StartupPlrPropertiesDlg::OnClosed(), C4Player::Save(), C4Player::Strip(), and C4StartupPlrSelDlg::PlayerListItem::UpdateCore().

108 {
109  StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
110  if (!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
111  return false;
112  if (!hGroup.Add(C4CFN_PlayerInfoCore,Source,false,true))
113  return false;
114  hGroup.Delete("C4Player.ocb");
115  return true;
116 }
const char * getData() const
Definition: StdBuf.h:442
bool Delete(const char *szFiles, bool fRecursive=false)
Definition: C4Group.cpp:1334
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
#define C4CFN_PlayerInfoCore
Definition: C4Components.h:45
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
#define DirSep

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

C4ScenarioParameters C4PlayerInfoCore::Achievements

Definition at line 108 of file C4InfoCore.h.

Referenced by CompileFunc(), and C4Player::GainScenarioAchievement().

char C4PlayerInfoCore::Comment[C4MaxComment+1]
C4ValueMapData C4PlayerInfoCore::ExtraData

Definition at line 93 of file C4InfoCore.h.

Referenced by CompileFunc(), and Default().

C4RoundResult C4PlayerInfoCore::LastRound
char C4PlayerInfoCore::LeagueName[C4MaxName+1]

Definition at line 94 of file C4InfoCore.h.

Referenced by CompileFunc(), and Default().

int32_t C4PlayerInfoCore::OldPrefAutoContextMenu
int32_t C4PlayerInfoCore::OldPrefControl
int32_t C4PlayerInfoCore::OldPrefControlStyle
int32_t C4PlayerInfoCore::PrefClonkSkin
uint32_t C4PlayerInfoCore::PrefColor2Dw

Definition at line 99 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), Load(), and C4PlayerInfo::LoadFromLocalFile().

int32_t C4PlayerInfoCore::PrefMouse

Definition at line 97 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), and C4Player::InitControl().

int32_t C4PlayerInfoCore::Rank

Definition at line 87 of file C4InfoCore.h.

Referenced by CheckPromotion(), CompileFunc(), Default(), and Promote().

char C4PlayerInfoCore::RankName[C4MaxName+1]

Definition at line 88 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), and Promote().

int32_t C4PlayerInfoCore::Rounds

Definition at line 90 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), and C4Player::Evaluate().

int32_t C4PlayerInfoCore::RoundsLost

Definition at line 90 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), and C4Player::Evaluate().

int32_t C4PlayerInfoCore::RoundsWon

Definition at line 90 of file C4InfoCore.h.

Referenced by CompileFunc(), Default(), and C4Player::Evaluate().

int32_t C4PlayerInfoCore::TotalPlayingTime
int32_t C4PlayerInfoCore::TotalScore

The documentation for this class was generated from the following files: