Skip to content

Commit 9170280

Browse files
ntsikUE4SS
authored andcommitted
Add error modals for search by address feature
1 parent cd0e12d commit 9170280

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

UE4SS/include/GUI/LiveView.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ namespace RC::GUI
9999
bool m_modal_edit_property_value_is_open{};
100100
bool m_modal_edit_property_value_opened_this_frame{};
101101
bool m_modal_edit_property_value_error_unable_to_edit{};
102+
bool m_modal_search_by_address_error_not_hex{};
103+
bool m_modal_search_by_address_error_out_of_range{};
102104
bool m_listeners_set{};
103105
bool m_listeners_allowed{};
104106
bool m_is_initialized{};

UE4SS/src/GUI/LiveView.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,8 +1874,14 @@ namespace RC::GUI
18741874
{
18751875
address_to_search_by = std::stoull(LiveView::s_name_to_search_by, nullptr, 16);
18761876
}
1877-
catch (std::invalid_argument) {} // query isn't a valid hex number; can't be an address
1878-
catch (std::out_of_range) {} // is a hex number, but too big, or negative; can't be address
1877+
catch (std::invalid_argument)
1878+
{
1879+
m_modal_search_by_address_error_not_hex = true;
1880+
}
1881+
catch (std::out_of_range)
1882+
{
1883+
m_modal_search_by_address_error_out_of_range = true;
1884+
}
18791885
}
18801886

18811887
UObjectGlobals::ForEachUObject([&](UObject* object, ...) {
@@ -3592,6 +3598,33 @@ namespace RC::GUI
35923598
ImGui::BeginDisabled();
35933599
}
35943600

3601+
// Render search by address error modals
3602+
if (m_modal_search_by_address_error_not_hex)
3603+
{
3604+
ImGui::OpenPopup("UnableToSearchByAddressNotHexError");
3605+
}
3606+
3607+
if (ImGui::BeginPopupModal("UnableToSearchByAddressNotHexError",
3608+
&m_modal_search_by_address_error_not_hex,
3609+
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize))
3610+
{
3611+
ImGui::Text("Query isn't a valid hex number.");
3612+
ImGui::EndPopup();
3613+
}
3614+
3615+
if (m_modal_search_by_address_error_out_of_range)
3616+
{
3617+
ImGui::OpenPopup("UnableToSearchByAddressOutOfRangeError");
3618+
}
3619+
3620+
if (ImGui::BeginPopupModal("UnableToSearchByAddressOutOfRangeError",
3621+
&m_modal_search_by_address_error_out_of_range,
3622+
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize))
3623+
{
3624+
ImGui::Text("Query is a hex number, but is either too big or negative.");
3625+
ImGui::EndPopup();
3626+
}
3627+
35953628
// Update this text if corresponding button's text changes. Textinput width = Spacing + Window margin + Button padding + Button text width
35963629
ImGui::PushItemWidth(-(8.0f + 16.0f + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::CalcTextSize(ICON_FA_COPY " Copy search result").x));
35973630
bool push_inactive_text_color = !m_search_field_cleared;

0 commit comments

Comments
 (0)