Skip to content

Commit

Permalink
support info hud for overworld
Browse files Browse the repository at this point in the history
  • Loading branch information
LozenChen committed Jan 8, 2025
1 parent 367b0a6 commit b74c564
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
23 changes: 18 additions & 5 deletions CelesteTAS-EverestInterop/Source/EverestInterop/InfoHUD/InfoHud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
using Monocle;
using StudioCommunication;
using TAS.Entities;
using TAS.InfoHUD;
using TAS.Input;
using TAS.Module;
using TAS.Utils;

namespace TAS.EverestInterop.InfoHUD;

// TODO show info hud on overworld
public static class InfoHud {
private static EaseInSubMenu subMenuItem;
public static Vector2 Size { get; private set; }
Expand All @@ -23,14 +21,17 @@ public static class InfoHud {
private static void Load() {
On.Celeste.Level.Render += LevelOnRender;
On.Celeste.Pico8.Emulator.Render += EmulatorOnRender;
On.Monocle.Scene.Render += SceneOnRender;
}

[Unload]
private static void Unload() {
On.Celeste.Level.Render -= LevelOnRender;
On.Celeste.Pico8.Emulator.Render -= EmulatorOnRender;
On.Monocle.Scene.Render -= SceneOnRender;
}


private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self) {
orig(self);

Expand All @@ -45,6 +46,14 @@ private static void EmulatorOnRender(On.Celeste.Pico8.Emulator.orig_Render orig,
InfoMouse.DragAndDropHud();
}

private static void SceneOnRender(On.Monocle.Scene.orig_Render orig, Scene self) {
orig(self);

if (self is Overworld) {
DrawInfo(self, drawSubpixelIndicator: false);
InfoMouse.DragAndDropHud();
}
}
public static void Toggle() {
if (Hotkeys.InfoHud.DoublePressed) {
TasSettings.InfoHud = !TasSettings.InfoHud;
Expand All @@ -58,7 +67,7 @@ public static void Toggle() {
}
}

private static void DrawInfo(Scene scene) {
private static void DrawInfo(Scene scene, bool drawSubpixelIndicator = true) {
if (!TasSettings.Enabled || !TasSettings.InfoHud) {
return;
}
Expand Down Expand Up @@ -94,7 +103,9 @@ private static void DrawInfo(Scene scene) {
float infoAlpha = 1f;

Size = JetBrainsMonoFont.Measure(text) * fontSize;
Size = InfoSubPixelIndicator.TryExpandSize(Size, padding);
if (drawSubpixelIndicator) {
Size = InfoSubPixelIndicator.TryExpandSize(Size, padding);
}

float maxX = viewWidth - Size.X - margin - padding * 2;
float maxY = viewHeight - Size.Y - margin - padding * 2;
Expand All @@ -116,7 +127,9 @@ private static void DrawInfo(Scene scene) {

Draw.Rect(bgRect, Color.Black * alpha);

InfoSubPixelIndicator.DrawIndicator(bgRect.Bottom, padding, infoAlpha);
if (drawSubpixelIndicator) {
InfoSubPixelIndicator.DrawIndicator(bgRect.Bottom, padding, infoAlpha);
}

Vector2 textPosition = new(x + padding, y + padding);
Vector2 scale = new(fontSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ public static class JetBrainsMonoFont {

public static PixelFont Font {
get {
if (Engine.Scene is Overworld) {
return null;
} else {
// try fixing a crash via use Fonts.orig_Load() instead of Fonts.Load()
// https://discord.com/channels/403698615446536203/1205319809525354537/1205319809525354537
return Fonts.Get(FontFace) ?? Fonts.orig_Load(FontFace);
}
// try fixing a crash via use Fonts.orig_Load() instead of Fonts.Load()
// https://discord.com/channels/403698615446536203/1205319809525354537/1205319809525354537
return Fonts.Get(FontFace) ?? Fonts.orig_Load(FontFace);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public static void Update(bool updateVel = false) {
ouiName = $"{oui.GetType().Name} ";
}

Status = ExactStatus = $"Overworld {ouiName}{overworld.ShowInputUI}";
Status = ExactStatus = ouiName;
} else if (scene != null) {
Status = ExactStatus = scene.GetType().Name;
}
Expand Down

0 comments on commit b74c564

Please sign in to comment.