Skip to content

Menu System

DoDoCat edited this page Jul 4, 2020 · 7 revisions

Code Example:

<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>

Elements:

<Menu> Element

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

<Title> Element

The menu title

<Logic> Element

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> Element

Children block will contains the items of this menu

<MenuItem> Element

MenuItem will be showned as the menu options which player can choose
Each menuItem has id and displayText

Usage:

menuInit script function

Parameter Name Description
None -

menuButtonClicked script function

Parameter Name Description
Menu Item ID Which menu item you clicked

switch a menu

Use switch_menu script command to switch a specific menu, the parameter on needed is menu's id
such like:

switch_menu YourMenuID  
Clone this wiki locally