Skip to content

Commit

Permalink
Merge pull request #220 from UE4SS-RE/live-view-enum-nice-name
Browse files Browse the repository at this point in the history
Made enum values use their display name when appropriate in the live tab
  • Loading branch information
UE4SS authored Oct 16, 2023
2 parents 4634348 + 33e0409 commit d991abc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions UE4SS/src/GUI/LiveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <DynamicOutput/DynamicOutput.hpp>
#include <ExceptionHandling.hpp>
#include <Constructs/Views/EnumerateView.hpp>
#include <GUI/GUI.hpp>
#include <GUI/ImGuiUtility.hpp>
#include <GUI/LiveView.hpp>
Expand All @@ -32,6 +33,8 @@
#include <Unreal/Property/FArrayProperty.hpp>
#include <Unreal/Property/FBoolProperty.hpp>
#include <Unreal/Property/FObjectProperty.hpp>
#include <Unreal/Property/FEnumProperty.hpp>
#include <Unreal/Property/NumericPropertyTypes.hpp>
#include <Unreal/UClass.hpp>
#include <Unreal/UEnum.hpp>
#include <Unreal/UFunction.hpp>
Expand Down Expand Up @@ -1385,6 +1388,32 @@ namespace RC::GUI
}
render_property_value_context_menu(tree_node_id);
}
else if (property->IsA<FEnumProperty>() || property->IsA<FByteProperty>())
{
UEnum* uenum{};
if (property->IsA<FByteProperty>())
{
uenum = static_cast<FByteProperty*>(property)->GetEnum();
}
else
{
uenum = static_cast<FEnumProperty*>(property)->GetEnum();
}
auto value_raw = *std::bit_cast<uint8*>(container_ptr);
uint8 enum_index{};
for (const auto& [key_value_pair, index] : uenum->ForEachName() | views::enumerate)
{
if (key_value_pair.Value == value_raw)
{
enum_index = index;
break;
}
}
auto value_as_string = Unreal::UKismetNodeHelperLibrary::GetEnumeratorUserFriendlyName(uenum, enum_index);
ImGui::SameLine();
ImGui::Text("%S", value_as_string.c_str());
render_property_value_context_menu();
}
else
{
ImGui::SameLine();
Expand Down

0 comments on commit d991abc

Please sign in to comment.