mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
scripting: PagesControl
This commit is contained in:
parent
93acc5ce57
commit
b3ca4b8efc
8 changed files with 95 additions and 43 deletions
|
|
@ -104,6 +104,16 @@ static bool getattr(lua_State* L, gui::FullCheckBox* box, const std::string& att
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool getattr(lua_State* L, gui::PagesControl* menu, const std::string& attr) {
|
||||
if (menu == nullptr)
|
||||
return false;
|
||||
if (attr == "page") {
|
||||
lua_pushstring(L, menu->getCurrentName().c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool getattr(lua_State* L, gui::TextBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
|
|
@ -162,6 +172,21 @@ static bool setattr(lua_State* L, gui::Label* label, const std::string& attr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::PagesControl* menu, const std::string& attr) {
|
||||
if (menu == nullptr)
|
||||
return false;
|
||||
if (attr == "page") {
|
||||
auto page = lua_tostring(L, 4);
|
||||
if (menu->has(page)) {
|
||||
menu->setPage(page);
|
||||
} else {
|
||||
menu->setPage("404");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int l_gui_getattr(lua_State* L) {
|
||||
auto docname = lua_tostring(L, 1);
|
||||
auto element = lua_tostring(L, 2);
|
||||
|
|
@ -194,6 +219,8 @@ static int l_gui_getattr(lua_State* L) {
|
|||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::PagesControl*>(node), attr))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -232,6 +259,8 @@ static int l_gui_setattr(lua_State* L) {
|
|||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::PagesControl*>(node), attr))
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue