OpenClonk
C4ScenarioParameterDef Class Reference

#include <C4ScenarioParameters.h>

Classes

struct  Option
 

Public Types

enum  ParameterType { SPDT_Enum }
 

Public Member Functions

 C4ScenarioParameterDef ()=default
 
 ~C4ScenarioParameterDef ()=default
 
const char * GetName () const
 
const char * GetDescription () const
 
const char * GetID () const
 
ParameterType GetType () const
 
int32_t GetDefault () const
 
int32_t GetLeagueValue () const
 
const OptionGetOptionByValue (int32_t val) const
 
const OptionGetOptionByIndex (size_t idx) const
 
bool IsAchievement () const
 
const char * GetAchievement () const
 
void CompileFunc (StdCompiler *pComp)
 

Detailed Description

Definition at line 24 of file C4ScenarioParameters.h.

Member Enumeration Documentation

◆ ParameterType

Enumerator
SPDT_Enum 

Definition at line 28 of file C4ScenarioParameters.h.

29  {
30  SPDT_Enum, // only one type so far
31  };

Constructor & Destructor Documentation

◆ C4ScenarioParameterDef()

C4ScenarioParameterDef::C4ScenarioParameterDef ( )
default

◆ ~C4ScenarioParameterDef()

C4ScenarioParameterDef::~C4ScenarioParameterDef ( )
default

Member Function Documentation

◆ CompileFunc()

void C4ScenarioParameterDef::CompileFunc ( StdCompiler pComp)

Definition at line 47 of file C4ScenarioParameters.cpp.

48 {
49  if (!pComp->Name("ParameterDef")) { pComp->NameEnd(); pComp->excNotFound("ParameterDef"); }
51  pComp->Value(mkNamingAdapt(mkParAdapt(Description, StdCompiler::RCT_All), "Description", StdCopyStrBuf()));
53  StdEnumEntry<ParameterType> ParTypeEntries[] =
54  {
55  { "Enumeration", SPDT_Enum },
56  { nullptr, SPDT_Enum }
57  };
58  pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(Type, ParTypeEntries), "Type", SPDT_Enum));
59  pComp->Value(mkNamingAdapt(Default, "Default", 0));
60  pComp->Value(mkNamingAdapt(LeagueValue, "LeagueValue", 0));
61  pComp->Value(mkNamingAdapt(mkParAdapt(Achievement, StdCompiler::RCT_Idtf), "Achievement", StdCopyStrBuf()));
62  pComp->Value(mkNamingAdapt(mkSTLContainerAdapt(Options, StdCompiler::SEP_NONE), "Options"));
63  pComp->NameEnd();
64 }
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:713
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
Definition: StdAdaptors.h:795
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:78
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
virtual bool Name(const char *szName)
Definition: StdCompiler.h:77

References StdCompiler::excNotFound(), mkNamingAdapt(), mkParAdapt(), mkSTLContainerAdapt(), StdCompiler::Name(), StdCompiler::NameEnd(), StdCompiler::RCT_All, StdCompiler::RCT_Idtf, StdCompiler::SEP_NONE, SPDT_Enum, and StdCompiler::Value().

Here is the call graph for this function:

◆ GetAchievement()

const char* C4ScenarioParameterDef::GetAchievement ( ) const
inline

Definition at line 69 of file C4ScenarioParameters.h.

69 { return Achievement.getData(); }
const char * getData() const
Definition: StdBuf.h:442

References StdStrBuf::getData().

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefault()

int32_t C4ScenarioParameterDef::GetDefault ( ) const
inline

Definition at line 63 of file C4ScenarioParameters.h.

63 { return Default; }

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

Here is the caller graph for this function:

◆ GetDescription()

const char* C4ScenarioParameterDef::GetDescription ( ) const
inline

Definition at line 60 of file C4ScenarioParameters.h.

60 { return Description.getData(); }

References StdStrBuf::getData().

Here is the call graph for this function:

◆ GetID()

const char* C4ScenarioParameterDef::GetID ( ) const
inline

Definition at line 61 of file C4ScenarioParameters.h.

61 { return ID.getData(); }

References StdStrBuf::getData().

Referenced by C4GameParameters::EnforceLeagueRules(), and C4ScenarioListLoader::Scenario::LoadCustomPre().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLeagueValue()

int32_t C4ScenarioParameterDef::GetLeagueValue ( ) const
inline

Definition at line 64 of file C4ScenarioParameters.h.

64 { return LeagueValue; }

Referenced by C4GameParameters::EnforceLeagueRules().

Here is the caller graph for this function:

◆ GetName()

const char* C4ScenarioParameterDef::GetName ( ) const
inline

Definition at line 59 of file C4ScenarioParameters.h.

59 { return Name.getData(); }

References StdStrBuf::getData().

Here is the call graph for this function:

◆ GetOptionByIndex()

const C4ScenarioParameterDef::Option * C4ScenarioParameterDef::GetOptionByIndex ( size_t  idx) const

Definition at line 41 of file C4ScenarioParameters.cpp.

42 {
43  if (idx >= Options.size()) return nullptr;
44  return &Options[idx];
45 }

◆ GetOptionByValue()

const C4ScenarioParameterDef::Option * C4ScenarioParameterDef::GetOptionByValue ( int32_t  val) const

Definition at line 32 of file C4ScenarioParameters.cpp.

33 {
34  // search option by value
35  for (const auto & Option : Options)
36  if (Option.Value == val)
37  return &Option;
38  return nullptr;
39 }

References C4ScenarioParameterDef::Option::Value.

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

Here is the caller graph for this function:

◆ GetType()

ParameterType C4ScenarioParameterDef::GetType ( ) const
inline

Definition at line 62 of file C4ScenarioParameters.h.

62 { return Type; }

◆ IsAchievement()

bool C4ScenarioParameterDef::IsAchievement ( ) const
inline

Definition at line 68 of file C4ScenarioParameters.h.

68 { return Achievement.getLength()>0; }
size_t getLength() const
Definition: StdBuf.h:445

References StdStrBuf::getLength().

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

Here is the call graph for this function:
Here is the caller graph for this function:

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