mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
even more boilerplate code
This commit is contained in:
parent
7792c1a6f4
commit
5c23b4125d
11 changed files with 220 additions and 72 deletions
|
|
@ -93,6 +93,16 @@ static bool getattr(lua_State* L, gui::Label* label, const std::string& attr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool getattr(lua_State* L, gui::FullCheckBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
if (attr == "checked") {
|
||||
lua_pushboolean(L, box->isChecked());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::Button* button, const std::string& attr) {
|
||||
if (button == nullptr)
|
||||
return false;
|
||||
|
|
@ -105,6 +115,16 @@ static bool setattr(lua_State* L, gui::Button* button, const std::string& attr)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::FullCheckBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
if (attr == "checked") {
|
||||
box->setChecked(lua_toboolean(L, 4));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::Label* label, const std::string& attr) {
|
||||
if (label == nullptr)
|
||||
return false;
|
||||
|
|
@ -143,6 +163,8 @@ int l_gui_getattr(lua_State* L) {
|
|||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::TrackBar*>(node), attr))
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -177,6 +199,8 @@ int l_gui_setattr(lua_State* L) {
|
|||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::TrackBar*>(node), attr))
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue