Skip to content

Commit

Permalink
Merge pull request #95 from LozenChen/refactor
Browse files Browse the repository at this point in the history
Bugfix: Open Console doesn't work properly
  • Loading branch information
psyGamer authored Jan 4, 2025
2 parents 92f693c + 741dcd9 commit 4a2040d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,33 @@ internal static void UpdateMeta() {
return;
}

justClosed = false;
if (Engine.Commands.Open) {
Engine.Commands.UpdateOpen();
if (!Engine.Commands.Open) {
justClosed = true;
}
} else if (Engine.Commands.Enabled) {
Engine.Commands.UpdateClosed();
}
}

private static bool justClosed = false;
internal static void OpenConsole() {
if (!Manager.Running) {
return; // Only allow inside a TAS, since outside it's already handled
}
if (Engine.Commands.Open) {
return;
}
if (justClosed) {
// when commands open, hotkeys are not updated (in Hotkeys.UpdateMeta(), updateKey = false)
// so if without this extra check:
// Gameloop 1: Commands open
// Gameloop 2: CoreModule.(Toggle)DebugConsole gets pressed (note this is not our OpenConsole hotkey), and Commands get closed
// Gameloop 3: Hotkeys find Commands are closed and decide to update, and find that OpenConsole gets pressed, so it Opens Console again!
return;
}

// Copied from Commands.UpdateClosed
Engine.Commands.Open = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
using Celeste;
using JetBrains.Annotations;
using Microsoft.Xna.Framework;
using Mono.Cecil.Cil;
using Monocle;
Expand Down Expand Up @@ -84,7 +85,8 @@ private static void Unload() {
On.Celeste.Level.End -= LevelOnEnd;
}

private static bool HideHitbox(Entity entity) {
[PublicAPI]
public static bool HideHitbox(Entity entity) {
if (!TasSettings.ShowHitboxes || InfoWatchEntity.CurrentlyWatchedEntities.Contains(entity)) {
return false;
}
Expand Down
7 changes: 1 addition & 6 deletions CelesteTAS-EverestInterop/Source/EverestInterop/Hotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ private static GamePadState GetGamePadState() {
// No controller connected
return default;
}

[Obsolete("Use UpdateMeta")]
public static void Update() => UpdateMeta();

// Used by TAS Helper
public static void UpdateMeta() {
internal static void UpdateMeta() {
// Determined which inputs are already used for something else
bool updateKey = true;
bool updateButton = true;
Expand Down

0 comments on commit 4a2040d

Please sign in to comment.