BlueprintAppDev

description: 娴忚銆佷娇鐢ㄣ€佸埗浣?D宸ョ▼鍥撅紱涓庢湅鍙嬪垎浜綘鐨?D浣滃搧. 涓昏鏄畝鍖栫敤鎴峰湪骞虫椂鍜屾煇浜汚PP涓殑鍒涗綔銆傚簲璇ヤ篃浼氭湁浜哄垱閫犲嚭闈炲父濂界殑宸ョ▼鍥撅紝鍦ㄥ叧绯荤綉涓祦浼犲紑鏉ャ€傜帺瀹剁殑鑳屽寘涓彲浠ユ湁鏈嬪弸鐨勶紝鑷繁鐨勶紝浠栦汉鐨勫伐绋嬪浘绾搞€傚伐绋嬪浘APP鏄畼鏂规瘮杈冮噸瑕佺殑APP涔嬩竴

Contents:

Blueprint app for Paraworld

Title Blueprint app for Paraworld
Author(s) LiXizhi
Date 2008/1/12
File script/kids/3DMapSystemApp/BlueprintApp/app_main.lua

Description

db registration insert script INSERT INTO apps VALUES (NULL, 'Blueprint_GUID', 'Blueprint', '1.0.0', 'http://www.paraengine.com/apps/Blueprint_v1.zip', 'YourCompany', 'enUS', 'script/kids/3DMapSystemApp/BlueprintApp/IP.xml', '', 'script/kids/3DMapSystemApp/BlueprintApp/app_main.lua', 'Map3DSystem.App.Blueprint.MSGProc', 1);

TIP Sample Code

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

Member Functions

Map3DSystem.App.Blueprint.OnConnection

requires


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.Blueprint.OnConnection(app, connectMode)

parameters

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

Map3DSystem.App.Blueprint.OnDisconnection

Receives notification that the Add-in is being unloaded.

syntax

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

parameters

app  
disconnectMode  

Map3DSystem.App.Blueprint.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.Blueprint.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.Blueprint.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.Blueprint.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.Blueprint.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.Blueprint.OnRenderBox(mcmlData)

parameters

mcmlData  

Map3DSystem.App.Blueprint.Navigate

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

syntax

function Map3DSystem.App.Blueprint.Navigate()

Map3DSystem.App.Blueprint.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.Blueprint.GotoHomepage()

Map3DSystem.App.Blueprint.DoQuickAction

called when user clicks the quick action for this application.

syntax

function Map3DSystem.App.Blueprint.DoQuickAction()

Map3DSystem.App.Blueprint.OnActivateDesktop

Add terrain, sky and ocean button to the toolbar.

syntax

function Map3DSystem.App.Blueprint.OnActivateDesktop()

Map3DSystem.App.Blueprint.OnDeactivateDesktop

deactivate:clear miniscene graphs if any.

syntax

function Map3DSystem.App.Blueprint.OnDeactivateDesktop()

Map3DSystem.App.Blueprint.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.Blueprint.MSGProc(window, msg)

parameters

window  
msg  

Bills Of Materials window for a given blueprint

Title Bills Of Materials window for a given blueprint
Author(s) LiXizhi
Date 2008/1/12
File script/kids/3DMapSystemApp/BlueprintApp/BomWnd.lua

Description

TIP Sample Code

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

-- to create a bom
local bom --  = {radius= 10, center = {x,y,z}};
bom = Map3DSystem.App.Blueprint.CreateNewBom(bom);
Map3DSystem.App.Blueprint.SelectBom(bom);

-- to open a bom
local bom = Map3DSystem.App.Blueprint.LoadBomFromFile(filename);
if(bom~=nil) then
   bom.center.x, bom.center.y,bom.center.z = ParaScene.GetPlayer():GetPosition();
   Map3DSystem.App.Blueprint.SelectBom(bom);
else
   _guihelper.MessageBox("鏃犳硶鎵撳紑宸ョ▼鍥炬枃浠?"..filename);
end

Member Functions

BomWnd.Bom:new

 common control library
NPL.load("(gl)script/ide/common_control.lua");

local BomWnd = {}
commonlib.setfield("Map3DSystem.App.Blueprint.BomWnd", BomWnd);

BomWnd.BomStatus = {
   -- a newly created empty bom, 
   Empty = nil, 
   -- a bom that is being designed. 
   Designing = 1,
   -- a bom that is being built by user manually. 
   Building = 2,
   -- a bom that is being automatically deployed. 
   Deploying = 3,
   -- a bom that is being previewed in miniscenegraph, user needs to decide whether to build it themselves or buy it. 
   Preview = 4,
};

 a single bom template
BomWnd.Bom = {
   -- item GUID string. if this is nil, the item is never uploaded before. 
   id = nil,
   author = nil, 
   name = nil,
   description = nil, 
   -- E price and P price. 
   priceE = nil,
   priceP = nil,
   
   -- array of objects {} in building order
   objects = nil,
   -------------------------------------------
   -- per instance
   -------------------------------------------
   -- point of reference {x, y, z}
   center = nil,
   -- the radius of the building site. this determines how large we should rendering the construction spot. 
   radius = 10,
   -- facing 
   facing = 0,
   -- status of type BomWnd.BomStatus
   status = nil,
   -- the number of steps (objects) that have been deployed during automatic deploy or build.
   -- if this number equals to the size of Bom.objects, then the building is finished. 
   BuildingStep = 0,
   -- whether to ignore wrong object creation
   bIgnoreWrongCreation = nil, 
}
;

TODO: a list of active boms in the scene. BomWnd.Boms = {};

the currently selected bom that the current BomWnd is bind to. CurBom = nil;

create a new bom

syntax

function BomWnd.Bom:new(o)

parameters

o  

BomWnd.Bom:ClearAll

clear all objects

syntax

function BomWnd.Bom:ClearAll()

BomWnd.Bom:AddObject

add a new object to the bom list. it is usually the table returned from GetObjectParams(). however, one needs to manually assign an optional field called cmdName, which contains information about command button (Icon to display, etc) if objParam.cmdName is nil, the icon in the BomWnd for this object will be a question mark, indicating that it will only be deployed when user is implementing manually.

syntax

function BomWnd.Bom:AddObject(objParam)

parameters

objParam  

Map3DSystem.App.Blueprint.CreateNewBom

create a new bom. One can later call SelectBom to select it by UI.

  • param bom : partial class of BomWnd.Bom. if bom is nil, a default one at the current player position will be created. otherwise, the caller can specify where to create the bom and how big is the construction site.
  • return return : the bom object created.

syntax

function Map3DSystem.App.Blueprint.CreateNewBom(bom)

parameters

| bom | partial class of BomWnd.Bom. if bom is nil, a default one at the current player position will be created. otherwise, the caller can specify where to create the bom and how big is the construction site. |

Map3DSystem.App.Blueprint.LoadBomFromFile

load bom from file. it returned the bom object. it may return nil if failed.

syntax

function Map3DSystem.App.Blueprint.LoadBomFromFile(filename)

parameters

filename  

BomWnd.SelectAllToBom

select all things in the bom region to bom's object list

syntax

function BomWnd.SelectAllToBom()

BomWnd.UpdateTreeView

private: update the BOM tree view according to the curren bom list's objects

syntax

function BomWnd.UpdateTreeView()

Map3DSystem.App.Blueprint.SelectBom

select a bom as the current bom and display its BomWnd. when a bom is (de)selected, it will (un)hook object creation events.

  • param bom : the bom object to be selected. if nil, nothing will be selected.

syntax

function Map3DSystem.App.Blueprint.SelectBom(bom)

parameters

bom the bom object to be selected. if nil, nothing will be selected.

Map3DSystem.App.Blueprint.UpdateScenegraphHelper

update the 3d helper in the miniscenegraph.

syntax

function Map3DSystem.App.Blueprint.UpdateScenegraphHelper(bom)

parameters

bom  

Map3DSystem.App.Blueprint.ShowBomWnd

display the bom window. It will rebuilt bom each time it is called.

syntax

function Map3DSystem.App.Blueprint.ShowBomWnd(_app)

parameters

app  

Map3DSystem.App.Blueprint.BomHookProc

hook procedure to detect what object the user has created.

syntax

function Map3DSystem.App.Blueprint.BomHookProc(nCode, appName, msg)

parameters

nCode  
appName  
msg  

BomWnd.Show

  • param bShow : boolean to show or hide. if nil, it will toggle current setting.
  • param __ :_parent: parent window inside which the content is displayed. it can be nil.

syntax

function BomWnd.Show(bShow, _parent, parentWindow)

parameters

bShow boolean to show or hide. if nil, it will toggle current setting.
parent  
parentWindow  

BomWnd.OnDestroy

destory the control

syntax

function BomWnd.OnDestroy()

BomWnd.SaveBom

save the bom to file and optional publish it to app server.

syntax

function BomWnd.SaveBom()

BomWnd.BuyBom

Purchase the bom

syntax

function BomWnd.BuyBom()

BomWnd.DIYBom

TODO: save the bom to file and optional publish it to app server.

syntax

function BomWnd.DIYBom()

BomWnd.PreviewBom

TODO: switch to preview mode

syntax

function BomWnd.PreviewBom()

BomWnd.FinishBom

TODO: finish DIY building

syntax

function BomWnd.FinishBom()

BomWnd.OnSizeChangeBlueprint

when the user changes the size of the miniscene graph.

syntax

function BomWnd.OnSizeChangeBlueprint(sCtrlName)

parameters

sCtrlName  

BomWnd.OnClickPreviewInPlace

preview a ready-made blueprint in the current 3D scene using miniscenegraph.

syntax

function BomWnd.OnClickPreviewInPlace()

BomWnd.OnClickPreviewRelocateCenter

relocate the center position of the construction site at the current player location

  • param x :,y,z: if nil, the current player position is used.

syntax

function BomWnd.OnClickPreviewRelocateCenter(x,y,z)

parameters

x ,y,z: if nil, the current player position is used.
y  
z  

BomWnd.OnClickClose

close

syntax

function BomWnd.OnClickClose()

BomWnd.MSGProc

normal windows messages here

syntax

function BomWnd.MSGProc(window, msg)

parameters

window  
msg  

template: windows form or modeless dialog

Title template: windows form or modeless dialog
Author(s) [your name], original template by LiXizhi
Date 2007/2/7
File script/kids/3DMapSystemApp/BlueprintApp/Homepage.lua

Description

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/BlueprintApp/Homepage.lua");
Homepage.Show();

Member Functions

Homepage.Show

common control library NPL.load("(gl)script/ide/common_control.lua");

if(not Homepage) then Homepage={}; end

  • param bShow : boolean to show or hide. if nil, it will toggle current setting.

syntax

function Homepage.Show(bShow)

parameters

bShow boolean to show or hide. if nil, it will toggle current setting.

Homepage.OnDestory

destory the control

syntax

function Homepage.OnDestory()

save a collection of objects on the construction site

Title save a collection of objects on the construction site
Author(s) LiXizhi
Date 2008/1/14
File script/kids/3DMapSystemApp/BlueprintApp/SaveBom.lua

Description

TIP Sample Code

NPL.load("(gl)script/kids/3DMapSystemApp/BlueprintApp/SaveBom.lua");
SaveBom.ShowWnd(_app);

Member Functions

Map3DSystem.App.Blueprint.ShowWnd

common control library NPL.load("(gl)script/ide/common_control.lua");

commonlib.setfield("Map3DSystem.App.Blueprint.SaveBom", {});

create and show a sub window of a given application

  • param __ :_app: the os.app object.

syntax

function Map3DSystem.App.Blueprint.ShowWnd(_app)

parameters

app  

Map3DSystem.App.Blueprint.SaveBom.Show

  • param bShow : boolean to show or hide. if nil, it will toggle current setting.
  • param __ :_parent: parent window inside which the content is displayed. it can be nil.

syntax

function Map3DSystem.App.Blueprint.SaveBom.Show(bShow, _parent, parentWindow)

parameters

bShow boolean to show or hide. if nil, it will toggle current setting.
parent  
parentWindow  

Map3DSystem.App.Blueprint.SaveBom.OnDestory

destory the control

syntax

function Map3DSystem.App.Blueprint.SaveBom.OnDestory()

Map3DSystem.App.Blueprint.SaveBom.OnMouseDown


window events

mouse down position SaveBom.lastMouseDown = {x = 0, y=0} SaveBom.lastMousePos = {x = 0, y=0} whether mouse button is down IsMouseDown = false;

syntax

function Map3DSystem.App.Blueprint.SaveBom.OnMouseDown()

Map3DSystem.App.Blueprint.SaveBom.OnSave

save the current to a file and call the inventory give function.

syntax

function Map3DSystem.App.Blueprint.SaveBom.OnSave()
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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