Skip to content
Merged
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
32 changes: 24 additions & 8 deletions Source/FunctionalZoomOutModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Celeste.Mod.FunctionalZoomOut;
using Celeste.Mod.FunctionalZoomOut.Interop;
using MonoMod.ModInterop;

namespace Celeste.Mod.FunctionalZoomOut;

public class FunctionalZoomOutModule : EverestModule {

Expand Down Expand Up @@ -31,6 +34,8 @@ public override void Load() {
HookHelper.Initialize(typeof(FunctionalZoomOutModule).Assembly);
HookHelper.LoadTag("loader");

typeof(MotionSmoothingImports).ModInterop();

Everest.Events.Level.OnLoadEntity += Event_OnLoadEntity;
}

Expand Down Expand Up @@ -141,13 +146,19 @@ public static float GetFixedHDUpscale(float orig) {
public static float GetFixedCameraSizePadded(float orig, int padding) => GetFixedCameraSize(orig - padding) + padding;
public static int GetFixedCameraSizeIntPadded(int orig, int padding) => (int)GetFixedCameraSize(orig - padding) + padding;

public static void EnsureBufferDimensions(VirtualRenderTarget target, int padding = 0) {
if (target is null || target.IsDisposed || (target.Width + padding == GameplayBufferWidth + padding && target.Height + padding == GameplayBufferHeight + padding))
return;
public static bool EnsureBufferDimensions(VirtualRenderTarget target, int padding = 0) {
if (target == null)
return false;

target = MotionSmoothingImports.GetResizableBuffer?.Invoke(target) ?? target;

if (target.IsDisposed || (target.Width + padding == GameplayBufferWidth + padding && target.Height + padding == GameplayBufferHeight + padding))
return false;

target.Width = GameplayBufferWidth + padding;
target.Height = GameplayBufferHeight + padding;
target.Reload();
return true;
}

#endregion
Expand Down Expand Up @@ -304,18 +315,23 @@ private static void Level_LoadLevel(On.Celeste.Level.orig_LoadLevel orig, Level
}

private static void EnsureVanillaBuffers() {
EnsureBufferDimensions(GameplayBuffers.Gameplay);
EnsureBufferDimensions(GameplayBuffers.Level);
bool needToReloadLargeTextures = false;

needToReloadLargeTextures |= EnsureBufferDimensions(GameplayBuffers.Gameplay);
needToReloadLargeTextures |= EnsureBufferDimensions(GameplayBuffers.Level);
EnsureBufferDimensions(GameplayBuffers.Light);
EnsureBufferDimensions(GameplayBuffers.Displacement);
EnsureBufferDimensions(GameplayBuffers.ResortDust);
EnsureBufferDimensions(GameplayBuffers.TempA);
EnsureBufferDimensions(GameplayBuffers.TempB);
needToReloadLargeTextures |= EnsureBufferDimensions(GameplayBuffers.TempA);
needToReloadLargeTextures |= EnsureBufferDimensions(GameplayBuffers.TempB);
// ??
EnsureBufferDimensions(GameplayBuffers.MirrorSources, 64);
EnsureBufferDimensions(GameplayBuffers.MirrorMasks, 64);

UpdateEffectSwap();

if (needToReloadLargeTextures)
MotionSmoothingImports.ReloadLargeTextures?.Invoke();
}

#endregion
Expand Down
11 changes: 11 additions & 0 deletions Source/Interop/MotionSmoothingImports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MonoMod.ModInterop;

namespace Celeste.Mod.FunctionalZoomOut.Interop;

[ModImportName("MotionSmoothing")]
public static class MotionSmoothingImports
{
public static Func<VirtualRenderTarget, VirtualRenderTarget> GetResizableBuffer;

public static Action ReloadLargeTextures;
}
5 changes: 4 additions & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
- Name: ZoomOutHelperPrototype
Version: 0.2.0
Version: 0.2.1
DLL: bin/FunctionalZoomOut.dll
Dependencies:
- Name: EverestCore
Version: 1.5577.0
OptionalDependencies:
- Name: MotionSmoothing
Version: 1.3.2
Loading