Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/API/OpenAnimationReplacerAPI-Animations.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ namespace OAR_API::Animations
/// </summary>
/// <param name="a_refr">The refr to clear related condition state data for.</param>
virtual void ClearConditionStateData(RE::TESObjectREFR* a_refr) noexcept = 0;

/// <summary>
/// Reloads all animations and mod configurations.
/// </summary>
virtual void ReloadAnimations() noexcept = 0;
};

using IAnimationsInterface = IAnimationsInterface1;
Expand Down
4 changes: 4 additions & 0 deletions src/Jobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ namespace Jobs
}
}
}
void ReloadAnimationsJob::Run()
{
OpenAnimationReplacer::GetSingleton().ReloadAnimations();
}
}
5 changes: 5 additions & 0 deletions src/Jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,9 @@ namespace Jobs
replacerMod->RemoveConditionPreset(conditionPresetName);
}
};

struct ReloadAnimationsJob : GenericJob
{
void Run() override;
};
}
4 changes: 4 additions & 0 deletions src/ModAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace OAR_API
{
OpenAnimationReplacer::GetSingleton().ClearConditionStateDataForRefr(a_refr);
}
void AnimationsInterface::ReloadAnimations() noexcept
{
OpenAnimationReplacer::GetSingleton().QueueJob<Jobs::ReloadAnimationsJob>();
}
}

namespace Conditions
Expand Down
1 change: 1 addition & 0 deletions src/ModAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace OAR_API
[[nodiscard]] ReplacementAnimationInfo GetCurrentReplacementAnimationInfo(RE::hkbClipGenerator* a_clipGenerator) noexcept override;
void ClearConditionStateData(RE::hkbClipGenerator* a_clipGenerator) noexcept override;
void ClearConditionStateData(RE::TESObjectREFR* a_refr) noexcept override;
void ReloadAnimations() noexcept override;

private:
AnimationsInterface() = default;
Expand Down
17 changes: 17 additions & 0 deletions src/OpenAnimationReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,23 @@ void OpenAnimationReplacer::ForEachSortedReplacerMod(const std::function<void(Re
}
}

void OpenAnimationReplacer::ReloadAnimations()
{
_replacerMods.clear();
_legacyReplacerMod.reset();
_replacerModNameMap.clear();
_animationPathToSubModsMap.clear();
_processedDatas.clear();
_replacerProjectDatas.clear();
_activeClips.clear();
_activeSynchronizedAnimations.clear();
_activeScenelessSynchronizedClips.clear();
_clipsPendingNonAnnotationTriggersRemoval.clear();
_activeAnimationPreviews.clear();

CreateReplacerMods();
}

void OpenAnimationReplacer::SetSynchronizedClipsIDOffset(RE::hkbCharacterStringData* a_stringData, uint16_t a_offset)
{
if (const auto search = _replacerProjectDatas.find(a_stringData); search != _replacerProjectDatas.end()) {
Expand Down
1 change: 1 addition & 0 deletions src/OpenAnimationReplacer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class OpenAnimationReplacer : public IStateDataContainerHolder
void ForEachReplacerProjectData(const std::function<void(RE::hkbCharacterStringData*, ReplacerProjectData*)>& a_func) const;
void ForEachReplacerMod(const std::function<void(ReplacerMod*)>& a_func) const;
void ForEachSortedReplacerMod(const std::function<void(ReplacerMod*)>& a_func) const;
void ReloadAnimations();

void SetSynchronizedClipsIDOffset(RE::hkbCharacterStringData* a_stringData, uint16_t a_offset);
[[nodiscard]] uint16_t GetSynchronizedClipsIDOffset(RE::hkbCharacterStringData* a_stringData) const;
Expand Down
8 changes: 8 additions & 0 deletions src/UI/UIMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,14 @@ namespace UI
}
ImGui::SameLine();
UICommon::HelpMarker("Enable to increase the animation limit to double the default value. Should generally work fine, but I might have missed some places to patch in the game code so this is still considered to be experimental. There's no benefit in enabling this if you're not going over the limit.");
ImGui::Spacing();
ImGui::Separator();

if (ImGui::Button("Reload animations")) {
OpenAnimationReplacer::GetSingleton().QueueJob<Jobs::ReloadAnimationsJob>();
}
ImGui::SameLine();
UICommon::HelpMarker("Reload all animations mod config");
}

ImGui::End();
Expand Down