Entry 05 - Fun with UI ~Part Deux
After another week working on it, I’m glad to say the main menu for the game is pretty much finished. It took longer than I anticipated, but I’m very happy with what I’ve achieved. Let’s go into what I’ve added.
File Menu Navigation
I wanted the player to be able to cycle between the horizontal save slot list, shifting them left or right depending on the player’s input, while making designated the file landing in the middle as the selected file. To achieve this I implemented a method very similar to the method I detailed in my second post (where each button on the main menu is shifted up or down upon input). I created 9 save slots, with four extra potential positions on each side of the slot list, making for a total of 17 possible slot positions. I think this’ll be explained better with the screenshot below.
From their position in this image, the slots can be shifted a maximum of four spaces in either direction.
Happily, this navigation works as well as the navigation on the main menu. From there, it was just a case of checking whether the file cursor was highlighted before moving any of the buttons, which was a simple enough check. The code for this save slot navigation can be seen below.
Quite similar to my method from earlier, though I still had to work through some IndexOutOfRange exceptions.
File Selection Test
After I had the navigation set up, I set about testing file selection. I don’t have saving and loading implemented yet, so I set it up with a “Dummy” save file script, where it would find the save file and simply load the next scene if it did so. This test worked out successfully, and will surely facilitate my work on saving and loading in future. The methods for determining the highlighted save file and reading it can be seen below. They are quite small at the moment.
My methods for selecting the highlighted file and reading its data, along with my empty save file class, no doubt the code here will get more complex later on.
Info Panel
After I had completed implementing the file screen’s functionality, I decided to change the main menu somewhat. I decided it would be better if the player always went through the file menu before playing the menu, this would make the “New Game” and “Load Game” options redundant, so I changed the main menu option names as well as their behaviours. The new menu options can be seen below:
How the options on the main menu look now.
As you can see above, “New Game” has been replaced with “Start”, this option will now take the player to the file selection screen. Also, “Load Game” has been replaced with “Info”, this is a new panel I created. I felt that this panel could be used to inform the player of the controls and the game’s backstory. At the moment, it is bare-bones (I haven’t added the game controls yet, as we haven’t finalised them yet), all it displays is the scenario for the game. This scenario has given me an idea I may try in future: The scenario info could change depending on the progress of the last save file played. For example, if the player last saved one of the slots at level 2, the scenario for level 2 would be displayed on the info screen instead. I think this would be a nifty idea, something similar can be seen in the title screen of Half-Life 2. The Info screen as it is currently can be seen below.
The info screen, displaying the game’s backstory.
Moving Panels
As an extra, I managed to add functionality that allows panels to move onto and off the screen depending on whether or not they were active. Previously, the menus would just appear and disappear. I achieved this by providing each panel with an active and inactive position, so that they could lerp to each position when appropriate. The only challenge with this was ensuring the highlighter could keep up with the menus moving on startup. After some troubleshooting and use of bools, I managed to get the highlighter to appear natural at all times.
That’s all for this week, the menu is pretty much finished. Next week I will likely work on implementing joystick input for the game.
‘Til next time!