2 Adding MenuData items to a menu
combustiblelemonade edited this page 1 year ago

In this article we will describe what steps need to be taken to add a menudata item to a menu. First, a menu data type needs to be chosen. Currently there are four: MenuColor, MenuCheckButton, MenuSlider, and MenuLineEdit. They are available as scenes in Assets/UI. Each MenuData object has a label and an index property. The label property is what is shown to the end user, and the index property is the key that is used to store data. These menu items can be added anywhere in a menu.

For this example we take a look at the "Glow" MenuCheckButton. When adding the checkbutton, we set the label and index accorddingly:


We also add a callback to on_glow_toggled, in GraphicsMenu.gd:


The function contains the following code:

func on_glow_toggled(button_pressed):
	if GUI:

In the GUI object there is a function to set the glow:

func set_glow(is_enabled):

Now, all we need to do is call this function at startup too, so the value is initialized correctly. We do this in the apply_settings function in GUI.gd:

func apply_settings():
	for key in settings.keys():
		match key: