OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PlayerControl::CSync Struct Reference

#include <C4PlayerControl.h>

Classes

struct  ControlDownState
 

Public Types

typedef std::vector
< ControlDownState
DownStateVec
 
typedef std::vector< int32_t > DisableStateVec
 

Public Member Functions

const ControlDownStateGetControlDownState (int32_t iControl) const
 
int32_t GetControlDisabled (int32_t iControl) const
 
bool IsControlDisabled (int32_t iControl) const
 
void SetControlDownState (int32_t iControl, const C4KeyEventData &rDownState, int32_t iDownFrame, bool fDownByUser)
 
void SetControlMovedState (int32_t iControl, const C4KeyEventData &rMovedState, int32_t iMovedFrame)
 
void ResetControlDownState (int32_t iControl)
 
bool SetControlDisabled (int32_t iControl, int32_t iVal)
 
void InitDefaults (const C4PlayerControlDefs &ControlDefs)
 
void Clear ()
 
void CompileFunc (StdCompiler *pComp)
 
bool operator== (const CSync &cmp) const
 

Public Attributes

DownStateVec ControlDownStates
 
DisableStateVec ControlDisableStates
 

Detailed Description

Definition at line 357 of file C4PlayerControl.h.

Member Typedef Documentation

typedef std::vector<int32_t> C4PlayerControl::CSync::DisableStateVec

Definition at line 374 of file C4PlayerControl.h.

Definition at line 372 of file C4PlayerControl.h.

Member Function Documentation

void C4PlayerControl::CSync::Clear ( )

Definition at line 983 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

Referenced by C4PlayerControl::Clear().

984 {
985  ControlDownStates.clear();
986  ControlDisableStates.clear();
987 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates

Here is the caller graph for this function:

void C4PlayerControl::CSync::CompileFunc ( StdCompiler pComp)

Definition at line 989 of file C4PlayerControl.cpp.

References ControlDisableStates, ControlDownStates, mkNamingAdapt(), mkSTLContainerAdapt(), and StdCompiler::Value().

990 {
993 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
DownStateVec ControlDownStates
void Value(const T &rStruct)
Definition: StdCompiler.h:171
std::vector< int32_t > DisableStateVec
DisableStateVec ControlDisableStates
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:682
std::vector< ControlDownState > DownStateVec

Here is the call graph for this function:

int32_t C4PlayerControl::CSync::GetControlDisabled ( int32_t  iControl) const

Definition at line 920 of file C4PlayerControl.cpp.

References ControlDisableStates.

Referenced by IsControlDisabled().

921 {
922  // safe access
923  if (iControl < 0 || iControl >= int32_t(ControlDisableStates.size())) return 0;
924  return ControlDisableStates[iControl];
925 }
DisableStateVec ControlDisableStates

Here is the caller graph for this function:

const C4PlayerControl::CSync::ControlDownState * C4PlayerControl::CSync::GetControlDownState ( int32_t  iControl) const

Definition at line 913 of file C4PlayerControl.cpp.

References ControlDownStates.

Referenced by ResetControlDownState().

914 {
915  // safe access
916  if (iControl < 0 || iControl >= int32_t(ControlDownStates.size())) return nullptr;
917  return &ControlDownStates[iControl];
918 }
DownStateVec ControlDownStates

Here is the caller graph for this function:

void C4PlayerControl::CSync::InitDefaults ( const C4PlayerControlDefs ControlDefs)

Definition at line 972 of file C4PlayerControl.cpp.

References C4PlayerControlDefs::GetControlByIndex(), C4PlayerControlDef::IsDefaultDisabled(), and SetControlDisabled().

Referenced by C4PlayerControl::CompileFunc().

973 {
974  const C4PlayerControlDef *def;
975  int32_t i=0;
976  while ((def = ControlDefs.GetControlByIndex(i)))
977  {
978  if (def->IsDefaultDisabled()) SetControlDisabled(i, true);
979  ++i;
980  }
981 }
bool SetControlDisabled(int32_t iControl, int32_t iVal)
const C4PlayerControlDef * GetControlByIndex(int32_t idx) const
bool IsDefaultDisabled() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerControl::CSync::IsControlDisabled ( int32_t  iControl) const
inline

Definition at line 379 of file C4PlayerControl.h.

References GetControlDisabled().

379 { return GetControlDisabled(iControl)>0; }
int32_t GetControlDisabled(int32_t iControl) const

Here is the call graph for this function:

bool C4PlayerControl::CSync::operator== ( const CSync cmp) const

Definition at line 995 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

996 {
997  return ControlDownStates == cmp.ControlDownStates
998  && ControlDisableStates == cmp.ControlDisableStates;
999 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates
void C4PlayerControl::CSync::ResetControlDownState ( int32_t  iControl)

Definition at line 959 of file C4PlayerControl.cpp.

References C4PlayerControl::CSync::ControlDownState::DownState, GetControlDownState(), C4PlayerControl::CSync::ControlDownState::IsDown(), C4KeyEventData::iStrength, SetControlDownState(), and SetControlMovedState().

Referenced by SetControlDisabled().

960 {
961  // silently reset down state of control
962  const ControlDownState *pDownState = GetControlDownState(iControl);
963  if (pDownState && pDownState->IsDown())
964  {
965  C4KeyEventData KeyDownState = pDownState->DownState;
966  KeyDownState.iStrength = 0;
967  SetControlDownState(iControl, KeyDownState, 0, false);
968  SetControlMovedState(iControl, KeyDownState, 0);
969  }
970 }
void SetControlDownState(int32_t iControl, const C4KeyEventData &rDownState, int32_t iDownFrame, bool fDownByUser)
const ControlDownState * GetControlDownState(int32_t iControl) const
void SetControlMovedState(int32_t iControl, const C4KeyEventData &rMovedState, int32_t iMovedFrame)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PlayerControl::CSync::SetControlDisabled ( int32_t  iControl,
int32_t  iVal 
)

Definition at line 948 of file C4PlayerControl.cpp.

References ControlDisableStates, and ResetControlDownState().

Referenced by InitDefaults().

949 {
950  // disable control
951  if (iControl < 0) return false;
952  if (iControl >= int32_t(ControlDisableStates.size())) ControlDisableStates.resize(iControl+1);
953  ControlDisableStates[iControl] = iVal;
954  // if a control is disabled, its down-state is reset silently
955  ResetControlDownState(iControl);
956  return true;
957 }
void ResetControlDownState(int32_t iControl)
DisableStateVec ControlDisableStates

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PlayerControl::CSync::SetControlDownState ( int32_t  iControl,
const C4KeyEventData rDownState,
int32_t  iDownFrame,
bool  fDownByUser 
)

Definition at line 927 of file C4PlayerControl.cpp.

References ControlDownStates, C4PlayerControl::CSync::ControlDownState::DownState, C4PlayerControl::CSync::ControlDownState::fDownByUser, and C4PlayerControl::CSync::ControlDownState::iDownFrame.

Referenced by ResetControlDownState().

928 {
929  // update state
930  if (iControl < 0) return;
931  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
932  ControlDownState &rState = ControlDownStates[iControl];
933  rState.DownState = rDownState;
934  rState.iDownFrame = iDownFrame;
935  rState.fDownByUser = fDownByUser;
936 }
DownStateVec ControlDownStates

Here is the caller graph for this function:

void C4PlayerControl::CSync::SetControlMovedState ( int32_t  iControl,
const C4KeyEventData rMovedState,
int32_t  iMovedFrame 
)

Definition at line 938 of file C4PlayerControl.cpp.

References ControlDownStates, C4PlayerControl::CSync::ControlDownState::iMovedFrame, and C4PlayerControl::CSync::ControlDownState::MovedState.

Referenced by ResetControlDownState().

939 {
940  // update state
941  if (iControl < 0) return;
942  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
943  ControlDownState &rState = ControlDownStates[iControl];
944  rState.MovedState = rMovedState;
945  rState.iMovedFrame = iMovedFrame;
946 }
DownStateVec ControlDownStates

Here is the caller graph for this function:

Member Data Documentation

DisableStateVec C4PlayerControl::CSync::ControlDisableStates
DownStateVec C4PlayerControl::CSync::ControlDownStates

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