-
Notifications
You must be signed in to change notification settings - Fork 18
Menu System
DoDoCat edited this page Jul 4, 2020
·
7 revisions
<Menu id="mnu_start_game">
<Title>Welcome to OpenMB, please choose the game difficult before starting game.</Title>
<Logic>mnu_start_game.script</Logic>
<Children>
<MenuItem id="mni_start_game_easy">Easy</MenuItem>
<MenuItem id="mni_start_game_medium">Medium</MenuItem>
<MenuItem id="mni_start_game_hard">Hard</MenuItem>
<MenuItem id="mni_return">Return</MenuItem>
</Children>
</Menu>
Each menu should start with a element named <Menu> and end with a </Menu>
There is only one attribute called id in <Menu> which set the menu id
The menu title
Logic block will define which script file will be called when this menu is loaded by engine
this engine should be a valid script file and only has two functions:
-
menuInit- When the menu is inited by the engine -
menuButtonClicked- When you click a menu item
Children block will contains the items of this menu
MenuItem will be showned as the menu options which player can choose
Each menuItem has id and displayText
| Parameter Name | Description |
|---|---|
| None | - |
| Parameter Name | Description |
|---|---|
| Menu Item ID | Which menu item you clicked |
Think about you create a menu in xml with ID menu_example and script is menu_example.script
It has three menu item as following:
- Option 1 with ID
mni_option_1 - Option 2 with ID
mni_option_2
You can use your menu in script like this:
function menuInit
end
function menuButtonClicked
store_input_param %menuID 1 #Store the menu ID into variable %menuID
switch %menuID
case mni_option_1
display_message @{You clicked Option 1!}
end
case mni_option_2
display_message @{You clicked Option 2!}
end
end
end
Use switch_menu script command to switch a specific menu, the parameter on needed is menu's id
such like:
switch_menu YourMenuID