Skip to content

Commit

Permalink
version 1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
neomoth committed Oct 23, 2024
1 parent 88f53b1 commit 624616e
Show file tree
Hide file tree
Showing 15 changed files with 648 additions and 15 deletions.
13 changes: 12 additions & 1 deletion NeoQOLPack/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Mod : IMod
public Config Config;
public ILogger Logger;

private static readonly string versionTag = "Beta5";
private static readonly string versionTag = "v1.0";
private static readonly string repo = "neomoth/NeoQOLPack";

private bool injectUpdateNotice = false;
Expand All @@ -37,6 +37,8 @@ public Mod(IModInterface modInterface) {
modInterface.RegisterScriptMod(new MenuPatcher(this, versionTag));
modInterface.RegisterScriptMod(new OptionsMenuPatcher());
modInterface.RegisterScriptMod(new EscMenuPatcher());
modInterface.RegisterScriptMod(new ButtonSellPatcher());
modInterface.RegisterScriptMod(new ShopCategoryPatcher());
if (injectUpdateNotice) ;
}

Expand All @@ -56,6 +58,15 @@ private async Task GetVersion()

injectUpdateNotice = newVer > currVer;
}
else
{
Version latest = new Version(latestVersion.StartsWith('v') ? latestVersion[1..] : latestVersion);
Version current = new Version(versionTag.StartsWith('v') ? versionTag[1..] : versionTag);

int comparison = latest.CompareTo(current);

injectUpdateNotice = comparison > 0;
}
}
catch (Exception e)
{
Expand Down
115 changes: 115 additions & 0 deletions NeoQOLPack/Mods/ButtonSellPatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using GDWeave.Godot;
using GDWeave.Modding;
using GDWeave.Godot.Variants;

namespace NeoQOLPack.Mods;

public class ButtonSellPatcher : IScriptMod
{
public bool ShouldRun(string path) => path == "res://Scenes/HUD/Shop/ShopButtons/button_sell.gdc";

public IEnumerable<Token> Modify(string path, IEnumerable<Token> tokens)
{
// when not waiting for this the error goes away but then i get another error saying "item" isn't valid in this scope at the same line number?????
MultiTokenWaiter setupItemWaiter = new MultiTokenWaiter([
t => t is IdentifierToken { Name: "_setup" },
t => t is IdentifierToken { Name: "slot_desc" },
t => t.Type is TokenType.Newline
], allowPartialMatch: true);

// i thought maybe i wasn't getting the right spot? no fucking clue
MultiTokenWaiter customUpdateWaiter = new MultiTokenWaiter([
t => t is IdentifierToken { Name: "_custom_update" },
t => t is IdentifierToken { Name: "linked_ref" },
t => t is IdentifierToken { Name: "has" },
t => t.Type is TokenType.OpAssign,
t => t is ConstantToken { Value: BoolVariant { Value: true } },
t => t.Type is TokenType.Newline
], allowPartialMatch: true);

MultiTokenWaiter customPurchaseWaiter = new MultiTokenWaiter([
t => t is IdentifierToken { Name: "_custom_purchase" },
t => t is IdentifierToken { Name: "linked_ref" },
t => t.Type is TokenType.Newline
], allowPartialMatch: true);

foreach (Token token in tokens)
{
if (setupItemWaiter.Check(token))
{
yield return token;

yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("item");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("PlayerData");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("_find_item_code");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("linked_ref");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("item");
yield return new Token(TokenType.BracketOpen);
yield return new ConstantToken(new StringVariant("locked"));
yield return new Token(TokenType.BracketClose);
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("locked");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(true));
yield return new Token(TokenType.Newline, 2);
yield return new IdentifierToken("slot_desc");
yield return new Token(TokenType.OpAssignAdd);
yield return new ConstantToken(new StringVariant("\n[color=red]This item is locked and cannot be sold.[/color]"));

yield return new Token(TokenType.Newline);
}
else if (customUpdateWaiter.Check(token))
{
yield return token;

yield return new Token(TokenType.Newline, 3);
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("item");
yield return new Token(TokenType.BracketOpen);
yield return new ConstantToken(new StringVariant("locked"));
yield return new Token(TokenType.BracketClose);
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 4);
yield return new IdentifierToken("locked");
yield return new Token(TokenType.OpAssign);
yield return new ConstantToken(new BoolVariant(true));

yield return new Token(TokenType.Newline, 1);
}
else if (customPurchaseWaiter.Check(token))
{
yield return token;

yield return new Token(TokenType.PrVar);
yield return new IdentifierToken("item");
yield return new Token(TokenType.OpAssign);
yield return new IdentifierToken("PlayerData");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("_find_item_code");
yield return new Token(TokenType.ParenthesisOpen);
yield return new IdentifierToken("linked_ref");
yield return new Token(TokenType.ParenthesisClose);
yield return new Token(TokenType.Newline, 1);
yield return new Token(TokenType.CfIf);
yield return new IdentifierToken("item");
yield return new Token(TokenType.Period);
yield return new IdentifierToken("locked");
yield return new Token(TokenType.Colon);
yield return new Token(TokenType.Newline, 2);
yield return new Token(TokenType.CfReturn);

yield return new Token(TokenType.Newline, 1);
}
else yield return token;
}
}
}
Loading

0 comments on commit 624616e

Please sign in to comment.