mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 20:41:49 +00:00
xml and lua support
This commit is contained in:
parent
a0e1d4acfe
commit
d04fb4f886
2 changed files with 129 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "graphics/ui/elements/InventoryView.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
#include "graphics/ui/elements/Panel.hpp"
|
||||
#include "graphics/ui/elements/ProgressBar.hpp"
|
||||
#include "graphics/ui/elements/TextBox.hpp"
|
||||
#include "graphics/ui/elements/TrackBar.hpp"
|
||||
#include "graphics/ui/elements/InlineFrame.hpp"
|
||||
|
|
@ -263,15 +264,54 @@ static int p_is_checked(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());
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getValue());
|
||||
} else if (auto box = dynamic_cast<SelectBox*>(node)) {
|
||||
return lua::pushstring(L, box->getSelected().value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_progress(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getProgress());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_bar_color(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushcolor(L, bar->getBarColor());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_bg_color(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushcolor(L, bar->getBgColor());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_text_format(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushstring(L, bar->getTextFormat());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_is_smooth(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushboolean(L, bar->isSmooth());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_min(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getMin());
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getMin());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -279,6 +319,8 @@ static int p_get_min(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());
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getMax());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -307,6 +349,8 @@ static int p_get_track_color(UINode* node, lua::State* L) {
|
|||
static int p_get_text_color(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushcolor(L, box->getTextColor());
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushcolor(L, bar->getTextColor());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -676,12 +720,18 @@ static int l_gui_getattr(lua::State* L) {
|
|||
{"src", p_get_src},
|
||||
{"fallback", p_get_fallback},
|
||||
{"value", p_get_value},
|
||||
{"progress", p_get_progress},
|
||||
{"min", p_get_min},
|
||||
{"max", p_get_max},
|
||||
{"step", p_get_step},
|
||||
{"scroll", p_get_scroll},
|
||||
{"trackWidth", p_get_track_width},
|
||||
{"trackColor", p_get_track_color},
|
||||
{"barColor", p_get_bar_color},
|
||||
{"bgColor", p_get_bg_color},
|
||||
{"textColor", p_get_text_color},
|
||||
{"textFormat", p_get_text_format},
|
||||
{"smooth", p_is_smooth},
|
||||
{"textColor", p_get_text_color},
|
||||
{"checked", p_is_checked},
|
||||
{"page", p_get_page},
|
||||
|
|
@ -851,6 +901,8 @@ static void p_set_zindex(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));
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setValue(lua::tonumber(L, idx));
|
||||
} else if (auto selectbox = dynamic_cast<SelectBox*>(node)) {
|
||||
auto value = lua::require_lstring(L, idx);
|
||||
const auto& options = selectbox->getOptions();
|
||||
|
|
@ -867,11 +919,39 @@ static void p_set_value(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));
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setMin(lua::tonumber(L, 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));
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setMax(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
|
||||
static void p_set_bar_color(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setBarColor(lua::tocolor(L, idx));
|
||||
}
|
||||
}
|
||||
|
||||
static void p_set_bg_color(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setBgColor(lua::tocolor(L, idx));
|
||||
}
|
||||
}
|
||||
|
||||
static void p_set_text_format(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setTextFormat(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
|
||||
static void p_set_smooth(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setSmooth(lua::toboolean(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_step(UINode* node, lua::State* L, int idx) {
|
||||
|
|
@ -892,6 +972,8 @@ static void p_set_track_color(UINode* node, lua::State* L, int idx) {
|
|||
static void p_set_text_color(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setTextColor(lua::tocolor(L, idx));
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setTextColor(lua::tocolor(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_checked(UINode* node, lua::State* L, int idx) {
|
||||
|
|
@ -989,7 +1071,11 @@ static int l_gui_setattr(lua::State* L) {
|
|||
{"scroll", p_set_scroll},
|
||||
{"trackWidth", p_set_track_width},
|
||||
{"trackColor", p_set_track_color},
|
||||
{"barColor", p_set_bar_color},
|
||||
{"bgColor", p_set_bg_color},
|
||||
{"textColor", p_set_text_color},
|
||||
{"textFormat", p_set_text_format},
|
||||
{"smooth", p_set_smooth},
|
||||
{"checked", p_set_checked},
|
||||
{"page", p_set_page},
|
||||
{"inventory", p_set_inventory},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue