refactor: complete 'lua' namespace use
This commit is contained in:
@@ -26,7 +26,7 @@ struct DocumentNode {
|
||||
std::shared_ptr<UINode> node;
|
||||
};
|
||||
|
||||
static DocumentNode getDocumentNode(lua_State*, const std::string& name, const std::string& nodeName) {
|
||||
static DocumentNode getDocumentNode(lua::State*, const std::string& name, const std::string& nodeName) {
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
if (doc == nullptr) {
|
||||
throw std::runtime_error("document '"+name+"' not found");
|
||||
@@ -38,31 +38,31 @@ static DocumentNode getDocumentNode(lua_State*, const std::string& name, const s
|
||||
return {doc, node};
|
||||
}
|
||||
|
||||
static DocumentNode getDocumentNode(lua_State* L, int idx=1) {
|
||||
lua_getfield(L, idx, "docname");
|
||||
lua_getfield(L, idx, "name");
|
||||
static DocumentNode getDocumentNode(lua::State* L, int idx=1) {
|
||||
lua::getfield(L, "docname", idx);
|
||||
lua::getfield(L, "name", idx);
|
||||
auto docname = lua::require_string(L, -2);
|
||||
auto name = lua::require_string(L, -1);
|
||||
auto node = getDocumentNode(L, docname, name);
|
||||
lua_pop(L, 2);
|
||||
lua::pop(L, 2);
|
||||
return node;
|
||||
}
|
||||
|
||||
static int l_menu_back(lua_State* L) {
|
||||
static int l_menu_back(lua::State* L) {
|
||||
auto node = getDocumentNode(L);
|
||||
auto menu = dynamic_cast<Menu*>(node.node.get());
|
||||
menu->back();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_menu_reset(lua_State* L) {
|
||||
static int l_menu_reset(lua::State* L) {
|
||||
auto node = getDocumentNode(L);
|
||||
auto menu = dynamic_cast<Menu*>(node.node.get());
|
||||
menu->reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_textbox_paste(lua_State* L) {
|
||||
static int l_textbox_paste(lua::State* L) {
|
||||
auto node = getDocumentNode(L);
|
||||
auto box = dynamic_cast<TextBox*>(node.node.get());
|
||||
auto text = lua::require_string(L, 2);
|
||||
@@ -70,7 +70,7 @@ static int l_textbox_paste(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_container_add(lua_State* L) {
|
||||
static int l_container_add(lua::State* L) {
|
||||
auto docnode = getDocumentNode(L);
|
||||
auto node = dynamic_cast<Container*>(docnode.node.get());
|
||||
auto xmlsrc = lua::require_string(L, 2);
|
||||
@@ -84,7 +84,7 @@ static int l_container_add(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_node_destruct(lua_State* L) {
|
||||
static int l_node_destruct(lua::State* L) {
|
||||
auto docnode = getDocumentNode(L);
|
||||
auto node = std::dynamic_pointer_cast<Container>(docnode.node);
|
||||
engine->getGUI()->postRunnable([node]() {
|
||||
@@ -96,7 +96,7 @@ static int l_node_destruct(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_container_clear(lua_State* L) {
|
||||
static int l_container_clear(lua::State* L) {
|
||||
auto node = getDocumentNode(L, 1);
|
||||
if (auto container = std::dynamic_pointer_cast<Container>(node.node)) {
|
||||
container->clear();
|
||||
@@ -104,7 +104,7 @@ static int l_container_clear(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_container_set_interval(lua_State* L) {
|
||||
static int l_container_set_interval(lua::State* L) {
|
||||
auto node = getDocumentNode(L, 1);
|
||||
auto interval = lua::tointeger(L, 2) / 1000.0f;
|
||||
if (auto container = std::dynamic_pointer_cast<Container>(node.node)) {
|
||||
@@ -115,14 +115,14 @@ static int l_container_set_interval(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_move_into(lua_State* L) {
|
||||
static int l_move_into(lua::State* L) {
|
||||
auto node = getDocumentNode(L, 1);
|
||||
auto dest = getDocumentNode(L, 2);
|
||||
UINode::moveInto(node.node, std::dynamic_pointer_cast<Container>(dest.node));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_inventory(UINode* node, lua_State* L) {
|
||||
static int p_get_inventory(UINode* node, lua::State* L) {
|
||||
if (auto inventory = dynamic_cast<InventoryView*>(node)) {
|
||||
auto inv = inventory->getInventory();
|
||||
return lua::pushinteger(L, inv ? inv->getId() : 0);
|
||||
@@ -130,35 +130,35 @@ static int p_get_inventory(UINode* node, lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_reset(UINode* node, lua_State* L) {
|
||||
static int p_get_reset(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<Menu*>(node)) {
|
||||
return lua::pushcfunction(L, l_menu_reset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_back(UINode* node, lua_State* L) {
|
||||
static int p_get_back(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<Menu*>(node)) {
|
||||
return lua::pushcfunction(L, l_menu_back);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_paste(UINode* node, lua_State* L) {
|
||||
static int p_get_paste(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushcfunction(L, l_textbox_paste);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_page(UINode* node, lua_State* L) {
|
||||
static int p_get_page(UINode* node, lua::State* L) {
|
||||
if (auto menu = dynamic_cast<Menu*>(node)) {
|
||||
return lua::pushstring(L, menu->getCurrent().name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_is_checked(UINode* node, lua_State* L) {
|
||||
static int p_is_checked(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<CheckBox*>(node)) {
|
||||
return lua::pushboolean(L, box->isChecked());
|
||||
} else if (auto box = dynamic_cast<FullCheckBox*>(node)) {
|
||||
@@ -167,70 +167,70 @@ static int p_is_checked(UINode* node, lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_value(UINode* node, lua_State* L) {
|
||||
static int p_get_value(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getValue());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_min(UINode* node, lua_State* L) {
|
||||
static int p_get_min(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getMin());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_max(UINode* node, lua_State* L) {
|
||||
static int p_get_max(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getMax());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_step(UINode* node, lua_State* L) {
|
||||
static int p_get_step(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getStep());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_track_width(UINode* node, lua_State* L) {
|
||||
static int p_get_track_width(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getTrackWidth());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_track_color(UINode* node, lua_State* L) {
|
||||
static int p_get_track_color(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushcolor_arr(L, bar->getTrackColor());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_is_valid(UINode* node, lua_State* L) {
|
||||
static int p_is_valid(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushboolean(L, box->validate());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_caret(UINode* node, lua_State* L) {
|
||||
static int p_get_caret(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushinteger(L, static_cast<integer_t>(box->getCaret()));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_placeholder(UINode* node, lua_State* L) {
|
||||
static int p_get_placeholder(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushwstring(L, box->getPlaceholder());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_text(UINode* node, lua_State* L) {
|
||||
static int p_get_text(UINode* node, lua::State* L) {
|
||||
if (auto button = dynamic_cast<Button*>(node)) {
|
||||
return lua::pushwstring(L, button->getText());
|
||||
} else if (auto label = dynamic_cast<Label*>(node)) {
|
||||
@@ -241,93 +241,93 @@ static int p_get_text(UINode* node, lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_editable(UINode* node, lua_State* L) {
|
||||
static int p_get_editable(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushboolean(L, box->isEditable());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_src(UINode* node, lua_State* L) {
|
||||
static int p_get_src(UINode* node, lua::State* L) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
return lua::pushstring(L, image->getTexture());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_add(UINode* node, lua_State* L) {
|
||||
static int p_get_add(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<Container*>(node)) {
|
||||
return lua::pushcfunction(L, lua::wrap<l_container_add>);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_destruct(UINode*, lua_State* L) {
|
||||
static int p_get_destruct(UINode*, lua::State* L) {
|
||||
return lua::pushcfunction(L, lua::wrap<l_node_destruct>);
|
||||
}
|
||||
|
||||
static int p_get_clear(UINode* node, lua_State* L) {
|
||||
static int p_get_clear(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<Container*>(node)) {
|
||||
return lua::pushcfunction(L, lua::wrap<l_container_clear>);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_set_interval(UINode* node, lua_State* L) {
|
||||
static int p_set_interval(UINode* node, lua::State* L) {
|
||||
if (dynamic_cast<Container*>(node)) {
|
||||
return lua::pushcfunction(L, lua::wrap<l_container_set_interval>);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_color(UINode* node, lua_State* L) {
|
||||
static int p_get_color(UINode* node, lua::State* L) {
|
||||
return lua::pushcolor_arr(L, node->getColor());
|
||||
}
|
||||
static int p_get_hover_color(UINode* node, lua_State* L) {
|
||||
static int p_get_hover_color(UINode* node, lua::State* L) {
|
||||
return lua::pushcolor_arr(L, node->getHoverColor());
|
||||
}
|
||||
static int p_get_pressed_color(UINode* node, lua_State* L) {
|
||||
static int p_get_pressed_color(UINode* node, lua::State* L) {
|
||||
return lua::pushcolor_arr(L, node->getPressedColor());
|
||||
}
|
||||
static int p_get_tooltip(UINode* node, lua_State* L) {
|
||||
static int p_get_tooltip(UINode* node, lua::State* L) {
|
||||
return lua::pushwstring(L, node->getTooltip());
|
||||
}
|
||||
static int p_get_tooltip_delay(UINode* node, lua_State* L) {
|
||||
static int p_get_tooltip_delay(UINode* node, lua::State* L) {
|
||||
return lua::pushnumber(L, node->getTooltipDelay());
|
||||
}
|
||||
static int p_get_pos(UINode* node, lua_State* L) {
|
||||
static int p_get_pos(UINode* node, lua::State* L) {
|
||||
return lua::pushvec2_arr(L, node->getPos());
|
||||
}
|
||||
static int p_get_wpos(UINode* node, lua_State* L) {
|
||||
static int p_get_wpos(UINode* node, lua::State* L) {
|
||||
return lua::pushvec2_arr(L, node->calcPos());
|
||||
}
|
||||
static int p_get_size(UINode* node, lua_State* L) {
|
||||
static int p_get_size(UINode* node, lua::State* L) {
|
||||
return lua::pushvec2_arr(L, node->getSize());
|
||||
}
|
||||
static int p_is_interactive(UINode* node, lua_State* L) {
|
||||
static int p_is_interactive(UINode* node, lua::State* L) {
|
||||
return lua::pushboolean(L, node->isInteractive());
|
||||
}
|
||||
static int p_is_visible(UINode* node, lua_State* L) {
|
||||
static int p_is_visible(UINode* node, lua::State* L) {
|
||||
return lua::pushboolean(L, node->isVisible());
|
||||
}
|
||||
static int p_is_enabled(UINode* node, lua_State* L) {
|
||||
static int p_is_enabled(UINode* node, lua::State* L) {
|
||||
return lua::pushboolean(L, node->isEnabled());
|
||||
}
|
||||
static int p_move_into(UINode*, lua_State* L) {
|
||||
static int p_move_into(UINode*, lua::State* L) {
|
||||
return lua::pushcfunction(L, l_move_into);
|
||||
}
|
||||
static int p_get_focused(UINode* node, lua_State* L) {
|
||||
static int p_get_focused(UINode* node, lua::State* L) {
|
||||
return lua::pushboolean(L, node->isFocused());
|
||||
}
|
||||
|
||||
static int l_gui_getattr(lua_State* L) {
|
||||
static int l_gui_getattr(lua::State* L) {
|
||||
auto docname = lua::require_string(L, 1);
|
||||
auto element = lua::require_string(L, 2);
|
||||
auto attr = lua::require_string(L, 3);
|
||||
auto docnode = getDocumentNode(L, docname, element);
|
||||
auto node = docnode.node;
|
||||
|
||||
static const std::unordered_map<std::string_view, std::function<int(UINode*,lua_State*)>> getters {
|
||||
static const std::unordered_map<std::string_view, std::function<int(UINode*,lua::State*)>> getters {
|
||||
{"color", p_get_color},
|
||||
{"hoverColor", p_get_hover_color},
|
||||
{"pressedColor", p_get_pressed_color},
|
||||
@@ -371,45 +371,45 @@ static int l_gui_getattr(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void p_set_color(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_color(UINode* node, lua::State* L, int idx) {
|
||||
node->setColor(lua::tocolor(L, idx));
|
||||
}
|
||||
static void p_set_hover_color(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_hover_color(UINode* node, lua::State* L, int idx) {
|
||||
node->setHoverColor(lua::tocolor(L, idx));
|
||||
}
|
||||
static void p_set_pressed_color(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_pressed_color(UINode* node, lua::State* L, int idx) {
|
||||
node->setPressedColor(lua::tocolor(L, idx));
|
||||
}
|
||||
static void p_set_tooltip(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_tooltip(UINode* node, lua::State* L, int idx) {
|
||||
node->setTooltip(lua::require_wstring(L, idx));
|
||||
}
|
||||
static void p_set_tooltip_delay(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_tooltip_delay(UINode* node, lua::State* L, int idx) {
|
||||
node->setTooltipDelay(lua::tonumber(L, idx));
|
||||
}
|
||||
static void p_set_pos(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_pos(UINode* node, lua::State* L, int idx) {
|
||||
node->setPos(lua::tovec2(L, idx));
|
||||
}
|
||||
static void p_set_wpos(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_wpos(UINode* node, lua::State* L, int idx) {
|
||||
node->setPos(lua::tovec2(L, idx)-node->calcPos());
|
||||
}
|
||||
static void p_set_size(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_size(UINode* node, lua::State* L, int idx) {
|
||||
node->setSize(lua::tovec2(L, idx));
|
||||
}
|
||||
static void p_set_interactive(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_interactive(UINode* node, lua::State* L, int idx) {
|
||||
node->setInteractive(lua::toboolean(L, idx));
|
||||
}
|
||||
static void p_set_visible(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_visible(UINode* node, lua::State* L, int idx) {
|
||||
node->setVisible(lua::toboolean(L, idx));
|
||||
}
|
||||
static void p_set_enabled(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_enabled(UINode* node, lua::State* L, int idx) {
|
||||
node->setEnabled(lua::toboolean(L, idx));
|
||||
}
|
||||
static void p_set_placeholder(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_placeholder(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setPlaceholder(lua::require_wstring(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_text(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_text(UINode* node, lua::State* L, int idx) {
|
||||
if (auto label = dynamic_cast<Label*>(node)) {
|
||||
label->setText(lua::require_wstring(L, idx));
|
||||
} else if (auto button = dynamic_cast<Button*>(node)) {
|
||||
@@ -418,64 +418,64 @@ static void p_set_text(UINode* node, lua_State* L, int idx) {
|
||||
box->setText(lua::require_wstring(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_caret(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_caret(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setCaret(static_cast<ptrdiff_t>(lua::tointeger(L, idx)));
|
||||
}
|
||||
}
|
||||
static void p_set_editable(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_editable(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setEditable(lua::toboolean(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_src(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_src(UINode* node, lua::State* L, int idx) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
image->setTexture(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_value(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_value(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setValue(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_min(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_min(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setMin(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_max(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_max(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setMax(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_step(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_step(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setStep(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_track_width(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_track_width(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setTrackWidth(lua::tointeger(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_track_color(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_track_color(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
bar->setTrackColor(lua::tocolor(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_checked(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_checked(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<CheckBox*>(node)) {
|
||||
box->setChecked(lua::toboolean(L, idx));
|
||||
} else if (auto box = dynamic_cast<FullCheckBox*>(node)) {
|
||||
box->setChecked(lua::toboolean(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_page(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_page(UINode* node, lua::State* L, int idx) {
|
||||
if (auto menu = dynamic_cast<Menu*>(node)) {
|
||||
menu->setPage(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_inventory(UINode* node, lua_State* L, int idx) {
|
||||
static void p_set_inventory(UINode* node, lua::State* L, int idx) {
|
||||
if (auto view = dynamic_cast<InventoryView*>(node)) {
|
||||
auto inventory = level->inventories->get(lua::tointeger(L, idx));
|
||||
if (inventory == nullptr) {
|
||||
@@ -485,7 +485,7 @@ static void p_set_inventory(UINode* node, lua_State* L, int idx) {
|
||||
}
|
||||
}
|
||||
}
|
||||
static void p_set_focused(const std::shared_ptr<UINode> &node, lua_State* L, int idx) {
|
||||
static void p_set_focused(const std::shared_ptr<UINode> &node, lua::State* L, int idx) {
|
||||
if (lua::toboolean(L, idx) && !node->isFocused()) {
|
||||
engine->getGUI()->setFocus(node);
|
||||
} else if (node->isFocused()){
|
||||
@@ -493,7 +493,7 @@ static void p_set_focused(const std::shared_ptr<UINode> &node, lua_State* L, int
|
||||
}
|
||||
}
|
||||
|
||||
static int l_gui_setattr(lua_State* L) {
|
||||
static int l_gui_setattr(lua::State* L) {
|
||||
auto docname = lua::require_string(L, 1);
|
||||
auto element = lua::require_string(L, 2);
|
||||
auto attr = lua::require_string(L, 3);
|
||||
@@ -501,7 +501,7 @@ static int l_gui_setattr(lua_State* L) {
|
||||
auto docnode = getDocumentNode(L, docname, element);
|
||||
auto node = docnode.node;
|
||||
|
||||
static const std::unordered_map<std::string_view, std::function<void(UINode*,lua_State*,int)>> setters {
|
||||
static const std::unordered_map<std::string_view, std::function<void(UINode*,lua::State*,int)>> setters {
|
||||
{"color", p_set_color},
|
||||
{"hoverColor", p_set_hover_color},
|
||||
{"pressedColor", p_set_pressed_color},
|
||||
@@ -532,7 +532,7 @@ static int l_gui_setattr(lua_State* L) {
|
||||
if (func != setters.end()) {
|
||||
func->second(node.get(), L, 4);
|
||||
}
|
||||
static const std::unordered_map<std::string_view, std::function<void(std::shared_ptr<UINode>,lua_State*,int)>> setters2 {
|
||||
static const std::unordered_map<std::string_view, std::function<void(std::shared_ptr<UINode>,lua::State*,int)>> setters2 {
|
||||
{"focused", p_set_focused},
|
||||
};
|
||||
auto func2 = setters2.find(attr);
|
||||
@@ -542,7 +542,7 @@ static int l_gui_setattr(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_gui_get_env(lua_State* L) {
|
||||
static int l_gui_get_env(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
if (doc == nullptr) {
|
||||
@@ -552,7 +552,7 @@ static int l_gui_get_env(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_gui_str(lua_State* L) {
|
||||
static int l_gui_str(lua::State* L) {
|
||||
auto text = lua::require_wstring(L, 1);
|
||||
if (!lua::isnoneornil(L, 2)) {
|
||||
auto context = lua::require_wstring(L, 2);
|
||||
@@ -563,7 +563,7 @@ static int l_gui_str(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_gui_reindex(lua_State* L) {
|
||||
static int l_gui_reindex(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
if (doc == nullptr) {
|
||||
@@ -574,7 +574,7 @@ static int l_gui_reindex(lua_State* L) {
|
||||
}
|
||||
|
||||
/// @brief gui.get_locales_info() -> table of tables
|
||||
static int l_gui_get_locales_info(lua_State* L) {
|
||||
static int l_gui_get_locales_info(lua::State* L) {
|
||||
auto& locales = langs::locales_info;
|
||||
lua::createtable(L, 0, locales.size());
|
||||
for (auto& entry : locales) {
|
||||
@@ -586,7 +586,7 @@ static int l_gui_get_locales_info(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_gui_getviewport(lua_State* L) {
|
||||
static int l_gui_getviewport(lua::State* L) {
|
||||
return lua::pushvec2_arr(L, engine->getGUI()->getContainer()->getSize());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user