-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added ModdedLobbyTag patch, to show which lobbies have mods.
-Credit for this patch goes to myself and Badryuner
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Collections.Generic; | ||
using static System.Reflection.Emit.OpCodes; | ||
using HarmonyLib; | ||
using static PulsarModLoader.Patches.HarmonyHelpers; | ||
|
||
namespace PulsarModLoader.Patches | ||
{ | ||
[HarmonyPatch(typeof(PLUIPlayMenu), "Update")] | ||
class ModdedLobbyTag | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> targetSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(Ldfld), | ||
new CodeInstruction(Ldsfld), | ||
new CodeInstruction(Ldloc_S), | ||
new CodeInstruction(Callvirt), | ||
new CodeInstruction(Callvirt, AccessTools.Method(typeof(PLReadableStringManager), "GetFormattedResultFromInputString")), | ||
new CodeInstruction(Callvirt, AccessTools.Method(typeof(UnityEngine.UI.Text), "set_text")) | ||
}; | ||
|
||
List<CodeInstruction> injectedSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(Call, AccessTools.Method(typeof(ModdedLobbyTag), "PatchMethod")) | ||
}; | ||
return PatchBySequence(instructions, targetSequence, injectedSequence, patchMode: PatchMode.REPLACE, checkMode: CheckMode.NONNULL); | ||
} | ||
static void PatchMethod(PLUIPlayMenu.UIJoinGameElement jge) | ||
{ | ||
if (jge == null) | ||
return; | ||
|
||
string formattedResultInputString = PLReadableStringManager.Instance.GetFormattedResultFromInputString(jge.Room.Name); | ||
|
||
if (jge.Room.CustomProperties.TryGetValue("isModded", out object _)) | ||
{ | ||
jge.GameName.text = "<size=20><color=yellow>M</color></size> " + formattedResultInputString; | ||
} | ||
else jge.GameName.text = formattedResultInputString; | ||
} | ||
} | ||
} |
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