From c574d925c5251289d9f2fc32190b44cbe766f387 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 20 Apr 2024 23:34:02 +0100 Subject: Add AssetManager LoadFlags --- .../src/openvic-extension/utility/UITools.cpp | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'extension/src/openvic-extension/utility') 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(); + using enum AssetManager::LoadFlags; + Ref 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 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(progress_bar->get_size()))); + godot_progress_bar->set_custom_minimum_size( + Utilities::to_godot_fvec2(static_cast(progress_bar->get_size())) + ); args.result = godot_progress_bar; } else if (icon.get_sprite()->is_type()) { @@ -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); } -- cgit v1.2.3-56-ga3b1