AppMainMenu
Mainmenu in InGame UI for 3D Map system
Title |
Mainmenu in InGame UI for 3D Map system |
Author(s) |
Andy, Xizhi |
Date |
2007/12/29 |
File |
script/kids/3DMapSystemUI/Desktop/MainMenu.lua |
Description
Show the main menu in game UI
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Desktop/MainMenu.lua");
Map3DSystem.UI.MainMenu.InitMainMenu();
Map3DSystem.UI.MainMenu.SendMessage({type = Map3DSystem.UI.MainMenu.MSGTYPE.MENU_SHOW});
Member Functions
Map3DSystem.UI.MainMenu.AddMenuCommand
messge types
Map3DSystem.UI.MainMenu.MSGTYPE = {
MENU_SHOW = 1000,
}
add a menu command at given position. the parent folders must be created beforehand, otherwise it will be inserted to the first unfound folder.
if there is already an object at the position, the add command will do nothing.
- param command :; type of Map3DSystem.App.Command
- param position : this is a tree path string of folder names separated by dot e.g. "Tools.Artist", "File.Save", "File.Open".
- param posIndex : if position is a item in another folder, this is the index at which to add the item. if nil, it is added to end, if 1 it is the beginning.
syntax
function Map3DSystem.UI.MainMenu.AddMenuCommand(command, position, posIndex)
parameters
|
posIndex | if position is a item in another folder, this is the index at which to add the item.
if nil, it is added to end, if 1 it is the beginning. |
Map3DSystem.UI.MainMenu.GetAppCommands
return an iterator for all menu commands whose appKey is same as input
- param appKey : appKey we search for.
syntax
function Map3DSystem.UI.MainMenu.GetAppCommands(appKey)
parameters
appKey |
appKey we search for. |
Map3DSystem.UI.MainMenu.GetItemIndex
return a menu item index by its position. This function is mosted called before
AddMenuCommand to determine where to insert a new command.
- param position : this is a tree path string of folder names separated by dot e.g. "Tools.Artist", "File.Save", "File.Open".
- return nil : if not found, other the item index integer is returned. please note that the index may change when new items are added later on.
syntax
function Map3DSystem.UI.MainMenu.GetItemIndex(position)
parameters
|
position | this is a tree path string of folder names separated by dot
e.g. "Tools.Artist", "File.Save", "File.Open". |
Map3DSystem.UI.MainMenu.OnClickCommand
call the application command
syntax
function Map3DSystem.UI.MainMenu.OnClickCommand(treeNode)
parameters
Map3DSystem.UI.MainMenu.InitMainMenu
call this only once during the game.
init main bar: this does not show the menu, it just build the data structure and messaging system.
syntax
function Map3DSystem.UI.MainMenu.InitMainMenu()
Map3DSystem.UI.MainMenu.SendMessage
send a message to
MainMenu:main window handler
SendMessage({type = Map3DSystem.UI.MainMenu.MSGTYPE.MENU_SHOW});
syntax
function Map3DSystem.UI.MainMenu.SendMessage(msg)
parameters
Map3DSystem.UI.MainMenu.MSGProc
main bar:
MainMenu window handler
syntax
function Map3DSystem.UI.MainMenu.MSGProc(window, msg)
parameters
Map3DSystem.UI.MainMenu.Show
private: for autohide animation.
local function
OnMenuAutoHideToggle(bShow, uiobj)
if(bShow and uiobj and uiobj:IsValid()) then
if(not
FadeInMotion_) then
-- create animation if not create before.
NPL.load("(gl)script/ide/Motion/AnimatorEngine.lua");
FadeInMotion_ =
AnimatorEngine:new({framerate=24});
local groupManager =
AnimatorManager:new();
local layerManager =
LayerManager:new();
local
PopupAnimator =
CommonCtrl.Motion.Animator:new();
PopupAnimator:Init("script/kids/3DMapSystemUI/styles/MenuFadeInMotionData.xml", uiobj.id);
layerManager:AddChild(
PopupAnimator);
groupManager:AddChild(layerManager);
groupManager:AddChild(layerBGManager);
FadeInMotion_:SetAnimatorManager(groupManager);
end
-- play animation
FadeInMotion_:doPlay();
end
end
show or hide main bar UI
syntax
function Map3DSystem.UI.MainMenu.Show(bShow)
parameters
Map3DSystem.UI.MainMenu.UpdateUI
update UI according to data
syntax
function Map3DSystem.UI.MainMenu.UpdateUI()