Skip to content
nhmkdev edited this page Jan 2, 2014 · 6 revisions

The custom menu system is used for accessing other custom menus and or game modes via a standard interface. The custom menu system uses the mode stack.

Menu data is part of the global data:

var Menus = ig.global.data.menus;

A menu is the following:

  • Title text (optional)
  • List of options (optional) ** Selector (icon or character)
  • Windows (optional)

Menu data format: (Note that the sampleBaseSettings is a seperate object for easy reuse across objects)

var sampleBaseSettings =
{
	x:50, // target x (default: 0)
	y:20, // target y (default: 0)
	ys:20, // y space between items (default: 10)
	w:true, // wrap on menu down/up on first/last item (default: false)
	ab:false, // allow backup (previous menu) (default: true)
	f: '04b03.font', // font ('media/' is prepended and '.png' is appended)
	
	// menu selection can be indicated with a graphic or a character
	// selection character
	mc: '=', // menu char (default: '>')
	// selection icon
	micn:'slime-grenade', // icon ('media/' is prepended and '.png' is appended)
	micna:
	{
			sx:0, // source x (default: 0)
			sy:0, // source y (default: 0)
			w:8, // width (default: image width)
			h:8 // height (default: image height)
	},
}

Menus.sample =
{
	mi: // menu items array
	[
		{
			t: "Start Game", // text
			g:'MainGame', // game mode (if selected it will switch)
			// OR
			m:'mainMenu' // custom menu (if selected with switch) -- 'ig.support.global.menus.' is prepended
		},
	],
	s: // settings for the menu
	{
		base:sampleBaseSettings, // base settings
		ys:30 // sample override of a value in base
	}
};

Code Usage

Setting the current menu

Any time you need open a menu (game mode!):

Support.custommenu.data = Menus.mainMenu;
ig.system.setGame(CustomMenu);

Clone this wiki locally