#pragma once #include #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)); } godot::String int_to_formatted_string(int64_t val); godot::String float_to_formatted_string(float val); godot::String date_to_formatted_string(Date date); 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) { return { vec.x, vec.y }; } inline godot::Vector2 to_godot_fvec2(fvec2_t vec) { return { vec.x, vec.y }; } /* Loads a Resource from a file in the Godot project directory given by a path beginning with "res://". */ godot::Ref load_resource(godot::String const& path, godot::String const& type_hint = {}); /* Load an Image from anywhere on the machine, using Godot's image-loading function or, in the case of * ".dds" image files which Godot is unable to load at runtime, GLI's DDS loading function. */ godot::Ref load_godot_image(godot::String const& path); /* Load a Font from anywhere on the machine, combining the ".fnt" file loaded from the given path with the * already-loaded image file containing the actual characters. */ godot::Ref load_godot_font(godot::String const& fnt_path, godot::Ref const& image); godot::Ref make_solid_colour_image( godot::Color const& colour, int32_t width, int32_t height, godot::Image::Format format = godot::Image::Format::FORMAT_RGBA8 ); godot::Ref make_solid_colour_texture( godot::Color const& colour, int32_t width, int32_t height, godot::Image::Format format = godot::Image::Format::FORMAT_RGBA8 ); }