ActionFeedAppDev
description: 涓哄簲鐢ㄧ▼搴忓紑鍙戝晢鍜岀敤鎴锋彁渚涚敤鎴疯涓哄湪浜洪檯鍏崇郴缃戜腑鐨勪紶鎾
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.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemApp/ActionFeed/app_main.lua");
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 ConnectMode.
syntax
function Map3DSystem.App.ActionFeed.OnConnection(app, connectMode)
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
function Map3DSystem.App.ActionFeed.OnDisconnection(app, disconnectMode)
parameters
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 CommandStatusWanted
- return __ : returns according to statusWanted. it may return an integer by adding values in CommandStatus.
syntax
function Map3DSystem.App.ActionFeed.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.ActionFeed.OnExec
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,
}
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.ActionFeed.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.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
function Map3DSystem.App.ActionFeed.OnRenderBox(mcmlData)
parameters
Map3DSystem.App.ActionFeed.Navigate
called when the user wants to nagivate to the 3D world location relavent to this application
syntax
function Map3DSystem.App.ActionFeed.Navigate()
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
function Map3DSystem.App.ActionFeed.GotoHomepage()
Map3DSystem.App.ActionFeed.DoQuickAction
called when user clicks the quick action for this application.
syntax
function Map3DSystem.App.ActionFeed.DoQuickAction()
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
function Map3DSystem.App.ActionFeed.MSGProc(window, msg)
parameters
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
function Map3DSystem.App.ActionFeed.GetDSTable(output, uid, feedtype, pageCtrl, cache_policy)
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.
---- 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
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
function Map3DSystem.App.ActionFeed.DataSourceFunc(index, dsTable, uid, feedtype, pageCtrl, cache_policy)
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
function Map3DSystem.App.ActionFeed.ClearFeed(category, pageCtrl)
parameters
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.
Sample Code
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,
})
Member Functions
Map3DSystem.App.ActionFeed.ActionFeedBar.CreateFeedFromMsg
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,
}
create a new feed from a feed message
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.CreateFeedFromMsg(msg)
parameters
Map3DSystem.App.ActionFeed.ActionFeedBar.AddFeed
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)
}
]]
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.AddFeed(msg)
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
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)
}
]] |
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
function Map3DSystem.App.ActionFeed.ActionFeedBar.OnRenderBox(mcml)
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
function Map3DSystem.App.ActionFeed.ActionFeedBar.ShowWnd(app)
parameters
Map3DSystem.App.ActionFeed.ActionFeedBar.Show
internal show method
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.Show(bShow,_parent,parentWindow)
parameters
bShow |
|
parent |
|
parentWindow |
|
Map3DSystem.App.ActionFeed.ActionFeedBar.Reset
clear all feeds. Call
UpdateUI() afterwards to reflect the changes to the UI.
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.Reset()
Map3DSystem.App.ActionFeed.ActionFeedBar.UpdateUI
update the UI: call this function when new item(s) are added.
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.UpdateUI()
Map3DSystem.App.ActionFeed.ActionFeedBar.MSGProc
all related messages
syntax
function Map3DSystem.App.ActionFeed.ActionFeedBar.MSGProc(window, msg)
parameters
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
Sample Code
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
Member Functions
PublishFeedPage.OnInit
page event handlers
first time init page
syntax
function PublishFeedPage.OnInit()
PublishFeedPage.SendFeed
user clicks to send the feed.
syntax
function PublishFeedPage.SendFeed(btnName, values)
parameters
PublishFeedPage.SelectFriends
open a dialog to select to which friends we will send the message.
syntax
function PublishFeedPage.SelectFriends(btnName)
parameters
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.
Sample Code
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,
})
Member Functions
Map3DSystem.App.ActionFeed.StatusBar.Init
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,
}
init the status bar in at application connection
syntax
function Map3DSystem.App.ActionFeed.StatusBar.Init()
Map3DSystem.App.ActionFeed.StatusBar.AddTask
create a new feed from a feed message
function
CreateFeedFromMsg(msg)
--local feed = {ticks=0};
--if(msg ~= nil) then
--feed.app_key = msg.app_key;
--feed.isLocal = msg.isLocal;
--feed.Icon =
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
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
StatusBar.feeds = {};
an array of all tasks
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
function Map3DSystem.App.ActionFeed.StatusBar.AddTask(task)
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
function Map3DSystem.App.ActionFeed.StatusBar.RemoveTask(taskName)
parameters
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
function Map3DSystem.App.ActionFeed.StatusBar.AddFeed(feed)
parameters
Map3DSystem.App.ActionFeed.StatusBar.RemoveFeed
remove feed from the status bar, automatically refresh the UI
- param feedName : feed name
syntax
function Map3DSystem.App.ActionFeed.StatusBar.RemoveFeed(feedName)
parameters
Map3DSystem.App.ActionFeed.StatusBar.Reset
append a feed object into the feed array. Call
UpdateUI() afterwards to reflect the changes to the UI.
function
AppendFeed(feed)
--Map3DSystem.App.ActionFeed.StatusBar.feeds[table.getn(
StatusBar.feeds) + 1] = feed;
end
append a task object into the feed array. Call
UpdateUI() afterwards to reflect the changes to the UI.
function
AppendTask(task)
--Map3DSystem.App.ActionFeed.StatusBar.tasks[table.getn(
StatusBar.tasks) + 1] = task;
end
clear all feeds. Call
UpdateUI() afterwards to reflect the changes to the UI.
syntax
function Map3DSystem.App.ActionFeed.StatusBar.Reset()
Map3DSystem.App.ActionFeed.StatusBar.OnClickTask
onclick the task on the status bar
syntax
function Map3DSystem.App.ActionFeed.StatusBar.OnClickTask(taskName)
parameters
Map3DSystem.App.ActionFeed.StatusBar.OnClickPopUpFeed
onclick the pop up feed
syntax
function Map3DSystem.App.ActionFeed.StatusBar.OnClickPopUpFeed(feedName)
parameters
Map3DSystem.App.ActionFeed.StatusBar.Show
show the status bar in the _parent container
syntax
function Map3DSystem.App.ActionFeed.StatusBar.Show(_parent)
parameters
Map3DSystem.App.ActionFeed.StatusBar.OnRenderBox
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)
}
]]
function
AddFeed(msg)
--
--local _app =
ActionFeed.app._app;
--local _wnd = _app:FindWindow(
WndName);
--
--if(_wnd ~= nil) then
--msg.wndName =
WndName;
--msg.type = Map3DSystem.App.ActionFeed.StatusBar.MSGTYPE.ADD_ACTIONFEED;
--Map3DSystem.App.ActionFeed.app._app:SendMessage(msg)
--end
end
--function
AddTask(msg)
--
--local _app =
ActionFeed.app._app;
--local _wnd = _app:FindWindow(
WndName);
--
--if(_wnd ~= nil) then
--msg.wndName =
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
function Map3DSystem.App.ActionFeed.StatusBar.OnRenderBox(mcml)
parameters
Map3DSystem.App.ActionFeed.StatusBar.UpdateUI
this function is called in
RefreshStatusBar() when status bar is recreated or new item is added to it.
status bar is heavily depend on this refresh mechanism
function
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 =
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(
StatusBar.tasks) do
----if(task.AppCommand) then
--if((left + taskWidth) < maxWidth) then
--local _task =
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 = CreateUIObject("button", "Icon", "_rt", -(left + taskWidth), 6, taskHeight, taskHeight); --_icon.background = task.icon; --_icon.animstyle = 12; --_parent:AddChild(_icon); -- --local _text = 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 = 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 ShowStatusBarExtensionMenu() --local ctl = GetControl("statusbar.ExtensionMenu"); --if(ctl == nil)then --ctl = 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 = 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(StatusBar.tasks); --for index = ExtensionItemIndex, nSize do --ctl.RootNode:AddChild(TreeNode:new(TreeNode:new({ --Text = StatusBar.tasks[index].text, --Name = StatusBar.tasks[index].text, --Icon = 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
function Map3DSystem.App.ActionFeed.StatusBar.UpdateUI()
Map3DSystem.App.ActionFeed.StatusBar.MSGProc
all related messages
syntax
function Map3DSystem.App.ActionFeed.StatusBar.MSGProc(window, msg)
parameters