Skip to content

Commit

Permalink
feat: show subpixel indicator in pico8
Browse files Browse the repository at this point in the history
  • Loading branch information
DemoJameson committed Sep 25, 2023
1 parent e3c2aff commit 2e5f8c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
14 changes: 5 additions & 9 deletions CelesteTAS-EverestInterop/Source/EverestInterop/DesyncFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,14 @@ private static void PreventEmoteMod(ILCursor ilCursor, ILContext ilContext) {
ins => ins.OpCode == OpCodes.Callvirt,
ins => ins.OpCode == OpCodes.Callvirt && ins.Operand.ToString().Contains("::get_Count()")
)) {
object getSettings = ilCursor.Next.Operand;
object getEmoteWheelBindingSettings = ilCursor.Next.Next.Operand;
ilCursor.Index += 4;
ilCursor
.Emit(OpCodes.Call, getSettings)
.Emit(OpCodes.Callvirt, getEmoteWheelBindingSettings)
.EmitDelegate(IsEmoteWheelBindingPressed);
ilCursor.Index += 2;
ilCursor.Emit(OpCodes.Dup);
ilCursor.Index += 2;
ilCursor.EmitDelegate(IsEmoteWheelBindingPressed);
}

}

private static int IsEmoteWheelBindingPressed(int count, ButtonBinding binding) {
private static int IsEmoteWheelBindingPressed(ButtonBinding binding, int count) {
return binding.Pressed ? count : 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using Celeste;
using Celeste.Pico8;
using Microsoft.Xna.Framework;
using Monocle;
using TAS.Utils;
Expand All @@ -20,14 +22,18 @@ public static void DrawIndicator(float y, float padding, float alpha) {
float subPixelBottom = 0.5f;
int decimals = TasSettings.SubpixelIndicatorDecimals;

Player player = Engine.Scene.Tracker.GetEntity<Player>();
if (player != null) {
subPixelLeft = (float) Math.Round(player.movementCounter.X + 0.5f, decimals, MidpointRounding.AwayFromZero);
subPixelTop = (float) Math.Round(player.movementCounter.Y + 0.5f, decimals, MidpointRounding.AwayFromZero);
subPixelRight = 1f - subPixelLeft;
subPixelBottom = 1f - subPixelTop;
Vector2 remainder = Engine.Scene.Tracker.GetEntity<Player>()?.movementCounter ?? Vector2.Zero;
if (Engine.Scene is Level level && level.GetPlayer() is { } player) {
remainder = player.movementCounter;
} else if (Engine.Scene is Emulator emulator && emulator.game?.objects.FirstOrDefault(o => o is Classic.player) is Classic.player classicPlayer) {
remainder = classicPlayer.rem;
}

subPixelLeft = (float) Math.Round(remainder.X + 0.5f, decimals, MidpointRounding.AwayFromZero);
subPixelTop = (float) Math.Round(remainder.Y + 0.5f, decimals, MidpointRounding.AwayFromZero);
subPixelRight = 1f - subPixelLeft;
subPixelBottom = 1f - subPixelTop;

Vector2 textSize = GetSubPixelTextSize();
float textWidth = textSize.X;
float textHeight = textSize.Y;
Expand All @@ -39,7 +45,6 @@ public static void DrawIndicator(float y, float padding, float alpha) {
Draw.Rect(x + (rectSide - thickness) * subPixelLeft, y + (rectSide - thickness) * subPixelTop, thickness, thickness,
Color.Red * alpha);

Vector2 remainder = player?.movementCounter ?? Vector2.One;
int hDecimals = Math.Abs(remainder.X) switch {
0.5f => 0,
_ => decimals
Expand Down
11 changes: 1 addition & 10 deletions CelesteTAS-EverestInterop/Source/Module/CelesteTasSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,7 @@ public SimplifiedGraphicsFeature.SolidTilesStyle SimplifiedSolidTilesStyle {
public bool EnableInfoHudFirstTime = true;
public bool InfoGame { get; set; } = true;
public bool InfoTasInput { get; set; } = true;

[YamlMember(Alias = "InfoSubpixelIndicator")]
public bool _InfoSubpixelIndicator { get; set; } = true;

[YamlIgnore]
public bool InfoSubpixelIndicator {
get => _InfoSubpixelIndicator && Engine.Scene is Level;
set => _InfoSubpixelIndicator = value;
}

public bool InfoSubpixelIndicator { get; set; } = true;
public HudOptions InfoCustom { get; set; } = HudOptions.Off;
public HudOptions InfoWatchEntity { get; set; } = HudOptions.Both;
public WatchEntityType InfoWatchEntityType { get; set; } = WatchEntityType.Position;
Expand Down
5 changes: 2 additions & 3 deletions CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ public static void Update(bool updateVel = false) {
Classic.player player = emulator.game.objects.FirstOrDefault(o => o is Classic.player) as Classic.player;
if (player != null) {
stringBuilder.AppendLine($"Pos: {player.x}, {player.y}");
stringBuilder.AppendLine($"Rem: {player.rem.ToSimpleString(3)}");
stringBuilder.AppendLine($"Speed: {player.spd.ToSimpleString(3)}");

stringBuilder.AppendLine($"Rem: {player.rem.ToSimpleString(TasSettings.PositionDecimals)}");
stringBuilder.AppendLine($"Speed: {player.spd.ToSimpleString(TasSettings.SpeedDecimals)}");
}

stringBuilder.AppendLine($"Seed: {Pico8Fixer.Seed}");
Expand Down

0 comments on commit 2e5f8c1

Please sign in to comment.