Theory done, let’s make a menu.
Actually I lied, there’s one more bit of theory we must go through. Specifically let’s talk about what we want to do.
We need to make a button that will be generated through a loop based on a list, and if that list is longer than 15 items it generates arrows that will navigate to the other items.
That last point is actually important to solve now because the other menus require a “refresh” where the buttons are regenerated with other parameters so it will give me the general theory I could use.
The buttons are also meant to be polaroid-like, so they have to be made with two “layers” of sorts, a “frame” and its contents.
And this is all a preamble to the buttons doing their actual function of changing locations. Also, secondary to that, I should look up some kind of tooltip or on-hover text of some kind.
First we create two images, the “base” and the “frame”.


They are 202 x 240, so they’re the exact size of the grid. Ideally the final version will have some breathing space between buttons, but for test purposes this is Fine.

Next, we make the object that will become a prefab. It also has a script attached to it, but that came AFTER I took the screenshot.
…actually, there is one more thing we need to add.

Before we test the base image changing, we will make sure that things are being iterated properly by seeing if a number over it all changes. The main thing is that the first test will involve the list going over 15 so that’s easier than making 16 textures for now.
ANYWAY, we then save the button as a prefab.

Next, before anything else, we load the button scene onto memory uh… where, actually?
Oh yeah, on the bit of code that creates the second window.
…should we load the second window earlier since it’s a constant? NO, I’m getting sidetracked, that’s for later and we’re making the code modular enough that we can adjust later.

Took the chance to clean up a bunch of the variables used during testing while at it.
Wait… wait, no. I cannot call from child to parent so the button can’t be loaded here…
It can be loaded on Global though, which would allow every other script to use it proper.

So we move it there.
Next after that we have to make a single button appear on the Move menu. We start by attaching a script to the Node2D at the root of the Move scene. We add an enter_tree even in advance.

Next we must create a function that loops through it all… we also need a List that holds all the button objects, actually.
Wait no, we don’t need a list, we just need a parent node. The point being that when that object goes away eeeeeeeeeverything else also goes away.
Actually I’m dumb, we do need a list but not to hold all the buttons, rather it’s the list we will temporarily draw from to test the “more than 15 items” scenario.
AHEM
Mental back and forth aside, we end up with this.

cur_holder carries the parent node that carries all the stuff into itself, then cur_button will instantiate the buttons. The loop then sets its position before adding +1 to a variable that basically shifts the image by that much depending on how many times the loop happened. And when the vertical one reaches a fourth row it stops the loop.
So let’s test…

Oh boy that felt good.
Next we need to make the arrows to navigate the other elements. While it’s admittedly not an urgent necessity, I wanna be able to have that context from now instead of in the middle of a more hectic part of the project.
Anyway, we’re gonna need a few things for this. Aside from the navigation buttons that only show up when the list is over a certain amount, we need something to offset from where the loop starts working… So it starts from item 16 and such.
Now, at this point my brain is going like seven different places at once, and all of them carry a similar intrusive thought: Make the button generator global.
My reasoning is that I realized I’m gonna need to copy most of this code at least three times so I might as well make life easier on myself. Not to mention that I can reuse the existing code.

This is the result, it’s roughly the same code but it’s now housed in a function that takes two arguments: a string that tells it a buncha things (which menu to use, where, and draw from what list), and an integer (non-decimal number) that tells it which “page” to start.
As you might guess from that last detail, my intent is for the pages to use this code. This is also why the code is made to loop with different start and end points.
So we do this on the Move script…

…aaaaaaaaaaaaaaaand this code is faulty because it spawns everything as intended… inside Global. Which is not visible nor should be visible.
Simple solution, though.

First we add a new argument.

Then we use it here.

And then we modify the part where the function is used like this.
Now, at this point it works exactly the same but with a fancier codebase. So I move to the next test.

First we modify this line of code.

Then we modify the command like this
IN THEORY, doing this means it generates the Move menu starting from item 15 of the list… and since the list ends there, it stops.

It sure does… I should make a quick test to make sure that it goes up to item 15 and it’s not repeating one.

It’s time we use those text labels I added to the button. This simply replaces the blank text with whatever number that iteration had on the list.

How nice.
Now let’s try modifying that one 0 in the command into a 1…

We’re in the clear.
Next would come the arrows, but setting aside the fact that my brain is already overheating a little, that’s gonna require some extra steps that I’d rather tackle when I’m not rubbing the bridge of my nose every five to ten minutes.
