Time for action – using the UI Emulator to test the FreeSDK demo menus
Follow the given steps:
Open the UI Emulator and enable the Flow Graph updates (the play button in the top menu bar). Clear the state by pressing the little trash icon.
Now click on the Sys->UI button in the Objects panel. If you select the System UIEventSytem, you will find a list of all the system events. If you double-click on one of the events in the event list, it gets attached to the Emulation panel on the right.
For now, we want to see what happens if the game starts, if a level loads, and if the gameplay starts. So let's add the following events to the Emulation panel:
OnSystemStart
OnLoadingStart
OnGameplayStated
If you call OnSystemStart, the main menu should appear. You can also look into the Flow Graph and enable Flow Graph debugging to see which nodes are triggered to fill the main menu. The flow starts in the sys_statecontrol UI Action (there should be the UI:Events:System:OnSystemStart node that then starts another UI Action).
You can always reset the state by pressing the trash icon. If you enable UI Action logging (in the Settings tab on the left-hand side of the UI Emulator, or with the gfx_uiaction_log 1 CVAR), you will see what happens in the EventLog window.
Note
With the big X button in the top button bar, you can clear the log.
Repeat the steps with the OnLoadingStart and OnGameplayStarted events.
What just happened?
By using the UI Emulator, you can easily see how the UI Action flow handles the different system events. This is a great tool that helps a lot in setting up your menus without the need of starting the launcher and restarting it every time you changed something. You can also change your UI Actions and see the result directly, without the need of using Sandbox to create/change your UI Actions and then starting the launcher to see the results.
Have a go Hero – creating a new menu page
Try to create a new menu page for the main menu. Look into the MM_Main UI Action Flow Graph and add a new button for your new menu page. Look into MM_SoundSettings, on how this page is set up and how the button in the MM_Main UI Action is set up to go to the Sound Settings menu.
Note
Look in the UI:Functions:MainMenu:AddButton node of the mm_main UI Action that creates the button with the @ui_SoundSettings caption. Look for it's id. Isn't it the same name as the MM_SoundSettings UI Action?
Pop quiz – UI Actions
Where are the Flash element XML definition files located?
LibsUI
LibsUIUIElements
LibsUIUIActions
When using a textfield to display some info, such as the current health, what type of textfield do you have to use?
Input Text
Static Text
Dynamic Text
If you want to raise an event from Flash, what ActionScript function do you need to call?