-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Control vector refactor. Light tweaker
- Loading branch information
Showing
9 changed files
with
122 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,61 @@ | ||
#pragma once | ||
#include <functional> | ||
#include <utility> | ||
#include <vector> | ||
#include <Corrade/Containers/Pointer.h> | ||
|
||
namespace MagnumGame { | ||
|
||
class Tweakables { | ||
public: | ||
Tweakables(); | ||
|
||
/** | ||
* @brief Named pointer for tweaking a configurable float value at runtime | ||
*/ | ||
struct TweakableValue { | ||
const char* name; | ||
float* pValue; | ||
class Tweakables { | ||
public: | ||
Tweakables(); | ||
|
||
/** | ||
* @brief Named pointer for tweaking a configurable float value at runtime | ||
*/ | ||
class TweakableValue { | ||
public: | ||
const char *name; | ||
|
||
TweakableValue(const char *name, float *value) | ||
: TweakableValue{ | ||
name, | ||
[value]() { return *value; }, | ||
[value](float v) { *value = v; } | ||
} { | ||
} | ||
|
||
TweakableValue(const char *name, | ||
std::function<float()> getter, | ||
std::function<void(float)> setter) | ||
: name(name), getter(std::move(getter)), setter(std::move(setter)) { | ||
} | ||
|
||
private: | ||
std::function<void(float)> setter; | ||
std::function<float()> getter; | ||
}; | ||
|
||
/** | ||
* @brief Group of tweakable values for tuning | ||
*/ | ||
struct DebugMode { | ||
const char *modeName; | ||
size_t currentTweakIndex = 0; | ||
std::vector<TweakableValue> tweakableValues; | ||
}; | ||
|
||
const DebugMode ¤tDebugMode() const { return _debugModes[_currentDebugModeIndex]; } | ||
DebugMode ¤tDebugMode() { return _debugModes[_currentDebugModeIndex]; } | ||
bool hasActiveDebugMode() const { return _currentDebugModeIndex > 0; } | ||
|
||
void addDebugMode(const char *modeName, size_t initialIndex, std::vector<TweakableValue> &&tweakableValues); | ||
|
||
std::string getDebugText() const; | ||
|
||
void changeDebugModeIndex(int delta); | ||
|
||
private: | ||
std::vector<DebugMode> _debugModes; | ||
int _currentDebugModeIndex = 0; | ||
}; | ||
|
||
/** | ||
* @brief Group of tweakable values for tuning | ||
*/ | ||
struct DebugMode { | ||
const char* modeName; | ||
size_t currentTweakIndex = 0; | ||
std::vector<TweakableValue> tweakableValues; | ||
}; | ||
const DebugMode& currentDebugMode() const { return _debugModes[_currentDebugModeIndex]; } | ||
DebugMode& currentDebugMode() { return _debugModes[_currentDebugModeIndex]; } | ||
bool hasActiveDebugMode() const {return _currentDebugModeIndex > 0;} | ||
|
||
void addDebugMode(const char* modeName, size_t initialIndex, std::vector<TweakableValue>&& tweakableValues); | ||
std::string getDebugText() const; | ||
|
||
void changeDebugModeIndex(int delta); | ||
|
||
private: | ||
std::vector<DebugMode> _debugModes; | ||
int _currentDebugModeIndex = 0; | ||
|
||
}; | ||
|
||
} |