Tuesday, 24 May 2016

FMP Week 19 - Adding Menus and Sound

16/05/16 - 20/05/16

This week I added menus and sound - amazing!

The main menu looks like this:


Here you can change the quality settings:


This displays the controls, but you can't change the key bindings:


I added a credits page for the sounds I used:


Annnnd the ingame pause menu looks like this:


The main menu graph is pretty straightforward, mostly.

When the main menu is constructed, full screen is toggled on. Unfortunately, there doesn't seem to be a simple command to set the game to full screen and keep it there without also specifying the resolution, so if the player were to exit the game back to the main menu it would toggle full screen again, making it windowed. To solve this, after the game is toggled to full screen the first time, the max  screen res values are set and stored.


Using those values, we construct a string to use as a command to set the game to full screen with max res.


Everything else is mostly just setting things visible or invisible.



The settings menu uses console commands to change the quality settings.



In order for the menu to work properly with a gamepad, we need to do a few things. Firstly, we make this:

What this does it change the colour of any button that being focused on, making it easy to see which options are being selected without using a mouse.

Next, we need to set the focus on different buttons, depending on what menus are open. Setting the focus looks like this:

These notes are added whenever we need to open a new set of menus and stuff. The delay is used as a work around for a bug in 4.8 so focus can actually be set.