OpenClonk
C4PlayerControl::CSync Struct Reference

#include <C4PlayerControl.h>

Classes

struct  ControlDownState
 

Public Types

typedef std::vector< ControlDownStateDownStateVec
 
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 351 of file C4PlayerControl.h.

Member Typedef Documentation

◆ DisableStateVec

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

Definition at line 368 of file C4PlayerControl.h.

◆ DownStateVec

Definition at line 366 of file C4PlayerControl.h.

Member Function Documentation

◆ Clear()

void C4PlayerControl::CSync::Clear ( )

Definition at line 965 of file C4PlayerControl.cpp.

966 {
967  ControlDownStates.clear();
968  ControlDisableStates.clear();
969 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates

References ControlDisableStates, and ControlDownStates.

Referenced by C4PlayerControl::Clear().

Here is the caller graph for this function:

◆ CompileFunc()

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

Definition at line 971 of file C4PlayerControl.cpp.

972 {
975 }
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:713
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void Value(const T &rStruct)
Definition: StdCompiler.h:161
std::vector< int32_t > DisableStateVec
std::vector< ControlDownState > DownStateVec

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

Here is the call graph for this function:

◆ GetControlDisabled()

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

Definition at line 902 of file C4PlayerControl.cpp.

903 {
904  // safe access
905  if (iControl < 0 || iControl >= int32_t(ControlDisableStates.size())) return 0;
906  return ControlDisableStates[iControl];
907 }

References ControlDisableStates.

Referenced by IsControlDisabled().

Here is the caller graph for this function:

◆ GetControlDownState()

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

Definition at line 895 of file C4PlayerControl.cpp.

896 {
897  // safe access
898  if (iControl < 0 || iControl >= int32_t(ControlDownStates.size())) return nullptr;
899  return &ControlDownStates[iControl];
900 }

References ControlDownStates.

Referenced by ResetControlDownState().

Here is the caller graph for this function:

◆ InitDefaults()

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

Definition at line 954 of file C4PlayerControl.cpp.

955 {
956  const C4PlayerControlDef *def;
957  int32_t i=0;
958  while ((def = ControlDefs.GetControlByIndex(i)))
959  {
960  if (def->IsDefaultDisabled()) SetControlDisabled(i, true);
961  ++i;
962  }
963 }
bool IsDefaultDisabled() const
const C4PlayerControlDef * GetControlByIndex(int32_t idx) const
bool SetControlDisabled(int32_t iControl, int32_t iVal)

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

Referenced by C4PlayerControl::CompileFunc().

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

◆ IsControlDisabled()

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

Definition at line 373 of file C4PlayerControl.h.

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

References GetControlDisabled().

Here is the call graph for this function:

◆ operator==()

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

Definition at line 977 of file C4PlayerControl.cpp.

978 {
979  return ControlDownStates == cmp.ControlDownStates
980  && ControlDisableStates == cmp.ControlDisableStates;
981 }

References ControlDisableStates, and ControlDownStates.

◆ ResetControlDownState()

void C4PlayerControl::CSync::ResetControlDownState ( int32_t  iControl)

Definition at line 941 of file C4PlayerControl.cpp.

942 {
943  // silently reset down state of control
944  const ControlDownState *pDownState = GetControlDownState(iControl);
945  if (pDownState && pDownState->IsDown())
946  {
947  C4KeyEventData KeyDownState = pDownState->DownState;
948  KeyDownState.iStrength = 0;
949  SetControlDownState(iControl, KeyDownState, 0, false);
950  SetControlMovedState(iControl, KeyDownState, 0);
951  }
952 }
void SetControlMovedState(int32_t iControl, const C4KeyEventData &rMovedState, int32_t iMovedFrame)
void SetControlDownState(int32_t iControl, const C4KeyEventData &rDownState, int32_t iDownFrame, bool fDownByUser)
const ControlDownState * GetControlDownState(int32_t iControl) const

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

Referenced by SetControlDisabled().

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

◆ SetControlDisabled()

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

Definition at line 930 of file C4PlayerControl.cpp.

931 {
932  // disable control
933  if (iControl < 0) return false;
934  if (iControl >= int32_t(ControlDisableStates.size())) ControlDisableStates.resize(iControl+1);
935  ControlDisableStates[iControl] = iVal;
936  // if a control is disabled, its down-state is reset silently
937  ResetControlDownState(iControl);
938  return true;
939 }
void ResetControlDownState(int32_t iControl)

References ControlDisableStates, and ResetControlDownState().

Referenced by InitDefaults().

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

◆ SetControlDownState()

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

Definition at line 909 of file C4PlayerControl.cpp.

910 {
911  // update state
912  if (iControl < 0) return;
913  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
914  ControlDownState &rState = ControlDownStates[iControl];
915  rState.DownState = rDownState;
916  rState.iDownFrame = iDownFrame;
917  rState.fDownByUser = fDownByUser;
918 }

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

Referenced by ResetControlDownState().

Here is the caller graph for this function:

◆ SetControlMovedState()

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

Definition at line 920 of file C4PlayerControl.cpp.

921 {
922  // update state
923  if (iControl < 0) return;
924  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
925  ControlDownState &rState = ControlDownStates[iControl];
926  rState.MovedState = rMovedState;
927  rState.iMovedFrame = iMovedFrame;
928 }

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

Referenced by ResetControlDownState().

Here is the caller graph for this function:

Member Data Documentation

◆ ControlDisableStates

DisableStateVec C4PlayerControl::CSync::ControlDisableStates

◆ ControlDownStates

DownStateVec C4PlayerControl::CSync::ControlDownStates

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