Skip to content

Commit 198fcc7

Browse files
fix: Re-introduce gridding in mixed craft tree tabs (#565)
1 parent 931ffb1 commit 198fcc7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Nautilus/Patchers/CraftDataPatcher.cs

+39
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,45 @@ internal static void Patch(Harmony harmony)
7878

7979
InternalLogger.Log("CraftDataPatcher is done.", LogLevel.Debug);
8080
}
81+
82+
[HarmonyPatch(typeof(uGUI_CraftingMenu), nameof(uGUI_CraftingMenu.IsGrid))]
83+
[HarmonyPrefix]
84+
private static bool ShouldGridPostfix(uGUI_CraftingMenu.Node node, ref bool __result)
85+
{
86+
__result = ShouldGrid();
87+
return false;
88+
89+
bool ShouldGrid()
90+
{
91+
var craftings = 0;
92+
var tabs = 0;
93+
94+
foreach (var child in node)
95+
{
96+
if (child.action == TreeAction.Expand)
97+
{
98+
tabs++;
99+
}
100+
else if (child.action == TreeAction.Craft)
101+
{
102+
craftings++;
103+
}
104+
}
105+
106+
return craftings > tabs;
107+
}
108+
}
109+
110+
[HarmonyPatch(typeof(uGUI_CraftingMenu), nameof(uGUI_CraftingMenu.Collapse))]
111+
[HarmonyPostfix]
112+
private static void CollapsePostfix(uGUI_CraftingMenu.Node parent)
113+
{
114+
if (parent == null) return;
115+
116+
if (parent.action != TreeAction.Craft) return;
117+
118+
parent.icon.SetActive(false);
119+
}
81120

82121
[HarmonyPrefix]
83122
[HarmonyPatch(typeof(CraftData), nameof(CraftData.GetTechType), new Type[] { typeof(GameObject), typeof(GameObject) }, argumentVariations: new ArgumentType[] { ArgumentType.Normal, ArgumentType.Out })]

0 commit comments

Comments
 (0)