Initial commit
This commit is contained in:
45
mod/Patches/MaterialSelectionPanel.cs
Normal file
45
mod/Patches/MaterialSelectionPanel.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace PriorityUX {
|
||||
[HarmonyPatch(typeof(MaterialSelectionPanel))]
|
||||
public class MaterialSelectionPanelPatches {
|
||||
|
||||
[HarmonyPatch(nameof(MaterialSelectionPanel.RefreshSelectors))]
|
||||
[HarmonyPostfix]
|
||||
static void RefreshSelectorsPostfix(PriorityScreen ___priorityScreen) {
|
||||
Debug.Log("RefreshSelectors");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user