aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/utility/UITools.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-29 12:04:03 +0100
committer GitHub <noreply@github.com>2023-12-29 12:04:03 +0100
commit62b0e39e7cd294cab9c428d15f1be97a8c39eecc (patch)
treecb3671592c2d1e7697371510f455de7e99f75a12 /extension/src/openvic-extension/utility/UITools.cpp
parentc21e9b7a529aebcf0148a6671377c3e8478fafdf (diff)
parentd04d0247479b229407048a37cd0ad60933aa3bf1 (diff)
Merge pull request #184 from OpenVicProject/error-macros
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.cpp13
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(