Skip to content

Commit

Permalink
UObjectHook: Disable key now restores visibility states (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jan 3, 2024
1 parent 9c2f7e7 commit 78125a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/mods/UObjectHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,10 +1204,15 @@ std::shared_ptr<UObjectHook::PersistentCameraState> UObjectHook::deserialize_cam
}

void UObjectHook::update_persistent_states() {
if (m_uobject_hook_disabled) {
if (m_uobject_hook_disabled && m_fixed_visibilities) {
return;
}

// For when we disable UObjectHook
utility::ScopeGuard ___{[this]() {
m_fixed_visibilities = true;
}};

// Camera state
if (m_persistent_camera_state != nullptr) {
auto obj = m_persistent_camera_state->path.resolve();
Expand Down Expand Up @@ -1276,7 +1281,11 @@ void UObjectHook::update_persistent_states() {
}

if (prop_base->hide && obj->is_a(scene_comp_t)) {
((sdk::USceneComponent*)obj)->set_visibility(false, false);
if (m_uobject_hook_disabled) {
((sdk::USceneComponent*)obj)->set_visibility(true, false);
} else {
((sdk::USceneComponent*)obj)->set_visibility(false, false);
}
}

for (const auto& prop_state : prop_base->properties) {
Expand Down Expand Up @@ -1618,6 +1627,7 @@ sdk::UObject* UObjectHook::StatePath::resolve() const {
void UObjectHook::on_frame() {
if (m_keybind_toggle_uobject_hook->is_key_down_once()) {
m_uobject_hook_disabled = !m_uobject_hook_disabled;
m_fixed_visibilities = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/mods/UObjectHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ class UObjectHook : public Mod {

ModKey::Ptr m_keybind_toggle_uobject_hook{ModKey::create(generate_name("ToggleUObjectHookKey"))};
bool m_uobject_hook_disabled{false};
bool m_fixed_visibilities{false};

ValueList m_options{
*m_enabled_at_startup,
Expand Down

0 comments on commit 78125a5

Please sign in to comment.