Skip to content

Commit 131118a

Browse files
Merge pull request EXOK#58 from psyGamer/dynamic-resolution
Add dynamic resolution support
2 parents 1e4e82e + 07a71c5 commit 131118a

File tree

11 files changed

+89
-56
lines changed

11 files changed

+89
-56
lines changed

Source/Actors/Cutscene.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ public override void Update()
204204

205205
public virtual void RenderUI(Batcher batch, Rect bounds)
206206
{
207-
const float BarSize = 40 * Game.RelativeScale;
208-
const float PortraitSize = 128 * Game.RelativeScale;
209-
const float TopOffset = 100 * Game.RelativeScale;
210-
const float EaseOffset = 32 * Game.RelativeScale;
211-
const float Padding = 8 * Game.RelativeScale;
207+
float BarSize = 40 * Game.RelativeScale;
208+
float PortraitSize = 128 * Game.RelativeScale;
209+
float TopOffset = 100 * Game.RelativeScale;
210+
float EaseOffset = 32 * Game.RelativeScale;
211+
float Padding = 8 * Game.RelativeScale;
212212

213213
batch.Rect(new Rect(bounds.X, bounds.Y, bounds.Width, BarSize * Ease), Color.Black);
214214
batch.Rect(new Rect(bounds.X, bounds.Bottom - BarSize * Ease, bounds.Width, BarSize * Ease), Color.Black);

Source/Data/Assets.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Celeste64;
88

99
public static class Assets
1010
{
11-
public const float FontSize = Game.RelativeScale * 16;
11+
public static float FontSize => Game.RelativeScale * 16;
1212
public const string AssetFolder = "Content";
1313

1414
public const string MapsFolder = "Maps";

Source/Data/Language.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void Use()
110110
}
111111

112112
spriteFont = new SpriteFont(Assets.Fonts[Font], Assets.FontSize, codepoints.ToArray());
113+
Game.OnResolutionChanged += () => spriteFont = new SpriteFont(Assets.Fonts[Font], Assets.FontSize, codepoints.ToArray());
113114
}
114115

115116
public void Absorb(Language other, GameMod mod)

Source/Game.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,42 @@ private enum TransitionStep
4040
public const string GamePath = "Celeste64";
4141
// ModloaderCustom
4242
public const string GameTitle = "Celeste 64: Fragments of the Mountain + Fuji Mod Loader";
43-
public const int Width = 640;
44-
public const int Height = 360;
4543
public static readonly Version GameVersion = typeof(Game).Assembly.GetName().Version!;
4644
public static readonly string VersionString = $"Celeste 64: v.{GameVersion.Major}.{GameVersion.Minor}.{GameVersion.Build}";
4745
public static string LoaderVersion { get; set; } = "";
46+
47+
public const int DefaultWidth = 640;
48+
public const int DefaultHeight = 360;
49+
50+
public static event Action OnResolutionChanged;
51+
52+
private static float _resolutionScale = 1.0f;
53+
public static float ResolutionScale
54+
{
55+
get => _resolutionScale;
56+
set
57+
{
58+
if (_resolutionScale == value)
59+
return;
60+
61+
_resolutionScale = value;
62+
OnResolutionChanged.Invoke();
63+
}
64+
}
65+
66+
public static int Width => (int)(DefaultWidth * _resolutionScale);
67+
public static int Height => (int)(DefaultHeight * _resolutionScale);
4868

4969
/// <summary>
5070
/// Used by various rendering elements to proportionally scale if you change the default game resolution
5171
/// </summary>
52-
public const float RelativeScale = Height / 360.0f;
72+
public static float RelativeScale => _resolutionScale;
5373

5474
private static Game? instance;
5575
public static Game Instance => instance ?? throw new Exception("Game isn't running");
5676

5777
private readonly Stack<Scene> scenes = new();
58-
private readonly Target target = new(Width, Height, [TextureFormat.Color, TextureFormat.Depth24Stencil8]);
78+
private Target target = new(Width, Height, [TextureFormat.Color, TextureFormat.Depth24Stencil8]);
5979
private readonly Batcher batcher = new();
6080
private Transition transition;
6181
private TransitionStep transitionStep = TransitionStep.None;
@@ -78,6 +98,12 @@ private enum TransitionStep
7898

7999
public Game()
80100
{
101+
OnResolutionChanged += () =>
102+
{
103+
target.Dispose();
104+
target = new(Width, Height, [TextureFormat.Color, TextureFormat.Depth24Stencil8]);
105+
};
106+
81107
// If this isn't stored, the delegate will get GC'd and everything will crash :)
82108
audioEventCallback = MusicTimelineCallback;
83109
imGuiManager = new ImGuiManager();

Source/Helpers/Menu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ namespace Celeste64;
33

44
public class Menu
55
{
6-
public const float Spacing = 4 * Game.RelativeScale;
7-
public const float SpacerHeight = 12 * Game.RelativeScale;
6+
public static float Spacing => 4 * Game.RelativeScale;
7+
public static float SpacerHeight => 12 * Game.RelativeScale;
88
public const float TitleScale = 0.75f;
99

1010
public abstract class Item

Source/Helpers/UI.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ namespace Celeste64;
33

44
public static class UI
55
{
6-
public const float IconSize = 30 * Game.RelativeScale;
7-
public const float PromptSize = 28 * Game.RelativeScale;
6+
public static float IconSize => 30 * Game.RelativeScale;
7+
public static float PromptSize => 28 * Game.RelativeScale;
88

99
public static void Text(Batcher batch, string text, in Vec2 at, in Vec2 justify, in Color color)
1010
{
1111
var font = Language.Current.SpriteFont;
1212
for (int x = -1; x <= 1; x++)
1313
for (int y = -1; y <= 3; y++)
14-
batch.Text(font, text, at + new Vec2(x, y), justify, Color.Black);
14+
if (x != 0 || y != 0)
15+
batch.Text(font, text, at + new Vec2(x, y) * Game.RelativeScale, justify, Color.Black);
1516
batch.Text(font, text, at, justify, color);
1617
}
1718

@@ -35,7 +36,7 @@ public static void Icon(Batcher batch, Subtexture icon, string label, in Vec2 at
3536
for (int x = -1; x <= 1; x++)
3637
for (int y = -1; y <= 1; y++)
3738
if (x != 0 || y != 0)
38-
batch.ImageFit(icon, new Rect(pos.X + x, pos.Y + y, size, size), Vec2.One * 0.50f, Color.Black, false, false);
39+
batch.ImageFit(icon, new Rect(pos.X + x * Game.RelativeScale, pos.Y + y * Game.RelativeScale, size, size), Vec2.One * 0.50f, Color.Black, false, false);
3940
batch.ImageFit(icon, new Rect(pos.X, pos.Y, size, size), Vec2.One * 0.50f, Color.White, false, false);
4041

4142
Text(batch, label, new Vec2(pos.X + iconAdvance, pos.Y + size / 2), new Vec2(0, 0.5f), Color.White);

Source/Mod/Menu/ModInfoMenu.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ namespace Celeste64.Mod;
22

33
public class ModInfoMenu : Menu
44
{
5-
public const int CardWidth = (int)(480 * Game.RelativeScale);
6-
public const int CardHeight = (int)(320 * Game.RelativeScale);
7-
public readonly Target Target;
5+
public Target Target;
86

97
Subtexture postcardImage;
108
Subtexture stampImage;
@@ -18,11 +16,13 @@ public class ModInfoMenu : Menu
1816

1917
internal ModInfoMenu(Menu? rootMenu)
2018
{
19+
Target = new Target(Overworld.CardWidth, Overworld.CardHeight);
20+
Game.OnResolutionChanged += () => Target = new Target(Overworld.CardWidth, Overworld.CardHeight);
21+
2122
RootMenu = rootMenu;
2223
postcardImage = new(Assets.Textures["postcards/back-empty"]);
2324
stampImage = Assets.Subtextures["stamp"];
2425
strawberryImage = Assets.Subtextures["icon_strawberry"];
25-
Target = new Target(CardWidth, CardHeight);
2626

2727
modOptionsMenu = new ModOptionsMenu(rootMenu);
2828

@@ -149,8 +149,8 @@ protected override void RenderItems(Batcher batch)
149149
var scale = MathF.Max(bounds.Width / postcardImage.Width, bounds.Height / postcardImage.Height);
150150
var size = new Vec2(postcardImage.Width, postcardImage.Height);
151151
batch.Image(postcardImage, bounds.TopLeft, size / 2, Vec2.One * scale, 0, Color.White);
152-
batch.Text(font, $"{Mod.ModInfo.Name}\nBy: {Mod.ModInfo.ModAuthor ?? "Unknown"}\nv.{Mod.ModInfo.Version}", bounds.TopLeft - size / 4 + new Vec2(16, 12) * Game.RelativeScale, Color.Black * 0.7f);
153-
batch.PushMatrix(Matrix3x2.CreateScale(.7f) * Matrix3x2.CreateTranslation(bounds.TopLeft - size / 4 + new Vec2(14, 72) * Game.RelativeScale));
152+
batch.Text(font, $"{Mod.ModInfo.Name}\nBy: {Mod.ModInfo.ModAuthor ?? "Unknown"}\nv.{Mod.ModInfo.Version}", bounds.TopLeft + (-size / 4 + new Vec2(16, 12)) * Game.RelativeScale, Color.Black * 0.7f);
153+
batch.PushMatrix(Matrix3x2.CreateScale(.7f) * Matrix3x2.CreateTranslation(bounds.TopLeft + (-size / 4 + new Vec2(14, 72)) * Game.RelativeScale));
154154
batch.Text(font, GenerateModDescription(Mod.ModInfo.Description ?? "", 40, 15), Vec2.Zero, Color.Black);
155155
batch.PopMatrix();
156156

@@ -161,10 +161,10 @@ protected override void RenderItems(Batcher batch)
161161
Vec2 imageSize = new Vec2(imgSizeMin / image.Width, imgSizeMin / image.Height);
162162
Vec2 stampPos = bounds.TopLeft - (new Vec2(imgSizeMin, imgSizeMin) * imgScale) / 2 + new Vec2(size.X / 5.5f, -size.Y / 4.7f);
163163
Vec2 pos = bounds.TopLeft - (new Vec2(imgSizeMin, imgSizeMin) * imgScale) / 2 + new Vec2(size.X / 5.05f, -size.Y / 5.3f);
164-
batch.Image(stampImage, stampPos + new Vec2(imgSizeMin, imgSizeMin) * imgScale * 0.05f, stampImageSize * imgScale, stampImageSize * imgScale * 1.3f, 0, Color.White);
165-
batch.Image(image, pos + new Vec2(imgSizeMin, imgSizeMin) * imgScale * 0.05f, imageSize * imgScale, imageSize * imgScale, 0, Color.White);
164+
batch.Image(stampImage, (stampPos + new Vec2(imgSizeMin, imgSizeMin) * imgScale * 0.05f) * Game.RelativeScale, stampImageSize * imgScale * Game.RelativeScale, stampImageSize * imgScale * 1.3f * Game.RelativeScale, 0, Color.White);
165+
batch.Image(image, (pos + new Vec2(imgSizeMin, imgSizeMin) * imgScale * 0.05f) * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, 0, Color.White);
166166

167-
batch.PushMatrix(Matrix3x2.CreateScale(1.0f) * Matrix3x2.CreateTranslation(bounds.TopLeft + new Vec2(size.X / 6.8f, -size.Y/20)));
167+
batch.PushMatrix(Matrix3x2.CreateScale(1.0f) * Matrix3x2.CreateTranslation(bounds.TopLeft + new Vec2(size.X / 6.8f, -size.Y / 20) * Game.RelativeScale));
168168
base.RenderItems(batch);
169169
batch.PopMatrix();
170170
}

Source/Mod/Menu/ModSelectionMenu.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ namespace Celeste64.Mod;
22

33
public class ModSelectionMenu : Menu
44
{
5-
public const int CardWidth = (int)(480 * Game.RelativeScale);
6-
public const int CardHeight = (int)(320 * Game.RelativeScale);
7-
public readonly Target Target;
5+
public Target Target;
86

97
private int currentPage = 0;
108
private int currentRow = 0;
@@ -26,11 +24,14 @@ public class ModSelectionMenu : Menu
2624

2725
internal ModSelectionMenu(Menu? rootMenu)
2826
{
27+
Target = new Target(Overworld.CardWidth, Overworld.CardHeight);
28+
Game.OnResolutionChanged += () => Target = new Target(Overworld.CardWidth, Overworld.CardHeight);
29+
2930
RootMenu = rootMenu;
3031
postcardImage = new(Assets.Textures["postcards/back-empty"]);
3132
strawberryImage = Assets.Subtextures["icon_strawberry"];
32-
Target = new Target(CardWidth, CardHeight);
3333
mods = ModManager.Instance.Mods.Where(mod => mod is not VanillaGameMod).ToArray();
34+
3435
modInfoMenu = new ModInfoMenu(rootMenu);
3536

3637
FailedToLoadModsMenu = new Menu(rootMenu);
@@ -68,9 +69,9 @@ private void RenderMod(Batcher batch, GameMod mod, Vec2 pos, Vec2 size)
6869
float imgScale = 0.7f;
6970
Subtexture image = mod.Subtextures.TryGetValue(mod.ModInfo.Icon ?? "", out Subtexture value) ? value : strawberryImage;
7071
Vec2 imageSize = new Vec2(size.X / image.Width, size.Y / image.Height);
71-
batch.Rect(pos - (size * imgScale) / 2, size * imgScale, Color.White);
72-
batch.Image(image, pos - (size * imgScale) / 2, imageSize * imgScale, imageSize * imgScale, 0, mod.Enabled ? Color.White : Color.Gray);
73-
batch.PushMatrix(Matrix3x2.CreateScale(.6f) * Matrix3x2.CreateTranslation(pos + new Vec2(0, size.Y * 0.4f)));
72+
batch.Rect((pos - (size * imgScale) / 2) * Game.RelativeScale, size * imgScale * Game.RelativeScale, Color.White);
73+
batch.Image(image, (pos - (size * imgScale) / 2) * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, 0, mod.Enabled ? Color.White : Color.Gray);
74+
batch.PushMatrix(Matrix3x2.CreateScale(.6f) * Matrix3x2.CreateTranslation((pos + new Vec2(0, size.Y * 0.4f)) * Game.RelativeScale));
7475
batch.Text(Language.Current.SpriteFont, GenerateModName(mod.ModInfo.Name ?? "", 16, 2), Vec2.Zero, new Vec2(0.5f, 0), Color.Black * 0.7f);
7576
batch.PopMatrix();
7677
}
@@ -80,9 +81,9 @@ private void RenderCurrentMod(Batcher batch, GameMod mod, Vec2 pos, Vec2 size)
8081
float imgScale = 0.8f;
8182
Subtexture image = mod.Subtextures.TryGetValue(mod.ModInfo.Icon ?? "", out Subtexture value) ? value : strawberryImage;
8283
Vec2 imageSize = new Vector2(size.X / image.Width, size.Y / image.Height);
83-
batch.Rect(pos - (size * imgScale) / 2, size * imgScale, Color.LightGray);
84-
batch.Image(image, pos - (size * imgScale) / 2, imageSize * imgScale, imageSize * imgScale, 0, mod.Enabled ? Color.White : Color.Gray);
85-
batch.PushMatrix(Matrix3x2.CreateScale(.7f) * Matrix3x2.CreateTranslation(pos + new Vec2(0, size.Y * 0.4f)));
84+
batch.Rect((pos - (size * imgScale) / 2) * Game.RelativeScale, size * imgScale * Game.RelativeScale, Color.LightGray);
85+
batch.Image(image, (pos - (size * imgScale) / 2) * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, imageSize * imgScale * Game.RelativeScale, 0, mod.Enabled ? Color.White : Color.Gray);
86+
batch.PushMatrix(Matrix3x2.CreateScale(.7f) * Matrix3x2.CreateTranslation((pos + new Vec2(0, size.Y * 0.4f)) * Game.RelativeScale));
8687
batch.Text(Language.Current.SpriteFont, GenerateModName(mod.ModInfo.Name ?? "", 16, 2), Vec2.Zero, new Vec2(0.5f, 0), mod.Enabled ? Color.Black : Color.Black * 0.7f);
8788
batch.PopMatrix();
8889
}

Source/Scenes/Overworld.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ namespace Celeste64;
44

55
public class Overworld : Scene
66
{
7-
public const int CardWidth = (int)(480 * Game.RelativeScale);
8-
public const int CardHeight = (int)(320 * Game.RelativeScale);
7+
public const int DefaultCardWidth = 480;
8+
public const int DefaultCardHeight = 320;
9+
public static int CardWidth => (int)(DefaultCardWidth * Game.RelativeScale);
10+
public static int CardHeight => (int)(DefaultCardHeight * Game.RelativeScale);
11+
912
public bool Paused;
1013
public Menu? pauseMenu;
1114

1215
public class Entry
1316
{
1417
public readonly LevelInfo Level;
15-
public readonly Target Target;
18+
public Target Target;
1619
public readonly Subtexture Image;
1720
public readonly Menu Menu;
1821
public readonly bool Complete = false;
@@ -24,6 +27,7 @@ public Entry(LevelInfo level, GameMod mod)
2427
{
2528
Level = level;
2629
Target = new Target(CardWidth, CardHeight);
30+
Game.OnResolutionChanged += () => Target = new Target(CardWidth, CardHeight);
2731

2832
// Postcards should always come from the current mod if they are available
2933
if (mod != null && mod.Textures.ContainsKey(level.Preview))
@@ -53,7 +57,7 @@ public Entry(LevelInfo level, GameMod mod)
5357

5458
public void Redraw(Batcher batch, float shine)
5559
{
56-
const float Padding = 16 * Game.RelativeScale;
60+
float Padding = 16 * Game.RelativeScale;
5761

5862
Target.Clear(Color.Transparent);
5963
batch.SetSampler(new(TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge));
@@ -75,7 +79,7 @@ public void Redraw(Batcher batch, float shine)
7579
{
7680
batch.Image(
7781
new Subtexture(texture),
78-
bounds.BottomRight - new Vec2(50, 0),
82+
bounds.BottomRight - new Vec2(50, 0) * Game.RelativeScale,
7983
new Vec2(texture.Width / 2, texture.Height),
8084
Vec2.One * 0.50f, 0, Color.White);
8185
}
@@ -104,9 +108,9 @@ public void Redraw(Batcher batch, float shine)
104108
time = record.Time;
105109
}
106110

107-
UI.Strawberries(batch, strawbs, new Vec2(-8, -UI.IconSize / 2 - 4), 1);
108-
UI.Deaths(batch, deaths, new Vec2(8, -UI.IconSize / 2 - 4), 0);
109-
UI.Timer(batch, time, new Vec2(0, UI.IconSize / 2 + 4), 0.5f);
111+
UI.Strawberries(batch, strawbs, new Vec2(-8 * Game.RelativeScale, -UI.IconSize / 2 - 4 * Game.RelativeScale), 1);
112+
UI.Deaths(batch, deaths, new Vec2(8 * Game.RelativeScale, -UI.IconSize / 2 - 4 * Game.RelativeScale), 0);
113+
UI.Timer(batch, time, new Vec2(0 * Game.RelativeScale, UI.IconSize / 2 + 4 * Game.RelativeScale), 0.5f);
110114
}
111115
batch.PopMatrix();
112116

@@ -117,13 +121,13 @@ public void Redraw(Batcher batch, float shine)
117121
if (shine > 0)
118122
{
119123
batch.Line(
120-
bounds.BottomLeft + new Vec2(-50 + shine * 50, 50),
121-
bounds.TopCenter + new Vec2(shine * 50, -50), 120,
124+
bounds.BottomLeft + new Vec2(-50 + shine * 50, 50) * Game.RelativeScale,
125+
bounds.TopCenter + new Vec2(shine * 50, -50) * Game.RelativeScale, 120 * Game.RelativeScale,
122126
Color.White * shine * 0.30f);
123127

124128
batch.Line(
125-
bounds.BottomLeft + new Vec2(-50 + 100 + shine * 120, 50),
126-
bounds.TopCenter + new Vec2(100 + shine * 120, -50), 70,
129+
bounds.BottomLeft + new Vec2(-50 + 100 + shine * 120, 50) * Game.RelativeScale,
130+
bounds.TopCenter + new Vec2(100 + shine * 120, -50) * Game.RelativeScale, 70 * Game.RelativeScale,
127131
Color.White * shine * 0.30f);
128132
}
129133

@@ -164,8 +168,8 @@ public Overworld(bool startOnLastSelected)
164168
}
165169
}
166170

167-
var cardWidth = CardWidth / 6.0f / Game.RelativeScale;
168-
var cardHeight = CardHeight / 6.0f / Game.RelativeScale;
171+
var cardWidth = DefaultCardWidth / 6.0f;
172+
var cardHeight = DefaultCardHeight / 6.0f;
169173

170174
mesh.SetVertices<SpriteVertex>([
171175
new(new Vec3(-cardWidth, 0, -cardHeight) / 2, new Vec2(0, 0), Color.White),

Source/Scenes/World.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ public override void Render(Target target)
879879
Camera.Target.Clear(Color.Black, 1, 0, ClearMask.Depth);
880880

881881
batch.Rect(Camera.Target.Bounds, Color.Black * 0.90f);
882-
batch.Image(img, Camera.Target.Bounds.Center, orig, Vec2.One, 0, Color.White);
882+
batch.Image(img, Camera.Target.Bounds.Center, orig, Vec2.One * Game.RelativeScale, 0, Color.White);
883883
batch.Render(Camera.Target);
884884
batch.Clear();
885885

@@ -920,11 +920,11 @@ public override void Render(Target target)
920920

921921
// stats
922922
{
923-
var at = bounds.TopLeft + new Vec2(4, 8);
923+
var at = bounds.TopLeft + new Vec2(4, 8) * Game.RelativeScale;
924924
if (IsInEndingArea || Save.Instance.SpeedrunTimer)
925925
{
926926
UI.Timer(batch, Save.CurrentRecord.Time, at);
927-
at.Y += UI.IconSize + 4;
927+
at.Y += UI.IconSize + 4 * Game.RelativeScale;
928928
}
929929

930930
if (strawbCounterEase > 0)
@@ -972,7 +972,7 @@ private void ApplyPostEffects()
972972
// perform post processing effects
973973
if (Camera.Target != null)
974974
{
975-
if (postTarget == null || postTarget.Width < Camera.Target.Width || postTarget.Height < Camera.Target.Height)
975+
if (postTarget == null || postTarget.Width != Camera.Target.Width || postTarget.Height != Camera.Target.Height)
976976
{
977977
postTarget?.Dispose();
978978
postTarget = new(Camera.Target.Width, Camera.Target.Height);
@@ -986,7 +986,7 @@ private void ApplyPostEffects()
986986
if (postMaterial.Shader?.Has("u_depth") ?? false)
987987
postMaterial.Set("u_depth", Camera.Target.Attachments[1]);
988988
if (postMaterial.Shader?.Has("u_pixel") ?? false)
989-
postMaterial.Set("u_pixel", new Vec2(1.0f / postCam.Target.Width, 1.0f / postCam.Target.Height));
989+
postMaterial.Set("u_pixel", new Vec2(1.0f / postCam.Target.Width * Game.RelativeScale, 1.0f / postCam.Target.Height * Game.RelativeScale));
990990
if (postMaterial.Shader?.Has("u_edge") ?? false)
991991
postMaterial.Set("u_edge", new Color(0x110d33));
992992
batch.PushMaterial(postMaterial);

Source/Screenwipes/SpotlightWipe.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class SpotlightWipe : ScreenWipe
66
public Vec2? FocusPoint;
77
public float Modifier = 0;
88
public bool Linear = false;
9-
private const float SmallCircleRadius = 96 * Game.RelativeScale;
9+
private static float SmallCircleRadius => 96 * Game.RelativeScale;
1010
private const float EaseDuration = 1.2f;
1111
private const float EaseOpenPercent = 0.3f; // how long (in percent) it eases the small circle open
1212
private const float EaseClosePercent = 0.3f; // how long (in percent) it eases the entire screen
@@ -60,7 +60,7 @@ public override void Render(Batcher batch, Rect bounds)
6060
public static void DrawSpotlight(Batcher batch, Vec2 position, float radius)
6161
{
6262
var lastAngle = new Vec2(1, 0);
63-
var steps = 256;
63+
int steps = (int)(256 * Game.RelativeScale);
6464

6565
for (int i = 0; i < steps; i += 12)
6666
{

0 commit comments

Comments
 (0)