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

#include <C4PlayerControl.h>

Collaboration diagram for C4PlayerControlDefs:
[legend]

Classes

struct  CInternalCons
 

Public Member Functions

void UpdateInternalCons ()
 
 C4PlayerControlDefs ()
 
 ~C4PlayerControlDefs ()
 
void Clear ()
 
void CompileFunc (StdCompiler *pComp)
 
void MergeFrom (const C4PlayerControlDefs &Src)
 
void FinalInit ()
 
const C4PlayerControlDefGetControlByIndex (int32_t idx) const
 
int32_t GetControlIndexByIdentifier (const char *szIdentifier) const
 
size_t GetCount () const
 
bool operator== (const C4PlayerControlDefs &cmp) const
 

Public Attributes

struct
C4PlayerControlDefs::CInternalCons 
InternalCons
 

Detailed Description

Definition at line 99 of file C4PlayerControl.h.

Constructor & Destructor Documentation

C4PlayerControlDefs::C4PlayerControlDefs ( )
inline

Definition at line 116 of file C4PlayerControl.h.

116 : clear_previous(false) {}
C4PlayerControlDefs::~C4PlayerControlDefs ( )
inline

Definition at line 117 of file C4PlayerControl.h.

117 {}

Member Function Documentation

void C4PlayerControlDefs::Clear ( )

Definition at line 119 of file C4PlayerControl.cpp.

References UpdateInternalCons().

Referenced by C4Game::Clear(), and C4PlayerControlFile::Clear().

120 {
121  clear_previous = false;
122  Defs.clear();
124 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PlayerControlDefs::CompileFunc ( StdCompiler pComp)

Definition at line 126 of file C4PlayerControl.cpp.

References StdCompiler::isDeserializer(), mkNamingAdapt(), mkSTLContainerAdapt(), StdCompiler::SEP_NONE, UpdateInternalCons(), and StdCompiler::Value().

127 {
128  pComp->Value(mkNamingAdapt(clear_previous, "ClearPrevious", false));
130  if (pComp->isDeserializer()) UpdateInternalCons();
131 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual bool isDeserializer()
Definition: StdCompiler.h:63
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:679

Here is the call graph for this function:

void C4PlayerControlDefs::FinalInit ( )

Definition at line 171 of file C4PlayerControl.cpp.

References C4VInt(), FormatString(), C4AulScriptEngine::RegisterGlobalConstant(), ScriptEngine, and SEqual().

Referenced by C4Game::InitGame().

172 {
173  // Assume all defs have been loaded
174  // Register scritp constants
175  for (DefVecImpl::const_iterator i = Defs.begin(); i != Defs.end(); ++i)
176  {
177  const char *szIdtf = (*i).GetIdentifier();
178  if (szIdtf && *szIdtf && !SEqual(szIdtf, "None"))
179  {
180  ::ScriptEngine.RegisterGlobalConstant(FormatString("CON_%s", szIdtf).getData(), C4VInt(i-Defs.begin()));
181  }
182  }
183 }
void RegisterGlobalConstant(const char *szName, const C4Value &rValue)
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

Here is the caller graph for this function:

const C4PlayerControlDef * C4PlayerControlDefs::GetControlByIndex ( int32_t  idx) const

Definition at line 156 of file C4PlayerControl.cpp.

Referenced by C4PlayerControlAssignmentSet::GetAssignmentsByKey(), C4PlayerControlAssignment::GetGUIDesc(), C4PlayerControlAssignment::GetGUIName(), C4PlayerControlAssignmentSet::GetTriggerKeys(), and C4PlayerControl::CSync::InitDefaults().

157 {
158  // safe index
159  if (idx<0 || idx>=int32_t(Defs.size())) return nullptr;
160  return &(Defs[idx]);
161 }

Here is the caller graph for this function:

int32_t C4PlayerControlDefs::GetControlIndexByIdentifier ( const char *  szIdentifier) const

Definition at line 163 of file C4PlayerControl.cpp.

References CON_None, and SEqual().

Referenced by MergeFrom(), C4PlayerControlAssignment::ResolveRefs(), and UpdateInternalCons().

164 {
165  for (DefVecImpl::const_iterator i = Defs.begin(); i != Defs.end(); ++i)
166  if (SEqual((*i).GetIdentifier(), szIdentifier))
167  return i-Defs.begin();
168  return CON_None;
169 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

size_t C4PlayerControlDefs::GetCount ( ) const
inline

Definition at line 127 of file C4PlayerControl.h.

127 { return Defs.size(); }
void C4PlayerControlDefs::MergeFrom ( const C4PlayerControlDefs Src)

Definition at line 133 of file C4PlayerControl.cpp.

References CON_None, GetControlIndexByIdentifier(), C4PlayerControlDef::GetIdentifier(), and UpdateInternalCons().

Referenced by C4Game::LoadAdditionalSystemGroup().

134 {
135  // Clear previous defs if specified in merge set
136  if (Src.clear_previous) Defs.clear();
137  // copy all defs from source file; overwrite defs of same name if found
138  for (DefVecImpl::const_iterator i = Src.Defs.begin(); i != Src.Defs.end(); ++i)
139  {
140  const C4PlayerControlDef &SrcDef = *i;
141  // overwrite if def of same name existed
142  int32_t iPrevIdx = GetControlIndexByIdentifier(SrcDef.GetIdentifier());
143  if (iPrevIdx != CON_None)
144  {
145  Defs[iPrevIdx] = SrcDef;
146  }
147  else
148  {
149  // new def: Append a copy
150  Defs.push_back(SrcDef);
151  }
152  }
154 }
int32_t GetControlIndexByIdentifier(const char *szIdentifier) const
const char * GetIdentifier() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerControlDefs::operator== ( const C4PlayerControlDefs cmp) const
inline

Definition at line 129 of file C4PlayerControl.h.

129 { return Defs == cmp.Defs && clear_previous == cmp.clear_previous; }
void C4PlayerControlDefs::UpdateInternalCons ( )

Definition at line 110 of file C4PlayerControl.cpp.

References C4PlayerControlDefs::CInternalCons::CON_CursorPos, C4PlayerControlDefs::CInternalCons::CON_ObjectMenuCancel, C4PlayerControlDefs::CInternalCons::CON_ObjectMenuOK, C4PlayerControlDefs::CInternalCons::CON_ObjectMenuOKAll, C4PlayerControlDefs::CInternalCons::CON_ObjectMenuSelect, GetControlIndexByIdentifier(), and InternalCons.

Referenced by Clear(), CompileFunc(), and MergeFrom().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation


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