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

Member Typedef Documentation

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

Definition at line 369 of file C4PlayerControl.h.

Definition at line 367 of file C4PlayerControl.h.

Member Function Documentation

void C4PlayerControl::CSync::Clear ( )

Definition at line 965 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

Referenced by C4PlayerControl::Clear().

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

Here is the caller graph for this function:

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

Definition at line 971 of file C4PlayerControl.cpp.

References ControlDisableStates, ControlDownStates, 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:

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

Definition at line 902 of file C4PlayerControl.cpp.

References ControlDisableStates.

Referenced by IsControlDisabled().

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

Here is the caller graph for this function:

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

Definition at line 895 of file C4PlayerControl.cpp.

References ControlDownStates.

Referenced by ResetControlDownState().

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:

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

Definition at line 954 of file C4PlayerControl.cpp.

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

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

References GetControlDisabled().

374 { 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 977 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

978 {
979  return ControlDownStates == cmp.ControlDownStates
980  && ControlDisableStates == cmp.ControlDisableStates;
981 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates
void C4PlayerControl::CSync::ResetControlDownState ( int32_t  iControl)

Definition at line 941 of file C4PlayerControl.cpp.

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

Referenced by SetControlDisabled().

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)
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 930 of file C4PlayerControl.cpp.

References ControlDisableStates, and ResetControlDownState().

Referenced by InitDefaults().

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 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 909 of file C4PlayerControl.cpp.

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

Referenced by ResetControlDownState().

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

Here is the caller graph for this function:

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

Definition at line 920 of file C4PlayerControl.cpp.

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

Referenced by ResetControlDownState().

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

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: