Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow crafting nodes & tabs in the same space #330

Closed
LeeTwentyThree opened this issue May 15, 2023 · 5 comments · Fixed by #556
Closed

Allow crafting nodes & tabs in the same space #330

LeeTwentyThree opened this issue May 15, 2023 · 5 comments · Fixed by #556

Comments

@LeeTwentyThree
Copy link
Member

Describe the feature
No idea what it is, I got it from Eldritch.

private static class Test21
        { 
            [HarmonyPatch(typeof(uGUI_CraftingMenu), nameof(uGUI_CraftingMenu.IsGrid))] 
            private static void Postfix(uGUI_CraftingMenu.Node node, ref bool __result)
            { 
                __result = ShouldGrid(node);
            }

            private static bool ShouldGrid(uGUI_CraftingMenu.Node node)
            {
                var craftings = 0;
                var tabs = 0;

                foreach (var child in node)
                {
                    if (child.action == TreeAction.Expand) tabs++;
                    else if (child.action == TreeAction.Craft) craftings++;
                }

                return craftings > tabs;
            }

            [HarmonyPatch(typeof(uGUI_CraftingMenu), nameof(uGUI_CraftingMenu.Collapse))] 
            private static void Postfix(uGUI_CraftingMenu.Node parent)
            {
                if (parent == null) return;

                if (parent.action != TreeAction.Craft) return;

                parent.icon.SetActive(false);
            }
        }
@EldritchCarMaker
Copy link
Contributor

The initial patch and the ShouldGrid method are used to decide if a specific crafting node should be displayed as a grid or as a single vertical line. Normally in the game if there is even a single tab node in a section then it will force every single node to be completely vertical. This changes that so that it only becomes vertical if there's more tab nodes than crafting nodes. This means that all vanilla crafting trees will remain untouched, but that theoretically you could add a new modded tab node to a crafting section without forcing the entire section to unnecessarily become a straight vertical line.

@EldritchCarMaker
Copy link
Contributor

EldritchCarMaker commented May 15, 2023

The second patch is there to disable any crafting nodes that are on the same tab as an opened tab node. Normally the game closes any other tab nodes when a new one is opened, but this extends it slightly further to also disable any other crafting nodes when a tab is opened. This also will have no effect on vanilla crafting trees, but it means that a mod could add a tab to a set of crafting nodes without having to deal with overlapping

This does have a decent flaw, however, in that the tabs retain their original position when they're opened, while all the craft nodes disappear. So this means that the tab nodes will basically be floating.

For example, in a 2x2 grid,

A, B
C, D

if A, B, and C are all craft nodes, but D is a tab node, if D is opened then A, B, and C will all disappear, but D will remain in the same place, leading to

0 0
0 D

Where the zeroes are simply empty space.

@LeeTwentyThree
Copy link
Member Author

What mods can I use to test this?

@LeeTwentyThree LeeTwentyThree changed the title Look into adding this code Allow crafting nodes & tabs in the same space May 15, 2023
@EldritchCarMaker
Copy link
Contributor

Unfortunately there are currently none public, largely because nautilus itself stops mods from doing it

InternalLogger.Error($"Cannot add tab: {tab.Name} as it is being added to a parent node that contains crafting nodes.");

So this check should be removed first for a custom nautilus build, and then a test mod can be made (or you can use the repl console, depending on how much experience you have with the original code

@MrPurple6411
Copy link
Member

MrPurple6411 commented Sep 25, 2023

@EldritchCarMaker I put those limitations in place because the only way it doesn't currently MASSIVLY break the visuals when you have them together is using the Radial Tabs mod.

If you are not using the radial tabs mod and do as you are asking and then try and open the new tab node that is horizontally placed it will open right where it is and you then have its sub items overlapping the current nodes which are also there.

One day I will see about reworking the system so that it Only shows the Crafting nodes of the currently opened tab which should fix this issue at which point I will implement your request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants