mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-28 23:09:32 -05:00
Reintroduce Lua conversions to BoolProperty as it doesn't derive from NumericalProperty
This commit is contained in:
@@ -43,6 +43,8 @@ public:
|
||||
using TemplateProperty<bool>::operator=;
|
||||
|
||||
protected:
|
||||
bool fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
std::string toStringConversion() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,15 @@ int BoolProperty::typeLua() const {
|
||||
return LUA_TBOOLEAN;
|
||||
}
|
||||
|
||||
bool BoolProperty::fromLuaConversion(lua_State* state, bool& success) const {
|
||||
success = (lua_isboolean(state, -1) == 1);
|
||||
return success ? (lua_toboolean(state, -1) == 1) : false;
|
||||
}
|
||||
|
||||
void BoolProperty::toLuaConversion(lua_State* state) const {
|
||||
ghoul::lua::push(state, _value);
|
||||
}
|
||||
|
||||
std::string BoolProperty::toStringConversion() const {
|
||||
return _value ? "true" : "false";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user