Feature/globals handling (#1352)

* Cleaner handling of global state
* Prevent Lua memory corruption (closes #982)
* Initialize glfw first thing to prevent weird joystick loading bug during startup
This commit is contained in:
Alexander Bock
2020-10-21 22:30:05 +02:00
committed by GitHub
parent 1525a0490d
commit efffc25ce0
164 changed files with 1484 additions and 1390 deletions

View File

@@ -137,7 +137,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = global::fontManager.font(_fontName, _fontSize);
_font = global::fontManager->font(_fontName, _fontSize);
});
addProperty(_fontName);
@@ -145,7 +145,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
}
_fontSize.onChange([this](){
_font = global::fontManager.font(_fontName, _fontSize);
_font = global::fontManager->font(_fontName, _fontSize);
});
addProperty(_fontSize);
@@ -173,14 +173,14 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
_requestedUnit.setVisibility(properties::Property::Visibility::Hidden);
addProperty(_requestedUnit);
_font = global::fontManager.font(_fontName, _fontSize);
_font = global::fontManager->font(_fontName, _fontSize);
}
void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
ZoneScoped
const double targetDt = global::timeManager.targetDeltaTime();
const double currentDt = global::timeManager.deltaTime();
const double targetDt = global::timeManager->targetDeltaTime();
const double currentDt = global::timeManager->deltaTime();
std::pair<double, std::string> targetDeltaTime;
std::pair<double, std::string> currentDeltaTime;
if (_doSimplification) {
@@ -201,9 +201,9 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
}
}
std::string pauseText = global::timeManager.isPaused() ? " (Paused)" : "";
std::string pauseText = global::timeManager->isPaused() ? " (Paused)" : "";
if (targetDt != currentDt && !global::timeManager.isPaused()) {
if (targetDt != currentDt && !global::timeManager->isPaused()) {
// We are in the middle of a transition
RenderFont(
*_font,
@@ -232,7 +232,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
glm::vec2 DashboardItemSimulationIncrement::size() const {
ZoneScoped
double t = global::timeManager.targetDeltaTime();
double t = global::timeManager->targetDeltaTime();
std::pair<double, std::string> deltaTime;
if (_doSimplification) {
deltaTime = simplifyTime(t);