#pragma once #include #include namespace AB_NAMESPACE { void _registerSetting(std::weak_ptr setting); template class ChatterinoSetting : public pajlada::Settings::Setting { public: ChatterinoSetting(const std::string &path) : pajlada::Settings::Setting(path) { _registerSetting(this->getData()); } ChatterinoSetting(const std::string &path, const Type &defaultValue) : pajlada::Settings::Setting(path, defaultValue) { _registerSetting(this->getData()); } template ChatterinoSetting &operator=(const T2 &newValue) { this->setValue(newValue); return *this; } ChatterinoSetting &operator=(Type &&newValue) noexcept { pajlada::Settings::Setting::operator=(newValue); return *this; } using pajlada::Settings::Setting::operator==; using pajlada::Settings::Setting::operator!=; using pajlada::Settings::Setting::operator Type; }; using BoolSetting = ChatterinoSetting; using FloatSetting = ChatterinoSetting; using DoubleSetting = ChatterinoSetting; using IntSetting = ChatterinoSetting; using StringSetting = ChatterinoSetting; using QStringSetting = ChatterinoSetting; template class EnumSetting : public ChatterinoSetting::type> { using Underlying = typename std::underlying_type::type; public: using ChatterinoSetting::ChatterinoSetting; EnumSetting(const std::string &path, const Enum &defaultValue) : ChatterinoSetting(path, Underlying(defaultValue)) { _registerSetting(this->getData()); } template EnumSetting &operator=(Enum newValue) { this->setValue(Underlying(newValue)); return *this; } operator Enum() { return Enum(this->getValue()); } Enum getEnum() { return Enum(this->getValue()); } }; } // namespace AB_NAMESPACE