1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
typedef void (*setterptrFloat)(float);
typedef void (*setterptrInt)(int); //pour plus tard
typedef void (*setterptrUint)(uint); //pour plus tard
typedef void (*setterptrBool)(bool); //pour plus tard
typedef float (*getterptrFloat)(void);
typedef int (*getterptrInt)(void); //pour plus tard
typedef uint (*getterptrUint)(void); //pour plus tard
typedef bool (*getterptrBool)(void); //pour plus tard
class DebugMenuEntry
{
//protected :
public :
void (*setterFloat)(float);
float (*getterFloat)(void);
void (*setterInt)(int);
int (*getterInt)(void);
void (*setterUint)(uint);
uint (*getterUint)(void);
void (*setterBool)(bool);
bool (*getterBool)(void);
public :
string m_text;
virtual void Increment() = 0;
virtual void Decrement() = 0;
};
class FloatValue : public DebugMenuEntry
{
float m_Min;
float m_Max;
float m_Step;
public :
FloatValue(string _text, float _step, float _min, float _max, getterptrFloat _getter, setterptrFloat _setter)
{
m_Step = _step;
m_Min = _min;
m_Max = _max;
m_text = _text;
getterFloat = _getter;
setterFloat = _setter;
}
virtual void Increment()
{
float currentVal = (*getterFloat)();
currentVal += m_Step;
if(currentVal > m_Max)
currentVal = m_Max;
(*setterFloat)(currentVal);
}
virtual void Decrement()
{
float currentVal = (*getterFloat)();
currentVal -= m_Step;
if(currentVal < m_Min)
currentVal = m_Min;
(*setterFloat)(currentVal);
}
};
class DebugMenuManager
{
//private :
public :
uint m_uSelectedItem;
std::vector< DebugMenuEntry * > m_vEntries;
DebugMenuManager() { }
void addFloatValue(string _text, float _step, float _min, float _max, getterptrFloat _getter, setterptrFloat _setter)
{
m_vEntries.push_back( new FloatValue( _text, _step, _min, _max, _getter, _setter) );
}
void draw()
{
//draw content of m_vEntries[i].text + val getter
}
void keyboardunct(char key) //to navigate in the menu & change values
{
...
}
}; |
Partager