From 9ee1940ac3d15aa4c0a87b84d1c4ab8958184f63 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 3 Mar 2024 13:40:20 +0000 Subject: Add GUIListBox + GUIScrollbar tweaks --- .../src/openvic-extension/utility/UITools.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'extension/src/openvic-extension/utility/UITools.cpp') diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp index 3cc0d53..c00b64d 100644 --- a/extension/src/openvic-extension/utility/UITools.cpp +++ b/extension/src/openvic-extension/utility/UITools.cpp @@ -15,6 +15,7 @@ #include "openvic-extension/classes/GFXSpriteTexture.hpp" #include "openvic-extension/classes/GFXMaskedFlagTexture.hpp" #include "openvic-extension/classes/GFXPieChartTexture.hpp" +#include "openvic-extension/classes/GUIListBox.hpp" #include "openvic-extension/classes/GUIOverlappingElementsBox.hpp" #include "openvic-extension/classes/GUIScrollbar.hpp" #include "openvic-extension/singletons/AssetManager.hpp" @@ -485,6 +486,24 @@ static bool generate_overlapping_elements(generate_gui_args_t&& args) { return ret; } +static bool generate_listbox(generate_gui_args_t&& args) { + GUI::ListBox const& listbox = static_cast(args.element); + + const String listbox_name = std_view_to_godot_string(listbox.get_name()); + + GUIListBox* gui_listbox = nullptr; + bool ret = new_control(gui_listbox, listbox, args.name); + ERR_FAIL_NULL_V_MSG(gui_listbox, false, vformat("Failed to create GUIListBox for GUI listbox %s", listbox_name)); + + if (gui_listbox->set_gui_listbox(&listbox) != OK) { + UtilityFunctions::push_error("Error initialising GUIListBox for GUI listbox ", listbox_name); + ret = false; + } + + args.result = gui_listbox; + return ret; +} + template T> requires requires(T const& element) { { element.get_size() } -> std::same_as; @@ -513,10 +532,6 @@ static bool generate_placeholder(generate_gui_args_t&& args, Color colour) { return ret; } -static bool generate_listbox(generate_gui_args_t&& args) { - return generate_placeholder(std::move(args), { 0.0f, 0.0f, 1.0f, 0.3f }); -} - static bool generate_texteditbox(generate_gui_args_t&& args) { return generate_placeholder(std::move(args), { 0.0f, 1.0f, 0.0f, 0.3f }); } -- cgit v1.2.3-56-ga3b1