From d04d0247479b229407048a37cd0ad60933aa3bf1 Mon Sep 17 00:00:00 2001 From: hop311 Date: Thu, 28 Dec 2023 20:19:12 +0000 Subject: Use `ERR_FAIL_*` macros where possible --- extension/src/openvic-extension/utility/UITools.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'extension/src/openvic-extension/utility/UITools.cpp') diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp index cba65a4..67ea8f5 100644 --- a/extension/src/openvic-extension/utility/UITools.cpp +++ b/extension/src/openvic-extension/utility/UITools.cpp @@ -86,8 +86,7 @@ static T* new_control(GUI::Element const& element, String const& name) { if (it != orientation_map.end()) { node->set_anchors_and_offsets_preset(it->second); } else { - UtilityFunctions::push_error("Invalid orientation for GUI element ", - std_view_to_godot_string(element.get_name())); + UtilityFunctions::push_error("Invalid orientation for GUI element ", std_view_to_godot_string(element.get_name())); } node->set_position(Utilities::to_godot_fvec2(element.get_position())); node->set_h_size_flags(Control::SizeFlags::SIZE_SHRINK_BEGIN); @@ -426,12 +425,10 @@ static bool generate_element(GUI::Element const* element, String const& name, As { GUI::Window::get_type_static(), &generate_window } }; const decltype(type_map)::const_iterator it = type_map.find(element->get_type()); - if (it != type_map.end()) { - return it->second({ *element, name, asset_manager, result }); - } else { - UtilityFunctions::push_error("Invalid GUI element type: ", std_view_to_godot_string(element->get_type())); - return false; - } + ERR_FAIL_COND_V_MSG( + it == type_map.end(), false, vformat("Invalid GUI element type: %s", std_view_to_godot_string(element->get_type())) + ); + return it->second({ *element, name, asset_manager, result }); } bool UITools::generate_gui_element( -- cgit v1.2.3-56-ga3b1