BaseApp

Base class to all application.

Title Base class to all application.
Author(s) LiXizhi
Date 2007/12/28
File script/kids/3DMapSystemApp/BaseApp.lua

Description

One can see this file as an application API definition. Use the template script/templates/app_simple.lua Map3DSystem.App object is the root object. It is literally a pointer to the IDE through which all other objects that are exposed by IDE are referenced.

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/BaseApp.lua");

Member Functions

Map3DSystem.App.BaseApp.OnConnection

 requires
NPL.load("(gl)script/ide/commonlib.lua");
NPL.load("(gl)script/kids/3DMapSystemApp/AppCommands.lua");

if(not Map3DSystem.App.BaseApp) then Map3DSystem.App.BaseApp={}; end

 application predefined message types here 
Map3DSystem.App.MSGTYPE = {
   -- Receives notification that the app is being loaded.
   -- during one time init, its message handler may need to update the app structure with static integration points, 
   -- i.e. app.about, app.HomeButtonText, app.HasNavigation, app.HasQuickAction. See app template for more information.
   -- msg = {app [in/out], connectMode = Map3DSystem.App.ConnectMode }
   APP_CONNECTION = 501,
   -- Receives notification that the app is being unloaded.
   -- msg = {app, connectMode = Map3DSystem.App.DisconnectMode }
   APP_DISCONNECTION = 502,
   
   -- Receives notification that the user wants to nagivate to the 3D world location relavent to this application
   APP_NAVIGATION = 503,
   -- called when user clicks the quick action for this application. 
   APP_QUICK_ACTION = 504,
   -- called when user clicks to check out the homepage of this application. Homepage usually includes:
   -- developer info, support, developer worlds information, app global news, app updates, all community user rating, active users, trade, currency transfer, etc. 
   APP_HOMEPAGE = 505,
   
   -- Change and render the 3D world with mcml data that is usually retrieved from the current user's profile page for this application. 
   -- msg = {app, mcml = mcmlTable}
   APP_RENDER_BOX = 507,
   
   -- When the user clicks a command (menu or mainbar button), the QueryStatus event is fired. 
   -- The QueryStatus event returns the current status of the specified named command, whether it is enabled, disabled, 
   -- or hidden in the CommandStatus parameter, which is passed to the event by reference. 
   --[[ msg = {app, commandName = string, 
      statusWanted = of Map3DSystem.App.CommandStatusWanted
      status = [out] Map3DSystem.App.CommandStatus or anything else according to statusWanted
   }]]
   APP_QUERY_STATUS = 508,
   
   -- The Exec msg is fired after the QueryStatus event is fired, assuming that the return to the status option parameter of Query Status is supported and enabled. 
   -- This is the event where you place the actual code for handling the response to the user click on the command.
   -- msg = {app, commandName = string, params}
   APP_EXEC = 509,
   
   -- this msg is sent for each installed application, whenever a new world is loaded (just before the 3d scene is enabled, yet after world data is loaded). 
   -- per-world attributes is available here. This message is sent before APP_RENDER_BOX and after APP_CONNECTION(ConnectMode==UI_Setup)
   -- e.g. the CCS (character app) changes the avatar to the user defined avatar in this place just before the world show up. 
   -- Synchronous preprocessing code can also take place here,since there will be a progress bar informing the world loading progress. 
   APP_WORLD_LOAD = 510,
   
   -- TODO: this msg is sent for each installed application, whenever a new world is loaded (after APP_WORLD_LOAD and after the 3d scene is enabled). 
   -- However, the application can set msg.Pause = true to disallow following applications to receive this message
   -- For example, an tutorial app may display an interactive dialog or CG, before the main story begins. When an application paused step, 
   -- it should sent this message again in order for other applications to process. 
   APP_WORLD_STARTUP_STEPS = 511,
   
   -- TODO: this msg is sent for each installed application, whenever a new world is saved by an explicit user action. 
   -- __NOTE__: in most cases, an application should not rely on this message for saving. 
   -- Instead, save immediately to app profile when user made changes.
   APP_WORLD_SAVE = 512,
   
   -- TODO: this msg is sent for each installed application, whenever a world is being closed. 
   -- However, the application can set msg.DisableClosing = true to disallow closing, such as asking the user to save the world. 
   APP_WORLD_CLOSING = 513,
   
   -- TODO: this msg is sent for each installed application, whenever a world is closed. Usually application release resources used in the world session. 
   APP_WORLD_CLOSED = 514,
   
   -- This message is sent to an application, whenever the user clicks to enter the application exclusive desktop mode. 
   -- This message is triggered from the AppTaskBar. Inside this message, an application can add toolbar items to application toolbar via AppTaskBar.AddCommand method. 
   -- more information, please see AppTaskBar.
   APP_ACTIVATE_DESKTOP = 520,
   
   -- This message is sent to an application, whenever an application is requested to quit its current exclusive desktop mode. 
   -- This message is triggered automatically from the AppTaskBar before a new different application's desktop can be activated
   -- Normally, an application needs to save its desktop configuration or modification states for its next activation restoration.
   -- However, it is common for application to do nothing in this message and simple presents the user a default app desktop layout each time it is activated. 
   APP_DEACTIVATE_DESKTOP = 521,
   
   -- user messages should have values larger than this one. 
   APP_USER_MSG_BEGINS = 1000,
};

 how app was loaded by the integrated development environment (IDE). 
Map3DSystem.App.ConnectMode = {
   -- app was loaded when the the IDE was started 
   Startup = 2,
   -- app  was loaded by another program other than the IDE 
   External = 3,
   -- the devenv command loaded the add-in. devenv is a tool that lets you set various options for the IDE from the command line 
   Commandline = 4,
   -- app loaded when a 3D World session was loaded with a dependency on the add-in 
   WorldRequire = 5,
   -- called only once when application should add interface to places like menu, mainbar,etc. 
   UI_Setup= 6,
};

 how app is unloaded
Map3DSystem.App.DisconnectMode = {
   --  The app was unloaded when IDE was shut down.  
   HostShutdown = 1, 
   -- The app was unloaded when a dependent 3D world session was closed. This only happens that the app is only used in a remote world and that the local user does not install it. 
   WorldClosed = 2,
   -- The app was unloaded while IDE was still running.  I.e. The user removes it during game session.
   UserClosed = 3,
}
;


event handlers

OnConnection method is the obvious point to place your UI (menus, mainbars, tool buttons) through which the user will communicate to the app. This method is also the place to put your validation code if you are licensing the add-in. You would normally do this before putting up the UI. If the user is not a valid user, you would not want to put the UI into the IDE.

  • param app : the object representing the current application in the IDE.
  • param connectMode : type of ConnectMode.

syntax

function Map3DSystem.App.BaseApp.OnConnection(app, connectMode)

parameters

app the object representing the current application in the IDE.
connectMode  

Map3DSystem.App.BaseApp.OnDisconnection

Receives notification that the Add-in is being unloaded.

syntax

function Map3DSystem.App.BaseApp.OnDisconnection(app, disconnectMode)

parameters

app  
disconnectMode  

Map3DSystem.App.BaseApp.OnQueryStatus

This is called when the command's availability is updated When the user clicks a command (menu or mainbar button), the QueryStatus event is fired. The QueryStatus event returns the current status of the specified named command, whether it is enabled, disabled, or hidden in the CommandStatus parameter, which is passed to the msg by reference (or returned in the event handler).

  • param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
  • param statusWanted : what status of the command is queried. it is of type CommandStatusWanted
  • return __ : returns according to statusWanted. it may return an integer by adding values in CommandStatus.

syntax

function Map3DSystem.App.BaseApp.OnQueryStatus(app, commandName, statusWanted)

parameters

app  
commandName The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
statusWanted  
return returns according to statusWanted. it may return an integer by adding values in CommandStatus.

Map3DSystem.App.BaseApp.OnExec

This is called when the command is invoked.The Exec is fired after the QueryStatus event is fired, assuming that the return to the statusOption parameter of QueryStatus is supported and enabled. This is the event where you place the actual code for handling the response to the user click on the command.

  • param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".

syntax

function Map3DSystem.App.BaseApp.OnExec(app, commandName, params)

parameters

app  
commandName The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
params  

Map3DSystem.App.BaseApp.OnRenderBox

Change and render the 3D world with mcml data that is usually retrieved from the current user's profile page for this application.

syntax

function Map3DSystem.App.BaseApp.OnRenderBox(mcmlData)

parameters

mcmlData  

Map3DSystem.App.BaseApp.Navigate

called when the user wants to nagivate to the 3D world location relavent to this application

syntax

function Map3DSystem.App.BaseApp.Navigate()

Map3DSystem.App.BaseApp.GotoHomepage

called when user clicks to check out the homepage of this application. Homepage usually includes: developer info, support, developer worlds information, app global news, app updates, all community user rating, active users, trade, currency transfer, etc.

syntax

function Map3DSystem.App.BaseApp.GotoHomepage()

Map3DSystem.App.BaseApp.DoQuickAction

called when user clicks the quick action for this application.

syntax

function Map3DSystem.App.BaseApp.DoQuickAction()

Map3DSystem.App.BaseApp.MSGProc


client world database function helpers.


all related messages

APPS can be invoked in many ways: Through app Manager mainbar or menu command or buttons Command Line 3D World installed apps

syntax

function Map3DSystem.App.BaseApp.MSGProc(window, msg)

parameters

window  
msg  
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback