diff --git a/NeoQOLPack/Mod.cs b/NeoQOLPack/Mod.cs index 34fec7a..5c0f9ea 100644 --- a/NeoQOLPack/Mod.cs +++ b/NeoQOLPack/Mod.cs @@ -17,7 +17,7 @@ public class Mod : IMod public Config Config; public ILogger Logger; - private static readonly string versionTag = "Beta2"; + private static readonly string versionTag = "Beta4"; private static readonly string repo = "neomoth/NeoQOLPack"; private bool injectUpdateNotice = false; @@ -27,18 +27,20 @@ public Mod(IModInterface modInterface) { this.Config = modInterface.ReadConfig(); Logger = modInterface.Logger; _ = GetVersion(); - modInterface.RegisterScriptMod(new InventoryStackerItem(this)); - modInterface.RegisterScriptMod(new InventoryStackerPlayerData(this)); - modInterface.RegisterScriptMod(new InventoryStackerInventory(this)); - modInterface.RegisterScriptMod(new InventoryStackerSelect(this)); - modInterface.RegisterScriptMod(new CosmeticLoaderGlobals(this)); - modInterface.RegisterScriptMod(new CosmeticLoaderPlayer(this)); - modInterface.RegisterScriptMod(new CosmeticLoaderTitle()); + modInterface.RegisterScriptMod(new InventoryItemPatcher(this)); + modInterface.RegisterScriptMod(new PlayerDataPatcher(this)); + modInterface.RegisterScriptMod(new InventoryPactcher(this)); + modInterface.RegisterScriptMod(new ItemSelectPatcher(this)); + // modInterface.RegisterScriptMod(new GlobalsPatcher(this)); + modInterface.RegisterScriptMod(new PlayerPatcher(this)); + modInterface.RegisterScriptMod(new TitleScreenPatcher()); // modInterface.RegisterScriptMod(new ModScriptPatcher(this, versionTag, injectUpdateNotice)); modInterface.RegisterScriptMod(new ShopPatcher()); modInterface.RegisterScriptMod(new PlayerHudPatcher(this)); modInterface.RegisterScriptMod(new ShopButtonPatcher(this)); modInterface.RegisterScriptMod(new MenuPatcher(this, versionTag)); + modInterface.RegisterScriptMod(new OptionsMenuPatcher()); + modInterface.RegisterScriptMod(new EscMenuPatcher()); if (injectUpdateNotice) ; } diff --git a/NeoQOLPack/Mods/CosmeticLoaderPlayer.cs b/NeoQOLPack/Mods/CosmeticLoaderPlayer.cs deleted file mode 100644 index a5cfa32..0000000 --- a/NeoQOLPack/Mods/CosmeticLoaderPlayer.cs +++ /dev/null @@ -1,43 +0,0 @@ -using GDWeave.Godot; -using GDWeave.Godot.Variants; -using GDWeave.Modding; - -namespace NeoQOLPack.Mods; - -public class CosmeticLoaderPlayer(Mod mod) : IScriptMod -{ - public bool ShouldRun(string path) => path == "res://Scenes/Entities/Player/player.gdc"; - - public IEnumerable Modify(string path, IEnumerable tokens) - { - MultiTokenWaiter readyWaiter = new MultiTokenWaiter([ - t => t is IdentifierToken {Name: "_ready"}, - t => t.Type == TokenType.Newline - ],allowPartialMatch: true); - - - - //"/iamweest": PlayerData._unlock_cosmetic("title_streamerman") - // "/colonthreetimeseight": PlayerData._unlock_cosmetic("title_colonthreetimeseight") - // "/hithisisaveryhardstringtotrytoguesslol": PlayerData._unlock_cosmetic("title_seventvowner") - - foreach (Token token in tokens) - { - if (readyWaiter.Check(token)) - { - yield return token; - yield return new Token(TokenType.Dollar); - yield return new ConstantToken(new StringVariant("/root/NeoQOLPack")); - yield return new Token(TokenType.Period); - yield return new IdentifierToken("_replace_player_label"); - yield return new Token(TokenType.ParenthesisOpen); - yield return new IdentifierToken("title"); - yield return new Token(TokenType.ParenthesisClose); - - yield return new Token(TokenType.Newline, 1); - - } - else yield return token; - } - } -} \ No newline at end of file diff --git a/NeoQOLPack/Mods/EscMenuPatcher.cs b/NeoQOLPack/Mods/EscMenuPatcher.cs new file mode 100644 index 0000000..6934dcb --- /dev/null +++ b/NeoQOLPack/Mods/EscMenuPatcher.cs @@ -0,0 +1,118 @@ +using GDWeave.Godot; +using GDWeave.Godot.Variants; +using GDWeave.Modding; + +namespace NeoQOLPack.Mods; + +public class EscMenuPatcher : IScriptMod +{ + public bool ShouldRun(string path) => path == "res://Scenes/HUD/Esc Menu/esc_menu.gdc"; + + public IEnumerable Modify(string path, IEnumerable tokens) + { + //$VBoxContainer.anchor_top = 0.35 if Network.PLAYING_OFFLINE else 0.32 + // $VBoxContainer.anchor_bottom = 0.65 if Network.PLAYING_OFFLINE else 0.68 + + MultiTokenWaiter processWaiter = new MultiTokenWaiter([ + t=>t is IdentifierToken {Name: "_process"}, + t=>t.Type is TokenType.Newline + ], allowPartialMatch:true); + + MultiTokenWaiter openWaiter = new MultiTokenWaiter([ + t=>t is IdentifierToken {Name: "_open"}, + t=>t.Type is TokenType.Colon, + t=>t.Type is TokenType.Newline + ], allowPartialMatch:true); + + MultiTokenWaiter closeWaiter = new MultiTokenWaiter([ + t=>t is IdentifierToken {Name: "_close"}, + t=>t.Type is TokenType.Colon, + t=>t.Type is TokenType.Newline + ], allowPartialMatch:true); + + foreach (Token token in tokens) + { + if (processWaiter.Check(token)) + { + yield return token; + + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("VBoxContainer")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("anchor_top"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new RealVariant(0.35)); + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("Network"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("PLAYING_OFFLINE"); + yield return new Token(TokenType.CfElse); + yield return new ConstantToken(new RealVariant(0.32)); + yield return new Token(TokenType.Newline, 1); + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("VBoxContainer")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("anchor_bottom"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new RealVariant(0.65)); + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("Network"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("PLAYING_OFFLINE"); + yield return new Token(TokenType.CfElse); + yield return new ConstantToken(new RealVariant(0.68)); + + yield return new Token(TokenType.Newline, 1); + } + else if (openWaiter.Check(token)) + { + yield return token; + + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + yield return new Token(TokenType.Colon); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("set_mouse_mode"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_VISIBLE"); + yield return new Token(TokenType.ParenthesisClose); + + yield return new Token(TokenType.Newline, 1); + } + else if (closeWaiter.Check(token)) + { + yield return token; + + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + yield return new Token(TokenType.Colon); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("set_mouse_mode"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_CONFINED"); + yield return new Token(TokenType.ParenthesisClose); + + yield return new Token(TokenType.Newline, 1); + } + else yield return token; + } + } +} \ No newline at end of file diff --git a/NeoQOLPack/Mods/CosmeticLoaderGlobals.cs b/NeoQOLPack/Mods/GlobalsPatcher.cs similarity index 61% rename from NeoQOLPack/Mods/CosmeticLoaderGlobals.cs rename to NeoQOLPack/Mods/GlobalsPatcher.cs index 1070451..f13449d 100644 --- a/NeoQOLPack/Mods/CosmeticLoaderGlobals.cs +++ b/NeoQOLPack/Mods/GlobalsPatcher.cs @@ -4,17 +4,17 @@ namespace NeoQOLPack.Mods; -public class CosmeticLoaderGlobals(Mod mod) : IScriptMod +public class GlobalsPatcher(Mod mod) : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/Singletons/globals.gdc"; public IEnumerable Modify(string path, IEnumerable tokens) { // mod.Logger.Information("loaded globals.gdc"); - MultiTokenWaiter extendsWaiter = new MultiTokenWaiter([ - t=>t.Type == TokenType.PrExtends, - t => t.Type == TokenType.Newline, - ], allowPartialMatch: true); + // MultiTokenWaiter extendsWaiter = new MultiTokenWaiter([ + // t=>t.Type == TokenType.PrExtends, + // t => t.Type == TokenType.Newline, + // ], allowPartialMatch: true); MultiTokenWaiter readyWaiter = new MultiTokenWaiter([ t => t is IdentifierToken {Name: "_ready"}, @@ -24,31 +24,31 @@ public IEnumerable Modify(string path, IEnumerable tokens) foreach (Token token in tokens) { - if (extendsWaiter.Check(token)) - { + // if (extendsWaiter.Check(token)) + // { //var nqolutil = preload("res://mods/NeoQOLPack/util.gd") - yield return token; - yield return new Token(TokenType.PrFunction); - yield return new IdentifierToken("_get_mod"); - yield return new Token(TokenType.ParenthesisOpen); - yield return new Token(TokenType.ParenthesisClose); - yield return new Token(TokenType.Colon); - yield return new Token(TokenType.Newline, 1); + // yield return token; + // yield return new Token(TokenType.PrFunction); + // yield return new IdentifierToken("_get_mod"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Colon); + // yield return new Token(TokenType.Newline, 1); // yield return new Token(TokenType.PrVar); // yield return new IdentifierToken("neo_mod"); // yield return new Token(TokenType.OpAssign); - yield return new Token(TokenType.Dollar); - yield return new ConstantToken(new StringVariant("/root/NeoQOLPack")); - yield return new Token(TokenType.Period); - yield return new IdentifierToken("_load_mod_resources"); + // yield return new Token(TokenType.Dollar); + // yield return new ConstantToken(new StringVariant("/root/NeoQOLPack")); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("_load_mod_resources"); // yield return new IdentifierToken("load"); - yield return new Token(TokenType.ParenthesisOpen); + // yield return new Token(TokenType.ParenthesisOpen); // yield return new ConstantToken(new StringVariant("res://mods/NeoQOLPack/util.gd")); - yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.ParenthesisClose); - yield return new Token(TokenType.Newline); - } - else if (readyWaiter.Check(token)) + // yield return new Token(TokenType.Newline); + // } + /*else*/ if (readyWaiter.Check(token)) { // mod.Logger.Information("found ready func"); yield return token; @@ -67,11 +67,11 @@ public IEnumerable Modify(string path, IEnumerable tokens) // yield return new Token(TokenType.ParenthesisClose); // yield return new Token(TokenType.Newline, 1); - yield return new IdentifierToken("call_deferred"); - yield return new Token(TokenType.ParenthesisOpen); - yield return new ConstantToken(new StringVariant("_get_mod")); + // yield return new IdentifierToken("call_deferred"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new StringVariant("_get_mod")); // yield return new IdentifierToken("_get_mod"); - yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.ParenthesisClose); // yield return new IdentifierToken("nqolutil"); // yield return new Token(TokenType.Period); @@ -79,7 +79,7 @@ public IEnumerable Modify(string path, IEnumerable tokens) // yield return new Token(TokenType.ParenthesisOpen); // yield return new Token(TokenType.ParenthesisClose); - yield return new Token(TokenType.Newline, 1); + // yield return new Token(TokenType.Newline, 1); } else yield return token; } diff --git a/NeoQOLPack/Mods/InventoryStackerItem.cs b/NeoQOLPack/Mods/InventoryItemPatcher.cs similarity index 98% rename from NeoQOLPack/Mods/InventoryStackerItem.cs rename to NeoQOLPack/Mods/InventoryItemPatcher.cs index 3bc4eb8..90864a7 100644 --- a/NeoQOLPack/Mods/InventoryStackerItem.cs +++ b/NeoQOLPack/Mods/InventoryItemPatcher.cs @@ -4,7 +4,7 @@ namespace NeoQOLPack.Mods; -public class InventoryStackerItem(Mod mod) : IScriptMod +public class InventoryItemPatcher(Mod mod) : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/HUD/inventory_item.gdc"; diff --git a/NeoQOLPack/Mods/InventoryStackerInventory.cs b/NeoQOLPack/Mods/InventoryPactcher.cs similarity index 97% rename from NeoQOLPack/Mods/InventoryStackerInventory.cs rename to NeoQOLPack/Mods/InventoryPactcher.cs index 10f2822..349909e 100644 --- a/NeoQOLPack/Mods/InventoryStackerInventory.cs +++ b/NeoQOLPack/Mods/InventoryPactcher.cs @@ -4,7 +4,7 @@ namespace NeoQOLPack.Mods; -public class InventoryStackerInventory(Mod mod) : IScriptMod +public class InventoryPactcher(Mod mod) : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/HUD/inventory.gdc"; diff --git a/NeoQOLPack/Mods/InventoryStackerSelect.cs b/NeoQOLPack/Mods/ItemSelectPatcher.cs similarity index 95% rename from NeoQOLPack/Mods/InventoryStackerSelect.cs rename to NeoQOLPack/Mods/ItemSelectPatcher.cs index 668877f..7b18195 100644 --- a/NeoQOLPack/Mods/InventoryStackerSelect.cs +++ b/NeoQOLPack/Mods/ItemSelectPatcher.cs @@ -4,7 +4,7 @@ namespace NeoQOLPack.Mods; -public class InventoryStackerSelect(Mod mod) : IScriptMod +public class ItemSelectPatcher(Mod mod) : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/HUD/ItemSelect/item_select.gdc"; diff --git a/NeoQOLPack/Mods/OptionsMenuPatcher.cs b/NeoQOLPack/Mods/OptionsMenuPatcher.cs new file mode 100644 index 0000000..09bb064 --- /dev/null +++ b/NeoQOLPack/Mods/OptionsMenuPatcher.cs @@ -0,0 +1,449 @@ +using GDWeave.Godot; +using GDWeave.Godot.Variants; +using GDWeave.Modding; + +namespace NeoQOLPack.Mods; + +public class OptionsMenuPatcher : IScriptMod +{ + //$"%lockmouse".add_item("Unlocked") + // $"%lockmouse".add_item("Locked") + + public bool ShouldRun(string path) => path == "res://Scenes/Singletons/OptionsMenu/options_menu.gdc"; + + public IEnumerable Modify(string path, IEnumerable tokens) + { + MultiTokenWaiter extendsWaiter = new MultiTokenWaiter([ + t => t.Type is TokenType.PrExtends, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + MultiTokenWaiter readyWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken { Name: "_ready" }, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + MultiTokenWaiter setSelectionWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken { Name: "_set_selections_to_save" }, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + MultiTokenWaiter resetWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken { Name: "_reset" }, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + MultiTokenWaiter applySelectionsWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken { Name: "_apply_selections" }, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + foreach (Token token in tokens) + { + if (extendsWaiter.Check(token)) + { + yield return token; + + yield return new Token(TokenType.PrVar); + yield return new IdentifierToken("lock_mouse_node"); + + yield return new Token(TokenType.Newline); + } + else if (readyWaiter.Check(token)) + { + yield return token; + + // yield return new Token(TokenType.PrVar); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("HBoxContainer"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("new"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // yield return new Token(TokenType.PrVar); + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Label"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("new"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + + yield return new Token(TokenType.PrVar); + yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.OpAssign); + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Control/Panel/tabs_main/main/ScrollContainer/HBoxContainer/VBoxContainer/punchable")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("duplicate"); + yield return new Token(TokenType.ParenthesisOpen); + // yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new Token(TokenType.PrVar); + yield return new IdentifierToken("lock_mouse_label"); + yield return new Token(TokenType.OpAssign); + yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("get_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new IntVariant(0)); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.OpAssign); + yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("get_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new IntVariant(1)); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("name"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new StringVariant("lockmouse")); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_label"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("text"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new StringVariant("Lock Mouse to Window: ")); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Control/Panel/tabs_main/main/ScrollContainer/HBoxContainer/VBoxContainer")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("add_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Control/Panel/tabs_main/main/ScrollContainer/HBoxContainer/VBoxContainer")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("move_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("lock_mouse_div"); + yield return new Token(TokenType.Comma); + yield return new IdentifierToken("get_node"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Control/Panel/tabs_main/main/ScrollContainer/HBoxContainer/VBoxContainer")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("get_child_count"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.OpSub); + yield return new ConstantToken(new IntVariant(4)); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("add_child"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("OptionButton"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("new"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("add_child"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("size_flags_horizontal"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_FILL"); + // yield return new Token(TokenType.OpBitOr); // try AssignBitOr if this doesn't work :/ + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_EXPAND"); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("size_flags_horizontal"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_FILL"); + // yield return new Token(TokenType.OpBitOr); // try AssignBitOr if this doesn't work :/ + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_EXPAND"); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("size_flags_horizontal"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_FILL"); + // yield return new Token(TokenType.OpBitOr); // try AssignBitOr if this doesn't work :/ + // yield return new IdentifierToken("Control"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("SIZE_FLAGS_EXPAND"); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("rect_position"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Vector2"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new RealVariant(0)); + // yield return new Token(TokenType.Comma); + // yield return new ConstantToken(new RealVariant(342)); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("rect_size"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Vector2"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new RealVariant(684)); + // yield return new Token(TokenType.Comma); + // yield return new ConstantToken(new RealVariant(34)); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_left"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(0)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_top"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(342)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_right"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(684)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_div"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_bottom"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(376)); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("rect_size"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Vector2"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new RealVariant(388)); + // yield return new Token(TokenType.Comma); + // yield return new ConstantToken(new RealVariant(34)); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_bottom"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(388)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_label"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_bottom"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(34)); + // yield return new Token(TokenType.Newline, 1); + + + + + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_left"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(392)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_right"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(684)); + // yield return new Token(TokenType.Newline, 1); + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("margin_bottom"); + // yield return new Token(TokenType.OpAssign); + // yield return new ConstantToken(new RealVariant(34)); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("rect_position"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Vector2"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new RealVariant(392)); + // yield return new Token(TokenType.Comma); + // yield return new ConstantToken(new RealVariant(0)); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("rect_size"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("Vector2"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new RealVariant(292)); + // yield return new Token(TokenType.Comma); + // yield return new ConstantToken(new RealVariant(34)); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new Token(TokenType.PrVar); + // yield return new IdentifierToken("lock_mouse_script"); + // yield return new Token(TokenType.OpAssign); + // yield return new IdentifierToken("load"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new ConstantToken(new StringVariant("res://Scenes/Menus/Main Menu/ui_generic_button.gd")); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + // + // yield return new IdentifierToken("lock_mouse_node"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("set_script"); + // yield return new Token(TokenType.ParenthesisOpen); + // yield return new IdentifierToken("lock_mouse_script"); + // yield return new Token(TokenType.ParenthesisClose); + // yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("add_item"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Unlocked")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("add_item"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("Locked")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_label"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("get_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new IntVariant(0)); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("header"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new StringVariant("Lock Mouse to Window")); + yield return new Token(TokenType.Newline, 1); + + yield return new IdentifierToken("lock_mouse_label"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("get_child"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new IntVariant(0)); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("body"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new StringVariant("When set to Locked, the mouse will be locked within the game window unless the game is paused.")); + yield return new Token(TokenType.Newline, 1); + + yield return new Token(TokenType.Newline, 1); + } + else if (setSelectionWaiter.Check(token)) + { + //$"%lockmouse".selected = PlayerData.player_options.lockmouse + yield return token; + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("selected"); + yield return new Token(TokenType.OpAssign); + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + + yield return new Token(TokenType.Newline, 1); + } + else if (resetWaiter.Check(token)) + { + //$"%lockmouse".selected = 0 + yield return token; + + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("selected"); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new IntVariant(0)); + + yield return new Token(TokenType.Newline, 1); + } + else if (applySelectionsWaiter.Check(token)) + { + //PlayerData.player_options.lockmouse = $"%lockmouse".selected + yield return token; + + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + yield return new Token(TokenType.OpAssign); + yield return new IdentifierToken("lock_mouse_node"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("selected"); + + yield return new Token(TokenType.Newline, 1); + } + else yield return token; + } + } +} \ No newline at end of file diff --git a/NeoQOLPack/Mods/InventoryStackerPlayerData.cs b/NeoQOLPack/Mods/PlayerDataPatcher.cs similarity index 83% rename from NeoQOLPack/Mods/InventoryStackerPlayerData.cs rename to NeoQOLPack/Mods/PlayerDataPatcher.cs index ae03c2e..5d52d76 100644 --- a/NeoQOLPack/Mods/InventoryStackerPlayerData.cs +++ b/NeoQOLPack/Mods/PlayerDataPatcher.cs @@ -4,7 +4,7 @@ namespace NeoQOLPack.Mods; -public class InventoryStackerPlayerData(Mod mod) : IScriptMod +public class PlayerDataPatcher(Mod mod) : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/Singletons/playerdata.gdc"; @@ -13,12 +13,35 @@ public IEnumerable Modify(string path, IEnumerable tokens) MultiTokenWaiter entryWaiter = new MultiTokenWaiter([ t => t is IdentifierToken { Name: "_add_item" }, t => t is IdentifierToken { Name: "entry" }, - t => t.Type == TokenType.Newline + t => t.Type is TokenType.Newline ], allowPartialMatch: true); MultiTokenWaiter readyWaiter = new MultiTokenWaiter([ t => t is IdentifierToken { Name: "_ready" }, - t => t.Type == TokenType.Newline + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + MultiTokenWaiter resetWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken { Name: "_reset" }, + t => t is IdentifierToken { Name: "player_options" }, + t => t.Type is TokenType.OpAssign, + t => t.Type is TokenType.CurlyBracketOpen, + t => t.Type is TokenType.Newline + ], allowPartialMatch: true); + + + //if VERSION_MATCH and ( not stored_save.keys().has("version") or stored_save["version"] != Globals.GAME_VERSION): + // _reset_save() + // USING_SAVE = false + // return true + + MultiTokenWaiter storedSaveWaiter = new MultiTokenWaiter([ + t=>t is IdentifierToken { Name: "_load_save" }, + t => t.Type is TokenType.CfIf, + t => t is IdentifierToken {Name: "VERSION_MATCH"}, + t => t.Type is TokenType.OpAnd, + t => t.Type is TokenType.CfReturn, + t => t.Type is TokenType.Newline ], allowPartialMatch: true); MultiTokenWaiter loadedWaiter = new MultiTokenWaiter([ @@ -324,6 +347,49 @@ public IEnumerable Modify(string path, IEnumerable tokens) // yield return new Token(TokenType.Newline, 1); + } else if (storedSaveWaiter.Check(token)) + { + yield return token; + + //if not stored_save["player_options"].keys().has("lockmouse"): stored_save["player_options"]["lockmouse"] = 0 + yield return new Token(TokenType.CfIf); + yield return new Token(TokenType.OpNot); + yield return new IdentifierToken("stored_save"); + yield return new Token(TokenType.BracketOpen); + yield return new ConstantToken(new StringVariant("player_options")); + yield return new Token(TokenType.BracketClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("keys"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("has"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new ConstantToken(new StringVariant("lockmouse")); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Colon); + yield return new Token(TokenType.Newline, 2); + yield return new IdentifierToken("stored_save"); + yield return new Token(TokenType.BracketOpen); + yield return new ConstantToken(new StringVariant("player_options")); + yield return new Token(TokenType.BracketClose); + yield return new Token(TokenType.BracketOpen); + yield return new ConstantToken(new StringVariant("lockmouse")); + yield return new Token(TokenType.BracketClose); + yield return new Token(TokenType.OpAssign); + yield return new ConstantToken(new IntVariant(0)); + + yield return new Token(TokenType.Newline, 1); + } else if (resetWaiter.Check(token)) + { + yield return token; + + yield return new ConstantToken(new StringVariant("lockmouse")); + yield return new Token(TokenType.Colon); + yield return new ConstantToken(new IntVariant(0)); + yield return new Token(TokenType.Comma); + + yield return new Token(TokenType.Newline, 2); } else yield return token; } diff --git a/NeoQOLPack/Mods/PlayerPatcher.cs b/NeoQOLPack/Mods/PlayerPatcher.cs new file mode 100644 index 0000000..5080c8b --- /dev/null +++ b/NeoQOLPack/Mods/PlayerPatcher.cs @@ -0,0 +1,218 @@ +using GDWeave.Godot; +using GDWeave.Godot.Variants; +using GDWeave.Modding; + +namespace NeoQOLPack.Mods; + +public class PlayerPatcher(Mod mod) : IScriptMod +{ + public bool ShouldRun(string path) => path == "res://Scenes/Entities/Player/player.gdc"; + + public IEnumerable Modify(string path, IEnumerable tokens) + { + MultiTokenWaiter readyWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken {Name: "_ready"}, + t => t.Type is TokenType.Newline + ],allowPartialMatch: true); + + MultiTokenWaiter busyWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken {Name: "_get_input"}, + t => t.Type is TokenType.CfIf, + t => t is IdentifierToken {Name: "busy"}, + // t => t is IdentifierToken {Name: "MOUSE_MODE_VISIBLE"}, + t => t.Type is TokenType.Newline + ],allowPartialMatch: true); + + MultiTokenWaiter busyWaiter2 = new MultiTokenWaiter([ + t => t is IdentifierToken {Name: "_get_input"}, + t => t.Type is TokenType.CfIf, + t => t is IdentifierToken {Name: "busy"}, + // t => t is IdentifierToken {Name: "MOUSE_MODE_VISIBLE"}, + t => t.Type is TokenType.ParenthesisOpen, + // t => t.Type is TokenType.Newline + ],allowPartialMatch: true); + + MultiTokenWaiter elseWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken {Name: "_get_input"}, + //if Input.mouse_mode != Input.MOUSE_MODE_VISIBLE + t => t.Type is TokenType.CfIf, + t => t is IdentifierToken {Name: "Input"}, + t => t.Type is TokenType.Period, + t => t is IdentifierToken {Name: "mouse_mode"}, + t => t.Type is TokenType.OpNotEqual, + t => t is IdentifierToken {Name: "Input"}, + t => t.Type is TokenType.Period, + t => t is IdentifierToken {Name: "MOUSE_MODE_VISIBLE"}, + ],allowPartialMatch: true); + + MultiTokenWaiter visibleWaiter = new MultiTokenWaiter([ + t => t is IdentifierToken {Name: "_get_input"}, + t => t.Type is TokenType.CfIf, + t => t is IdentifierToken {Name: "Input"}, + t => t.Type is TokenType.Period, + t => t is IdentifierToken {Name: "mouse_mode"}, + t => t.Type is TokenType.OpNotEqual, + t => t is IdentifierToken {Name: "Input"}, + t => t.Type is TokenType.Period, + t => t is IdentifierToken {Name: "MOUSE_MODE_VISIBLE"}, + t => t.Type is TokenType.ParenthesisClose, + t => t.Type is TokenType.Newline + ],allowPartialMatch: true); + + //"/iamweest": PlayerData._unlock_cosmetic("title_streamerman") + // "/colonthreetimeseight": PlayerData._unlock_cosmetic("title_colonthreetimeseight") + // "/hithisisaveryhardstringtotrytoguesslol": PlayerData._unlock_cosmetic("title_seventvowner") + + //if busy: + // if hud.menu == hud.MENUS.ESC: Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + // else: Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED if PlayerData.player_options.lockmouse else Input.MOUSE_MODE_VISIBLE) + // return + // + // if Input.is_action_pressed("secondary_action") or camera_zoom <= 0.0: + // if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: + // PlayerData.original_mouse_position = get_tree().get_nodes_in_group("world_viewport")[0].get_mouse_position() + // Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + // else : + // if Input.mouse_mode != Input.MOUSE_MODE_VISIBLE and Input.mouse_mode != Input.MOUSE_MODE_CONFINED: + // if hud.menu == hud.MENUS.ESC: Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + // else: Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED if PlayerData.player_options.lockmouse else Input.MOUSE_MODE_VISIBLE) + // Input.warp_mouse_position(PlayerData.original_mouse_position) + + foreach (Token token in tokens) + { + // mod.Logger.Information(token.ToString()); + if (readyWaiter.Check(token)) + { + yield return token; + yield return new Token(TokenType.Dollar); + yield return new ConstantToken(new StringVariant("/root/NeoQOLPack")); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("_replace_player_label"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("title"); + yield return new Token(TokenType.ParenthesisClose); + + yield return new Token(TokenType.Newline, 1); + } + + else if (busyWaiter.Check(token)) + { + mod.Logger.Information("found busy"); + yield return token; + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("hud"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("menu"); + yield return new Token(TokenType.OpEqual); + yield return new IdentifierToken("hud"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MENUS"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("ESC"); + yield return new Token(TokenType.Colon); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("set_mouse_mode"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_VISIBLE"); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 2); + yield return new Token(TokenType.CfElse); + yield return new Token(TokenType.Colon); + + yield return new Token(TokenType.Newline, 3); + } + else if (busyWaiter2.Check(token)) + { + yield return token; + + // yield return new IdentifierToken("Input"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("set_mouse_mode"); + // yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_CONFINED"); + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + yield return new Token(TokenType.CfElse); + // yield return new IdentifierToken("Input"); + // yield return new Token(TokenType.Period); + // yield return new IdentifierToken("MOUSE_MODE_VISIBLE"); + // yield return new Token(TokenType.ParenthesisClose); + + // yield return new Token(TokenType.Newline, 2); + } + else if (elseWaiter.Check(token)) + { + mod.Logger.Information("found else"); + yield return token; + + yield return new Token(TokenType.OpAnd); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("mouse_mode"); + yield return new Token(TokenType.OpNotEqual); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_CONFINED"); + + // yield return new Token(TokenType.Newline, 1); + } + else if (visibleWaiter.Check(token)) + { + mod.Logger.Information("found visible"); + yield return token; + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("hud"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("menu"); + yield return new Token(TokenType.OpEqual); + yield return new IdentifierToken("hud"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MENUS"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("ESC"); + yield return new Token(TokenType.Colon); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("set_mouse_mode"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_VISIBLE"); + yield return new Token(TokenType.ParenthesisClose); + yield return new Token(TokenType.Newline, 3); + yield return new Token(TokenType.CfElse); + yield return new Token(TokenType.Colon); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("set_mouse_mode"); + yield return new Token(TokenType.ParenthesisOpen); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_CONFINED"); + yield return new Token(TokenType.CfIf); + yield return new IdentifierToken("PlayerData"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("player_options"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("lockmouse"); + yield return new Token(TokenType.CfElse); + yield return new IdentifierToken("Input"); + yield return new Token(TokenType.Period); + yield return new IdentifierToken("MOUSE_MODE_VISIBLE"); + yield return new Token(TokenType.ParenthesisClose); + + yield return new Token(TokenType.Newline, 3); + } + else yield return token; + } + } +} \ No newline at end of file diff --git a/NeoQOLPack/Mods/CosmeticLoaderTitle.cs b/NeoQOLPack/Mods/TitleScreenPatcher.cs similarity index 97% rename from NeoQOLPack/Mods/CosmeticLoaderTitle.cs rename to NeoQOLPack/Mods/TitleScreenPatcher.cs index 3141809..1a8337a 100644 --- a/NeoQOLPack/Mods/CosmeticLoaderTitle.cs +++ b/NeoQOLPack/Mods/TitleScreenPatcher.cs @@ -4,7 +4,7 @@ namespace NeoQOLPack.Mods; -public class CosmeticLoaderTitle : IScriptMod +public class TitleScreenPatcher : IScriptMod { public bool ShouldRun(string path) => path == "res://Scenes/Entities/Player/player_label.gdc"; diff --git a/mods/NeoQOLPack/main.gd b/mods/NeoQOLPack/main.gd index 0c87cca..3cde09d 100644 --- a/mods/NeoQOLPack/main.gd +++ b/mods/NeoQOLPack/main.gd @@ -62,13 +62,6 @@ static func _append_entry(entry): entry["stack_size"] = 0 entry["stacked"] = false -static func _initialize_keys(): - print("######################## INITIALIZING KEYS ########################") - for item in PlayerData.inventory: - if !item.has("locked"): item["locked"] = false - if !item.has("stack_size"): item["stack_size"] = 0 # note: stack size is zero indexed, 0 = 1, 1 = 2, etc - if !item.has("stacked"): item["stacked"] = false # tracks if item is considered stacked with another item - static func _replace_player_label(title): var parent = title.get_child(0) var original = parent.get_child(1) @@ -164,27 +157,3 @@ static func _add_mod_resource(file, file_name): match type: "cosmetic": Globals.cosmetic_data[file_name] = new "item": Globals.item_data[file_name] = new - -static func _stack_items(): - print("######################## STACKING ITEMS ########################") - var tools_to_stack = [] - var items_marked_for_stack = [] - - # Required to ensure everyone's save is updated with the new dictionary keys - for item in PlayerData.inventory: - var file = Globals.item_data[item["id"]]["file"] - if file.category == "tool": - var found_item = false - for t_item in tools_to_stack: - if item["id"] == t_item["id"]: - found_item = true - t_item["stack_size"] += 1 - items_marked_for_stack.append(item) - break - if not found_item: - item["stack_size"] = 0 - item["stacked"] = false - tools_to_stack.append(item) - - for item in items_marked_for_stack: - item["stacked"] = true