aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2024-05-04 16:39:51 +0200
committer GitHub <noreply@github.com>2024-05-04 16:39:51 +0200
commitbf3df0ee900f406a5a2aa56609ecb89c67055351 (patch)
treec9891fc675ed60f2390b5a25f3acaea21143f15f
parent2fc3f945f22966d209986ab38575aa26e2e6c1fd (diff)
parent812d82dee030299b33181c102f906d58781d4fe0 (diff)
Merge pull request #224 from Spartan322/update/godot4.2.2-stable
Update to Godot 4.2.2 Stable Release
-rw-r--r--.github/workflows/builds.yml2
-rw-r--r--README.md4
-rw-r--r--extension/src/openvic-extension/utility/UITools.cpp21
-rw-r--r--extension/src/openvic-extension/utility/Utilities.hpp12
m---------godot-cpp0
5 files changed, 28 insertions, 11 deletions
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml
index afc2d7e..c888b57 100644
--- a/.github/workflows/builds.yml
+++ b/.github/workflows/builds.yml
@@ -20,7 +20,7 @@ on:
env:
GODOT_BASE_DOWNLOAD_URL: https://github.com/godotengine/godot
- GODOT_VERSION: 4.2.1
+ GODOT_VERSION: 4.2.2
GODOT_VERSION_TYPE: stable
OPENVIC_BASE_BRANCH: master
diff --git a/README.md b/README.md
index fe90e61..109ab64 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Main Repo for the OpenVic Project
For detailed instructions, view the Contributor Quickstart Guide [here](docs/contribution-quickstart-guide.md)
## System Requirements
-* [Godot 4.2.1](https://github.com/godotengine/godot/releases/tag/4.2.1-stable)
+* [Godot 4.2.2](https://github.com/godotengine/godot/releases/tag/4.2.2-stable)
* [scons](https://scons.org/)
> [!WARNING]
@@ -24,7 +24,7 @@ See [Cloning](docs/contribution/cloning.md).
## [Godot Documentation](https://docs.godotengine.org/en/latest/)
## Build/Run Instructions
-1. Install [Godot 4.2.1](https://github.com/godotengine/godot/releases/tag/4.2.1-stable) and [scons](https://scons.org/) for your system.
+1. Install [Godot 4.2.2](https://github.com/godotengine/godot/releases/tag/4.2.2-stable) and [scons](https://scons.org/) for your system.
2. Run the command `git submodule update --init --recursive` to retrieve all related submodules.
3. Run `scons` in the project root, you should see a libopenvic file in `game/bin/openvic`.
4. Open with Godot 4, click import and navigate to the `game` directory.
diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp
index 510c6da..6a9384b 100644
--- a/extension/src/openvic-extension/utility/UITools.cpp
+++ b/extension/src/openvic-extension/utility/UITools.cpp
@@ -128,6 +128,8 @@ static bool add_theme_stylebox(Control* control, StringName const& theme_name, R
};
static bool generate_icon(generate_gui_args_t&& args) {
+ using namespace OpenVic::Utilities::literals;
+
GUI::Icon const& icon = static_cast<GUI::Icon const&>(args.element);
const String icon_name = std_view_to_godot_string(icon.get_name());
@@ -274,7 +276,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.0f;
+ pos.x -= texture->get_width() / 2.0_real;
godot_texture_rect->set_position(pos);
} else {
UtilityFunctions::push_error("Failed to make GFXPieChartTexture for GUI icon ", icon_name);
@@ -291,11 +293,11 @@ static bool generate_icon(generate_gui_args_t&& args) {
}
if (args.result != nullptr) {
- const float rotation = icon.get_rotation();
- if (rotation != 0.0f) {
+ const real_t rotation = icon.get_rotation();
+ if (rotation != 0.0_real) {
args.result->set_position(
args.result->get_position() - args.result->get_custom_minimum_size().height * Vector2 {
- sin(rotation), cos(rotation) - 1.0f
+ Math::sin(rotation), Math::cos(rotation) - 1.0_real
}
);
args.result->set_rotation(-rotation);
@@ -441,6 +443,8 @@ static bool generate_checkbox(generate_gui_args_t&& args) {
}
static bool generate_text(generate_gui_args_t&& args) {
+ using namespace OpenVic::Utilities::literals;
+
GUI::Text const& text = static_cast<GUI::Text const&>(args.element);
const String text_name = std_view_to_godot_string(text.get_name());
@@ -451,7 +455,7 @@ static bool generate_text(generate_gui_args_t&& args) {
godot_label->set_text(std_view_to_godot_string(text.get_text()));
- static const Vector2 default_padding { 1.0f, 0.0f };
+ static const Vector2 default_padding { 1.0_real, 0.0_real };
const Vector2 border_size = Utilities::to_godot_fvec2(text.get_border_size()) + default_padding;
const Vector2 max_size = Utilities::to_godot_fvec2(text.get_max_size());
godot_label->set_position(godot_label->get_position() + border_size);
@@ -553,7 +557,8 @@ static bool generate_placeholder(generate_gui_args_t&& args, Color colour) {
}
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 });
+ using namespace OpenVic::Utilities::literals;
+ return generate_placeholder<GUI::TextEditBox>(std::move(args), { 0.0_real, 1.0_real, 0.0_real, 0.3_real });
}
static bool generate_scrollbar(generate_gui_args_t&& args) {
@@ -578,6 +583,8 @@ static bool generate_scrollbar(generate_gui_args_t&& args) {
static bool generate_element(GUI::Element const* element, String const& name, AssetManager& asset_manager, Control*& result);
static bool generate_window(generate_gui_args_t&& args) {
+ using namespace OpenVic::Utilities::literals;
+
GUI::Window const& window = static_cast<GUI::Window const&>(args.element);
// TODO - moveable, fullscreen, dontRender (disable visibility?)
@@ -588,7 +595,7 @@ static bool generate_window(generate_gui_args_t&& args) {
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 });
+ godot_panel->set_self_modulate({ 1.0_real, 1.0_real, 1.0_real, 0.0_real });
for (std::unique_ptr<GUI::Element> const& element : window.get_window_elements()) {
Control* node = nullptr;
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
diff --git a/godot-cpp b/godot-cpp
-Subproject 78ffea5b136f3178c31cddb28f6b963ceaa8942
+Subproject 98c143a48365f3f3bf5f99d6289a2cb25e6472d