diff options
author | hop311 <hop3114@gmail.com> | 2023-12-28 21:19:12 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-28 21:22:27 +0100 |
commit | d04d0247479b229407048a37cd0ad60933aa3bf1 (patch) | |
tree | cb3671592c2d1e7697371510f455de7e99f75a12 /extension/src/openvic-extension/utility/UITools.cpp | |
parent | c21e9b7a529aebcf0148a6671377c3e8478fafdf (diff) |
Use `ERR_FAIL_*` macros where possible
Diffstat (limited to 'extension/src/openvic-extension/utility/UITools.cpp')
-rw-r--r-- | extension/src/openvic-extension/utility/UITools.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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( |