generated from NotNite/GDWeave.Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
186 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
Teemaw.Calico/ScriptMod/LobbyId/LobbyIdMainMenuScriptModFactory.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
Teemaw.Calico/ScriptMod/LobbyQol/LobbyQolMainMenuScriptModFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using GDWeave; | ||
using GDWeave.Godot; | ||
using GDWeave.Modding; | ||
using Teemaw.Calico.LexicalTransformer; | ||
using static GDWeave.Godot.TokenType; | ||
using static Teemaw.Calico.LexicalTransformer.Operation; | ||
using static Teemaw.Calico.LexicalTransformer.TransformationPatternFactory; | ||
|
||
namespace Teemaw.Calico.ScriptMod.LobbyQol; | ||
|
||
public static class LobbyQolMainMenuScriptModFactory | ||
{ | ||
public static IScriptMod Create(IModInterface mod) | ||
{ | ||
return new TransformationRuleScriptModBuilder() | ||
.ForMod(mod) | ||
.Named("LobbyQolMainMenuScriptMod") | ||
.Patching("res://Scenes/Menus/Main Menu/main_menu.gdc") | ||
.AddRule(new TransformationRuleBuilder() | ||
.Named("globals") | ||
.Matching(CreateGlobalsPattern()) | ||
.Do(Append) | ||
.With( | ||
""" | ||
var calico_most_players | ||
func calico_sort_lobbies_desc(a, b): | ||
return Steam.getNumLobbyMembers(a) > Steam.getNumLobbyMembers(b) | ||
""" | ||
) | ||
) | ||
.AddRule(new TransformationRuleBuilder() | ||
.Named("ready") | ||
.Matching(CreateFunctionDefinitionPattern("_ready")) | ||
.Do(Append) | ||
.With( | ||
""" | ||
code.max_length = 14 | ||
calico_most_players = $"%hidenames".duplicate() | ||
calico_most_players.text = "MOST USERS" | ||
var calico_tt = $"%hidenames".get_parent().get_node("Label").get_node("TooltipNode").duplicate() | ||
calico_tt.header = "Calico: Most Users" | ||
calico_tt.body = "Sorts the lobby list by user count." | ||
calico_most_players.add_child(calico_tt) | ||
$"%hidenames".get_parent().add_child(calico_most_players) | ||
""", 1 | ||
) | ||
) | ||
.AddRule(new TransformationRuleBuilder() | ||
.Named("lobby_list") | ||
.Matching(CreateFunctionDefinitionPattern("_lobby_list_returned", ["lobbies"])) | ||
.Do(Append) | ||
.With( | ||
""" | ||
if calico_most_players.pressed: | ||
lobbies.sort_custom(self, "calico_sort_lobbies_desc") | ||
""", 1 | ||
) | ||
) | ||
.AddRule(new TransformationRuleBuilder() | ||
.Named("lobby_list_cap") | ||
.Matching(CreateGdSnippetPattern("if created_lobbies.has(lobby): return")) | ||
.Do(ReplaceLast) | ||
.With(new Token(CfContinue)) | ||
) | ||
.Build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using GDWeave; | ||
|
||
namespace Teemaw.Calico.Util; | ||
|
||
public static class WeaveUtil | ||
{ | ||
public static bool IsModLoaded(IModInterface modInterface, string modName) => | ||
modInterface.LoadedMods.Contains(modName); | ||
} |