---++!! !AppCommands %TOC{title="Contents:"}% %STARTINCLUDE% ---++ commands in application | *Title* | commands in application | | *Author(s)* | LiXizhi | | *Date* | 2008/1/4 | | *File* | script/kids/3DMapSystemApp/AppCommands.lua | ---+++ Description * To call a command: Map3DSystem.App.Commands.Call("CommandName", param1, ...) * To get a command: local cmd = Map3DSystem.App.Commands.GetCommand("CommandName") %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/AppCommands.lua"); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.IsCommandAvailable <verbatim> A constant specifying if information is returned from the check, and if so, what type of information is returned. Map3DSystem.App.CommandStatusWanted = { -- the status of the current command (Map3DSystem.App.CommandStatus) is wanted StatusWanted = 1, -- the command name is wanted in the current language setting. NameWanted = 2, -- the command description is wanted. DescriptionWanted = 3, -- the tooltip for this command is wanted. TooltipWanted = 4, }; descripting the current status of a given application command item such as in mainbar or menu. values can be added together to achieve some bitwise operation like (Map3DSystem.App.CommandStatus.Enabled + Map3DSystem.App.CommandStatus.Supported) Map3DSystem.App.CommandStatus = { -- The command is currently enabled. Enabled = 1, -- The command is currently hidden. Invisible = 2, -- The command is currently latched (locked). Locked = 4, -- The command is Reserved for future use. Reserved = 8, -- The command is supported in this context. Supported = 16, -- The command is not supported in this context. Unsupported = 32, }</verbatim>; a static function that check if Map3DSystem.App.CommandStatus is available. __syntax__ <verbatim>function Map3DSystem.App.IsCommandAvailable(commandStatus)</verbatim> __parameters__ | *commandStatus* | | ---++++ !Map3DSystem.App.Command:new <verbatim> Defines command style options. Map3DSystem.App.CommandStyle = { --This command displays an icon only when placed on a mainbar. It displays an icon and text on a menubar. Pict = nil, -- This command displays both an icon and text on both mainbars and menubars. PictAndText = 1, -- This command displays text on a mainbar. It displays both icon and text on a menubar. Text = 2, -- this is just a separator not a clickable command. Separator = 3, }; ----------------------------------------- command ----------------------------------------- Represents a command in the environment. a command is usually displayed as a button in the mainmenu, mainbar, action feed bar, or even a tradable item. Map3DSystem.App.Command = { -- a command must have a unique string name, for tradable items, it may be the item name plus its GUID. -- name command with only letters with "." to seperate category. such as "Tools.Art.ModelBrowser", -- internally, we will use a tree hierarchy to store commands instead of a flat tree. Each dot in the name create a sub tree. name = nil, -- application key that this command should be executed in, this can be nil if onclick is not nil. app_key = nil, -- The name to use if the command is bound to a button that is displayed by name rather than by icon. ButtonText = nil, -- The text displayed when a user hovers the mouse pointer over any control bound to the new command. tooltip = nil, -- default icon path of the command icon = nil, -- whether the command is tradable. if true, it can be exchanged between different user's inventory box IsTradable = nil, -- any additional data associated with this command. tag = nil, -- type of the command, some application may needs this to distinguish the same command name under different situations. type = nil, -- command status, it should be nil or addition of the Map3DSystem.App.CommandStatus CommandStatus = nil, -- Value from the Map3DSystem.App.CommandStyle enumeration. Controls the visual style of any UI added for this command. CommandStyle = nil, -- this is function to be called when app_key is nil. format is function(self) end where self is the command object itself. onclick = nil, }</verbatim>; create a new command __syntax__ <verbatim>function Map3DSystem.App.Command:new (o)</verbatim> __parameters__ | *o* | | ---++++ !Map3DSystem.App.Command:IsAvailable Gets a value indicating whether or not the Command is currently enabled __syntax__ <verbatim>function Map3DSystem.App.Command:IsAvailable()</verbatim> ---++++ !Map3DSystem.App.Command:AddControl Creates a persistent command bar control for the command. It may be a button in mainbar or mainmenu or inventory, or actionfeed, etc * _param_ __owner__ : it may be "mainbar", "mainmenu", "actionfeed", "inventory", "desktop". * _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. See GetPosIndex() below __syntax__ <verbatim>function Map3DSystem.App.Command:AddControl(owner, position, posIndex)</verbatim> __parameters__ | *owner* | it may be "mainbar", "mainmenu", "actionfeed", "inventory", "desktop". | | *position* | | | *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. See GetPosIndex() below | ---++++ !Map3DSystem.App.Command.GetPosIndex [static function] get the position index of an existing position string. One can call this function on a predefined position, such as a named separator in the mainmenu, to determine where the current command should be inserted. * _param_ __owner__ : it may be "mainbar", "mainmenu", "actionfeed", "inventory", "desktop". * _param_ __position__ : this is a tree path string of folder names separated by dot e.g. "Tools.Artist", "File.Save", "File.Open". * _return_ ____ : return the index for the position string. it may return nil if position is not found. __syntax__ <verbatim>function Map3DSystem.App.Command.GetPosIndex(owner, position)</verbatim> __parameters__ | *owner* | it may be "mainbar", "mainmenu", "actionfeed", "inventory", "desktop". | | *position* | | | *return* | return the index for the position string. it may return nil if position is not found. | ---++++ !Map3DSystem.App.Command:HighLight TODO: use an UI highlighter to guide the user to click this command. It needs to save parameters in AddControl(owner, position) in order to do this automatically for each type of owner. __syntax__ <verbatim>function Map3DSystem.App.Command:HighLight()</verbatim> ---++++ !Map3DSystem.App.Command:Call Executes the specified command. It will first call QueryStatus and then call Exec of the given commands. * _param_ __params__ : optional parameters * _return_ __the__ : msg is returned. __syntax__ <verbatim>function Map3DSystem.App.Command:Call (params)</verbatim> __parameters__ | *params* | optional parameters | ---++++ !Map3DSystem.App.Command:Delete Removes a named command that was created with the Map3DSystem.App.AddNamedCommand method. __syntax__ <verbatim>function Map3DSystem.App.Command:Delete()</verbatim> ---++++ !Map3DSystem.App.Commands.AddNamedCommand <verbatim>----------------------------------------- commands ----------------------------------------- Contains all of the commands, in the form of Command objects, in the environment. internally, we will use a tree hierarchy to store commands instead of a flat tree. Each dot in the name create a sub tree. Map3DSystem.App.Commands = { -- private: internal data to store all commands _commands = {}, -- mapping from command id to command name DefaultCmds = { Login = "Profile.Login", LoadWorld = "File.EnterWorld", SysCommandLine = "File.SysCommandLine", EnterChat = "Profile.Chat.QuickChat", }, }</verbatim>; Creates a named command and add it to the IDE commands list * _param_ __command__ : partial table of Map3DSystem.App.Command __syntax__ <verbatim>function Map3DSystem.App.Commands.AddNamedCommand(command)</verbatim> __parameters__ | *command* | partial table of Map3DSystem.App.Command | ---++++ !Map3DSystem.App.Commands.Add not intended to be used directly from your code. Add a new command and overwrite existing ones. * _param_ __command__ : of type Map3DSystem.App.Command. command.name should only contain letters with "." to seperate category. such as "Tools.Art.ModelBrowser", internally, we will use a tree hierarchy to store commands instead of a flat tree. Each dot in the name create a sub tree. __syntax__ <verbatim>function Map3DSystem.App.Commands.Add(command)</verbatim> __parameters__ | *command* | of type Map3DSystem.App.Command. command.name should only contain letters with "." to seperate category. such as "Tools.Art.ModelBrowser", internally, we will use a tree hierarchy to store commands instead of a flat tree. Each dot in the name create a sub tree. | ---++++ !Map3DSystem.App.Commands.RemoveCommand not intended to be used directly from your code. remove a given command, in most cases, there is no need to remove it. __syntax__ <verbatim>function Map3DSystem.App.Commands.RemoveCommand(commandName)</verbatim> __parameters__ | *commandName* | | ---++++ !Map3DSystem.App.Commands.GetCommand get a Map3DSystem.App.Command object by its name from the command pool __syntax__ <verbatim>function Map3DSystem.App.Commands.GetCommand(commandName)</verbatim> __parameters__ | *commandName* | | ---++++ !Map3DSystem.App.Commands.GetEnumerator get a iterator of depth first tranversal for all elements (including folders) in commands. * _param_ __rootEnv__ : from which command group to search. if nil the root command is used. Otherwise it can be a command folder name, e.g. "Files", "Profile.MyApps" __syntax__ <verbatim>function Map3DSystem.App.Commands.GetEnumerator (rootEnv)</verbatim> __parameters__ | *rootEnv* | from which command group to search. if nil the root command is used. Otherwise it can be a command folder name, e.g. "Files", "Profile.MyApps" | ---++++ !Map3DSystem.App.Commands.SetLoginCommand set the default login command. If one wants to replace the login machanism, just replace this command with a user supplied one. * _param_ __cmd__ : default to "Profile.Login" __syntax__ <verbatim>function Map3DSystem.App.Commands.SetLoginCommand(cmd)</verbatim> __parameters__ | *cmd* | default to "Profile.Login" | ---++++ !Map3DSystem.App.Commands.GetLoginCommand return the command name to call when the user is not logged in * _return_ ____ : default to "Profile.Login" __syntax__ <verbatim>function Map3DSystem.App.Commands.GetLoginCommand()</verbatim> __parameters__ | *return* | default to "Profile.Login" | ---++++ !Map3DSystem.App.Commands.SetLoadWorldCommand set the default login command. If one wants to replace the login machanism, just replace this command with a user supplied one. * _param_ __cmd__ : default to "Profile.Login" __syntax__ <verbatim>function Map3DSystem.App.Commands.SetLoadWorldCommand(cmd)</verbatim> __parameters__ | *cmd* | default to "Profile.Login" | ---++++ !Map3DSystem.App.Commands.GetLoadWorldCommand return the command name to call when the user is not logged in * _return_ ____ : default to "Profile.Login" __syntax__ <verbatim>function Map3DSystem.App.Commands.GetLoadWorldCommand()</verbatim> __parameters__ | *return* | default to "Profile.Login" | ---++++ !Map3DSystem.App.Commands.SetSysCommandLineCommand set the default login command. If one wants to replace the login machanism, just replace this command with a user supplied one. * _param_ __cmd__ : default to "Profile.SysCommandLine" __syntax__ <verbatim>function Map3DSystem.App.Commands.SetSysCommandLineCommand(cmd)</verbatim> __parameters__ | *cmd* | default to "Profile.SysCommandLine" | ---++++ !Map3DSystem.App.Commands.GetSysCommandLineCommand return the command name to call when the user is not logged in * _return_ ____ : default to "Profile.SysCommandLine" __syntax__ <verbatim>function Map3DSystem.App.Commands.GetSysCommandLineCommand()</verbatim> __parameters__ | *return* | default to "Profile.SysCommandLine" | ---++++ !Map3DSystem.App.Commands.SetDefaultCommand set the default login command. If one wants to replace the login machanism, just replace this command with a user supplied one. * _param_ __cmdName__ : internal command name. such as "SysCommandLine", "LoadWorld", "Login", "EnterChat" * _param_ __cmd__ : __syntax__ <verbatim>function Map3DSystem.App.Commands.SetDefaultCommand(cmdName, cmd)</verbatim> __parameters__ | *cmdName* | internal command name. such as "SysCommandLine", "LoadWorld", "Login", "EnterChat" | | *cmd* | | ---++++ !Map3DSystem.App.Commands.GetDefaultCommand return the command name to call when the user is not logged in * _return_ ____ : __syntax__ <verbatim>function Map3DSystem.App.Commands.GetDefaultCommand(cmdName)</verbatim> __parameters__ | *cmdName* | | | *return* | | ---++++ !Map3DSystem.App.Commands.Call Executes the specified command. It will first call QueryStatus and then call Exec of the given commands. * _param_ __commandName__ : * _param_ __params__ : nil or additional parameters * _return_ __the__ : msg is returned. __syntax__ <verbatim>function Map3DSystem.App.Commands.Call (commandName, params)</verbatim> __parameters__ | *commandName* | | | *params* | | | *return* | msg is returned. | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback