diff options
author | hop311 <hop3114@gmail.com> | 2024-02-02 21:19:21 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-02-19 20:17:31 +0100 |
commit | 1455861632cd50f48f6e8ef8c50004087eff36f1 (patch) | |
tree | 5ce200d70f5f12d76dfd489ed06a6bb88204fd1c /extension | |
parent | 576986af57db806af284bbc05a799e72f113f35c (diff) |
Basic Nation Management Screen frameworknation-management-screens
Diffstat (limited to 'extension')
9 files changed, 130 insertions, 68 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation -Subproject 068c13ede817d17df599ca3481261bf17ed9560 +Subproject 5216e893ebc5253b123bbf15b7509745d38f5a8 diff --git a/extension/src/openvic-extension/classes/GFXIconTexture.cpp b/extension/src/openvic-extension/classes/GFXIconTexture.cpp index 5d29c07..99df7e4 100644 --- a/extension/src/openvic-extension/classes/GFXIconTexture.cpp +++ b/extension/src/openvic-extension/classes/GFXIconTexture.cpp @@ -3,7 +3,6 @@ #include <godot_cpp/variant/utility_functions.hpp> #include "openvic-extension/singletons/AssetManager.hpp" -#include "openvic-extension/singletons/GameSingleton.hpp" #include "openvic-extension/utility/ClassBindings.hpp" #include "openvic-extension/utility/UITools.hpp" #include "openvic-extension/utility/Utilities.hpp" @@ -11,7 +10,6 @@ using namespace godot; using namespace OpenVic; -using OpenVic::Utilities::godot_to_std_string; using OpenVic::Utilities::std_view_to_godot_string; using OpenVic::Utilities::std_view_to_godot_string_name; diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp index c9a2a72..f4c7851 100644 --- a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp +++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp @@ -1,16 +1,14 @@ #include "GFXPieChartTexture.hpp" -#include "openvic-extension/singletons/AssetManager.hpp" -#include "openvic-extension/singletons/GameSingleton.hpp" +#include <numbers> + #include "openvic-extension/utility/ClassBindings.hpp" #include "openvic-extension/utility/UITools.hpp" using namespace godot; using namespace OpenVic; -using OpenVic::Utilities::godot_to_std_string; using OpenVic::Utilities::std_view_to_godot_string; -using OpenVic::Utilities::std_view_to_godot_string_name; StringName const& GFXPieChartTexture::_slice_identifier_key() { static StringName const slice_identifier_key = "identifier"; diff --git a/extension/src/openvic-extension/classes/GUINode.cpp b/extension/src/openvic-extension/classes/GUINode.cpp index 89701e0..f95e3cd 100644 --- a/extension/src/openvic-extension/classes/GUINode.cpp +++ b/extension/src/openvic-extension/classes/GUINode.cpp @@ -10,9 +10,6 @@ using namespace godot; using namespace OpenVic; -using OpenVic::Utilities::godot_to_std_string; -using OpenVic::Utilities::std_view_to_godot_string; - #define APPLY_TO_CHILD_TYPES(F) \ F(Button, button) \ F(CheckBox, check_box) \ @@ -28,8 +25,9 @@ using OpenVic::Utilities::std_view_to_godot_string; F(GFXPieChartTexture, gfx_pie_chart_texture) void GUINode::_bind_methods() { - OV_BIND_SMETHOD(generate_gui_element, { "gui_file", "gui_element", "name" }, DEFVAL(String {})); - OV_BIND_METHOD(GUINode::add_gui_element, { "gui_file", "gui_element", "name" }, DEFVAL(String {})); + OV_BIND_SMETHOD(generate_gui_element, { "gui_scene", "gui_element", "name" }, DEFVAL(String {})); + OV_BIND_METHOD(GUINode::add_gui_element, { "gui_scene", "gui_element", "name" }, DEFVAL(String {})); + OV_BIND_SMETHOD(get_gui_position, { "gui_scene", "gui_position" }); #define GET_BINDINGS(type, name) \ OV_BIND_SMETHOD(get_##name##_from_node, { "node" }); \ @@ -55,19 +53,19 @@ GUINode::GUINode() { set_mouse_filter(MOUSE_FILTER_IGNORE); } -Control* GUINode::generate_gui_element(String const& gui_file, String const& gui_element, String const& name) { +Control* GUINode::generate_gui_element(String const& gui_scene, String const& gui_element, String const& name) { Control* result = nullptr; - if (!UITools::generate_gui_element(gui_file, gui_element, name, result)) { - UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI file ", gui_file); + if (!UITools::generate_gui_element(gui_scene, gui_element, name, result)) { + UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI scene ", gui_scene); } return result; } -Error GUINode::add_gui_element(String const& gui_file, String const& gui_element, String const& name) { +Error GUINode::add_gui_element(String const& gui_scene, String const& gui_element, String const& name) { Error err = OK; Control* result = nullptr; - if (!UITools::generate_gui_element(gui_file, gui_element, name, result)) { - UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI file ", gui_file); + if (!UITools::generate_gui_element(gui_scene, gui_element, name, result)) { + UtilityFunctions::push_error("Error generating GUI element ", gui_element, " from GUI scene ", gui_scene); err = FAILED; } if (result != nullptr) { @@ -76,6 +74,12 @@ Error GUINode::add_gui_element(String const& gui_file, String const& gui_element return err; } +Vector2 GUINode::get_gui_position(String const& gui_scene, String const& gui_position) { + GUI::Position const* position = UITools::get_gui_position(gui_scene, gui_position); + ERR_FAIL_NULL_V(position, {}); + return Utilities::to_godot_fvec2(position->get_position()); +} + template<std::derived_from<godot::Node> T> static T* _cast_node(Node* node) { ERR_FAIL_NULL_V(node, nullptr); diff --git a/extension/src/openvic-extension/classes/GUINode.hpp b/extension/src/openvic-extension/classes/GUINode.hpp index e38ed1f..0fbfc66 100644 --- a/extension/src/openvic-extension/classes/GUINode.hpp +++ b/extension/src/openvic-extension/classes/GUINode.hpp @@ -25,13 +25,15 @@ namespace OpenVic { GUINode(); static godot::Control* generate_gui_element( - godot::String const& gui_file, godot::String const& gui_element, godot::String const& name = "" + godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name = "" ); godot::Error add_gui_element( - godot::String const& gui_file, godot::String const& gui_element, godot::String const& name = "" + godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name = "" ); + static godot::Vector2 get_gui_position(godot::String const& gui_scene, godot::String const& gui_position); + static godot::Button* get_button_from_node(godot::Node* node); static godot::CheckBox* get_check_box_from_node(godot::Node* node); static godot::Label* get_label_from_node(godot::Node* node); diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp index e1cd873..1fcc574 100644 --- a/extension/src/openvic-extension/utility/UITools.cpp +++ b/extension/src/openvic-extension/utility/UITools.cpp @@ -37,17 +37,28 @@ GFX::Sprite const* UITools::get_gfx_sprite(godot::String const& gfx_sprite) { return sprite; } -GUI::Element const* UITools::get_gui_element(godot::String const& gui_file, godot::String const& gui_element) { +GUI::Element const* UITools::get_gui_element(godot::String const& gui_scene, godot::String const& gui_element) { GameSingleton const* game_singleton = GameSingleton::get_singleton(); ERR_FAIL_NULL_V(game_singleton, nullptr); GUI::Scene const* scene = - game_singleton->get_game_manager().get_ui_manager().get_scene_by_identifier(godot_to_std_string(gui_file)); - ERR_FAIL_NULL_V_MSG(scene, nullptr, vformat("Failed to find GUI file %s", gui_file)); + game_singleton->get_game_manager().get_ui_manager().get_scene_by_identifier(godot_to_std_string(gui_scene)); + ERR_FAIL_NULL_V_MSG(scene, nullptr, vformat("Failed to find GUI scene %s", gui_scene)); GUI::Element const* element = scene->get_scene_element_by_identifier(godot_to_std_string(gui_element)); - ERR_FAIL_NULL_V_MSG(element, nullptr, vformat("Failed to find GUI element %s in GUI file %s", gui_element, gui_file)); + ERR_FAIL_NULL_V_MSG(element, nullptr, vformat("Failed to find GUI element %s in GUI scene %s", gui_element, gui_scene)); return element; } +GUI::Position const* UITools::get_gui_position(String const& gui_scene, String const& gui_position) { + GameSingleton const* game_singleton = GameSingleton::get_singleton(); + ERR_FAIL_NULL_V(game_singleton, nullptr); + GUI::Scene const* scene = + game_singleton->get_game_manager().get_ui_manager().get_scene_by_identifier(godot_to_std_string(gui_scene)); + ERR_FAIL_NULL_V_MSG(scene, nullptr, vformat("Failed to find GUI scene %s", gui_scene)); + GUI::Position const* position = scene->get_scene_position_by_identifier(godot_to_std_string(gui_position)); + ERR_FAIL_NULL_V_MSG(position, nullptr, vformat("Failed to find GUI position %s in GUI scene %s", gui_position, gui_scene)); + return position; +} + /* GUI::Element tree -> godot::Control tree conversion code below: */ namespace OpenVic { @@ -65,9 +76,9 @@ namespace OpenVic { } template<std::derived_from<Control> T> -static T* new_control(GUI::Element const& element, String const& name) { - T* node = memnew(T); - ERR_FAIL_NULL_V(node, nullptr); +static bool new_control(T*& node, GUI::Element const& element, String const& name) { + node = memnew(T); + ERR_FAIL_NULL_V(node, false); using enum GUI::Element::orientation_t; using enum Control::LayoutPreset; @@ -83,20 +94,32 @@ static T* new_control(GUI::Element const& element, String const& name) { node->set_name(name); } + bool ret = true; const decltype(orientation_map)::const_iterator it = orientation_map.find(element.get_orientation()); if (it != orientation_map.end()) { node->set_anchors_and_offsets_preset(it->second); } else { UtilityFunctions::push_error("Invalid orientation for GUI element ", std_view_to_godot_string(element.get_name())); + ret = false; } + node->set_position(Utilities::to_godot_fvec2(element.get_position())); node->set_h_size_flags(Control::SizeFlags::SIZE_SHRINK_BEGIN); node->set_v_size_flags(Control::SizeFlags::SIZE_SHRINK_BEGIN); node->set_focus_mode(Control::FOCUS_NONE); - return node; + return ret; } +static bool add_theme_stylebox(Control* control, StringName const& theme_name, Ref<Texture2D> const& texture) { + Ref<StyleBoxTexture> stylebox; + stylebox.instantiate(); + ERR_FAIL_NULL_V(stylebox, false); + stylebox->set_texture(texture); + control->add_theme_stylebox_override(theme_name, stylebox); + return true; +}; + static bool generate_icon(generate_gui_args_t&& args) { GUI::Icon const& icon = static_cast<GUI::Icon const&>(args.element); @@ -106,7 +129,8 @@ static bool generate_icon(generate_gui_args_t&& args) { bool ret = true; if (icon.get_sprite() != nullptr) { if (icon.get_sprite()->is_type<GFX::TextureSprite>()) { - TextureRect* godot_texture_rect = new_control<TextureRect>(icon, args.name); + TextureRect* godot_texture_rect = nullptr; + ret &= new_control(godot_texture_rect, icon, args.name); ERR_FAIL_NULL_V_MSG(godot_texture_rect, false, vformat("Failed to create TextureRect for GUI icon %s", icon_name)); GFX::TextureSprite const* texture_sprite = icon.get_sprite()->cast_to<GFX::TextureSprite>(); @@ -120,7 +144,8 @@ static bool generate_icon(generate_gui_args_t&& args) { args.result = godot_texture_rect; } else if (icon.get_sprite()->is_type<GFX::MaskedFlag>()) { - TextureRect* godot_texture_rect = new_control<TextureRect>(icon, args.name); + TextureRect* godot_texture_rect = nullptr; + ret &= new_control(godot_texture_rect, icon, args.name); ERR_FAIL_NULL_V_MSG(godot_texture_rect, false, vformat("Failed to create TextureRect for GUI icon %s", icon_name)); GFX::MaskedFlag const* masked_flag = icon.get_sprite()->cast_to<GFX::MaskedFlag>(); @@ -134,7 +159,8 @@ static bool generate_icon(generate_gui_args_t&& args) { args.result = godot_texture_rect; } else if (icon.get_sprite()->is_type<GFX::ProgressBar>()) { - TextureProgressBar* godot_progress_bar = new_control<TextureProgressBar>(icon, args.name); + TextureProgressBar* godot_progress_bar = nullptr; + ret &= new_control(godot_progress_bar, icon, args.name); ERR_FAIL_NULL_V_MSG( godot_progress_bar, false, vformat("Failed to create TextureProgressBar for GUI icon %s", icon_name) ); @@ -210,7 +236,8 @@ static bool generate_icon(generate_gui_args_t&& args) { args.result = godot_progress_bar; } else if (icon.get_sprite()->is_type<GFX::PieChart>()) { - TextureRect* godot_texture_rect = new_control<TextureRect>(icon, args.name); + TextureRect* godot_texture_rect = nullptr; + ret &= new_control(godot_texture_rect, icon, args.name); ERR_FAIL_NULL_V_MSG(godot_texture_rect, false, vformat("Failed to create TextureRect for GUI icon %s", icon_name)); GFX::PieChart const* pie_chart = icon.get_sprite()->cast_to<GFX::PieChart>(); @@ -219,7 +246,7 @@ static bool generate_icon(generate_gui_args_t&& args) { godot_texture_rect->set_texture(texture); // TODO - work out why this is needed Vector2 pos = godot_texture_rect->get_position(); - pos.x -= texture->get_width() / 2; + pos.x -= texture->get_width() / 2.0f; godot_texture_rect->set_position(pos); } else { UtilityFunctions::push_error("Failed to make GFXPieChartTexture for GUI icon ", icon_name); @@ -228,12 +255,18 @@ static bool generate_icon(generate_gui_args_t&& args) { args.result = godot_texture_rect; } else if (icon.get_sprite()->is_type<GFX::LineChart>()) { - + // TODO - generate line chart } else { UtilityFunctions::push_error("Invalid sprite type ", std_view_to_godot_string(icon.get_sprite()->get_type()), " for GUI icon ", icon_name); ret = false; } + + if (args.result != nullptr) { + const float scale = icon.get_scale(); + args.result->set_scale({ scale, scale }); + // TODO - rotation (may have to translate as godot rotates around the top left corner) + } } else { UtilityFunctions::push_error("Null sprite for GUI icon ", icon_name); ret = false; @@ -247,7 +280,8 @@ static bool generate_button(generate_gui_args_t&& args) { // TODO - shortcut, sprite, text const String button_name = std_view_to_godot_string(button.get_name()); - Button* godot_button = new_control<Button>(button, args.name); + Button* godot_button = nullptr; + bool ret = new_control(godot_button, button, args.name); ERR_FAIL_NULL_V_MSG(godot_button, false, vformat("Failed to create Button for GUI button %s", button_name)); godot_button->set_mouse_filter(Control::MOUSE_FILTER_PASS); @@ -256,8 +290,6 @@ static bool generate_button(generate_gui_args_t&& args) { godot_button->set_text(std_view_to_godot_string(button.get_text())); } - bool ret = true; - using enum GFXButtonStateTexture::ButtonState; static constexpr std::array<GFXButtonStateTexture::ButtonState, 3> button_states { HOVER, PRESSED, DISABLED }; @@ -310,10 +342,10 @@ static bool generate_button(generate_gui_args_t&& args) { }; static const StringName theme_name_normal = "normal"; - ret &= add_stylebox(theme_name_normal, texture); + ret &= add_theme_stylebox(godot_button, theme_name_normal, texture); for (Ref<GFXButtonStateTexture> const& button_state_texture : button_state_textures) { - ret &= add_stylebox(button_state_texture->get_button_state_theme(), button_state_texture); + ret &= add_theme_stylebox(godot_button, button_state_texture->get_button_state_theme(), button_state_texture); } } } else { @@ -350,10 +382,10 @@ static bool generate_checkbox(generate_gui_args_t&& args) { // TODO - shortcut, sprite, text const String checkbox_name = std_view_to_godot_string(checkbox.get_name()); - CheckBox* godot_checkbox = new_control<CheckBox>(checkbox, args.name); + CheckBox* godot_checkbox = nullptr; + bool ret = new_control(godot_checkbox, checkbox, args.name); ERR_FAIL_NULL_V_MSG(godot_checkbox, false, vformat("Failed to create CheckBox for GUI checkbox %s", checkbox_name)); - bool ret = true; if (checkbox.get_sprite() != nullptr) { GFX::TextureSprite const* texture_sprite = checkbox.get_sprite()->cast_to<GFX::TextureSprite>(); if (texture_sprite != nullptr) { @@ -393,7 +425,8 @@ static bool generate_text(generate_gui_args_t&& args) { const String text_name = std_view_to_godot_string(text.get_name()); - Label* godot_label = new_control<Label>(text, args.name); + Label* godot_label = nullptr; + bool ret = new_control(godot_label, text, args.name); ERR_FAIL_NULL_V_MSG(godot_label, false, vformat("Failed to create Label for GUI text %s", text_name)); godot_label->set_text(std_view_to_godot_string(text.get_text())); @@ -411,9 +444,9 @@ static bool generate_text(generate_gui_args_t&& args) { godot_label->set_horizontal_alignment(it->second); } else { UtilityFunctions::push_error("Invalid text format (horizontal alignment) for GUI text ", text_name); + ret = false; } - bool ret = true; if (text.get_font() != nullptr) { const StringName font_file = std_view_to_godot_string_name(text.get_font()->get_fontname()); const Ref<Font> font = args.asset_manager.get_font(font_file); @@ -436,29 +469,55 @@ static bool generate_overlapping_elements(generate_gui_args_t&& args) { const String overlapping_elements_name = std_view_to_godot_string(overlapping_elements.get_name()); - GUIOverlappingElementsBox* box = new_control<GUIOverlappingElementsBox>(overlapping_elements, args.name); + GUIOverlappingElementsBox* box = nullptr; + bool ret = new_control(box, overlapping_elements, args.name); ERR_FAIL_NULL_V_MSG( box, false, vformat("Failed to create GUIOverlappingElementsBox for GUI overlapping elements %s", overlapping_elements_name) ); - const bool ret = box->set_gui_overlapping_elements_box(&overlapping_elements) == OK; + ret &= box->set_gui_overlapping_elements_box(&overlapping_elements) == OK; args.result = box; return ret; } -static bool generate_listbox(generate_gui_args_t&& args) { - GUI::ListBox const& listbox = static_cast<GUI::ListBox const&>(args.element); +template<std::derived_from<GUI::Element> T> +requires requires(T const& element) { + { element.get_size() } -> std::same_as<fvec2_t>; +} +static bool generate_placeholder(generate_gui_args_t&& args, Color colour) { + T const& cast_element = static_cast<T const&>(args.element); - const String listbox_name = std_view_to_godot_string(listbox.get_name()); + static const String type_name = std_view_to_godot_string(T::get_type_static()); + const String placeholder_name = std_view_to_godot_string(cast_element.get_name()); + const Vector2 godot_size = Utilities::to_godot_fvec2(cast_element.get_size()); - ColorRect* godot_rect = new_control<ColorRect>(listbox, args.name); - ERR_FAIL_NULL_V_MSG(godot_rect, false, vformat("Failed to create ColorRect for GUI listbox %s", listbox_name)); + UtilityFunctions::push_warning( + "Generating placeholder ColorRect for GUI ", type_name, " ", placeholder_name, " (size ", godot_size, ")" + ); - godot_rect->set_custom_minimum_size(Utilities::to_godot_fvec2(listbox.get_size())); - godot_rect->set_color({ 1.0f, 0.5f, 0.0f, 0.2f }); + ColorRect* godot_rect = nullptr; + bool ret = new_control(godot_rect, cast_element, args.name); + ERR_FAIL_NULL_V_MSG( + godot_rect, false, vformat("Failed to create placeholder ColorRect for GUI %s %s", type_name, placeholder_name) + ); + + godot_rect->set_custom_minimum_size(godot_size); + godot_rect->set_color(colour); args.result = godot_rect; - return true; + return ret; +} + +static bool generate_listbox(generate_gui_args_t&& args) { + return generate_placeholder<GUI::ListBox>(std::move(args), { 0.0f, 0.0f, 1.0f, 0.3f }); +} + +static bool generate_texteditbox(generate_gui_args_t&& args) { + return generate_placeholder<GUI::TextEditBox>(std::move(args), { 0.0f, 1.0f, 0.0f, 0.3f }); +} + +static bool generate_scrollbar(generate_gui_args_t&& args) { + return generate_placeholder<GUI::Scrollbar>(std::move(args), { 1.0f, 0.0f, 0.0f, 0.3f }); } /* Forward declaration for use in generate_window. */ @@ -470,13 +529,13 @@ static bool generate_window(generate_gui_args_t&& args) { // TODO - moveable, fullscreen, dontRender (disable visibility?) const String window_name = std_view_to_godot_string(window.get_name()); - Panel* godot_panel = new_control<Panel>(window, args.name); + Panel* godot_panel = nullptr; + bool ret = new_control(godot_panel, window, args.name); ERR_FAIL_NULL_V_MSG(godot_panel, false, vformat("Failed to create Panel for GUI window %s", window_name)); godot_panel->set_custom_minimum_size(Utilities::to_godot_fvec2(window.get_size())); godot_panel->set_self_modulate({ 1.0f, 1.0f, 1.0f, 0.0f }); - bool ret = true; for (std::unique_ptr<GUI::Element> const& element : window.get_window_elements()) { Control* node = nullptr; const bool element_ret = generate_element(element.get(), "", args.asset_manager, node); @@ -502,6 +561,8 @@ static bool generate_element(GUI::Element const* element, String const& name, As { GUI::Text::get_type_static(), &generate_text }, { GUI::OverlappingElementsBox::get_type_static(), &generate_overlapping_elements }, { GUI::ListBox::get_type_static(), &generate_listbox }, + { GUI::TextEditBox::get_type_static(), &generate_texteditbox }, + { GUI::Scrollbar::get_type_static(), &generate_scrollbar }, { GUI::Window::get_type_static(), &generate_window } }; const decltype(type_map)::const_iterator it = type_map.find(element->get_type()); @@ -521,7 +582,7 @@ bool UITools::generate_gui_element( } bool UITools::generate_gui_element( - godot::String const& gui_file, godot::String const& gui_element, godot::String const& name, godot::Control*& result + godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name, godot::Control*& result ) { - return generate_gui_element(get_gui_element(gui_file, gui_element), name, result); + return generate_gui_element(get_gui_element(gui_scene, gui_element), name, result); } diff --git a/extension/src/openvic-extension/utility/UITools.hpp b/extension/src/openvic-extension/utility/UITools.hpp index 65cf17a..6092853 100644 --- a/extension/src/openvic-extension/utility/UITools.hpp +++ b/extension/src/openvic-extension/utility/UITools.hpp @@ -7,12 +7,13 @@ namespace OpenVic::UITools { GFX::Sprite const* get_gfx_sprite(godot::String const& gfx_sprite); - GUI::Element const* get_gui_element(godot::String const& gui_file, godot::String const& gui_element); + GUI::Element const* get_gui_element(godot::String const& gui_scene, godot::String const& gui_element); + GUI::Position const* get_gui_position(godot::String const& gui_scene, godot::String const& gui_position); bool generate_gui_element( GUI::Element const* element, godot::String const& name, godot::Control*& result ); bool generate_gui_element( - godot::String const& gui_file, godot::String const& gui_element, godot::String const& name, godot::Control*& result + godot::String const& gui_scene, godot::String const& gui_element, godot::String const& name, godot::Control*& result ); } diff --git a/extension/src/openvic-extension/utility/Utilities.cpp b/extension/src/openvic-extension/utility/Utilities.cpp index a3fa40a..5957b70 100644 --- a/extension/src/openvic-extension/utility/Utilities.cpp +++ b/extension/src/openvic-extension/utility/Utilities.cpp @@ -1,7 +1,5 @@ #include "Utilities.hpp" -#include <numbers> - #include <godot_cpp/classes/file_access.hpp> #include <godot_cpp/classes/resource_loader.hpp> #include <godot_cpp/classes/translation_server.hpp> diff --git a/extension/src/openvic-extension/utility/Utilities.hpp b/extension/src/openvic-extension/utility/Utilities.hpp index 9bbc700..9b45abc 100644 --- a/extension/src/openvic-extension/utility/Utilities.hpp +++ b/extension/src/openvic-extension/utility/Utilities.hpp @@ -11,23 +11,23 @@ namespace OpenVic::Utilities { - inline std::string godot_to_std_string(godot::String const& str) { + _FORCE_INLINE_ std::string godot_to_std_string(godot::String const& str) { return str.ascii().get_data(); } - inline godot::String std_to_godot_string(std::string const& str) { + _FORCE_INLINE_ godot::String std_to_godot_string(std::string const& str) { return str.c_str(); } - inline godot::String std_view_to_godot_string(std::string_view str) { + _FORCE_INLINE_ godot::String std_view_to_godot_string(std::string_view const& str) { return std_to_godot_string(static_cast<std::string>(str)); } - inline godot::StringName std_to_godot_string_name(std::string const& str) { + _FORCE_INLINE_ godot::StringName std_to_godot_string_name(std::string const& str) { return str.c_str(); } - inline godot::StringName std_view_to_godot_string_name(std::string_view str) { + _FORCE_INLINE_ godot::StringName std_view_to_godot_string_name(std::string_view const& str) { return std_to_godot_string_name(static_cast<std::string>(str)); } @@ -37,15 +37,15 @@ namespace OpenVic::Utilities { godot::String date_to_formatted_string(Date date); - inline godot::Color to_godot_color(IsColour auto colour) { + _FORCE_INLINE_ godot::Color to_godot_color(IsColour auto colour) { return { colour.redf(), colour.greenf(), colour.bluef(), colour.alphaf() }; } - inline godot::Vector2i to_godot_ivec2(ivec2_t vec) { + _FORCE_INLINE_ godot::Vector2i to_godot_ivec2(ivec2_t vec) { return { vec.x, vec.y }; } - inline godot::Vector2 to_godot_fvec2(fvec2_t vec) { + _FORCE_INLINE_ godot::Vector2 to_godot_fvec2(fvec2_t vec) { return { vec.x, vec.y }; } |