From b8ee9b0ece35ac009e7919dc8ba107a2f7a5d5ae Mon Sep 17 00:00:00 2001 From: Ramen2X <64166386+Ramen2X@users.noreply.github.com> Date: Thu, 12 Jan 2023 11:36:47 -0500 Subject: [PATCH] patch: add random option for transition animation --- lib/hooks.cpp | 11 +++++++++-- src/patchgrid.cpp | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/hooks.cpp b/lib/hooks.cpp index ca99d90..63c96f8 100644 --- a/lib/hooks.cpp +++ b/lib/hooks.cpp @@ -740,6 +740,8 @@ _CRTIMP size_t __cdecl InterceptFread(void *buffer, size_t size, size_t count, F startTransitionFunction startTransitionOriginal = NULL; MxResult MxTransitionManager::InterceptStartTransition(TransitionType animationType, int speed, byte unk, bool playMusicInTransition) { + speed = config.GetInt("TransitionSpeed"); + std::string animation_type = config.GetString("TransitionType"); if (animation_type == "No Animation") { @@ -752,9 +754,14 @@ MxResult MxTransitionManager::InterceptStartTransition(TransitionType animationT animationType = VERTICAL_WIPE; } else if (animation_type == "Window") { animationType = WINDOW; + } else if (animation_type == "Random") { + animationType = (TransitionType)(rand() % 4 + 2); + // The Pixelation animation runs much faster by nature than the other animations, + // this magic is to make the speed inconsistency feel less jarring + if (animationType == PIXELATION && speed < 30) { + speed += 25; + } } - speed = config.GetInt(_T("TransitionSpeed")); - return (this->*startTransitionOriginal)(animationType, speed, unk, playMusicInTransition); } diff --git a/src/patchgrid.cpp b/src/patchgrid.cpp index 8e49ed4..94d6fdc 100644 --- a/src/patchgrid.cpp +++ b/src/patchgrid.cpp @@ -188,6 +188,7 @@ PatchGrid::PatchGrid() animationList.push_back("Pixelation"); animationList.push_back("Vertical Wipe"); animationList.push_back("Window"); + animationList.push_back("Random"); AddPatch("TransitionType", "Change LEGO Island's transition animation.", AddComboItem(sectionGraphics, "Transition Type", animationList, 2));