mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge bfc15a2a39 into dacebf94bc
This commit is contained in:
commit
8088ea5df5
8 changed files with 436 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"
|
||||
|
|
@ -271,15 +272,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_display_value(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getDisplayValue());
|
||||
}
|
||||
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_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_smooth_speed(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushnumber(L, bar->getSmoothSpeed());
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -287,6 +327,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;
|
||||
}
|
||||
|
|
@ -315,10 +357,33 @@ 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;
|
||||
}
|
||||
|
||||
static int p_get_orientation(UINode* node, lua::State* L) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
if (bar->getOrientation() == Orientation::VERTICAL) {
|
||||
return lua::pushstring(L, "vertical");
|
||||
}
|
||||
return lua::pushstring(L, "horizontal");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void p_set_orientation(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
std::string_view name = lua::require_string(L, idx);
|
||||
if (name == "vertical") {
|
||||
bar->setOrientation(Orientation::VERTICAL);
|
||||
} else if (name == "horizontal") {
|
||||
bar->setOrientation(Orientation::HORIZONTAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int p_is_valid(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushboolean(L, box->validate());
|
||||
|
|
@ -354,6 +419,8 @@ static int p_get_text(UINode* node, lua::State* L) {
|
|||
return lua::pushwstring(L, label->getText());
|
||||
} else if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushwstring(L, box->getText());
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
return lua::pushwstring(L, bar->getText());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -684,13 +751,20 @@ static int l_gui_getattr(lua::State* L) {
|
|||
{"src", p_get_src},
|
||||
{"fallback", p_get_fallback},
|
||||
{"value", p_get_value},
|
||||
{"progress", p_get_progress},
|
||||
{"displayValue", p_get_display_value},
|
||||
{"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},
|
||||
{"bgColor", p_get_bg_color},
|
||||
|
||||
{"textColor", p_get_text_color},
|
||||
{"smooth", p_is_smooth},
|
||||
{"smoothSpeed", p_get_smooth_speed},
|
||||
{"orientation", p_get_orientation},
|
||||
{"checked", p_is_checked},
|
||||
{"page", p_get_page},
|
||||
{"back", p_get_back},
|
||||
|
|
@ -765,6 +839,8 @@ static void p_set_text(UINode* node, lua::State* L, int idx) {
|
|||
button->setText(lua::require_wstring(L, idx));
|
||||
} else if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setText(lua::require_wstring(L, idx));
|
||||
} else if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setText(lua::require_wstring(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_caret(UINode* node, lua::State* L, int idx) {
|
||||
|
|
@ -859,6 +935,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();
|
||||
|
|
@ -875,11 +953,32 @@ 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_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_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_smooth_speed(UINode* node, lua::State* L, int idx) {
|
||||
if (auto bar = dynamic_cast<ProgressBar*>(node)) {
|
||||
bar->setSmoothSpeed(lua::tonumber(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_step(UINode* node, lua::State* L, int idx) {
|
||||
|
|
@ -900,6 +999,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) {
|
||||
|
|
@ -997,7 +1098,11 @@ static int l_gui_setattr(lua::State* L) {
|
|||
{"scroll", p_set_scroll},
|
||||
{"trackWidth", p_set_track_width},
|
||||
{"trackColor", p_set_track_color},
|
||||
{"bgColor", p_set_bg_color},
|
||||
{"textColor", p_set_text_color},
|
||||
{"smooth", p_set_smooth},
|
||||
{"smoothSpeed", p_set_smooth_speed},
|
||||
{"orientation", p_set_orientation},
|
||||
{"checked", p_set_checked},
|
||||
{"page", p_set_page},
|
||||
{"inventory", p_set_inventory},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue