1 /* 2 3 consvar.hpp 4 5 Console variables : i.e. values that can be adjusted at the console 6 7 */ 8 9 #ifndef _consvar_hpp 10 #define _consvar_hpp 1 11 12 #if defined( _MSC_VER ) 13 #pragma once 14 #endif 15 16 #ifndef _conssym_hpp 17 #include "conssym.hpp" 18 #endif 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* Version settings *****************************************************/ 25 26 /* Constants ***********************************************************/ 27 28 /* Macros ***************************************************************/ 29 30 /* Type definitions *****************************************************/ 31 32 // Abstract base class of console variable 33 // It's abstract because the Get/SetValue functions are pure virtual. 34 // There's a "standard" derived class defined within CONSVAR.CPP 35 // which has a direct link to a global int, and allows direct set/get 36 // For other variables (which might require additional processing), 37 // derive another class from the base and implement the Set/Get pairs 38 39 // Use single words only as symbols; the command interpreter looks 40 // for spaces 41 42 class ConsoleVariable : public ConsoleSymbol 43 { 44 public: 45 // Factory method: 46 static ConsoleVariable* MakeSimpleConsoleVariable_Int 47 ( 48 int& Value_ToUse, 49 ProjChar* pProjCh_Symbol_ToUse, 50 ProjChar* pProjCh_Description_ToUse, 51 int MinVal_New, 52 int MaxVal_New, 53 OurBool Cheat = FALSE 54 ); 55 static ConsoleVariable* MakeSimpleConsoleVariable_FixP 56 ( 57 int& Value_ToUse, 58 ProjChar* pProjCh_Symbol_ToUse, 59 ProjChar* pProjCh_Description_ToUse, 60 int MinVal_New, // fixed point value 61 int MaxVal_New, // fixed point value 62 OurBool Cheat = FALSE 63 ); 64 65 66 67 virtual int GetValue(void) const = 0; 68 virtual void SetValue(int Val_New) = 0; 69 virtual void SetValue(float Val_New) = 0; 70 71 static OurBool Process( ProjChar* pProjCh_In ); 72 // used for proccesing input text. Could decide that the user 73 // was requesting the value of a variable, or was setting a new 74 // value etc; if so, acts accordingly. 75 // return value = was any processing performed? 76 77 static void ListAllVariables(void); 78 79 static void CreateAll(void); 80 // hook to create all the console variables 81 // (to make it easy to add new ones) 82 83 protected: 84 ConsoleVariable 85 ( 86 ProjChar* pProjCh_Symbol_ToUse, 87 ProjChar* pProjCh_Description_ToUse, 88 int MinVal_New, 89 int MaxVal_New, 90 OurBool Cheat = FALSE 91 ); 92 93 private: 94 void Display(void); 95 // used by the list display and to interrogate an individual variable 96 97 void ProcessSetValue 98 ( 99 int Val_New 100 ); 101 void ProcessSetValue 102 ( 103 float Val_New 104 ); 105 // used by command processor; sets the value and outputs 106 // a message 107 108 void OutputResultOfSetValue( int OldVal ); 109 110 virtual SCString* MakeRangeString(void) = 0; 111 virtual SCString* MakeValueString(int Val) = 0; 112 113 114 // Data: 115 protected: 116 int MinVal; 117 int MaxVal; 118 119 private: 120 SCString* pSCString_Description; 121 122 static List <ConsoleVariable*> List_pConsoleVar; 123 public: 124 ~ConsoleVariable(); 125 }; // suggested naming: "ConsoleVar" 126 127 /* Exported globals *****************************************************/ 128 129 /* Function prototypes **************************************************/ 130 131 132 133 /* End of the header ****************************************************/ 134 135 136 #ifdef __cplusplus 137 }; 138 #endif 139 140 #endif 141