Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions Menu/LocalisedChoiceElement.cs

This file was deleted.

18 changes: 0 additions & 18 deletions Menu/LocalisedListChoiceModel.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Menu/LocalisedTextButton.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Menu/OnLanguageUpdatedHelper.cs

This file was deleted.

55 changes: 55 additions & 0 deletions Patches/ModMenuPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using HarmonyLib;
using Silksong.ModMenu.Elements;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;

namespace VVVVVV.Patches;

/*
If you are reading this, DO NOT copy this because it's wicked fragile and incredibly cursed.

Without this patch, MenuMod v0.4.1 is throwing an NRE because the component being
added immediately OnEnable's and attempts to access a member of its 'textField' member
before that actually is set to anything.

I need to investigate and figure out if that's somehow my fault or not.
And then file a bug report if it's not me. And then remove this patch.
*/
[HarmonyPatch(typeof(LocalizedTextExtensions), nameof(LocalizedTextExtensions.set_LocalizedText))]
internal static class ModMenuPatch {

private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
=> new CodeMatcher(instructions)

// component = self.gameObject.AddComponent<AutoLocalizeTextUI>();
.MatchStartForward([
new(x => x.opcode == OpCodes.Callvirt && x.operand is MethodInfo m && m.Name == "AddComponent"),
])
.Insert([
Transpilers.EmitDelegate(DeactivateAndReturnGO)
])

// component.textField = self;
.MatchStartForward([
new(x => x.opcode == OpCodes.Stfld && x.operand is FieldInfo f && f.Name == "textField"),
])
.Advance(1)
.Insert([
new(OpCodes.Ldarg_0),
new(OpCodes.Callvirt, typeof(Component).GetMethod("get_gameObject")),
Transpilers.EmitDelegate(ActivateAndConsumeGO),
])

.InstructionEnumeration();

static GameObject DeactivateAndReturnGO(GameObject go) {
go.SetActive(false);
return go;
}

static void ActivateAndConsumeGO(GameObject go)
=> go.SetActive(true);

}
20 changes: 7 additions & 13 deletions Settings/FaydownState.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Silksong.ModMenu.Models;
using System;
using System.Linq;
using VVVVVV.Menu;
using VVVVVV.Utils;

namespace VVVVVV.Settings;
Expand All @@ -15,17 +15,11 @@ internal static class FaydownStateExt {

public static bool FlipsGravity(this FaydownState state)
=> state == FaydownState.FlipGravity;
public static bool DoubleJumps(this FaydownState state)
=> state == FaydownState.DoubleJump;
public static bool IsDisabled(this FaydownState state)
=> state == FaydownState.Disabled;

public static LocalisedListChoiceModel<FaydownState> LocalisedChoiceModel()
=> new([
.. Enum.GetValues(typeof(FaydownState))
.Cast<FaydownState>()
.Select(x => (x, LangUtil.String(x.MenuLangKey()))),
]);

public static ListChoiceModel<FaydownState> LocalisedChoiceModel()
=> new([.. Enum.GetValues(typeof(FaydownState)).Cast<FaydownState>()]) {
DisplayFn = (int _, FaydownState val) => LangUtil.String(val.MenuLangKey())
};

public static string MenuLangKey(this FaydownState state)
=> state.LangKey("MENU_FLIPDOWN");
Expand Down
49 changes: 16 additions & 33 deletions Settings/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using Silksong.ModMenu.Elements;
using Silksong.ModMenu.Plugin;
using Silksong.ModMenu.Screens;
using System.Collections.Generic;
using UnityEngine;
using VVVVVV.Menu;
using VVVVVV.Utils;

namespace VVVVVV.Settings;
Expand All @@ -18,49 +16,26 @@ internal class ModSettings : IModMenuCustomMenu {

public FaydownState FaydownState => faydownState?.Value ?? FAYDOWN_STATE_DEFAULT;
private ConfigEntry<FaydownState>? faydownState;
private LocalisedChoiceElement<FaydownState>? faydownOption;
private ChoiceElement<FaydownState>? faydownOption;

public KeyCode RespawnKey => respawnKey?.Value ?? RESPAWN_KEY_DEFAULT;
private ConfigEntry<KeyCode>? respawnKey;
private LocalisedChoiceElement<KeyCode>? respawnKeyOption;
private static readonly List<KeyCode> bindableKeys = [
KeyCode.None,
KeyCode.F3,
KeyCode.F4,
KeyCode.F5,
KeyCode.F6,
KeyCode.F7,
KeyCode.F8,
KeyCode.F9,
KeyCode.F10,
KeyCode.Backspace,
KeyCode.Tab,
KeyCode.Backslash,
KeyCode.Slash,
KeyCode.LeftAlt,
KeyCode.RightAlt,
];
private KeyBindElement? respawnKeyOption;

public void BindConfigEntries() {
respawnKey = Config.Bind("", "RespawnKeybind", RESPAWN_KEY_DEFAULT);
if (!bindableKeys.Contains(respawnKey.Value))
respawnKey.Value = KeyCode.None;

faydownState = Config.Bind("", "FayfornsGift", FAYDOWN_STATE_DEFAULT);
}

public string ModMenuName() => V6Plugin.Name;

public AbstractMenuScreen BuildCustomMenu() {
LocalisedTextButton respawnBtn = new(LangUtil.String("MENU_RESPAWN_BUTTON")) {
OnSubmit = V6Plugin.QueueRespawnHero
};
// This does nothing when you press the button, now. It used to work on ModMenu 0.2.0...
//TextButton respawnBtn = new(LangUtil.String("MENU_RESPAWN_BUTTON")) {
// OnSubmit = V6Plugin.QueueRespawnHero
//};

respawnKeyOption = new(
LangUtil.String("MENU_RESPAWN_KEY_LABEL"),
bindableKeys,
LangUtil.String("MENU_RESPAWN_KEY_DESC")
);
respawnKeyOption = new(LangUtil.String("MENU_RESPAWN_KEY_LABEL"));
SyncEntryAndElement(respawnKey!, respawnKeyOption);

faydownOption = new(
Expand All @@ -71,7 +46,15 @@ public AbstractMenuScreen BuildCustomMenu() {
SyncEntryAndElement(faydownState!, faydownOption);

SimpleMenuScreen screen = new(ModMenuName());
screen.AddRange([respawnBtn, respawnKeyOption, faydownOption]);
MenuElement[] elements = [
//respawnBtn,
respawnKeyOption,
faydownOption,
];
screen.AddRange(elements);
// genuinely do not have a clue why this is needed, but it is
foreach(var elt in elements)
elt.Container.transform.SetParent(screen.Container.transform, false);

return screen;
}
Expand Down
4 changes: 2 additions & 2 deletions V6Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
namespace VVVVVV;

[BepInAutoPlugin(id: "io.github.kaycodes13.vvvvvv")]
[BepInDependency("org.silksong-modding.fsmutil", "0.3.12")]
[BepInDependency("org.silksong-modding.modmenu", "0.2.0")]
[BepInDependency("org.silksong-modding.fsmutil", "0.3.13")]
[BepInDependency("org.silksong-modding.modmenu", "0.4.1")]
[BepInDependency("org.silksong-modding.i18n", "0.1.0")]
public partial class V6Plugin : BaseUnityPlugin, IModMenuCustomMenu {

Expand Down
2 changes: 1 addition & 1 deletion VVVVVV.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="Hamunii.BepInEx.AutoPlugin" Version="2.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Unity.Analyzers" Version="1.26.0" PrivateAssets="all" />
<PackageReference Include="Silksong.FsmUtil" Version="0.3.13" />
<PackageReference Include="Silksong.ModMenu" Version="0.2.0" />
<PackageReference Include="Silksong.ModMenu" Version="0.4.1" />
<PackageReference Include="UnityEngine.Modules" Version="6000.0.50" IncludeAssets="compile" />
<PackageReference Include="Silksong.GameLibs" Version="*-*" PrivateAssets="all" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
},
"Silksong.ModMenu": {
"type": "Direct",
"requested": "[0.2.0, )",
"resolved": "0.2.0",
"contentHash": "4DPSOVaF7mZoHPyfF+hqI0BCm+OAZJpj9566ZwE93YmUZADf/6OlmI1jGY3/mHkRFrshwUpVdhE8okPZ06hpUQ==",
"requested": "[0.4.1, )",
"resolved": "0.4.1",
"contentHash": "eN1/ow8EREYoP/IggMZ0GQCOX3hCxL9RHLmWLwhrDrFdP/tHRiW0RYROwZ3hp9NiSnrqYtcYv+UcMBoavUO3Ag==",
"dependencies": {
"BepInEx.Core": "5.4.21",
"HarmonyX": "2.9.0",
Expand Down
4 changes: 2 additions & 2 deletions thunderstore/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ containsNsfwContent = false
# dependencies are specified in the format AuthorName-PackageName = "version". You should always have at least BepInExPack_Silksong.
[package.dependencies]
BepInEx-BepInExPack_Silksong = "5.4.2304"
silksong_modding-FsmUtil = "0.3.12"
silksong_modding-ModMenu = "0.2.0"
silksong_modding-FsmUtil = "0.3.13"
silksong_modding-ModMenu = "0.4.1"
silksong_modding-I18N = "0.1.0"


Expand Down