Skip to content

Commit

Permalink
Beta 3
Browse files Browse the repository at this point in the history
  • Loading branch information
neomoth committed Oct 23, 2024
1 parent 358aee2 commit 0557445
Show file tree
Hide file tree
Showing 12 changed files with 896 additions and 117 deletions.
18 changes: 10 additions & 8 deletions NeoQOLPack/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,18 +27,20 @@ public Mod(IModInterface modInterface) {
this.Config = modInterface.ReadConfig<Config>();
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) ;
}

Expand Down
43 changes: 0 additions & 43 deletions NeoQOLPack/Mods/CosmeticLoaderPlayer.cs

This file was deleted.

118 changes: 118 additions & 0 deletions NeoQOLPack/Mods/EscMenuPatcher.cs
Original file line number Diff line number Diff line change
@@ -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<Token> Modify(string path, IEnumerable<Token> 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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Token> Modify(string path, IEnumerable<Token> 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"},
Expand All @@ -24,31 +24,31 @@ public IEnumerable<Token> Modify(string path, IEnumerable<Token> 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;
Expand All @@ -67,19 +67,19 @@ public IEnumerable<Token> Modify(string path, IEnumerable<Token> 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);
// yield return new IdentifierToken("_load_mod_resources");
// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Loading

0 comments on commit 0557445

Please sign in to comment.