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 352 of file C4PlayerControl.h.

Member Typedef Documentation

◆ DisableStateVec

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

Definition at line 369 of file C4PlayerControl.h.

◆ DownStateVec

Definition at line 367 of file C4PlayerControl.h.

Member Function Documentation

◆ Clear()

void C4PlayerControl::CSync::Clear ( )

Definition at line 965 of file C4PlayerControl.cpp.

Referenced by C4PlayerControl::Clear().

966 {
967  ControlDownStates.clear();
968  ControlDisableStates.clear();
969 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates
Here is the caller graph for this function:

◆ CompileFunc()

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

Definition at line 971 of file C4PlayerControl.cpp.

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

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

◆ GetControlDownState()

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

Definition at line 895 of file C4PlayerControl.cpp.

Referenced by C4PlayerControl::GetControlDownState().

896 {
897  // safe access
898  if (iControl < 0 || iControl >= int32_t(ControlDownStates.size())) return nullptr;
899  return &ControlDownStates[iControl];
900 }
DownStateVec ControlDownStates
Here is the caller graph for this function:

◆ InitDefaults()

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

Definition at line 954 of file C4PlayerControl.cpp.

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

Referenced by C4PlayerControl::CompileFunc().

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 SetControlDisabled(int32_t iControl, int32_t iVal)
bool IsDefaultDisabled() const
const C4PlayerControlDef * GetControlByIndex(int32_t idx) const
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 374 of file C4PlayerControl.h.

References C4PlayerControlDef::CompileFunc(), and C4PlayerControlDef::operator==().

Referenced by C4PlayerControl::IsControlDisabled().

374 { return GetControlDisabled(iControl)>0; }
int32_t GetControlDisabled(int32_t iControl) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==()

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

Definition at line 977 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

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

◆ ResetControlDownState()

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

Definition at line 941 of file C4PlayerControl.cpp.

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

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 SetControlDownState(int32_t iControl, const C4KeyEventData &rDownState, int32_t iDownFrame, bool fDownByUser)
void SetControlMovedState(int32_t iControl, const C4KeyEventData &rMovedState, int32_t iMovedFrame)
const ControlDownState * GetControlDownState(int32_t iControl) const
Here is the call graph for this function:

◆ SetControlDisabled()

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

Definition at line 930 of file C4PlayerControl.cpp.

Referenced by C4PlayerControl::SetControlDisabled().

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)
DisableStateVec ControlDisableStates
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.

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

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 }
DownStateVec ControlDownStates

◆ SetControlMovedState()

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

Definition at line 920 of file C4PlayerControl.cpp.

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

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 }
DownStateVec ControlDownStates

Member Data Documentation

◆ ControlDisableStates

DisableStateVec C4PlayerControl::CSync::ControlDisableStates

Definition at line 370 of file C4PlayerControl.h.

Referenced by operator==().

◆ ControlDownStates

DownStateVec C4PlayerControl::CSync::ControlDownStates

Definition at line 368 of file C4PlayerControl.h.

Referenced by operator==().


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