From 3343fe6c894f036444908d99e076b4a13e3b4ec2 Mon Sep 17 00:00:00 2001 From: Unnamed Date: Tue, 12 Feb 2019 19:03:57 +0000 Subject: [PATCH] Key.hpp: workaround SDL symbols being used with no visuals enabled I'll write a better fix later, this one currently works --- include/settings/Key.hpp | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/include/settings/Key.hpp b/include/settings/Key.hpp index 65f08251..0f23b828 100644 --- a/include/settings/Key.hpp +++ b/include/settings/Key.hpp @@ -4,6 +4,8 @@ #pragma once +#if ENABLE_VISUALS + #include #include #include @@ -140,3 +142,64 @@ protected: Key value{}; }; } // namespace settings + +#else + +#include "Settings.hpp" + +namespace settings +{ + +struct Key +{ + int mouse{ 0 }; +}; + +template <> class Variable : public VariableBase +{ +public: + ~Variable() override = default; + VariableType getType() override + { + return VariableType::KEY; + } + // Valid inputs: "Mouse1", "Mouse5", "Key 6", "Key 10", "Key 2", "Space". + void fromString(const std::string &string) override + { + } + // Variable & causes segfault with gcc optimizations + these dont even + // return anything + void operator=(const std::string &string) + { + fromString(string); + } + inline const Key &operator*() override + { + return value; + } + inline const std::string &toString() override + { + return string; + } + + inline explicit operator bool() const + { + return false; + } + + inline bool isKeyDown() const + { + return false; + } + +protected: + void setInternal(Key next) + { + fireCallbacks(next); + } + Key value{}; + std::string string{}; +}; +} // namespace settings + +#endif