---++!! !ActionFeedAppDev __description__: 涓哄簲鐢ㄧ▼搴忓紑鍙戝晢鍜岀敤鎴锋彁渚涚敤鎴疯涓哄湪浜洪檯鍏崇郴缃戜腑鐨勪紶鎾 %TOC{title="Contents:"}% %STARTINCLUDE% ---++ ActionFeed app for Paraworld | *Title* | ActionFeed app for Paraworld | | *Author(s)* | LiXizhi | | *Date* | 2008/1/17 | | *File* | script/kids/3DMapSystemApp/ActionFeed/app_main.lua | ---+++ Description -- the second param can be a table of {name, title, url, DisplayNavBar, x,y, width, height, icon, iconsize} Map3DSystem.App.Commands.Call("Profile.ActionFeed.Add", {uid = "", content=""}); db registration insert script INSERT INTO apps VALUES (NULL, 'ActionFeed_GUID', 'ActionFeed', '1.0.0', 'http://www.paraengine.com/apps/ActionFeed_v1.zip', 'YourCompany', 'enUS', 'script/kids/3DMapSystemApp/ActionFeed/IP.xml', '', 'script/kids/3DMapSystemApp/ActionFeed/app_main.lua', 'Map3DSystem.App.ActionFeed.MSGProc', 1); [APP Integration Point]: Action feed bar Desc: Applications can send notifications to a user via action feed. Action feed is usually displayed on the very top of the in-game screen. It provides goal sets, action feeds, hints, requests, message alerts, etc in a simple icon sequence in time order. Action feed is very easy to catch the user attention and should always provide a concise goal-driven task that calls the user in to action. The interesting thing is that most action feeds are associated with user profile and viewable by both its owner and visitors, thus allowing viral distribution of user goals, contents and actions among its friends. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/ActionFeed/app_main.lua"); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.ActionFeed.OnConnection requires create class commonlib.setfield("Map3DSystem.App.ActionFeed", {}); ------------------------------------------- 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 Map3DSystem.App.ConnectMode. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.OnConnection(app, connectMode)</verbatim> __parameters__ | *app* | the object representing the current application in the IDE. | | *connectMode* | | ---++++ !Map3DSystem.App.ActionFeed.OnDisconnection Receives notification that the Add-in is being unloaded. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.OnDisconnection(app, disconnectMode)</verbatim> __parameters__ | *app* | | | *disconnectMode* | | ---++++ !Map3DSystem.App.ActionFeed.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 Map3DSystem.App.CommandStatusWanted * _return_ ____ : returns according to statusWanted. it may return an integer by adding values in Map3DSystem.App.CommandStatus. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.OnQueryStatus(app, commandName, statusWanted)</verbatim> __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 Map3DSystem.App.CommandStatus. | ---++++ !Map3DSystem.App.ActionFeed.OnExec <verbatim> feed templates are mapping from template name to template functions. which takes the feed content string and output the final feed string. local feedtemplates = { ["message"] = function(content) return string.format("<pe:name uid='%s'/> 璇?%s", Map3DSystem.App.profiles.ProfileManager.GetUserID() or "", content or "") end, ["poke"] = function(content) return string.format("<pe:name uid='%s'/> 鎵撲簡涓嫑鍛?%s", Map3DSystem.App.profiles.ProfileManager.GetUserID() or "", content or "") end, ["empty"] = function(content) return content; end, }</verbatim> 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__ <verbatim>function Map3DSystem.App.ActionFeed.OnExec(app, commandName, params)</verbatim> __parameters__ | *app* | | | *commandName* | The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". | | *params* | | ---++++ !Map3DSystem.App.ActionFeed.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__ <verbatim>function Map3DSystem.App.ActionFeed.OnRenderBox(mcmlData)</verbatim> __parameters__ | *mcmlData* | | ---++++ !Map3DSystem.App.ActionFeed.Navigate called when the user wants to nagivate to the 3D world location relavent to this application __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.Navigate()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.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__ <verbatim>function Map3DSystem.App.ActionFeed.GotoHomepage()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.DoQuickAction called when user clicks the quick action for this application. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.DoQuickAction()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.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__ <verbatim>function Map3DSystem.App.ActionFeed.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++++ !Map3DSystem.App.ActionFeed.GetDSTable ---------------------- public functions ---------------------- get action feed data for a given user and fill the data into a data source table. * _param_ __output__ : [in|out] the data source table to hold the returned data. the data item is a table {mcml=string} and output.Count, contains the data item count. output.status, contains the current download status: nil not available, 1 fetching, 2 fetched. * _param_ __uid__ : if nil, it is the current user. we will fetch via actionfeed profile for the given user. * _param_ __feedtype__ : feed type to retrieve. "Story", "Message", "Request", "Action". if nil, it defaults to "Story" * _param_ __cache__ :_policy: if nil, it will use default setting. if uid is current user and cache_policy is nil, the in memory version is used. * _param_ __pageCtrl__ :if this is not nil, pageCtrl:Refresh() will be called once data table is retrieved. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.GetDSTable(output, uid, feedtype, pageCtrl, cache_policy)</verbatim> __parameters__ | *output* | [in|out] the data source table to hold the returned data. the data item is a table {mcml=string} and output.Count, contains the data item count. output.status, contains the current download status: nil not available, 1 fetching, 2 fetched. | | *uid* | | | *feedtype* | feed type to retrieve. "Story", "Message", "Request", "Action". if nil, it defaults to "Story" | | *pageCtrl* | if this is not nil, pageCtrl:Refresh() will be called once data table is retrieved. | | *cache* | | | *policy* | | ---++++ !Map3DSystem.App.ActionFeed.DataSourceFunc get action feed data for a given user and fill the data into a data source function. in an mcml embedded script, we can built a actionfeed datasource function instance like below. <verbatim> ---- status: nil not available, 1 fetching, 2 fetched. dsActionFeed = Eval("dsActionFeed") or {status=nil, }; -- function DS_Func_ActionFeed_Story(index) --return Map3DSystem.App.ActionFeed.DataSourceFunc(index, dsActionFeed, hostuid, "Story", pageCtrl) end </verbatim> for an example: see ProfilePage.html. * _param_ __output__ : [in|out] the data source table to hold the returned data. the data item is a table {mcml=string} and output.Count, contains the data item count. output.status, contains the current download status: nil not available, 1 fetching, 2 fetched. * _param_ __uid__ : if nil, it is the current user. we will fetch via actionfeed profile for the given user. * _param_ __feedtype__ : feed type to retrieve. "Story", "Message", "Request", "Action". if nil, it defaults to "Story" * _param_ __cache__ :_policy: if nil, it will use default setting. if uid is current user and cache_policy is nil, the in memory version is used. * _param_ __pageCtrl__ :if this is not nil, pageCtrl:Refresh() will be called once data table is retrieved. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.DataSourceFunc(index, dsTable, uid, feedtype, pageCtrl, cache_policy)</verbatim> __parameters__ | *index* | | | *dsTable* | | | *uid* | | | *feedtype* | feed type to retrieve. "Story", "Message", "Request", "Action". if nil, it defaults to "Story" | | *pageCtrl* | if this is not nil, pageCtrl:Refresh() will be called once data table is retrieved. | | *cache* | | | *policy* | | ---++++ !Map3DSystem.App.ActionFeed.ClearFeed clear feed for a given category for the current logged in user. * _param_ __feedtype__ : "Story", "Message", "Request", "Action". if nil, it defaults to "Story" * _param_ __pageCtrl__ :if this is not nil, pageCtrl:Refresh() will be called once done __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ClearFeed(category, pageCtrl)</verbatim> __parameters__ | *category* | | | *pageCtrl* | | ---++ Action feed bar | *Title* | Action feed bar | | *Author(s)* | LiXizhi | | *Date* | 2007/12/28 | | *File* | script/kids/3DMapSystemApp/ActionFeed/ActionFeedBar.lua | ---+++ Description Applications can send notifications to a user via action feed. Action feed is usually displayed on the very top of the in-game screen. It provides goal sets, action feeds, hints, requests, message alerts, etc in a simple icon sequence in time order. Action feed is very easy to catch the user attention and should always provide a concise goal-driven task that calls the user in to action. The interesting thing is that most action feeds are associated with user profile and viewable by both its owner and visitors, thus allowing viral distribution of user goals, contents and actions among its friends. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/ActionFeed/ActionFeedBar.lua"); Map3DSystem.App.ActionFeed.ActionFeedBar.OnRenderBox(mcml) Map3DSystem.App.ActionFeed.ActionFeedBar.AddFeed({ Icon = "!", OnClick = "_guihelper.MessageBox(\"this is a tip\");", UpdateUI = true, }) </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.CreateFeedFromMsg <verbatim> create class commonlib.setfield("Map3DSystem.App.ActionFeed.ActionFeedBar", {}); messge types Map3DSystem.App.ActionFeed.ActionFeedBar.MSGTYPE = { ADD_ACTIONFEED = 1000, } an array of all feeds Map3DSystem.App.ActionFeed.ActionFeedBar.feeds = {}; a feed template Map3DSystem.App.ActionFeed.ActionFeedBar.feed = { -- nil or "GUID" the specified application must be installed and loaded before the onclick event can be called. -- we will download the application at runtime. If nil, it may be from in-game function. app_key = nil, -- icon to be displayed, in case the application is not installed locally. this icon will be displayed as an uninstalled icon. -- it will first index to into Map3DSystem.App.ActionFeed.ActionFeedBar.IconMap table using the icon string, if not found, the icon string is used as the actual icon path. Icon = nil, -- how icon is displayed: nil (normal style, 30% alpha until action bar has focus)| "Alert"(click once to stop beeping) | "ConstColor", IconStyle = nil, -- nil(normal) | "fly" how icon is animated when added to the bar. OnAddStyle = nil, -- function or string: this is only valid for local application or in-game function. OnClick = nil, -- mcmlTable or nil: it can only be an mcml table to be parsed to the associated app.OnActionFeedClick(mcmlTable). -- this is mostly used for external applications. Simply use OnClick if it is an local app. OnClickMCML = nil, -- boolean or nil: immediately update UI. default to no. UpdateUI = nil, -- nil or {x=0, y=0,z=0} position table, in case this action item is associated with a 3D scene position. position = nil, -- nil | "teleport": if an icon item has position and posAction, when clicking it, it will not only triggers onclick, but also bring the camera to the position -- and may teleport the user to the position on the second click depending on the posAction type. posAction = nil, -- nil or text: the mouse over tooltip to display. Text may contain mcml markups to include URLs like another user_id. tooltip = nil, -- the text to display. Currently, we do not display it. text = nil, -- time created creation_date = nil, -- ticks: in case an animation is used when adding this icon. ticks = 0, }</verbatim> create a new feed from a feed message __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.CreateFeedFromMsg(msg)</verbatim> __parameters__ | *msg* | | ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.AddFeed <verbatim> inner UI control name Map3DSystem.App.ActionFeed.ActionFeedBar.UIname = "ActionFeedBar"; Map3DSystem.App.ActionFeed.ActionFeedBar.AppName = "ActionFeedBar"; mapping from icon string to icon path. Map3DSystem.App.ActionFeed.ActionFeedBar.IconMap = { ["!"] = "Texture/whitedot.dds", ["?"] = "Texture/whitedot.dds", ["x"] = "Texture/whitedot.dds", ["tips"] = "Texture/whitedot.dds", ["question"] = "Texture/whitedot.dds", ["app"] = "Texture/whitedot.dds", ["app_uninstalled"] = "Texture/whitedot.dds", ["gift"] = "Texture/whitedot.dds", ["gift_sent"] = "Texture/whitedot.dds", ["blueprint_created"] = "Texture/whitedot.dds", ["blueprint_deployed"] = "Texture/whitedot.dds", ["blueprint_completed"] = "Texture/whitedot.dds", ["footprint"] = "Texture/whitedot.dds", ["friend_request"] = "Texture/whitedot.dds", ["city_request"] = "Texture/whitedot.dds", ["offline"] = "Texture/whitedot.dds", ["online"] = "Texture/whitedot.dds", ["person_join"] = "Texture/whitedot.dds", ["person_leave"] = "Texture/whitedot.dds", ["poke"] = "Texture/whitedot.dds", ["feed"] = "Texture/whitedot.dds", ["ads"] = "Texture/whitedot.dds", ["wall"] = "Texture/whitedot.dds", ["game"] = "Texture/whitedot.dds", ["gameHighScore"] = "Texture/whitedot.dds", ["treasure_quest"] = "Texture/whitedot.dds", ["treasure_gain"] = "Texture/whitedot.dds", ["pet_talk"] = "Texture/whitedot.dds", ["pet_wish"] = "Texture/whitedot.dds", ["pet_wish_completed"] = "Texture/whitedot.dds", ["chat"] = "Texture/whitedot.dds", ["card"] = "Texture/whitedot.dds", ["game"] = "Texture/whitedot.dds", ["rate"] = "Texture/whitedot.dds", ["save"] = "Texture/whitedot.dds", ["save_completed"] = "Texture/whitedot.dds", ["publish"] = "Texture/whitedot.dds", ["publish_completed"] = "Texture/whitedot.dds", ["Land_renting"] = "Texture/whitedot.dds", ["Land_confirmed"] = "Texture/whitedot.dds", } [[ add a new feed to the action feed bar. * _param_ __msg__ : is a table of the format msg = { -- no need to set, since we will set automatically for you. type = Map3DSystem.App.ActionFeed.ActionFeedBar.MSGTYPE.ADD_ACTIONFEED, -- the specified application must be installed and loaded before the onclick event can be called. -- we will download the application at runtime. If nil, it may be from in-game function. app_key = nil or "GUID", -- icon to be displayed, in case the application is not installed locally. this icon will be displayed as an uninstalled icon. -- it will first index to into Map3DSystem.App.ActionFeed.ActionFeedBar.IconMap table using the icon string, if not found, the icon string is used as the actual icon path. Icon = "!" or "Texture/whitedot.dds", etc, -- how icon is displayed. IconStyle = nil (normal style, 30% alpha until action bar has focus)| "Alert"(click once to stop beeping) | "ConstColor", -- how icon is animated when added to the bar. OnAddStyle = nil(normal) | "fly", -- this is only valid for local application or in-game function. OnClick = function or string, -- it can only be an mcml table to be parsed to the associated app.OnActionFeedClick(mcmlTable). -- this is mostly used for external applications. Simply use OnClick if it is an local app. OnClickMCML = mcmlTable or nil, -- immediately update UI. default to no. UpdateUI = boolean or nil, -- position table, in case this action item is associated with a 3D scene position. position = nil or {x=0, y=0,z=0}, -- if an icon item has position and posAction, when clicking it, it will not only triggers onclick, but also bring the camera to the position -- and may teleport the user to the position on the second click depending on the posAction type. posAction = nil | "teleport", -- the mouse over tooltip to display. Text may contain mcml markups to include URLs like another user_id. tooltip = nil or text, -- the text to display. Currently, we do not display it. text = nil, -- time created creation_date = nil, -- distribution method, we allow viral distribution of action feed among friends and current user. -- Please note that, not all client of applications is allowed to send feeds to the REST server directly. Basically, only app server can update feeds on REST server. -- so in most cases, this parameter is nil. distribution = nil (do nothing or just local feed) | "friends feed" (add this feed to friends) | "friends feed" (email this feed to all my friends) | "owner" (email to world owner) }</verbatim> ]] __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.AddFeed(msg)</verbatim> __parameters__ | *msg* | is a table of the format msg = { -- no need to set, since we will set automatically for you. type = Map3DSystem.App.ActionFeed.ActionFeedBar.MSGTYPE.ADD_ACTIONFEED, -- the specified application must be installed and loaded before the onclick event can be called. -- we will download the application at runtime. If nil, it may be from in-game function. app_key = nil or "GUID", -- icon to be displayed, in case the application is not installed locally. this icon will be displayed as an uninstalled icon. -- it will first index to into Map3DSystem.App.ActionFeed.ActionFeedBar.IconMap table using the icon string, if not found, the icon string is used as the actual icon path. Icon = "!" or "Texture/whitedot.dds", etc, -- how icon is displayed. IconStyle = nil (normal style, 30% alpha until action bar has focus)| "Alert"(click once to stop beeping) | "ConstColor", -- how icon is animated when added to the bar. OnAddStyle = nil(normal) | "fly", -- this is only valid for local application or in-game function. OnClick = function or string, -- it can only be an mcml table to be parsed to the associated app.OnActionFeedClick(mcmlTable). -- this is mostly used for external applications. Simply use OnClick if it is an local app. OnClickMCML = mcmlTable or nil, -- immediately update UI. default to no. UpdateUI = boolean or nil, -- position table, in case this action item is associated with a 3D scene position. position = nil or {x=0, y=0,z=0}, -- if an icon item has position and posAction, when clicking it, it will not only triggers onclick, but also bring the camera to the position -- and may teleport the user to the position on the second click depending on the posAction type. posAction = nil | "teleport", -- the mouse over tooltip to display. Text may contain mcml markups to include URLs like another user_id. tooltip = nil or text, -- the text to display. Currently, we do not display it. text = nil, -- time created creation_date = nil, -- distribution method, we allow viral distribution of action feed among friends and current user. -- Please note that, not all client of applications is allowed to send feeds to the REST server directly. Basically, only app server can update feeds on REST server. -- so in most cases, this parameter is nil. distribution = nil (do nothing or just local feed) | "friends feed" (add this feed to friends) | "friends feed" (email this feed to all my friends) | "owner" (email to world owner) }</verbatim> ]] | ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.OnRenderBox [APP IP Function] this function should be called when a game world is loaded. It will load all action feed icons that is relavent to this world since action feed bar contains integration points, only call OnRenderBox when mcml are retrieved from server and apps for this world are all installed * _param_ __mcml__ : the mcml descriptive data that is usually retrieved from the paraworld REST server. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.OnRenderBox(mcml)</verbatim> __parameters__ | *mcml* | the mcml descriptive data that is usually retrieved from the paraworld REST server. | ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.ShowWnd show the main window object __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.ShowWnd(app)</verbatim> __parameters__ | *app* | | ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.Show internal show method __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.Show(bShow,_parent,parentWindow)</verbatim> __parameters__ | *bShow* | | | *parent* | | | *parentWindow* | | ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.Reset clear all feeds. Call UpdateUI() afterwards to reflect the changes to the UI. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.Reset()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.UpdateUI update the UI: call this function when new item(s) are added. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.UpdateUI()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.ActionFeedBar.MSGProc ------------------------------------------ all related messages ------------------------------------------ __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.ActionFeedBar.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++ code behind page for PublishFeedPage.html | *Title* | code behind page for PublishFeedPage.html | | *Author(s)* | LiXizhi | | *Date* | 2008/6/1 | | *File* | script/kids/3DMapSystemApp/ActionFeed/PublishFeedPage.lua | ---+++ Description publish user defined action feed to all or selected friends %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/profiles/PublishFeedPage.lua"); -- you can specify who to receive by uid parameter and content script/kids/3DMapSystemApp/ActionFeed/PublishFeedPage.html?uid=ABC&content=hello there -- this will send to all user. script/kids/3DMapSystemApp/ActionFeed/PublishFeedPage.html </verbatim> ---+++ Member Functions ---++++ !PublishFeedPage.OnInit --------------------------------- page event handlers --------------------------------- first time init page __syntax__ <verbatim>function PublishFeedPage.OnInit()</verbatim> ---++++ !PublishFeedPage.SendFeed user clicks to send the feed. __syntax__ <verbatim>function PublishFeedPage.SendFeed(btnName, values)</verbatim> __parameters__ | *btnName* | | | *values* | | ---++++ !PublishFeedPage.SelectFriends open a dialog to select to which friends we will send the message. __syntax__ <verbatim>function PublishFeedPage.SelectFriends(btnName)</verbatim> __parameters__ | *btnName* | | ---++ Status bar on the AppTaskBar | *Title* | Status bar on the AppTaskBar | | *Author(s)* | WangTian | | *Date* | 2008/6/2 | | *File* | script/kids/3DMapSystemApp/ActionFeed/StatusBar.lua | ---+++ Description Desc: Applications can send notifications to a user via action feed. Action feed is displayed on the very right of the AppTaskBar. It provides goal sets, action feeds, hints, requests, message alerts, etc in a simple icon sequence in time order. Feed is very easy to catch the user attention and should always provide a concise goal-driven task that calls the user in to action. The interesting thing is that most action feeds are associated with user profile and viewable by both its owner and visitors, thus allowing viral distribution of user goals, contents and actions among its friends. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/ActionFeed/StatusBar.lua"); Map3DSystem.App.ActionFeed.StatusBar.OnRenderBox(mcml) Map3DSystem.App.ActionFeed.StatusBar.AddFeed({ Icon = "!", OnClick = "_guihelper.MessageBox(\"this is a tip\");", UpdateUI = true, }) </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.ActionFeed.StatusBar.Init <verbatim> create class commonlib.setfield("Map3DSystem.App.ActionFeed.StatusBar", {}); a feed template Map3DSystem.App.ActionFeed.StatusBar.FeedTemplate = { -- nil or "GUID" the specified application must be installed and loaded before the onclick event can be called. -- we will download the application at runtime. If nil, it may be from in-game function. app_key = nil, -- NOTE: by andy, local of external application isLocal = true, -- icon to be displayed, in case the application is not installed locally. this icon will be displayed as an uninstalled icon. -- it will first index to into Map3DSystem.App.ActionFeed.StatusBar.IconMap table using the icon string, if not found, the icon string is used as the actual icon path. Icon = nil, -- how icon is displayed: nil (normal style, 30% alpha until action bar has focus)| "Alert"(click once to stop beeping) | "ConstColor", IconStyle = nil, -- nil(normal) | "fly" how icon is animated when added to the bar. OnAddStyle = nil, -- function or string: this is only valid for local application or in-game function. OnClick = nil, -- mcmlTable or nil: it can only be an mcml table to be parsed to the associated app.OnActionFeedClick(mcmlTable). -- this is mostly used for external applications. Simply use OnClick if it is an local app. OnClickMCML = nil, -- boolean or nil: immediately update UI. default to no. UpdateUI = nil, -- nil or {x=0, y=0,z=0} position table, in case this action item is associated with a 3D scene position. position = nil, -- nil | "teleport": if an icon item has position and posAction, when clicking it, it will not only triggers onclick, but also bring the camera to the position -- and may teleport the user to the position on the second click depending on the posAction type. posAction = nil, -- nil or text: the mouse over tooltip to display. Text may contain mcml markups to include URLs like another user_id. tooltip = nil, -- the text to display. Currently, we do not display it. text = nil, -- time created --creation_date = nil, creation_time = nil, -- change to creation time -- ticks: in case an animation is used when adding this icon. ticks = 0, } a task template, task is a local window that stays perminently on the interface like chat window Map3DSystem.App.ActionFeed.StatusBar.TaskTemplate = { icon = nil, --icon to be displayed text = nil, --text to be displayed tasktab_bg = nil, -- the background on the statusbar, icon and text is shown in the task tab onclick = nil, -- function () end when the task is clicked } inner UI control name Map3DSystem.App.ActionFeed.StatusBar.UIname = "StatusBar"; Map3DSystem.App.ActionFeed.StatusBar.WndName = "StatusBar"; messge types Map3DSystem.App.ActionFeed.StatusBar.MSGTYPE = { ADD_ACTIONFEED = 1532, ADD_TASK = 1533, }</verbatim> init the status bar in at application connection __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.Init()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.StatusBar.AddTask ---- create a new feed from a feed message function Map3DSystem.App.ActionFeed.StatusBar.CreateFeedFromMsg(msg) --local feed = {ticks=0}; --if(msg ~= nil) then --feed.app_key = msg.app_key; --feed.isLocal = msg.isLocal; --feed.Icon = Map3DSystem.App.ActionFeed.StatusBar.IconMap[msg.Icon or "x"] or msg.Icon; --feed.IconStyle = msg.IconStyle; --feed.OnAddStyle = msg.OnAddStyle; --feed.OnClick = msg.OnClick; --feed.OnClickMCML = msg.OnClickMCML; --feed.UpdateUI = msg.UpdateUI; --feed.position = msg.position; --feed.posAction = msg.posAction; --feed.tooltip = msg.tooltip; --feed.text = msg.text; --feed.creation_time = msg.creation_time; --end --return feed; end ---- create a new task from a task message function Map3DSystem.App.ActionFeed.StatusBar.CreateTaskFromMsg(msg) --local task = {}; --if(msg ~= nil) then --task.icon = msg.icon or ""; --task.text = msg.text or "Untitled"; --task.tasktab_bg = msg.tasktab_bg or ""; --task.onclick = msg.onclick; --end --return task; end an array of all feeds Map3DSystem.App.ActionFeed.StatusBar.feeds = {}; an array of all tasks Map3DSystem.App.ActionFeed.StatusBar.tasks = {}; -------------------------- TASK -------------------------- add a task into status, it will automatically refresh the status bar * _param_ __task__ : { name = "Chat1", icon = "optional icon, usually has it", text = "this is optional", tooltip = "some text", commandName = "", } __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.AddTask(task)</verbatim> __parameters__ | *task* | { name = "Chat1", icon = "optional icon, usually has it", text = "this is optional", tooltip = "some text", commandName = "", } | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.RemoveTask remove task from the status bar, automatically refresh the UI * _param_ __taskName__ : task name __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.RemoveTask(taskName)</verbatim> __parameters__ | *taskName* | task name | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.AddFeed -------------------------- FEED -------------------------- add a feed, it will automatically popup the feed information * _param_ __task__ : { ownerDraw = function (_parent) name = "Chat1", icon = "...", text = "Andy", background = "", commandName = "", } __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.AddFeed(feed)</verbatim> __parameters__ | *feed* | | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.RemoveFeed remove feed from the status bar, automatically refresh the UI * _param_ __feedName__ : feed name __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.RemoveFeed(feedName)</verbatim> __parameters__ | *feedName* | feed name | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.Reset ---- append a feed object into the feed array. Call UpdateUI() afterwards to reflect the changes to the UI. function Map3DSystem.App.ActionFeed.StatusBar.AppendFeed(feed) --Map3DSystem.App.ActionFeed.StatusBar.feeds[table.getn(Map3DSystem.App.ActionFeed.StatusBar.feeds) + 1] = feed; end ---- append a task object into the feed array. Call UpdateUI() afterwards to reflect the changes to the UI. function Map3DSystem.App.ActionFeed.StatusBar.AppendTask(task) --Map3DSystem.App.ActionFeed.StatusBar.tasks[table.getn(Map3DSystem.App.ActionFeed.StatusBar.tasks) + 1] = task; end clear all feeds. Call UpdateUI() afterwards to reflect the changes to the UI. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.Reset()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.StatusBar.OnClickTask onclick the task on the status bar __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.OnClickTask(taskName)</verbatim> __parameters__ | *taskName* | | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.OnClickPopUpFeed onclick the pop up feed __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.OnClickPopUpFeed(feedName)</verbatim> __parameters__ | *feedName* | | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.Show show the status bar in the _parent container __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.Show(_parent)</verbatim> __parameters__ | *parent* | | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.OnRenderBox <verbatim> mapping from icon string to icon path. Map3DSystem.App.ActionFeed.StatusBar.IconMap = { ["!"] = "Texture/whitedot.dds", ["?"] = "Texture/whitedot.dds", ["x"] = "Texture/whitedot.dds", ["tips"] = "Texture/whitedot.dds", ["question"] = "Texture/whitedot.dds", ["app"] = "Texture/whitedot.dds", ["app_uninstalled"] = "Texture/whitedot.dds", ["gift"] = "Texture/whitedot.dds", ["gift_sent"] = "Texture/whitedot.dds", ["blueprint_created"] = "Texture/whitedot.dds", ["blueprint_deployed"] = "Texture/whitedot.dds", ["blueprint_completed"] = "Texture/whitedot.dds", ["footprint"] = "Texture/whitedot.dds", ["friend_request"] = "Texture/whitedot.dds", ["city_request"] = "Texture/whitedot.dds", ["offline"] = "Texture/whitedot.dds", ["online"] = "Texture/whitedot.dds", ["person_join"] = "Texture/whitedot.dds", ["person_leave"] = "Texture/whitedot.dds", ["poke"] = "Texture/whitedot.dds", ["feed"] = "Texture/whitedot.dds", ["ads"] = "Texture/whitedot.dds", ["wall"] = "Texture/whitedot.dds", ["game"] = "Texture/whitedot.dds", ["gameHighScore"] = "Texture/whitedot.dds", ["treasure_quest"] = "Texture/whitedot.dds", ["treasure_gain"] = "Texture/whitedot.dds", ["pet_talk"] = "Texture/whitedot.dds", ["pet_wish"] = "Texture/whitedot.dds", ["pet_wish_completed"] = "Texture/whitedot.dds", ["chat"] = "Texture/whitedot.dds", ["card"] = "Texture/whitedot.dds", ["game"] = "Texture/whitedot.dds", ["rate"] = "Texture/whitedot.dds", ["save"] = "Texture/whitedot.dds", ["save_completed"] = "Texture/whitedot.dds", ["publish"] = "Texture/whitedot.dds", ["publish_completed"] = "Texture/whitedot.dds", ["Land_renting"] = "Texture/whitedot.dds", ["Land_confirmed"] = "Texture/whitedot.dds", } [[ add a new feed to the action feed bar. * _param_ __msg__ : is a table of the format msg = { -- no need to set, since we will set automatically for you. type = Map3DSystem.App.ActionFeed.StatusBar.MSGTYPE.ADD_ACTIONFEED, -- the specified application must be installed and loaded before the onclick event can be called. -- we will download the application at runtime. If nil, it may be from in-game function. app_key = nil or "GUID", -- icon to be displayed, in case the application is not installed locally. this icon will be displayed as an uninstalled icon. -- it will first index to into Map3DSystem.App.ActionFeed.StatusBar.IconMap table using the icon string, if not found, the icon string is used as the actual icon path. Icon = "!" or "Texture/whitedot.dds", etc, -- how icon is displayed. IconStyle = nil (normal style, 30% alpha until action bar has focus)| "Alert"(click once to stop beeping) | "ConstColor", -- how icon is animated when added to the bar. OnAddStyle = nil(normal) | "fly", -- this is only valid for local application or in-game function. OnClick = function or string, -- it can only be an mcml table to be parsed to the associated app.OnActionFeedClick(mcmlTable). -- this is mostly used for external applications. Simply use OnClick if it is an local app. OnClickMCML = mcmlTable or nil, -- immediately update UI. default to no. UpdateUI = boolean or nil, -- position table, in case this action item is associated with a 3D scene position. position = nil or {x=0, y=0,z=0}, -- if an icon item has position and posAction, when clicking it, it will not only triggers onclick, but also bring the camera to the position -- and may teleport the user to the position on the second click depending on the posAction type. posAction = nil | "teleport", -- the mouse over tooltip to display. Text may contain mcml markups to include URLs like another user_id. tooltip = nil or text, -- the text to display. Currently, we do not display it. text = nil, -- time created creation_date = nil, -- distribution method, we allow viral distribution of action feed among friends and current user. -- Please note that, not all client of applications is allowed to send feeds to the REST server directly. Basically, only app server can update feeds on REST server. -- so in most cases, this parameter is nil. distribution = nil (do nothing or just local feed) | "friends feed" (add this feed to friends) | "friends feed" (email this feed to all my friends) | "owner" (email to world owner) }</verbatim> ]] function Map3DSystem.App.ActionFeed.StatusBar.AddFeed(msg) -- --local _app = Map3DSystem.App.ActionFeed.app._app; --local _wnd = _app:FindWindow(Map3DSystem.App.ActionFeed.StatusBar.WndName); -- --if(_wnd ~= nil) then --msg.wndName = Map3DSystem.App.ActionFeed.StatusBar.WndName; --msg.type = Map3DSystem.App.ActionFeed.StatusBar.MSGTYPE.ADD_ACTIONFEED; --Map3DSystem.App.ActionFeed.app._app:SendMessage(msg) --end end --function Map3DSystem.App.ActionFeed.StatusBar.AddTask(msg) -- --local _app = Map3DSystem.App.ActionFeed.app._app; --local _wnd = _app:FindWindow(Map3DSystem.App.ActionFeed.StatusBar.WndName); -- --if(_wnd ~= nil) then --msg.wndName = Map3DSystem.App.ActionFeed.StatusBar.WndName; --msg.type = Map3DSystem.App.ActionFeed.StatusBar.MSGTYPE.ADD_TASK; --Map3DSystem.App.ActionFeed.app._app:SendMessage(msg) --end end [APP IP Function] this function should be called when a game world is loaded. It will load all action feed icons that is relavent to this world since action feed bar contains integration points, only call OnRenderBox when mcml are retrieved from server and apps for this world are all installed * _param_ __mcml__ : the mcml descriptive data that is usually retrieved from the paraworld REST server. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.OnRenderBox(mcml)</verbatim> __parameters__ | *mcml* | | ---++++ !Map3DSystem.App.ActionFeed.StatusBar.UpdateUI ---- this function is called in AppTaskBar.RefreshStatusBar() when status bar is recreated or new item is added to it. ---- status bar is heavily depend on this refresh mechanism function Map3DSystem.App.ActionFeed.StatusBar.Refresh(_parent) ---- TODO: refresh the status bar --if(_parent:IsValid()) then --Map3DSystem.App.ActionFeed.StatusBar.parentUIObj = _parent; -- ---- remove all children, since we will rebuild all. --_parent:RemoveAll(); -- --local _feed = ParaUI.CreateUIObject("button", "FeedBtn", "_rt", -50, 6, 48, 24); --_feed.background = "Texture/alphadot.png"; --"Texture/3DMapSystem/MainBarIcon/Wishlist_2.png"; --_feed.text = "FEED"; --_parent:AddChild(_feed); -- --local taskWidth = 72; --local taskHeight = 24; --local left = 52; -- --local _,_, maxWidth = _parent:GetAbsPosition(); --maxWidth = maxWidth - 22; --local bNoSpaceLeft; -- --local count = 0; -- number of icon created. --local index, task; --for index, task in ipairs(Map3DSystem.App.ActionFeed.StatusBar.tasks) do ----if(task.AppCommand) then --if((left + taskWidth) < maxWidth) then --local _task = ParaUI.CreateUIObject("button", "Task", "_rt", -(left + taskWidth), 6, taskWidth, taskHeight); --_task.tooltip = task.text; --_guihelper.SetVistaStyleButton(_task, --"Texture/3DMapSystem/Desktop/LoginButton_Norm.png: 15 15 15 15", --"Texture/3DMapSystem/Desktop/LoginButton_HL.png: 15 15 15 15"); --_parent:AddChild(_task); -- --local _icon = ParaUI.CreateUIObject("button", "Icon", "_rt", -(left + taskWidth), 6, taskHeight, taskHeight); --_icon.background = task.icon; --_icon.animstyle = 12; --_parent:AddChild(_icon); -- --local _text = ParaUI.CreateUIObject("button", "Text", "_rt", -(left + taskWidth) + taskHeight, 6, taskWidth - taskHeight, taskHeight); --_text.background = ""; --_text.text = task.text; --_parent:AddChild(_text); -- --left = left + taskWidth + 2; --else --bNoSpaceLeft = true; --end -- --count = count + 1; ---- 5 is maximum status bar icon number --if(bNoSpaceLeft) then ---- show extension button << using a popup menu control. --Map3DSystem.App.ActionFeed.StatusBar.ExtensionItemIndex = index; -- --local _this = ParaUI.CreateUIObject("button", "extBtn", "_rt", -(left + 16), 5, 16, 16) --_this.background = "Texture/3DMapSystem/Desktop/ext_left.png"; --_this.animstyle = 12; --_this.onclick = ";Map3DSystem.App.ActionFeed.StatusBar.ShowStatusBarExtensionMenu();" --_parent:AddChild(_this); --break; --end ----end --end -- ---- bring up a context menu for selecting extension items. --function Map3DSystem.App.ActionFeed.StatusBar.ShowStatusBarExtensionMenu() --local ctl = CommonCtrl.GetControl("statusbar.ExtensionMenu"); --if(ctl == nil)then --ctl = CommonCtrl.ContextMenu:new{ --name = "statusbar.ExtensionMenu", --width = 130, --height = 150, --DefaultIconSize = 24, --DefaultNodeHeight = 26, --container_bg = "Texture/3DMapSystem/ContextMenu/BG2.png:8 8 8 8", --AutoPositionMode = "_lb", --}; --end --local _this = Map3DSystem.App.ActionFeed.StatusBar.parentUIObj:GetChild("extBtn"); --if(_this:IsValid()) then --local x,y,width,height = _this:GetAbsPosition(); -- --ctl.RootNode:ClearAllChildren(); -- --local index, node --local nSize = table.getn(Map3DSystem.App.ActionFeed.StatusBar.tasks); --for index = Map3DSystem.App.ActionFeed.StatusBar.ExtensionItemIndex, nSize do --ctl.RootNode:AddChild(CommonCtrl.TreeNode:new(CommonCtrl.TreeNode:new({ --Text = Map3DSystem.App.ActionFeed.StatusBar.tasks[index].text, --Name = Map3DSystem.App.ActionFeed.StatusBar.tasks[index].text, --Icon = Map3DSystem.App.ActionFeed.StatusBar.tasks[index].icon}))); --end -- --ctl:Show(x, y); --end --end -- -- --end end update the UI: call this function when new item(s) are added. __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.UpdateUI()</verbatim> ---++++ !Map3DSystem.App.ActionFeed.StatusBar.MSGProc ------------------------------------------ all related messages ------------------------------------------ __syntax__ <verbatim>function Map3DSystem.App.ActionFeed.StatusBar.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | %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