diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-05-04 16:22:06 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-05-04 16:22:06 +0200 |
commit | 812d82dee030299b33181c102f906d58781d4fe0 (patch) | |
tree | c9891fc675ed60f2390b5a25f3acaea21143f15f /extension/src/openvic-extension/utility/Utilities.hpp | |
parent | 2fc3f945f22966d209986ab38575aa26e2e6c1fd (diff) |
Update to Godot 4.2.2 Stable Release
Fix UITools.cpp float conversion warning
Add `OpenVic::Utilities::to_real_t(std::floating_point)`
Add _real user defined literal for real_t
Diffstat (limited to 'extension/src/openvic-extension/utility/Utilities.hpp')
-rw-r--r-- | extension/src/openvic-extension/utility/Utilities.hpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/extension/src/openvic-extension/utility/Utilities.hpp b/extension/src/openvic-extension/utility/Utilities.hpp index f7a0d67..15ff6b6 100644 --- a/extension/src/openvic-extension/utility/Utilities.hpp +++ b/extension/src/openvic-extension/utility/Utilities.hpp @@ -1,5 +1,7 @@ #pragma once +#include <concepts> + #include <godot_cpp/classes/font_file.hpp> #include <godot_cpp/classes/image_texture.hpp> @@ -35,6 +37,10 @@ namespace OpenVic::Utilities { godot::String float_to_formatted_string(float val, int32_t decimal_places); + constexpr real_t to_real_t(std::floating_point auto val) { + return static_cast<real_t>(val); + } + godot::String date_to_formatted_string(Date date); _FORCE_INLINE_ godot::Color to_godot_color(IsColour auto colour) { @@ -73,4 +79,8 @@ namespace OpenVic::Utilities { godot::Color const& colour, int32_t width, int32_t height, godot::Image::Format format = godot::Image::Format::FORMAT_RGBA8 ); -} + + namespace literals { + constexpr real_t operator""_real(long double val) { return to_real_t(val); } + } +}
\ No newline at end of file |