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 80 of file C4InfoCore.h.

Constructor & Destructor Documentation

C4PlayerInfoCore::C4PlayerInfoCore ( )

Definition at line 38 of file C4InfoCore.cpp.

References Default().

39 {
40  Default();
41 }
void Default(C4RankSystem *pRanks=nullptr)
Definition: C4InfoCore.cpp:43

Here is the call graph for this function:

Member Function Documentation

bool C4PlayerInfoCore::CheckPromotion ( C4RankSystem rRanks)

Definition at line 127 of file C4InfoCore.cpp.

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

128 {
129  if (TotalScore>=rRanks.Experience(Rank+1))
130  {
131  Promote(Rank+1,rRanks);
132  return true;
133  }
134  return false;
135 }
int32_t TotalScore
Definition: C4InfoCore.h:90
void Promote(int32_t iRank, C4RankSystem &rRanks)
Definition: C4InfoCore.cpp:121
int Experience(int iRank)

Here is the call graph for this function:

void C4PlayerInfoCore::CompileFunc ( StdCompiler pComp)

Definition at line 137 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().

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

Here is the call graph for this function:

void C4PlayerInfoCore::Default ( C4RankSystem pRanks = nullptr)

Definition at line 43 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().

44 {
45  *Comment='\0';
46  *RankName='\0';
47  TotalScore=0;
50  *LeagueName='\0';
54  Rank=0;
55  SCopy("Neuling",PrefName);
56  if (pRanks) SCopy(pRanks->GetRankName(Rank,false).getData(),RankName);
57  else SCopy("Rang",RankName);
58  PrefClonkSkin=0;
59  PrefColor=0;
60  PrefColorDw=0xff;
61  PrefColor2Dw=0;
63  PrefMouse=1;
67  ExtraData.Reset();
68 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
const char * getData() const
Definition: StdBuf.h:450
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
int32_t RoundsWon
Definition: C4InfoCore.h:91
int32_t OldPrefControl
Definition: C4InfoCore.h:104
void Clear()
Definition: StdBuf.h:474
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
int32_t PrefClonkSkin
Definition: C4InfoCore.h:101
char LeagueName[C4MaxName+1]
Definition: C4InfoCore.h:95
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:97
int32_t PrefMouse
Definition: C4InfoCore.h:98
C4ValueMapData ExtraData
Definition: C4InfoCore.h:94
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
int32_t RoundsLost
Definition: C4InfoCore.h:91
char Comment[C4MaxComment+1]
Definition: C4InfoCore.h:87
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
int32_t PrefColor
Definition: C4InfoCore.h:99
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
int32_t TotalScore
Definition: C4InfoCore.h:90
int32_t Rounds
Definition: C4InfoCore.h:91
C4RoundResult LastRound
Definition: C4InfoCore.h:93

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 70 of file C4InfoCore.cpp.

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

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

Here is the caller graph for this function:

bool C4PlayerInfoCore::Load ( C4Group hGroup)

Definition at line 81 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().

82 {
83  // New version
84  StdStrBuf Source;
85  if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,&Source))
86  {
87  // Compile
88  StdStrBuf GrpName = hGroup.GetFullName(); GrpName.Append(DirSep C4CFN_PlayerInfoCore);
89  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, GrpName.getData()))
90  return false;
91  // Pref for AutoContextMenus is still undecided: default by player's control style
92  if (OldPrefAutoContextMenu == -1)
94  // Determine true color from indexed pref color
95  if (!PrefColorDw)
97  // Validate colors
98  PrefColorDw &= 0xffffff;
99  PrefColor2Dw &= 0xffffff;
100  // Validate name
102  // Success
103  return true;
104  }
105 
106  // Old version no longer supported - sorry
107  return false;
108 }
int32_t OldPrefControlStyle
Definition: C4InfoCore.h:105
const char * getData() const
Definition: StdBuf.h:450
int32_t OldPrefAutoContextMenu
Definition: C4InfoCore.h:106
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
static DWORD GetPrefColorValue(int32_t iPrefColor)
Definition: C4InfoCore.cpp:70
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:527
int32_t PrefColor
Definition: C4InfoCore.h:99
uint32_t PrefColorDw
Definition: C4InfoCore.h:100
uint32_t PrefColor2Dw
Definition: C4InfoCore.h:100
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 121 of file C4InfoCore.cpp.

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

Referenced by CheckPromotion().

122 {
123  Rank=iRank;
125 }
const char * getData() const
Definition: StdBuf.h:450
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
char RankName[C4MaxName+1]
Definition: C4InfoCore.h:89
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 110 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().

111 {
112  StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
113  if (!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
114  return false;
115  if (!hGroup.Add(C4CFN_PlayerInfoCore,Source,false,true))
116  return false;
117  hGroup.Delete("C4Player.ocb");
118  return true;
119 }
const char * getData() const
Definition: StdBuf.h:450
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:527
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 109 of file C4InfoCore.h.

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

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

Definition at line 94 of file C4InfoCore.h.

Referenced by CompileFunc(), and Default().

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

Definition at line 95 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 100 of file C4InfoCore.h.

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

int32_t C4PlayerInfoCore::PrefMouse

Definition at line 98 of file C4InfoCore.h.

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

int32_t C4PlayerInfoCore::Rank

Definition at line 88 of file C4InfoCore.h.

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

char C4PlayerInfoCore::RankName[C4MaxName+1]

Definition at line 89 of file C4InfoCore.h.

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

int32_t C4PlayerInfoCore::Rounds

Definition at line 91 of file C4InfoCore.h.

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

int32_t C4PlayerInfoCore::RoundsLost

Definition at line 91 of file C4InfoCore.h.

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

int32_t C4PlayerInfoCore::RoundsWon

Definition at line 91 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: