52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using HarmonyLib;
|
|
|
|
namespace PriorityUX {
|
|
[HarmonyPatch(typeof(MaterialSelectionPanel))]
|
|
public class MaterialSelectionPanelPatches {
|
|
|
|
[HarmonyPatch(nameof(MaterialSelectionPanel.RefreshSelectors))]
|
|
[HarmonyPostfix]
|
|
static void RefreshSelectorsPostfix(PriorityScreen ___priorityScreen) {
|
|
if (___priorityScreen == null) {
|
|
Debug.Log("RefreshSelectors ___priorityScreen is null");
|
|
return;
|
|
}
|
|
Debug.Log("RefreshSelectors");
|
|
if (___priorityScreen.gameObject != null) {
|
|
Debug.Log("___priorityScreen.gameObject.activeSelf: " + ___priorityScreen.gameObject.activeSelf);
|
|
}
|
|
// if (___priorityScreen.gameObject.activeSelf)
|
|
Utils.refreshPriorityScreen(___priorityScreen);
|
|
}
|
|
|
|
public static void OnKeyDown(KButtonEvent e, MaterialSelectionPanel panel) {
|
|
Debug.Log("MaterialSelectionPanelPatches OnKeyDown " + e.GetAction());
|
|
if (!Options.Instance.enableKeysForBuilding)
|
|
return;
|
|
|
|
Action action = e.GetAction();
|
|
// Repurpose GotoUserNav1 keys (default: Shift+1/2/3/etc.)
|
|
// if (Action.GotoUserNav1 <= action && action <= Action.GotoUserNav10 && e.TryConsume(action)) {
|
|
// int num = (int)(action - 25 + 1);
|
|
if (Action.Plan1 <= action && action <= Action.Plan10 && e.TryConsume(action)) {
|
|
int num = (int)(action - 36 + 1);
|
|
if (num <= 9) {
|
|
panel.PriorityScreen.SetScreenPriority(new PrioritySetting(PriorityScreen.PriorityClass.basic, num), play_sound: true);
|
|
} else {
|
|
panel.PriorityScreen.SetScreenPriority(new PrioritySetting(PriorityScreen.PriorityClass.topPriority, 1), play_sound: true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void OnKeyUp(KButtonEvent e, MaterialSelectionPanel panel) {
|
|
if (!Options.Instance.enableKeysForBuilding)
|
|
return;
|
|
|
|
Action action = e.GetAction();
|
|
if (Action.GotoUserNav1 <= action && action <= Action.GotoUserNav10) {
|
|
e.TryConsume(action);
|
|
}
|
|
}
|
|
}
|
|
}
|