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

References ControlDisableStates, and ControlDownStates.

Referenced by C4PlayerControl::Clear().

968 {
969  ControlDownStates.clear();
970  ControlDisableStates.clear();
971 }
DownStateVec ControlDownStates
DisableStateVec ControlDisableStates

Here is the caller graph for this function:

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

Definition at line 973 of file C4PlayerControl.cpp.

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

974 {
977 }
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:681
std::vector< ControlDownState > DownStateVec

Here is the call graph for this function:

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

Definition at line 904 of file C4PlayerControl.cpp.

References ControlDisableStates.

Referenced by IsControlDisabled().

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

Here is the caller graph for this function:

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

Definition at line 897 of file C4PlayerControl.cpp.

References ControlDownStates.

Referenced by ResetControlDownState().

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

Here is the caller graph for this function:

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

Definition at line 956 of file C4PlayerControl.cpp.

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

Referenced by C4PlayerControl::CompileFunc().

957 {
958  const C4PlayerControlDef *def;
959  int32_t i=0;
960  while ((def = ControlDefs.GetControlByIndex(i)))
961  {
962  if (def->IsDefaultDisabled()) SetControlDisabled(i, true);
963  ++i;
964  }
965 }
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 979 of file C4PlayerControl.cpp.

References ControlDisableStates, and ControlDownStates.

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

Definition at line 943 of file C4PlayerControl.cpp.

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

Referenced by SetControlDisabled().

944 {
945  // silently reset down state of control
946  const ControlDownState *pDownState = GetControlDownState(iControl);
947  if (pDownState && pDownState->IsDown())
948  {
949  C4KeyEventData KeyDownState = pDownState->DownState;
950  KeyDownState.iStrength = 0;
951  SetControlDownState(iControl, KeyDownState, 0, false);
952  SetControlMovedState(iControl, KeyDownState, 0);
953  }
954 }
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 932 of file C4PlayerControl.cpp.

References ControlDisableStates, and ResetControlDownState().

Referenced by InitDefaults().

933 {
934  // disable control
935  if (iControl < 0) return false;
936  if (iControl >= int32_t(ControlDisableStates.size())) ControlDisableStates.resize(iControl+1);
937  ControlDisableStates[iControl] = iVal;
938  // if a control is disabled, its down-state is reset silently
939  ResetControlDownState(iControl);
940  return true;
941 }
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 911 of file C4PlayerControl.cpp.

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

Referenced by ResetControlDownState().

912 {
913  // update state
914  if (iControl < 0) return;
915  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
916  ControlDownState &rState = ControlDownStates[iControl];
917  rState.DownState = rDownState;
918  rState.iDownFrame = iDownFrame;
919  rState.fDownByUser = fDownByUser;
920 }
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 922 of file C4PlayerControl.cpp.

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

Referenced by ResetControlDownState().

923 {
924  // update state
925  if (iControl < 0) return;
926  if (iControl >= int32_t(ControlDownStates.size())) ControlDownStates.resize(iControl+1);
927  ControlDownState &rState = ControlDownStates[iControl];
928  rState.MovedState = rMovedState;
929  rState.iMovedFrame = iMovedFrame;
930 }
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: