Skip to content

Commit

Permalink
Merge pull request #419 from UE4SS-RE/live-view-implement-watch-to-fi…
Browse files Browse the repository at this point in the history
…le-for-functions

Implemented "Write to file" for UFunction watches in the watches tab & fixed a crash on shutdown
  • Loading branch information
narknon committed Mar 26, 2024
2 parents d2f6a97 + 601ec14 commit 8261a93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions UE4SS/src/GUI/LiveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,6 @@ namespace RC::GUI
}
if (auto struct_property = CastField<FStructProperty>(property); struct_property && struct_property->GetStruct()->GetFirstProperty())
{
is_watchable = false;
ImGui::SameLine();
auto tree_node_id = std::format("{}{}", static_cast<void*>(container_ptr), property_name);
if (ImGui_TreeNodeEx(std::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog))
Expand Down Expand Up @@ -1679,7 +1678,6 @@ namespace RC::GUI
}
else if (auto array_property = CastField<FArrayProperty>(property); array_property)
{
is_watchable = false;
ImGui::SameLine();
auto tree_node_id = std::format("{}{}", static_cast<void*>(container_ptr), property_name);
if (ImGui_TreeNodeEx(std::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog))
Expand Down Expand Up @@ -2695,6 +2693,11 @@ namespace RC::GUI

auto LiveView::process_function_post_watch(Unreal::UnrealScriptFunctionCallableContext& context, void*) -> void
{
if (!UnrealInitializer::StaticStorage::bIsInitialized)
{
return;
}

auto function = context.TheStack.Node();
std::lock_guard<decltype(LiveView::Watch::s_watch_lock)> lock{LiveView::Watch::s_watch_lock};
auto it = s_watch_containers.find(function);
Expand Down Expand Up @@ -2773,10 +2776,20 @@ namespace RC::GUI

buffer.append(STR("\n\n"));
watch.history.append(to_string(buffer));

if (watch.write_to_file)
{
watch.output.send(STR("{}"), buffer);
}
}

auto LiveView::process_watches() -> void
{
if (!UnrealInitializer::StaticStorage::bIsInitialized)
{
return;
}

std::lock_guard<decltype(Watch::s_watch_lock)> lock{Watch::s_watch_lock};
for (auto& watch : s_watches)
{
Expand Down
3 changes: 3 additions & 0 deletions assets/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TBD
### General

### Live View
Added support for watching ArrayProperty and StructProperty.

### UHT Dumper

Expand All @@ -41,6 +42,8 @@ Fixed BPModLoaderMod giving "bad conversion" errors.
Fixed some debug GUI layout alignments, especially with different GUI font scaling settings.

### Live View
Fixed the "Write to file" checkbox not working for functions in the `Watches` tab.
Reduced the likelihood of a crash happening on shutdown when at least one watch is enabled.

### UHT Dumper

Expand Down

0 comments on commit 8261a93

Please sign in to comment.