OpenClonk
C4PlayerControlDef Class Reference

#include <C4PlayerControl.h>

Public Types

enum  CoordinateSpace { COS_Game = 0 , COS_Viewport = 1 }
 
enum  Actions {
  CDA_None = 0 , CDA_Script , CDA_Menu , CDA_MenuOK ,
  CDA_MenuCancel , CDA_MenuLeft , CDA_MenuUp , CDA_MenuRight ,
  CDA_MenuDown , CDA_ObjectMenuTextComplete , CDA_ObjectMenuOK , CDA_ObjectMenuOKAll ,
  CDA_ObjectMenuSelect , CDA_ObjectMenuCancel , CDA_ObjectMenuLeft , CDA_ObjectMenuUp ,
  CDA_ObjectMenuRight , CDA_ObjectMenuDown , CDA_ZoomIn , CDA_ZoomOut
}
 

Public Member Functions

 C4PlayerControlDef ()
 
 ~C4PlayerControlDef ()=default
 
void CompileFunc (StdCompiler *pComp)
 
const char * GetIdentifier () const
 
const char * GetGUIName () const
 
const char * GetGUIDesc () const
 
Actions GetAction () const
 
bool IsHoldKey () const
 
C4ID GetExtraData () const
 
bool IsGlobal () const
 
int32_t GetRepeatDelay () const
 
int32_t GetInitialRepeatDelay () const
 
bool IsDefaultDisabled () const
 
CoordinateSpace GetCoordinateSpace () const
 
bool IsSendCursorPos () const
 
bool operator== (const C4PlayerControlDef &cmp) const
 
bool Execute (bool fUp, const C4KeyEventData &rKeyExtraData)
 
bool IsSyncObjectMenuControl () const
 
bool IsAsync () const
 
bool IsSync () const
 
bool IsValid () const
 

Detailed Description

Definition at line 29 of file C4PlayerControl.h.

Member Enumeration Documentation

◆ Actions

Enumerator
CDA_None 
CDA_Script 
CDA_Menu 
CDA_MenuOK 
CDA_MenuCancel 
CDA_MenuLeft 
CDA_MenuUp 
CDA_MenuRight 
CDA_MenuDown 
CDA_ObjectMenuTextComplete 
CDA_ObjectMenuOK 
CDA_ObjectMenuOKAll 
CDA_ObjectMenuSelect 
CDA_ObjectMenuCancel 
CDA_ObjectMenuLeft 
CDA_ObjectMenuUp 
CDA_ObjectMenuRight 
CDA_ObjectMenuDown 
CDA_ZoomIn 
CDA_ZoomOut 

Definition at line 37 of file C4PlayerControl.h.

38  {
39  CDA_None = 0, // do nothing
40  CDA_Script, // default: Script callback
41  CDA_Menu, // open player menu (async)
42  CDA_MenuOK, CDA_MenuCancel, CDA_MenuLeft, CDA_MenuUp, CDA_MenuRight, CDA_MenuDown, // player menu controls (async)
43  CDA_ObjectMenuTextComplete, // object menu fast-foward through text animation (async)
45  CDA_ZoomIn, CDA_ZoomOut // player viewport control (async)
46  };

◆ CoordinateSpace

Enumerator
COS_Game 
COS_Viewport 

Definition at line 32 of file C4PlayerControl.h.

33  {
34  COS_Game = 0, // game (landscape) coordinates
35  COS_Viewport = 1 // viewport (GUI) coordinates
36  };

Constructor & Destructor Documentation

◆ C4PlayerControlDef()

C4PlayerControlDef::C4PlayerControlDef ( )
inline

Definition at line 63 of file C4PlayerControl.h.

63  :
64  idControlExtraData(C4ID::None)
65  {}
static const C4ID None
Definition: C4Id.h:39

◆ ~C4PlayerControlDef()

C4PlayerControlDef::~C4PlayerControlDef ( )
default

Member Function Documentation

◆ CompileFunc()

void C4PlayerControlDef::CompileFunc ( StdCompiler pComp)

Definition at line 39 of file C4PlayerControl.cpp.

40 {
41  if (!pComp->Name("ControlDef")) { pComp->NameEnd(); pComp->excNotFound("ControlDef"); }
42  pComp->Value(mkNamingAdapt(mkParAdapt(sIdentifier, StdCompiler::RCT_Idtf), "Identifier", "None"));
43  pComp->Value(mkNamingAdapt(mkParAdapt(sGUIName, StdCompiler::RCT_All), "GUIName", ""));
44  pComp->Value(mkNamingAdapt(mkParAdapt(sGUIDesc, StdCompiler::RCT_All), "GUIDesc", ""));
45  pComp->Value(mkNamingAdapt(fGlobal, "Global", false));
46  pComp->Value(mkNamingAdapt(fIsHoldKey, "Hold", false));
47  pComp->Value(mkNamingAdapt(iRepeatDelay, "RepeatDelay", 0));
48  pComp->Value(mkNamingAdapt(iInitialRepeatDelay, "InitialRepeatDelay", 0));
49  pComp->Value(mkNamingAdapt(fDefaultDisabled, "DefaultDisabled", false));
50  pComp->Value(mkNamingAdapt(idControlExtraData, "ExtraData", C4ID::None));
51  const StdEnumEntry<CoordinateSpace> CoordSpaceNames[] =
52  {
53  { "Game", COS_Game },
54  { "Viewport", COS_Viewport },
55  { nullptr, COS_Game }
56  };
57  pComp->Value(mkNamingAdapt(mkEnumAdapt<CoordinateSpace, int32_t>(eCoordSpace, CoordSpaceNames), "CoordinateSpace", COS_Game));
58  pComp->Value(mkNamingAdapt(fSendCursorPos, "SendCursorPos", false));
59  const StdEnumEntry<Actions> ActionNames[] =
60  {
61  { "None", CDA_None },
62  { "Script", CDA_Script },
63  { "Menu", CDA_Menu },
64  { "MenuOK", CDA_MenuOK },
65  { "MenuCancel", CDA_MenuCancel },
66  { "MenuLeft", CDA_MenuLeft },
67  { "MenuUp", CDA_MenuUp },
68  { "MenuRight", CDA_MenuRight },
69  { "MenuDown", CDA_MenuDown },
70  { "ObjectMenuTextComplete", CDA_ObjectMenuTextComplete },
71  { "ObjectMenuOK", CDA_ObjectMenuOK },
72  { "ObjectMenuOKAll", CDA_ObjectMenuOKAll },
73  { "ObjectMenuSelect",CDA_ObjectMenuSelect },
74  { "ObjectMenuCancel",CDA_ObjectMenuCancel },
75  { "ObjectMenuLeft", CDA_ObjectMenuLeft },
76  { "ObjectMenuUp", CDA_ObjectMenuUp },
77  { "ObjectMenuRight", CDA_ObjectMenuRight },
78  { "ObjectMenuDown", CDA_ObjectMenuDown },
79  { "ZoomIn", CDA_ZoomIn },
80  { "ZoomOut", CDA_ZoomOut },
81  { nullptr, CDA_None }
82  };
83  pComp->Value(mkNamingAdapt(mkEnumAdapt<Actions, int32_t>(eAction, ActionNames), "Action", CDA_Script));
84  pComp->NameEnd();
85 }
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 CDA_Menu, CDA_MenuCancel, CDA_MenuDown, CDA_MenuLeft, CDA_MenuOK, CDA_MenuRight, CDA_MenuUp, CDA_None, CDA_ObjectMenuCancel, CDA_ObjectMenuDown, CDA_ObjectMenuLeft, CDA_ObjectMenuOK, CDA_ObjectMenuOKAll, CDA_ObjectMenuRight, CDA_ObjectMenuSelect, CDA_ObjectMenuTextComplete, CDA_ObjectMenuUp, CDA_Script, CDA_ZoomIn, CDA_ZoomOut, COS_Game, COS_Viewport, StdCompiler::excNotFound(), mkNamingAdapt(), mkParAdapt(), StdCompiler::Name(), StdCompiler::NameEnd(), C4ID::None, StdCompiler::RCT_All, StdCompiler::RCT_Idtf, and StdCompiler::Value().

Here is the call graph for this function:

◆ Execute()

bool C4PlayerControlDef::Execute ( bool  fUp,
const C4KeyEventData rKeyExtraData 
)

◆ GetAction()

Actions C4PlayerControlDef::GetAction ( ) const
inline

Definition at line 73 of file C4PlayerControl.h.

73 { return eAction; }

Referenced by C4PlayerControl::Execute().

Here is the caller graph for this function:

◆ GetCoordinateSpace()

CoordinateSpace C4PlayerControlDef::GetCoordinateSpace ( ) const
inline

Definition at line 80 of file C4PlayerControl.h.

80 { return eCoordSpace; }

◆ GetExtraData()

C4ID C4PlayerControlDef::GetExtraData ( ) const
inline

Definition at line 75 of file C4PlayerControl.h.

75 { return idControlExtraData; }

Referenced by C4PlayerControl::Execute().

Here is the caller graph for this function:

◆ GetGUIDesc()

const char* C4PlayerControlDef::GetGUIDesc ( ) const
inline

Definition at line 72 of file C4PlayerControl.h.

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

References StdStrBuf::getData().

Referenced by C4PlayerControlAssignment::GetGUIDesc().

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

◆ GetGUIName()

const char* C4PlayerControlDef::GetGUIName ( ) const
inline

Definition at line 71 of file C4PlayerControl.h.

71 { return sGUIName.getData(); }

References StdStrBuf::getData().

Referenced by C4PlayerControlAssignment::GetGUIName().

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

◆ GetIdentifier()

const char* C4PlayerControlDef::GetIdentifier ( ) const
inline

Definition at line 70 of file C4PlayerControl.h.

70 { return sIdentifier.getData(); }

References StdStrBuf::getData().

Here is the call graph for this function:

◆ GetInitialRepeatDelay()

int32_t C4PlayerControlDef::GetInitialRepeatDelay ( ) const
inline

Definition at line 78 of file C4PlayerControl.h.

78 { return iInitialRepeatDelay; }

Referenced by C4PlayerControl::Execute().

Here is the caller graph for this function:

◆ GetRepeatDelay()

int32_t C4PlayerControlDef::GetRepeatDelay ( ) const
inline

Definition at line 77 of file C4PlayerControl.h.

77 { return iRepeatDelay; }

Referenced by C4PlayerControl::Execute().

Here is the caller graph for this function:

◆ IsAsync()

bool C4PlayerControlDef::IsAsync ( ) const
inline

Definition at line 87 of file C4PlayerControl.h.

87 { return eAction != CDA_None && eAction != CDA_Script && !IsSyncObjectMenuControl(); } // true if to be executed directly when triggered
bool IsSyncObjectMenuControl() const

References CDA_None, CDA_Script, and IsSyncObjectMenuControl().

Here is the call graph for this function:

◆ IsDefaultDisabled()

bool C4PlayerControlDef::IsDefaultDisabled ( ) const
inline

Definition at line 79 of file C4PlayerControl.h.

79 { return fDefaultDisabled; }

Referenced by C4PlayerControl::CSync::InitDefaults().

Here is the caller graph for this function:

◆ IsGlobal()

bool C4PlayerControlDef::IsGlobal ( ) const
inline

Definition at line 76 of file C4PlayerControl.h.

76 { return fGlobal; }

◆ IsHoldKey()

bool C4PlayerControlDef::IsHoldKey ( ) const
inline

Definition at line 74 of file C4PlayerControl.h.

74 { return fIsHoldKey; }

Referenced by C4PlayerControlAssignmentSet::GetAssignmentsByKey(), and C4PlayerControlAssignmentSet::GetTriggerKeys().

Here is the caller graph for this function:

◆ IsSendCursorPos()

bool C4PlayerControlDef::IsSendCursorPos ( ) const
inline

Definition at line 81 of file C4PlayerControl.h.

81 { return fSendCursorPos; }

◆ IsSync()

bool C4PlayerControlDef::IsSync ( ) const
inline

Definition at line 88 of file C4PlayerControl.h.

88 { return eAction == CDA_Script || IsSyncObjectMenuControl(); } // true if to be executed via control queue

References CDA_Script, and IsSyncObjectMenuControl().

Referenced by C4PlayerControl::ExecuteControlPacket().

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

◆ IsSyncObjectMenuControl()

bool C4PlayerControlDef::IsSyncObjectMenuControl ( ) const
inline

Definition at line 86 of file C4PlayerControl.h.

86 { return eAction>=CDA_ObjectMenuOK && eAction<=CDA_ObjectMenuDown; }

References CDA_ObjectMenuDown, and CDA_ObjectMenuOK.

Referenced by IsAsync(), and IsSync().

Here is the caller graph for this function:

◆ IsValid()

bool C4PlayerControlDef::IsValid ( ) const
inline

Definition at line 89 of file C4PlayerControl.h.

89 { return eAction != CDA_None; }

References CDA_None.

◆ operator==()

bool C4PlayerControlDef::operator== ( const C4PlayerControlDef cmp) const

Definition at line 87 of file C4PlayerControl.cpp.

88 {
89  return sIdentifier == cmp.sIdentifier
90  && sGUIName == cmp.sGUIName
91  && sGUIDesc == cmp.sGUIDesc
92  && fGlobal == cmp.fGlobal
93  && fIsHoldKey == cmp.fIsHoldKey
94  && iRepeatDelay == cmp.iRepeatDelay
95  && iInitialRepeatDelay == cmp.iInitialRepeatDelay
96  && fDefaultDisabled == cmp.fDefaultDisabled
97  && idControlExtraData == cmp.idControlExtraData
98  && fSendCursorPos == cmp.fSendCursorPos
99  && eAction == cmp.eAction;
100 }

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