Skip to content

Commit

Permalink
move all my random debug keybinds to buttons in a proper debug popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixrec committed Mar 9, 2025
1 parent c54cc9f commit f6a2790
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 99 deletions.
101 changes: 7 additions & 94 deletions Source/APRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,103 +55,14 @@ private void Awake() {
}
}

// Item application testing
// TODO: make a proper debug interface, maybe a popup with a really weird shortcut?

Item[] items = [
Item.MysticNymphScoutMode,
Item.TaiChiKick,
Item.CloudLeap,
Item.ChargedStrike,
Item.AirDash,
Item.UnboundedCounter,
Item.SuperMutantBuster,
];
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[0]} count to 1"); ItemApplications.UpdateItemCount(items[0], 1); },
new KeyboardShortcut(KeyCode.Alpha1, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[1]} count to 1"); ItemApplications.UpdateItemCount(items[1], 1); },
new KeyboardShortcut(KeyCode.Alpha2, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[2]} count to 1"); ItemApplications.UpdateItemCount(items[2], 1); },
new KeyboardShortcut(KeyCode.Alpha3, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[3]} count to 1"); ItemApplications.UpdateItemCount(items[3], 1); },
new KeyboardShortcut(KeyCode.Alpha4, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[4]} count to 1"); ItemApplications.UpdateItemCount(items[4], 1); },
new KeyboardShortcut(KeyCode.Alpha5, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[5]} count to 1"); ItemApplications.UpdateItemCount(items[5], 1); },
new KeyboardShortcut(KeyCode.Alpha6, KeyCode.LeftControl));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[6]} count to 1"); ItemApplications.UpdateItemCount(items[6], 1); },
new KeyboardShortcut(KeyCode.Alpha7, KeyCode.LeftControl));

KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[0]} count to 0"); ItemApplications.UpdateItemCount(items[0], 0); },
new KeyboardShortcut(KeyCode.Alpha1, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[1]} count to 0"); ItemApplications.UpdateItemCount(items[1], 0); },
new KeyboardShortcut(KeyCode.Alpha2, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[2]} count to 0"); ItemApplications.UpdateItemCount(items[2], 0); },
new KeyboardShortcut(KeyCode.Alpha3, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[3]} count to 0"); ItemApplications.UpdateItemCount(items[3], 0); },
new KeyboardShortcut(KeyCode.Alpha4, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[4]} count to 0"); ItemApplications.UpdateItemCount(items[4], 0); },
new KeyboardShortcut(KeyCode.Alpha5, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[5]} count to 0"); ItemApplications.UpdateItemCount(items[5], 0); },
new KeyboardShortcut(KeyCode.Alpha6, KeyCode.LeftShift));
KeybindManager.Add(this, () => { ToastManager.Toast($"setting {items[6]} count to 0"); ItemApplications.UpdateItemCount(items[6], 0); },
new KeyboardShortcut(KeyCode.Alpha7, KeyCode.LeftShift));

KeybindManager.Add(this, () => { ToastManager.Toast("T"); }, new KeyboardShortcut(KeyCode.T));

/*var item = Item.PipeVial;
KeybindManager.Add(this, () => {
ItemApplications.UpdateItemCount(item, 0);
}, new KeyboardShortcut(KeyCode.Alpha0));
KeybindManager.Add(this, () => {
ItemApplications.UpdateItemCount(item, 1);
}, new KeyboardShortcut(KeyCode.Alpha1));
KeybindManager.Add(this, () => {
ItemApplications.UpdateItemCount(item, 2);
}, new KeyboardShortcut(KeyCode.Alpha2));
KeybindManager.Add(this, () => {
ItemApplications.UpdateItemCount(item, 3);
}, new KeyboardShortcut(KeyCode.Alpha3));
KeybindManager.Add(this, () => {
ItemApplications.UpdateItemCount(item, 4);
}, new KeyboardShortcut(KeyCode.Alpha4));*/

KeybindManager.Add(this, () => {
ToastManager.Toast("CST unlocking all TPs");
NewGameCreation.UnlockAllTeleportPoints();
}, new KeyboardShortcut(KeyCode.T, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSG giving 99999 jin");
SingletonBehaviour<GameCore>.Instance.playerGameData.AddGold(99999, GoldSourceTag.DevCheat);
}, new KeyboardShortcut(KeyCode.G, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSJ triggering Jiequan 1");
Jiequan1Fight.ActuallyTriggerJiequan1Fight();
}, new KeyboardShortcut(KeyCode.J, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSL triggering Lady E");
LadyESoulscapeEntrance.ActuallyTriggerLadyESoulscape();
}, new KeyboardShortcut(KeyCode.L, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSC triggering Chiyou in FSP");
var flag = (ScriptableDataBool)SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict["bf49eb7e251013c4cb62eca6e586b465ScriptableDataBool"];
flag.CurrentValue = true;
}, new KeyboardShortcut(KeyCode.C, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSK triggering Kuafu in FSP");
var flag = (ScriptableDataBool)SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict["e2ccc29dc8f187b45be6ce50e7f4174aScriptableDataBool"];
flag.CurrentValue = true;
}, new KeyboardShortcut(KeyCode.K, KeyCode.LeftShift, KeyCode.LeftControl));
KeybindManager.Add(this, () => {
ToastManager.Toast("CSD triggering test death link");
DeathLinkManager.OnDeathLinkReceived(new DeathLink("death link test player", "death link test cause"));
}, new KeyboardShortcut(KeyCode.D, KeyCode.LeftShift, KeyCode.LeftControl));
DebugTools.ShowDebugToolsPopup = !DebugTools.ShowDebugToolsPopup;
}, new KeyboardShortcut(KeyCode.D, KeyCode.LeftShift, KeyCode.LeftControl, KeyCode.LeftAlt));

KeybindManager.Add(this, () => {
ToastManager.Toast("CSZ triggering random location check");
var locId = ConnectionAndPopups.APSession.Locations.AllMissingLocations[0];
LocationTriggers.CheckLocation(LocationNames.archipelagoIdToLocation[locId]);
}, new KeyboardShortcut(KeyCode.Z, KeyCode.LeftShift, KeyCode.LeftControl));
for(var i = 0; i < 30; i++)
Log.Info("");
}, new KeyboardShortcut(KeyCode.X, KeyCode.LeftShift, KeyCode.LeftControl, KeyCode.LeftAlt));

Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}
Expand All @@ -164,8 +75,10 @@ private void OnDestroy() {

private void Update() {
ConnectionAndPopups.Update();
DebugTools.Update();
}
private void OnGUI() {
ConnectionAndPopups.OnGUI();
DebugTools.OnGUI();
}
}
184 changes: 184 additions & 0 deletions Source/DebugTools.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
using Archipelago.MultiClient.Net.BounceFeatures.DeathLink;
using NineSolsAPI;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

namespace ArchipelagoRandomizer;

class DebugTools
{
public static bool ShowDebugToolsPopup = false;

public static void Update() {
if (ShowDebugToolsPopup) {
Cursor.visible = true;
}
}

public static void OnGUI() {
ConnectionAndPopups.UpdateStyles();

if (ShowDebugToolsPopup) {
DrawDebugToolsPopup();
}
}

private static string DebugPopup_Item = "";
private static string DebugPopup_Count = "";

private static void DrawDebugToolsPopup() {
float windowWidth = Screen.width * 0.6f;
float windowHeight = Screen.height * 0.7f;
var windowRect = new Rect((Screen.width - windowWidth) / 2, (Screen.height - windowHeight) / 2, windowWidth, windowHeight);

var textFieldWidth = GUILayout.Width(windowRect.width * 0.6f);

var windowStyle = ConnectionAndPopups.windowStyle;
var labelStyle = ConnectionAndPopups.labelStyle;
var textFieldStyle = ConnectionAndPopups.textFieldStyle;
var buttonStyle = ConnectionAndPopups.buttonStyle;

var centeredLabelStyle = new GUIStyle(labelStyle);
centeredLabelStyle.alignment = TextAnchor.UpperCenter;

// "GUI.ModalWindow" exists but is useless here; it doesn't prevent RCG's UI widgets from receiving input
GUI.Window(11261728, windowRect, (int windowID) => {
GUILayout.Label("", centeredLabelStyle);
GUILayout.Label("NPCs & Events", centeredLabelStyle);

GUILayout.BeginHorizontal();
if (GUILayout.Button("Unlock Jiequan 1 Fight", buttonStyle)) {
ToastManager.Toast("unlocking Jiequan 1 Fight");
Jiequan1Fight.ActuallyTriggerJiequan1Fight();
}
if (GUILayout.Button("Unlock Lady E Soulscape", buttonStyle)) {
ToastManager.Toast("unlocking Lady E Soulscape");
LadyESoulscapeEntrance.ActuallyTriggerLadyESoulscape();
}
if (GUILayout.Button("Move Chiyou into FSP", buttonStyle)) {
ToastManager.Toast("moving Chiyou into FSP");
var flag = (ScriptableDataBool)SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict["bf49eb7e251013c4cb62eca6e586b465ScriptableDataBool"];
flag.CurrentValue = true;
}
if (GUILayout.Button("Move Kuafu into FSP", buttonStyle)) {
ToastManager.Toast("moving Kuafu into FSP");
var flag = (ScriptableDataBool)SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict["e2ccc29dc8f187b45be6ce50e7f4174aScriptableDataBool"];
flag.CurrentValue = true;
}
GUILayout.EndHorizontal();

GUILayout.Label("", centeredLabelStyle);
GUILayout.Label("Miscellaneous", centeredLabelStyle);

GUILayout.BeginHorizontal();
if (GUILayout.Button("Unlock Most Teleports", buttonStyle)) {
ToastManager.Toast("unlocking most teleport points");
NewGameCreation.UnlockAllTeleportPoints();
}
if (GUILayout.Button("Test Death Link", buttonStyle)) {
ToastManager.Toast("triggering test death link");
DeathLinkManager.OnDeathLinkReceived(new DeathLink("death link test player", "death link test cause"));
}
if (GUILayout.Button("Give 9999 Jin", buttonStyle)) {
ToastManager.Toast("giving 99999 jin");
SingletonBehaviour<GameCore>.Instance.playerGameData.AddGold(99999, GoldSourceTag.DevCheat);
}
if (GUILayout.Button("Check 1 Unchecked Location", buttonStyle)) {
ToastManager.Toast("triggering random unchecked location check");
var locId = ConnectionAndPopups.APSession.Locations.AllMissingLocations[0];
LocationTriggers.CheckLocation(LocationNames.archipelagoIdToLocation[locId]);
}
GUILayout.EndHorizontal();

GUILayout.Label("", centeredLabelStyle);
GUILayout.Label("Core Progression Items", centeredLabelStyle);

var fixedWidthLabelStyle = new GUIStyle(labelStyle);
fixedWidthLabelStyle.fixedWidth = 200;

var onOffButtonStyle = new GUIStyle(buttonStyle);
onOffButtonStyle.fixedWidth = 50;

GUILayout.BeginHorizontal();
GUILayout.Label("MysticNymphScoutMode", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.MysticNymphScoutMode, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.MysticNymphScoutMode, 0);
}

GUILayout.Label("TaiChiKick", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.TaiChiKick, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.TaiChiKick, 0);
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("ChargedStrike", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.ChargedStrike, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.ChargedStrike, 0);
}

GUILayout.Label("AirDash", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.AirDash, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.AirDash, 0);
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("UnboundedCounter", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.UnboundedCounter, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.UnboundedCounter, 0);
}

GUILayout.Label("CloudLeap", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.CloudLeap, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.CloudLeap, 0);
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("SuperMutantBuster", fixedWidthLabelStyle);
if (GUILayout.Button("On", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.SuperMutantBuster, 1);
}
if (GUILayout.Button("Off", onOffButtonStyle)) {
ItemApplications.UpdateItemCount(Item.SuperMutantBuster, 0);
}
GUILayout.EndHorizontal();

var updateButtonStyle = new GUIStyle(buttonStyle);
updateButtonStyle.fixedWidth = 80;

GUILayout.Label("", centeredLabelStyle);
GUILayout.Label("Arbitrary Item Update", centeredLabelStyle);

GUILayout.BeginHorizontal();
DebugPopup_Item = GUILayout.TextField(DebugPopup_Item, textFieldStyle, GUILayout.Width(windowRect.width * 0.3f));
DebugPopup_Count = GUILayout.TextField(DebugPopup_Count, textFieldStyle, GUILayout.Width(windowRect.width * 0.1f));
if (GUILayout.Button("Update", updateButtonStyle)) {
ItemApplications.UpdateItemCount(Enum.Parse<Item>(DebugPopup_Item), int.Parse(DebugPopup_Count));
}
GUILayout.EndHorizontal();

}, "Archipelago Randomizer Debug Tools (Ctrl+Alt+Shift+D to show/hide)", windowStyle);
}
}
10 changes: 5 additions & 5 deletions Source/MainMenu/ConnectionAndPopups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
namespace ArchipelagoRandomizer;

internal class ConnectionAndPopups {
private static GUIStyle windowStyle;
private static GUIStyle labelStyle;
private static GUIStyle textFieldStyle;
private static GUIStyle buttonStyle;
public static GUIStyle windowStyle;
public static GUIStyle labelStyle;
public static GUIStyle textFieldStyle;
public static GUIStyle buttonStyle;

private static void UpdateStyles() {
public static void UpdateStyles() {
if (labelStyle == null) {
windowStyle = new GUIStyle(GUI.skin.window);

Expand Down

0 comments on commit f6a2790

Please sign in to comment.