BVB Source Codes

CRYENGINE Show SelectionVariables.h Source code

Return Download CRYENGINE: download SelectionVariables.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __SelectionVariables_h__
  4. #define __SelectionVariables_h__
  5.  
  6. #pragma once
  7.  
  8. /*
  9.    This file implements variable value and variable declaration collections.
  10.  */
  11.  
  12. class CDebugDrawContext;
  13.  
  14. typedef uint32 SelectionVariableID;
  15.  
  16. class BlockyXmlBlocks;
  17. class SelectionVariableDeclarations;
  18.  
  19. class SelectionVariables
  20. {
  21. public:
  22.         SelectionVariables();
  23.  
  24.         bool   GetVariable(const SelectionVariableID& variableID, bool* value) const;
  25.         bool   SetVariable(const SelectionVariableID& variableID, bool value);
  26.  
  27.         void   ResetChanged(bool state = false);
  28.         bool   Changed() const;
  29.  
  30.         void   Swap(SelectionVariables& other);
  31.  
  32.         void   Serialize(TSerialize ser);
  33.  
  34.         size_t GetVariablesAmount() const { return m_variables.size(); }
  35.  
  36. #if defined(CRYAISYSTEM_DEBUG)
  37.  
  38.         void DebugTrackSignalHistory(const char* signalName);
  39.  
  40.         void DebugDraw(bool history, const SelectionVariableDeclarations& declarations) const;
  41.  
  42. #endif
  43.  
  44. private:
  45.  
  46. #if defined(CRYAISYSTEM_DEBUG)
  47.  
  48.         void DebugDrawSignalHistory(CDebugDrawContext& dc, float bottomLeftX, float bottomLeftY, float lineHeight, float fontSize) const;
  49.  
  50. #endif
  51.  
  52. private:
  53.         struct Variable
  54.         {
  55.                 Variable()
  56.                         : value(false)
  57.                 {
  58.                 }
  59.  
  60.                 bool value;
  61.  
  62.                 void Serialize(TSerialize ser)
  63.                 {
  64.                         ser.Value("value", value);
  65.                 }
  66.         };
  67.  
  68.         typedef std::unordered_map<SelectionVariableID, Variable, stl::hash_uint32> Variables;
  69.         Variables m_variables;
  70.  
  71.         bool      m_changed;
  72.  
  73.         struct VariableChangeEvent
  74.         {
  75.                 VariableChangeEvent(const CTimeValue& _when, const SelectionVariableID _variableID, bool _value)
  76.                         : when(_when)
  77.                         , variableID(_variableID)
  78.                         , value(_value)
  79.                 {
  80.                 }
  81.  
  82.                 CTimeValue          when;
  83.                 SelectionVariableID variableID;
  84.                 bool                value;
  85.         };
  86.  
  87.         typedef std::deque<VariableChangeEvent> History;
  88.         History m_history;
  89.  
  90. #if defined(CRYAISYSTEM_DEBUG)
  91.  
  92.         // Debug: we track the last few received signals here.
  93.         struct DebugSignalHistoryEntry
  94.         {
  95.                 DebugSignalHistoryEntry();
  96.                 DebugSignalHistoryEntry(const char* signalName, const CTimeValue timeStamp);
  97.  
  98.                 // The name of the signal.
  99.                 string m_Name;
  100.  
  101.                 // The time index at which the signal was delivered.
  102.                 CTimeValue m_TimeStamp;
  103.         };
  104.  
  105.         typedef std::list<DebugSignalHistoryEntry> DebugSignalHistory;
  106.         DebugSignalHistory m_DebugSignalHistory;
  107.  
  108. #endif
  109. };
  110.  
  111. class SelectionVariableDeclarations
  112. {
  113. public:
  114.         struct VariableDescription
  115.         {
  116.                 VariableDescription(const char* _name)
  117.                         : name(_name)
  118.                 {
  119.                 }
  120.  
  121.                 string name;
  122.         };
  123.         typedef std::map<SelectionVariableID, VariableDescription> VariableDescriptions;
  124.  
  125.         SelectionVariableDeclarations();
  126.         bool                        LoadFromXML(const _smart_ptr<BlockyXmlBlocks>& blocks, const XmlNodeRef& rootNode, const char* scopeName, const char* fileName);
  127.  
  128.         bool                        IsDeclared(const SelectionVariableID& variableID) const;
  129.  
  130.         SelectionVariableID         GetVariableID(const char* name) const;
  131.         const VariableDescription&  GetVariableDescription(const SelectionVariableID& variableID) const;
  132.         void                        GetVariablesNames(const char** variableNamesBuffer, const size_t maxSize, size_t& actualSize) const;
  133.  
  134.         const SelectionVariables&   GetDefaults() const;
  135.         const VariableDescriptions& GetDescriptions() const;
  136.  
  137. private:
  138.         VariableDescriptions m_descriptions;
  139.         SelectionVariables   m_defaults;
  140. };
  141.  
  142. #endif
  143.  
downloadSelectionVariables.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top