aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/utility
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-04-22 01:25:58 +0200
committer GitHub <noreply@github.com>2024-04-22 01:25:58 +0200
commit61e1e14ab7d206422004b4b4c6ffbb5e5f7dec58 (patch)
tree68efc91c394ae9dc76d6e9e7cadee86e2e2a02d3 /extension/src/openvic-extension/utility
parent34f161570fd7ca9381675be8a9ec3b9b409929e1 (diff)
parentc574d925c5251289d9f2fc32190b44cbe766f387 (diff)
Merge pull request #219 from OpenVicProject/asset-manager-load-flags
Add AssetManager LoadFlags
Diffstat (limited to 'extension/src/openvic-extension/utility')
-rw-r--r--extension/src/openvic-extension/utility/UITools.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp
index 4af2b74..510c6da 100644
--- a/extension/src/openvic-extension/utility/UITools.cpp
+++ b/extension/src/openvic-extension/utility/UITools.cpp
@@ -187,10 +187,12 @@ static bool generate_icon(generate_gui_args_t&& args) {
GFX::ProgressBar const* progress_bar = icon.get_sprite()->cast_to<GFX::ProgressBar>();
+ using enum AssetManager::LoadFlags;
+
Ref<ImageTexture> back_texture;
if (!progress_bar->get_back_texture_file().empty()) {
const StringName back_texture_file = std_view_to_godot_string_name(progress_bar->get_back_texture_file());
- back_texture = args.asset_manager.get_texture(back_texture_file, true);
+ back_texture = args.asset_manager.get_texture(back_texture_file, LOAD_FLAG_CACHE_TEXTURE | LOAD_FLAG_FLIP_Y);
if (back_texture.is_null()) {
UtilityFunctions::push_error(
"Failed to load progress bar sprite back texture ", back_texture_file, " for GUI icon ", icon_name
@@ -221,11 +223,14 @@ static bool generate_icon(generate_gui_args_t&& args) {
Ref<ImageTexture> progress_texture;
if (!progress_bar->get_progress_texture_file().empty()) {
- const StringName progress_texture_file = std_view_to_godot_string_name(progress_bar->get_progress_texture_file());
- progress_texture = args.asset_manager.get_texture(progress_texture_file, true);
+ const StringName progress_texture_file =
+ std_view_to_godot_string_name(progress_bar->get_progress_texture_file());
+ progress_texture =
+ args.asset_manager.get_texture(progress_texture_file, LOAD_FLAG_CACHE_TEXTURE | LOAD_FLAG_FLIP_Y);
if (progress_texture.is_null()) {
UtilityFunctions::push_error(
- "Failed to load progress bar sprite progress texture ", progress_texture_file, " for GUI icon ", icon_name
+ "Failed to load progress bar sprite progress texture ", progress_texture_file, " for GUI icon ",
+ icon_name
);
ret = false;
}
@@ -237,7 +242,8 @@ static bool generate_icon(generate_gui_args_t&& args) {
);
if (progress_texture.is_null()) {
UtilityFunctions::push_error(
- "Failed to generate progress bar sprite ", progress_colour, " progress texture for GUI icon ", icon_name
+ "Failed to generate progress bar sprite ", progress_colour, " progress texture for GUI icon ",
+ icon_name
);
ret = false;
}
@@ -252,7 +258,9 @@ static bool generate_icon(generate_gui_args_t&& args) {
}
// TODO - work out why progress bar is missing bottom border pixel (e.g. province building expansion bar)
- godot_progress_bar->set_custom_minimum_size(Utilities::to_godot_fvec2(static_cast<fvec2_t>(progress_bar->get_size())));
+ godot_progress_bar->set_custom_minimum_size(
+ Utilities::to_godot_fvec2(static_cast<fvec2_t>(progress_bar->get_size()))
+ );
args.result = godot_progress_bar;
} else if (icon.get_sprite()->is_type<GFX::PieChart>()) {
@@ -286,7 +294,9 @@ static bool generate_icon(generate_gui_args_t&& args) {
const float rotation = icon.get_rotation();
if (rotation != 0.0f) {
args.result->set_position(
- args.result->get_position() - args.result->get_custom_minimum_size().height * Vector2 { sin(rotation), cos(rotation) - 1.0f }
+ args.result->get_position() - args.result->get_custom_minimum_size().height * Vector2 {
+ sin(rotation), cos(rotation) - 1.0f
+ }
);
args.result->set_rotation(-rotation);
}