Managing the loading, unloading and message dispatching for all applications.

Title Managing the loading, unloading and message dispatching for all applications.
Author(s) LiXizhi
Date 2008/1/1
File script/kids/3DMapSystemApp/AppManager.lua


ParaEngine's APP IDE features a number of targeted, programmable object models. By using these models, you can access the underlying components and events. Each model contains types and members that represent worlds, mainbar, menus, events, user profiles, 3D objects, and more. Consequently, you can extend the functionality of the IDE, and integrate other applications into the IDE to increase the fun and social interactions among users.

Feature Highlights: - App Registration: Map3DSystem.App.Registration manages application registration and unregistration. One can use XML files (IP.xml) to define the registration settings for add-ins. See also [SampleIP.XML] - Application Template Wizard: Create a new application by using the solution manager in the .Net IDE or by duplicating and editing the [BaseApp.lua] file. - MainBar and MainMenu: Host your custom commands as buttons in the MainBar and MainMenu. - RegisterWindowFrame: makes it easier to create your own custom windows that host your application UI in various window styles like modal dialog, resizable window, toolbar, etc. - TODO: now enables you to specify the style of a button, such as text only, icon only, or text and icon. You can also create additional types of controls to place in the toolbars and menus, such as listbox controls, editbox controls, and drop-down menu controls. - Localization: On the one time init of connection event, app can retrieve the current IDE's language settings by calling GetLocale(). The app can then use different resource files for different language. - Application add-in Security: One can change global application addin security settings: Allow add-in components to load. Checked by default. When checked, add-ins are allowed to load from local disk or from a ParaEngine trusted website. Allow add-in components to load from a URL. Unchecked by default. When checked, add-ins are allowed to be loaded from external Web sites. Even checked, the installation of the external app still needs user confirmation. - programmable components models: the NPL source code and doc as well as all open source offical applications provide overview and examples of programmable components models that a third party application can use. - please note Application code is executed in a sandbox where some IO and log functions may be limited to certain folders.

TIP Sample Code


Member Functions


requires NPL.load("(gl)script/ide/os.lua"); NPL.load("(gl)script/kids/3DMapSystemApp/AppHelper.lua"); NPL.load("(gl)script/kids/3DMapSystemApp/AppRegistration.lua"); NPL.load("(gl)script/kids/3DMapSystemApp/BaseApp.lua"); NPL.load("(gl)script/kids/3DMapSystemApp/app.lua"); NPL.load("(gl)script/kids/3DMapSystemApp/API/ParaworldAPI.lua");

app security setting
if(not Map3DSystem.App.Security) then Map3DSystem.App.Security={}; end AllowTrustedAddin = true; AllowExternalAddin = nil;

app manager class pipeline: AppManager.Startup(), For each world( SetupUI(), LoadWorld, LoadUserProfile(), play), AppManager.Shutdown()

this function is called when IDE starts up.


function Map3DSystem.App.AppManager.Startup()


startup only the given app.

  • param row : the database app record. You can get it from database or create it manually.


function Map3DSystem.App.AppManager.StartupApp(row)


row the database app record. You can get it from database or create it manually.


call the render box function for all applications that is in the user profile or the current world's app attributes

  • param userProfile : mcml table.


function Map3DSystem.App.AppManager.LoadUserProfile(userProfile)


userProfile mcml table.


send APP_WORLD_LOAD msg 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. 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.


function Map3DSystem.App.AppManager.OnWorldLoad()


send APP_WORLD_CLOSING msg is 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.

  • return __ : true if any app disallow closing


function Map3DSystem.App.AppManager.OnWorldClosing()


return true if any app disallow closing


send APP_WORLD_CLOSING msg 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.


function Map3DSystem.App.AppManager.OnWorldClosed()


call this function to setup UI of all currently loaded applications. it will also add homepage icons to mainmenu for all user added applications.


function Map3DSystem.App.AppManager.SetupUI()


this function is called when IDE is shut down


function Map3DSystem.App.AppManager.Shutdown()


 app list
if(not Map3DSystem.App.AppManager.applist) then Map3DSystem.App.AppManager.applist = {}; end

 how an application is currently connected with the IDE. 
Map3DSystem.App.AppManager.ConnectionStatus = {
   -- application is not loaded. and should be loaded at properly time without the need of user confirmation. 
   NotLoaded = nil,
   -- loaded application
   Loaded = 1,
   -- locked. 
   Locked = 2,
   -- downloading from remote server
   Downloading = 3,
   --  User needs to confirm in order for this application to be loaded or added. This usually happens when a new application is successfully downloaded from the server. 
   RequestUserConfirm = 4,

add app to manager


function Map3DSystem.App.AppManager.AddApp(app_key, app)




get app structure by its app_key


function Map3DSystem.App.AppManager.GetApp(app_key)




return an iterator of (app_key, app) pairs.


function Map3DSystem.App.AppManager.GetNextApp ()
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