From bc0b3c61ae0b742da304cada451fba1df72bb0ad Mon Sep 17 00:00:00 2001 From: hop311 Date: Wed, 8 Nov 2023 22:24:21 +0000 Subject: GUI elements -> Godot UI nodes generator --- .../src/openvic-extension/utility/Utilities.hpp | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 extension/src/openvic-extension/utility/Utilities.hpp (limited to 'extension/src/openvic-extension/utility/Utilities.hpp') diff --git a/extension/src/openvic-extension/utility/Utilities.hpp b/extension/src/openvic-extension/utility/Utilities.hpp new file mode 100644 index 0000000..fc106db --- /dev/null +++ b/extension/src/openvic-extension/utility/Utilities.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +#include +#include + +#define ERR(x) ((x) ? OK : FAILED) + +namespace OpenVic::Utilities { + + 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) { + return str.c_str(); + } + + inline godot::String std_view_to_godot_string(std::string_view str) { + return std_to_godot_string(static_cast(str)); + } + + 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) { + return std_to_godot_string_name(static_cast(str)); + } + + inline godot::Color to_godot_color(colour_t colour) { + return { + colour_byte_to_float((colour >> 16) & 0xFF), + colour_byte_to_float((colour >> 8) & 0xFF), + colour_byte_to_float(colour & 0xFF) + }; + } + + inline godot::Vector2i to_godot_ivec2(ivec2_t vec) { + return { vec.x, vec.y }; + } + + godot::Ref load_godot_image(godot::String const& path); + + godot::Ref load_godot_font(godot::String const& fnt_path, godot::Ref const& image); + + void draw_pie_chart( + godot::Ref image, godot::Array const& stopAngles, godot::Array const& colours, float radius, + godot::Vector2 shadow_displacement, float shadow_tightness, float shadow_radius, float shadow_thickness, + godot::Color trim_colour, float trim_size, float gradient_falloff, float gradient_base, bool donut, + bool donut_inner_trim, float donut_inner_radius + ); +} -- cgit v1.2.3-56-ga3b1