---++!! !ChatAppDev __description__: 鑱婂ぉ鍗虫椂閫氳: 鏀寔缁勩€佸ソ鍙嬪垪琛ㄣ€侀殣绉佺鐞嗙瓑 %TOC{title="Contents:"}% %STARTINCLUDE% ---++ Chat app for Paraworld | *Title* | Chat app for Paraworld | | *Author(s)* | WangTian, original template by LiXizhi | | *Date* | 2008/1/9, Added Summon mode 2008.7.18 lxz | | *File* | script/kids/3DMapSystemUI/Chat/app_main.lua | ---+++ Description chatting via jabber ---++ Summon Mode More information, please see NPL.load("(gl)script/kids/3DMapSystemUI/Chat/SummonMode.lua"); <verbatim> -- activate summon mode Map3DSystem.App.Commands.Call("Profile.Chat.Summon"); -- block a summoned agent Map3DSystem.App.Commands.Call("Profile.Chat.BlockAgent", {JID = JID}); </verbatim> %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/app_main.lua"); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.Chat.OnConnection requires create class commonlib.setfield("Map3DSystem.App.Chat", {}); ------------------------------------------- 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.Chat.OnConnection(app, connectMode)</verbatim> __parameters__ | *app* | the object representing the current application in the IDE. | | *connectMode* | | ---++++ !Map3DSystem.App.Chat.OnDisconnection Receives notification that the Add-in is being unloaded. __syntax__ <verbatim>function Map3DSystem.App.Chat.OnDisconnection(app, disconnectMode)</verbatim> __parameters__ | *app* | | | *disconnectMode* | | ---++++ !Map3DSystem.App.Chat.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.Chat.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.Chat.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__ <verbatim>function Map3DSystem.App.Chat.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.Chat.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.Chat.OnRenderBox(mcmlData)</verbatim> __parameters__ | *mcmlData* | | ---++++ !Map3DSystem.App.Chat.Navigate called when the user wants to nagivate to the 3D world location relavent to this application __syntax__ <verbatim>function Map3DSystem.App.Chat.Navigate()</verbatim> ---++++ !Map3DSystem.App.Chat.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.Chat.GotoHomepage()</verbatim> ---++++ !Map3DSystem.App.Chat.DoQuickAction called when user clicks the quick action for this application. __syntax__ <verbatim>function Map3DSystem.App.Chat.DoQuickAction()</verbatim> ---++++ !Map3DSystem.App.Chat.OnDeactivateDesktop __syntax__ <verbatim>function Map3DSystem.App.Chat.OnDeactivateDesktop()</verbatim> ---++++ !Map3DSystem.App.Chat.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.Chat.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++ Lobby BBS channel manager | *Title* | Lobby BBS channel manager | | *Author(s)* | WangTian | | *Date* | 2008/6/24, Doc requirement added LiXizhi. 2008.7.20 | | *File* | script/kids/3DMapSystemUI/Chat/ChannelManager.lua | ---+++ Description ---++ Message format <verbatim> { uid = user id, date = send date, channelName = channel name that this message belongs to, channelColor = text color, [optional] text = pure or mcml text, name = fullname of the user sending the message. JID = JID of the user sending the message. } </verbatim> Please note that in the remote database, we only store three fields {uid, date, content} Hence, uid, date are read exactly as in the remote database. channelColor and channelName are added locally according to local settings when a message is retrieved. text, name, JID are stored as NPL table in content column. Whenever we received the content field from the server, we will decide if it is xml (pure text) or a serialized NPL table string(begins with '{'). If it is table, all table fields are extracted to the message. ---++ Sending message Usually when we send messages, we usually send a serialized table string containing {text, name, JID}, such as { uid, channelName, content = commonlib.serialize_compact({text, name, JID}); } The text length is limited to 256 characters. ---++ Displaying message in chat window we will reconstruct an mcml string from available message fields to display a given message. the reconstruction is as below. <p style='color:{msg.channelColor};' >[{msg.channelName}] <pe:name value='{msg.name}' uid='{msg.uid}'/>:{msg.text} </p> We will display 8 messsages at a time in a screen. ---++ Getting latest messages the way client getting messages from server is based on polling. the polling logic is below - If lastUpdateTime==nil, immediately fetch from the server the lastest 50 messages. - If we have just send out a text, immediately fetch from the server the lastest messages since the lastUpdateTime we will prevent entering text again until either the last update returned or some serverTimeOut(10 s) is passed. - If we have not been sending messages then if chat window is enabled then if the last fetched messages are Not empty update from server again activeUpdateInterval( 1 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed. else update from server again after activeEmptyUpdateInterval( 5 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed. end else if the last fetched messages are Not empty update from server again passiveUpdateInterval( 5 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed. else update from server again after passiveEmptyUpdateInterval( 10 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed. end end end ---++ Getting already fetched messages Call the following method to retrieve already fetched messages. It can be called as many times by any other applications. such as the summon mode. It only returns from the local memory. <verbatim> local msgs = Map3DSystem.App.Chat.ChannelManager.GetFetchedMessages({ channel = nil, if nil it means from all channels, afterDate = nil, if nil it means the latest pageSize = 50, return the latest number of message after afterDate }) </verbatim> %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChannelManager.lua"); Map3DSystem.App.Chat.ChannelManager.AddChannel("Channel_1") </verbatim> ---+++ Member Functions ---++++ !ChannelManager.Init create class local ChannelManager = {}; commonlib.setfield("Map3DSystem.App.Chat.ChannelManager", ChannelManager); all channel messages are stored in the channels table each entry with a treeview node inside residing all the messages in that channel treeview can use that node as a root node to show the messages directly ChannelManager.channels = {}; text color of the default channel messages ChannelManager.TextColors = { ["Public"] = "FAEBD7", ["Help"] = "ADD8E6", ["World"] = "32CD32", ["Chat"] = "FFC0CB", }; init the channels and the message time __syntax__ <verbatim>function ChannelManager.Init()</verbatim> ---++++ !ChannelManager.OnUISetup init the message on UISetup __syntax__ <verbatim>function ChannelManager.OnUISetup()</verbatim> ---++++ !ChannelManager.AddChannel add a channel to manager __syntax__ <verbatim>function ChannelManager.AddChannel(channelName, channelText)</verbatim> __parameters__ | *channelName* | | | *channelText* | | ---++++ !ChannelManager.RemoveChannel remove a channel from manager __syntax__ <verbatim>function ChannelManager.RemoveChannel(channelName)</verbatim> __parameters__ | *channelName* | | ---++++ !ChannelManager.GetChannelRootTreeNode get the channel root treenode, it containing all the message information NOTE: this node is the root node of channel manager, all channels post information to this node __syntax__ <verbatim>function ChannelManager.GetChannelRootTreeNode()</verbatim> ---++++ !ChannelManager.ChangeFocusChannel change focus to channel __syntax__ <verbatim>function ChannelManager.ChangeFocusChannel(channelName)</verbatim> __parameters__ | *channelName* | | ---++++ !ChannelManager.GetFocusChannelText get focus channel text __syntax__ <verbatim>function ChannelManager.GetFocusChannelText()</verbatim> ---++++ !ChannelManager.AppendJabberChatMessage append the jabber chat message to the channel root node __syntax__ <verbatim>function ChannelManager.AppendJabberChatMessage(JID, subject, body)</verbatim> __parameters__ | *JID* | | | *subject* | | | *body* | | ---++++ !ChannelManager.UpdateMessages common show update interval local isProcessing = false; -- is web service processing ChannelManager.CommonShowUpdateInterval = 500; -- in milliseconds update 0.1 second after text sent ChannelManager.TextSentUpdateLatency = 100; local _elapsedtime = 0; local _currentTime = 0; -- only for deltatime get all messages from all channels __syntax__ <verbatim>function ChannelManager.UpdateMessages()</verbatim> ---++++ !ChannelManager.PostMessage post message to the current focus channel * _param_ __content__ : the message content __syntax__ <verbatim>function ChannelManager.PostMessage(contentStr)</verbatim> __parameters__ | *contentStr* | | ---++ chat window | *Title* | chat window | | *Author(s)* | WangTian | | *Date* | 2007/10/14 | | *File* | script/kids/3DMapSystemUI/Chat/ChatWnd.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChatWnd.lua"); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.UI.Chat.ChatWnd:new constructor __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:new(o)</verbatim> __parameters__ | *o* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd:show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !Map3DSystem.UI.Chat.ChatWnd:InitUI init the ChatWnd UI __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:InitUI(parent)</verbatim> __parameters__ | *parent* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd.DrawContactNodeHandler chat window chatting history treeview owner draw function __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.DrawContactNodeHandler(_parent, treeNode)</verbatim> __parameters__ | *parent* | | | *treeNode* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd.MSGProc chat window message procedure __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd.GetWindowFrame get the window frame according to the user JID * _sJID_ ____ : user JID __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.GetWindowFrame(sJID)</verbatim> __parameters__ | *sJID* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd.ShowUI show ui function of the chat window * _param_ __bShow__ : true or false * _param_ __parentUI__ : parent UI contain object * _param_ __parentWindow__ : parent os window object __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.ShowUI(bShow, parentUI, parentWindow)</verbatim> __parameters__ | *bShow* | true or false | | *parentUI* | | | *parentWindow* | parent os window object | ---++++ !Map3DSystem.UI.Chat.ChatWnd.OnCloseWindow close callback function of the chat window __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.OnCloseWindow(sJID)</verbatim> __parameters__ | *sJID* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd:OnClose close the chat windows __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:OnClose()</verbatim> ---++++ !Map3DSystem.UI.Chat.ChatWnd:AddTextToChatHistory add a line of text to the chat history * _param_ __from__ : the name of the user * _param_ __subject__ : nil * _param_ __body__ : the message body __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:AddTextToChatHistory(from, subject, body)</verbatim> __parameters__ | *from* | the name of the user | | *subject* | | | *body* | the message body | ---++++ !Map3DSystem.UI.Chat.ChatWnd:OnReceiveMessage called when received a message from server * _param_ __from__ : the name of the user * _param_ __subject__ : nil * _param_ __body__ : the message body __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:OnReceiveMessage(from, subject, body)</verbatim> __parameters__ | *from* | the name of the user | | *subject* | | | *body* | the message body | ---++++ !Map3DSystem.UI.Chat.ChatWnd:SendChatMessage called to send a message * _param_ __to__ : JID * _param_ __body__ : the message body __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd:SendChatMessage(to, body)</verbatim> __parameters__ | *to* | JID | | *body* | | ---++++ !Map3DSystem.UI.Chat.ChatWnd.UpdateContactStatus update the contact status of the given user * _param_ __sJID__ : given user JID * _param_ __status__ : online status * _param_ __personalMSG__ : personal message __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.UpdateContactStatus(sJID, status, personalMSG)</verbatim> __parameters__ | *sJID* | given user JID | | *status* | | | *personalMSG* | personal message | ---++++ !Map3DSystem.UI.Chat.ChatWnd.GetWindowFrameDocument get the document window UI object of the given user * _param_ __sJID__ : given user JID __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.GetWindowFrameDocument(sJID)</verbatim> __parameters__ | *sJID* | given user JID | ---++++ !Map3DSystem.UI.Chat.ChatWnd.OnSendMessage_static static function send message in the textBox of the chat window __syntax__ <verbatim>function Map3DSystem.UI.Chat.ChatWnd.OnSendMessage_static(sJID)</verbatim> __parameters__ | *sJID* | | ---++ Chat contact window user interface | *Title* | Chat contact window user interface | | *Author(s)* | WangTian | | *Date* | 2008/5/27 | | *File* | script/kids/3DMapSystemUI/Chat/ChatWnd2.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChatWnd2.lua"); local chatwnd = Map3DSystem.App.Chat.ChatWnd:CreateGetWnd({"andy2@pala5.cn"}); chatwnd:ShowMainWnd(true); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.Chat.ChatWnd:CreateGetWnd get the ChatWnd by its JID list. if the ChatWnd of the given JIDs list is not created. it will create a new one and return. * _param_ __JIDs__ : e.x. {"andy2@pala5.cn", "leio@pala5.cn", "lixizhi@pala5.cn", "Clayman@pala5.cn", ...} create ChatWnd object __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:CreateGetWnd(JIDs)</verbatim> __parameters__ | *JIDs* | e.x. {"andy2 | ---++++ !Map3DSystem.App.Chat.ChatWnd:ShowMainWnd Show the Chat window * _param_ __bShow__ : * _param_ __bSilentInit__ : if true, the window is init but not show __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:ShowMainWnd(bShow, bSilentInit)</verbatim> __parameters__ | *bShow* | | | *bSilentInit* | | ---++++ !Map3DSystem.App.Chat.ChatWnd:GetVisible return the window frame visibility nil if the window frame is not inited __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:GetVisible()</verbatim> ---++++ !Map3DSystem.App.Chat.ChatWnd:IsTopFrame return if the window frame top frame __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:IsTopFrame()</verbatim> ---++++ !Map3DSystem.App.Chat.ChatWnd:GetTextAndIcon get the text and icon according to ChatWnd JID list * _return_ __text__ :, icon, shortText: string __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:GetTextAndIcon()</verbatim> __parameters__ | *return* | , icon, shortText: string | ---++++ !Map3DSystem.App.Chat.ChatWnd:Update update the UI __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:Update()</verbatim> ---++++ !Map3DSystem.App.Chat.ChatWnd:RecvMSG recv message * _param_ __JID__ : * _param_ __subject__ : * _param_ __body__ : __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:RecvMSG(JID, subject, body)</verbatim> __parameters__ | *JID* | | | *subject* | | | *body* | | ---++++ !Map3DSystem.App.Chat.ChatWnd:SendMSG send message __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:SendMSG()</verbatim> ---++++ !Map3DSystem.App.Chat.ChatWnd:AppendMSG append the message to conversation treeview and update __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd:AppendMSG(JID, body)</verbatim> __parameters__ | *JID* | | | *body* | | ---++++ !Map3DSystem.App.Chat.ChatWnd.OnToggleChatTab click on the chat tab __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.OnToggleChatTab(ID)</verbatim> __parameters__ | *ID* | | ---++++ !Map3DSystem.App.Chat.ChatWnd.GenerateID generate a unique ID of this chat window using the JIDs __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.GenerateID(JIDs)</verbatim> __parameters__ | *JIDs* | | ---++++ !Map3DSystem.App.Chat.ChatWnd.GetChatWndByID get the chat window using ID __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.GetChatWndByID(ID)</verbatim> __parameters__ | *ID* | | ---++++ !Map3DSystem.App.Chat.ChatWnd.MSGProc Message Processor of Chat chat window control __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++++ !Map3DSystem.App.Chat.ChatWnd.Show show Chat ChatWnd in the parent window * _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. * _param_ __parentWindow__ : parent os window object, parent window for sending messages __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.Show(bShow, _parent, parentWindow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | | *parent* | | | *parentWindow* | parent os window object, parent window for sending messages | ---++++ !Map3DSystem.App.Chat.ChatWnd.OnInputTextChange monitor the keychange, enter to send message __syntax__ <verbatim>function Map3DSystem.App.Chat.ChatWnd.OnInputTextChange(ChatWndID)</verbatim> __parameters__ | *ChatWndID* | | ---++ Chat system contacts bar | *Title* | Chat system contacts bar | | *Author(s)* | WangTian | | *Date* | 2008/8/13 | | *File* | script/kids/3DMapSystemUI/Chat/ContactsBar.lua | ---+++ Description contacts bar is a container shown on the right bottom of the screen, right above the status bar. Each item in the contacts bar is an icon represents a user in the chat contact list. Each icon is accociated with a chat window which is triggered by the user or receive a message. Chat window can be minimized to the coresponding icon. Online status of the contact is shown on the right bottom 1/4 corner over the icon. If new message received, and chat window is minimized(not visible), new messages are shown with a bubble. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ContactsBar.lua"); </verbatim> ---+++ Member Functions ---++++ !ContactsBar.AddContact if(not Map3DSystem.App.Chat.ContactsBar) then Map3DSystem.App.Chat.ContactsBar = {}; end local ContactsBar = {}; Map3DSystem.App.Chat.ContactsBar = ContactsBar; ContactsBar.ContactsBarNodes = CommonCtrl.TreeNode:new({Text = "contactsbar", Name = "contactsbar"}); add a status bar task. * _param_ __task__ : { name = "Chat1", icon = "optional icon, usually has it", text = "this is optional", tooltip = "some text", commandName = "", } * _param_ __priority__ : number Priority defines the position of the given command in the status bar. Higher priority shown on the right. For those items with the same priority, the more recent added has lower priority which shows on the left. Here are some default priorities for official applications: ChatWindow: 3, OfficalAppStatus: 8, DefaultPriority: 5 __syntax__ <verbatim>function ContactsBar.AddContact(contact, priority)</verbatim> __parameters__ | *contact* | | | *priority* | | ---++++ !ContactsBar.RemoveContact remove contact icon from the contacts bar * _param_ __contactName__ : the task to be removed from the contacts bar __syntax__ <verbatim>function ContactsBar.RemoveContact(contactName)</verbatim> __parameters__ | *contactName* | the task to be removed from the contacts bar | ---++++ !ContactsBar.ClearContacts remove all tasks in contacts bar __syntax__ <verbatim>function ContactsBar.ClearContacts()</verbatim> ---++++ !ContactsBar.Refresh refresh the contacts bar with the UI parent container __syntax__ <verbatim>function ContactsBar.Refresh(_parent)</verbatim> __parameters__ | *parent* | | ---++ history window | *Title* | history window | | *Author(s)* | WangTian | | *Date* | 2007/10/14 | | *File* | script/kids/3DMapSystemUI/Chat/HistoryWnd.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/HistoryWnd.lua"); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.UI.Chat.HistoryWnd.ShowUI * _param_ __bShow__ : show or hide the panel * _param_ __parentUI__ : parent container inside which the content is displayed. it can be nil. * _param_ __parentWindow__ : parent window for sending messages __syntax__ <verbatim>function Map3DSystem.UI.Chat.HistoryWnd.ShowUI(bShow, parentUI, parentWindow)</verbatim> __parameters__ | *bShow* | show or hide the panel | | *parentUI* | | | *parentWindow* | parent window for sending messages | ---++ Lobby BBS channel page | *Title* | Lobby BBS channel page | | *Author(s)* | WangTian | | *Date* | 2008/6/23 | | *File* | script/kids/3DMapSystemUI/Chat/LobbyBBSChannelPage.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/LobbyBBSChannelPage.lua"); Map3DSystem.App.Chat.LobbyBBSChannelPage.Show() </verbatim> ---+++ Member Functions ---++++ !LobbyBBSChannelPage.OnInit create class local LobbyBBSChannelPage = {}; commonlib.setfield("Map3DSystem.App.Chat.LobbyBBSChannelPage", LobbyBBSChannelPage); text line height of a message. some fixed line height. local FixedLineHeight = 18; on init show the current avatar in pe:avatar __syntax__ <verbatim>function LobbyBBSChannelPage.OnInit()</verbatim> ---++++ !LobbyBBSChannelPage.OnClose open using external system web browser, such as ie __syntax__ <verbatim>function LobbyBBSChannelPage.OnClose()</verbatim> ---++++ !LobbyBBSChannelPage.DoFramemove update 0.05 second after first shown local _elapsedtime = 0; LobbyBBSChannelPage.FirstShowUpdateLatency = 0.05; on init show the current avatar in pe:avatar __syntax__ <verbatim>function LobbyBBSChannelPage.DoFramemove()</verbatim> ---++++ !LobbyBBSChannelPage.Show show the lobby BBS channel page __syntax__ <verbatim>function LobbyBBSChannelPage.Show(bShow)</verbatim> __parameters__ | *bShow* | | ---++++ !LobbyBBSChannelPage.ShowBBS * _param_ __params__ : a table containing __syntax__ <verbatim>function LobbyBBSChannelPage.ShowBBS(bShow, _parent, params)</verbatim> __parameters__ | *bShow* | | | *parent* | | | *params* | a table containing | ---++++ !Map3DSystem.App.Chat.LobbyBBSChannelPage.ChatOption onclick the four control button in the channel page __syntax__ <verbatim>function Map3DSystem.App.Chat.LobbyBBSChannelPage.ChatOption()</verbatim> ---++ new chat system for 3D Map system | *Title* | new chat system for 3D Map system | | *Author(s)* | WangTian | | *Date* | 2008/5/27, Autoreconnect added LiXizhi 2009.1.15 | | *File* | script/kids/3DMapSystemUI/Chat/Main.lua | ---+++ Description Chat system main Chat system is based on the Jabber client and works as a part of the paraworld online experience. OneTimeInit funciton is part of login procedure. Users are organized in groups(router in jabber) and shown with user icon picture and online status. Chat system provides a chat window for each contact. The chat window can also minimized to icons lined on the right bottom corner of the screen, right above the status bar. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/Main.lua"); Map3DSystem.App.Chat.OneTimeInit(); -- call Map3DSystem.App.Chat.InitJabber periodically if disconnected. Map3DSystem.App.Chat.InitJabber(); -- they contains the jid Map3DSystem.App.Chat.jid; Map3DSystem.App.Chat.UserJID; </verbatim> ---+++ Member Functions ---++++ !Chat.OneTimeInit private: Chat.LastConnectionTime = 0; connect timer Chat.ConnectTimer = -100000; only reconnect every 20 seconds Chat.ConnectPeriod = 20000; -- 20000 milliseconds once ondisconnected, we will try to Auto reconnect by 2 times before waiting until the next ConnectPeriod Chat.AutoConnectCount = 2; Chat.ReconnectCount_ = 0; Chat.ReconnectTimerID = 5151; log chat application event traffic local LOG_CHAT_JC_TRAFFIC = true; a mapping from event name to their callback functions local jc_event_callbacks = {}; one time initialize to chat system Call Map3DSystem.App.Chat.OneTimeInit() at authentication success login to JGSL chat during login procedure, see Map3DSystem.App.Login.Proc_Authentication including: 1. init the jabber client instant messanger 2. init the os.window object for message process __syntax__ <verbatim>function Chat.OneTimeInit()</verbatim> ---++++ !Chat.GetClient Get default jabber client, create if not exist It does not open a connection immediately. __syntax__ <verbatim>function Chat.GetClient()</verbatim> ---++++ !Chat.GetConnectedClient get the currently connected client. return nil, if connection is not valid __syntax__ <verbatim>function Chat.GetConnectedClient()</verbatim> ---++++ !Chat.CheckLastTime this function will return true if nMilliSecondsPassed is passed since last timer of timerName is set * _param_ __timerName__ : such as "ConnectTimer" * _param_ __nMilliSecondsPassed__ : such as 20000 milliseconds * _param_ __bUpdateIfTrue__ : whether it will update last connection time if true. __syntax__ <verbatim>function Chat.CheckLastTime(timerName, nMilliSecondsPassed, bUpdateIfTrue)</verbatim> __parameters__ | *timerName* | such as "ConnectTimer" | | *nMilliSecondsPassed* | | | *bUpdateIfTrue* | whether it will update last connection time if true. | ---++++ !Chat.InitJabber initiate the instant messager client * _param_ __username__ : user name * _param_ __password__ : password * _param_ __servername__ : server name, "paraweb3d.com", "pala5.cn", "192.168.0.223" .etc * _param_ __NetworkHost__ : the actuall IP address to connect to. If it is nil, IP address will be resolved from servername. Such as "192.168.0.223", "119.145.5.38" such as Map3DSystem.App.Chat.InitIM("andy", "1234567", "pala5.cn") __syntax__ <verbatim>function Chat.InitJabber(username, password, servername, NetworkHost)</verbatim> __parameters__ | *username* | user name | | *password* | | | *servername* | server name, "paraweb3d.com", "pala5.cn", "192.168.0.223" .etc | | *NetworkHost* | | ---++++ !Chat.AddEventListener ------------------------- Connect and Auth Event ------------------------- add a function call back to a given JC event TODO: use hook for other message types. * _param_ __JE__ :_EventName: currently only "JE_OnAuthenticate" and "JE_OnDisconnect" is supported. * _param_ __funcCallBack__ : it is of type function(msg) end __syntax__ <verbatim>function Chat.AddEventListener(JE_EventName, funcCallBack)</verbatim> __parameters__ | *JE* | _EventName: currently only "JE_OnAuthenticate" and "JE_OnDisconnect" is supported. | | *EventName* | | | *funcCallBack* | | ---++++ !Chat.FireEvent fire a given event. __syntax__ <verbatim>function Chat.FireEvent(JE_EventName, msg)</verbatim> __parameters__ | *JE* | | | *EventName* | | | *msg* | | ---++++ !Chat.OnTimer set timer __syntax__ <verbatim>function Chat.OnTimer()</verbatim> ---++++ !Chat.OnMessage ------------------------- Common Event ------------------------- __syntax__ <verbatim>function Chat.OnMessage()</verbatim> ---++++ !Chat.OnReceiveChatMessage on receive chat message __syntax__ <verbatim>function Chat.OnReceiveChatMessage(msg)</verbatim> __parameters__ | *msg* | | ---++++ !Map3DSystem.App.Chat.VisualizeMessage show the message with ChatWnd * _param_ __JID__ : * _param_ __subject__ : * _param_ __body__ : __syntax__ <verbatim>function Map3DSystem.App.Chat.VisualizeMessage(JID, subject, body)</verbatim> __parameters__ | *JID* | | | *subject* | | | *body* | | ---++++ !Chat.GetPendingMSGs pending messages these messages usually need MessageBox to show, the message will queue up for the DoPendingMSGTimer() to show on screen one by one, otherwise the next message will close the previous messagebox Chat.PendingMSGs = Chat.PendingMSGs or {}; client user interface may get the PnRoster messaged that received before ui objects are created __syntax__ <verbatim>function Chat.GetPendingMSGs()</verbatim> ---++++ !Chat.OnSelfPresence presence mapping, updated every time jabber client receives a presence message Chat.JID_Presence_mapping = {}; __syntax__ <verbatim>function Chat.OnSelfPresence()</verbatim> ---++++ !Chat.UpdateContactList update contact list in online mode, contact information is retrieved from the jabber client in offline mode, contact information is retrieved from the history __syntax__ <verbatim>function Chat.UpdateContactList()</verbatim> ---++++ !Chat.GetContactList get the roster groups and roster items * _return_ ____ : RosterGroups and RosterItems __syntax__ <verbatim>function Chat.GetContactList()</verbatim> __parameters__ | *return* | RosterGroups and RosterItems | ---++++ !Chat.IsInContactList is JID in contact list * _param_ ____ : JID of the user __syntax__ <verbatim>function Chat.IsInContactList(JID)</verbatim> __parameters__ | *JID* | | ---++++ !Chat.GetNameFromJID return the name of a Jabber ID, if not including any "@" sign the whole JID is returned * _param_ __sJID__ : the given JID * _return_ ____ : the name of the JID e.g. for JID:"andy@paraweb3d.com" it returns "andy" __syntax__ <verbatim>function Chat.GetNameFromJID(sJID)</verbatim> __parameters__ | *sJID* | the given JID | ---++++ !Chat.MSGProc Message Processor of Chat jabber client it handles various messages __syntax__ <verbatim>function Chat.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++ Instant messenging main window in Map 3D system | *Title* | Instant messenging main window in Map 3D system | | *Author(s)* | WangTian | | *Date* | 2007/10/12 | | *File* | script/kids/3DMapSystemUI/Chat/MainWnd.lua | ---+++ Description ---+++ Member Functions ---++++ !Map3DSystem.UI.Chat.MainWnd.ShowMainWndUI * _param_ __bShow__ : show or hide the panel * _param_ __parentUI__ : parent container inside which the content is displayed. it can be nil. * _param_ __parentWindow__ : parent window for sending messages __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.ShowMainWndUI(bShow, parentUI, parentWindow)</verbatim> __parameters__ | *bShow* | show or hide the panel | | *parentUI* | | | *parentWindow* | parent window for sending messages | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnUserIconClick onclick function on the login user icon __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnUserIconClick()</verbatim> ---++++ !Map3DSystem.UI.Chat.MainWnd.DrawContactNodeHandler owner draw function of the contact list treeview __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.DrawContactNodeHandler(_parent, treeNode)</verbatim> __parameters__ | *parent* | | | *treeNode* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.UpdateContactList update the entire UI __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.UpdateContactList()</verbatim> ---++++ !Map3DSystem.UI.Chat.MainWnd.OnClickUser called when clicking a user * _param_ __treeNode__ : treenode of the contact treeview __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnClickUser(treeNode)</verbatim> __parameters__ | *treeNode* | treenode of the contact treeview | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnClickGroupContextMenuItem group context menu event handler * _param_ __menuItem__ : * _param_ __UserNode__ : __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnClickGroupContextMenuItem(menuItem, UserNode)</verbatim> __parameters__ | *menuItem* | | | *UserNode* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnClickUserContextMenuItem user context menu event handler * _param_ __menuItem__ : * _param_ __UserNode__ : __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnClickUserContextMenuItem(menuItem, UserNode)</verbatim> __parameters__ | *menuItem* | | | *UserNode* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.AddContact add the contact shown in the textBoxAddContact text box __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.AddContact()</verbatim> ---++++ !Map3DSystem.UI.Chat.MainWnd.ShowChatWithUser show the ChatWnd instance for a given sJID, it will create the window if it has never been created before. * _param_ __sJID__ : the JID of the communicate user __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.ShowChatWithUser(sJID)</verbatim> __parameters__ | *sJID* | the JID of the communicate user | ---++++ !Map3DSystem.UI.Chat.MainWnd.ShowUserOnMap TODO: show the user on the map TODO: write proper command for map application __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.ShowUserOnMap(sJID)</verbatim> __parameters__ | *sJID* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnChangePersonalMsg dirty change personal msg TODO: more actions for editBox __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnChangePersonalMsg()</verbatim> ---++++ !Map3DSystem.UI.Chat.MainWnd.SetUserPersonalMSG set the user's personal information * _param_ __personalMSG__ : the personal information message * _param_ __bBroadcast__ : whether broadcast the user presence information, default true __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.SetUserPersonalMSG(personalMSG, bBroadcast)</verbatim> __parameters__ | *personalMSG* | the personal information message | | *bBroadcast* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnSelectUserStatus change the main window current user status according to the control selection, automaticly set the user's presence information * _param_ __sCtrlName__ : dropdownlistbox name __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnSelectUserStatus(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | dropdownlistbox name | ---++++ !Map3DSystem.UI.Chat.MainWnd.SetUserStatus set main window current user status, automaticly set the user's presence information __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.SetUserStatus(status)</verbatim> __parameters__ | *status* | | ---++++ !Map3DSystem.UI.Chat.MainWnd.AddChattingTab add a new chatting tab in tab contianer in main chat window * _param_ __sJID__ : the communicating user JID __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.AddChattingTab(sJID)</verbatim> __parameters__ | *sJID* | the communicating user JID | ---++++ !Map3DSystem.UI.Chat.MainWnd.RemoveChattingTab remove a chatting tab in tab contianer in main chat window * _param_ __sJID__ : the communicating user JID __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.RemoveChattingTab(sJID)</verbatim> __parameters__ | *sJID* | the communicating user JID | ---++++ !Map3DSystem.UI.Chat.MainWnd.RefreshChattingTab refresh the chatting tab in main chat window __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.RefreshChattingTab()</verbatim> ---++++ !Map3DSystem.UI.Chat.MainWnd.GetNameFromJID return the name of a Jabber ID, if not including any "@" sign the whole JID is returned * _param_ __sJID__ : the given JID * _return_ ____ : the name of the JID e.g. for JID:"andy@paraweb3d.com" it returns "andy" __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.GetNameFromJID(sJID)</verbatim> __parameters__ | *sJID* | the given JID | ---++++ !Map3DSystem.UI.Chat.MainWnd.UpdateContactStatus update the contact status, automaticly update the chat window contact status * _param_ __sJID__ : contact's JID * _param_ __status__ : status of the contact * _param_ __personalMSG__ : personal information message __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.UpdateContactStatus(sJID, status, personalMSG)</verbatim> __parameters__ | *sJID* | contact's JID | | *status* | | | *personalMSG* | personal information message | ---++++ !Map3DSystem.UI.Chat.MainWnd.OnClickChattingTab onclick chatting tab info * _param_ __sJID__ : communicating user's JID __syntax__ <verbatim>function Map3DSystem.UI.Chat.MainWnd.OnClickChattingTab(sJID)</verbatim> __parameters__ | *sJID* | communicating user's JID | ---++ Chat main window user interface | *Title* | Chat main window user interface | | *Author(s)* | WangTian | | *Date* | 2008/5/27 | | *File* | script/kids/3DMapSystemUI/Chat/MainWnd2.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/MainWnd2.lua"); Map3DSystem.App.Chat.MainWnd.ShowMainWnd(true); </verbatim> ---+++ Member Functions ---++++ !Map3DSystem.App.Chat.MainWnd.ShowMainWnd Show the Chat main window * _param_ __bSilentInit__ : if true, the window is init but not show __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.ShowMainWnd(bShow, bSilentInit)</verbatim> __parameters__ | *bShow* | | | *bSilentInit* | if true, the window is init but not show | ---++++ !Map3DSystem.App.Chat.MainWnd.DestroyMainWnd destory the main window, usually called when the world is closed __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.DestroyMainWnd()</verbatim> ---++++ !Map3DSystem.App.Chat.MainWnd.MSGProc Message Processor of Chat main control __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++++ !Map3DSystem.App.Chat.MainWnd.ShowUnvisualizedMSG Message Processor of Chat main control __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.ShowUnvisualizedMSG()</verbatim> ---++++ !Map3DSystem.App.Chat.MainWnd.IsUIAvailable check if the main window UI is available on world switching the UI is all reset __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.IsUIAvailable()</verbatim> ---++++ !Map3DSystem.App.Chat.MainWnd.Show show Chat MainWnd in the parent window * _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. * _param_ __parentWindow__ : parent os window object, parent window for sending messages __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.Show(bShow, _parent, parentWindow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | | *parent* | | | *parentWindow* | parent os window object, parent window for sending messages | ---++++ !Map3DSystem.App.Chat.MainWnd.AddContactImmediate add contact immediately * _param_ __JID__ : the JID of user to be added __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.AddContactImmediate(JID)</verbatim> __parameters__ | *JID* | the JID of user to be added | ---++++ !Map3DSystem.App.Chat.MainWnd.ChatWithContactImmediate chat with contact immediately * _param_ __JID__ : the JID of user to be chatted to __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.ChatWithContactImmediate(JID)</verbatim> __parameters__ | *JID* | the JID of user to be chatted to | ---++++ !Map3DSystem.App.Chat.MainWnd.SetUserStatus set main window current user status, automaticly set the user's presence information __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.SetUserStatus(status)</verbatim> __parameters__ | *status* | | ---++++ !Map3DSystem.App.Chat.MainWnd.OnSelfPresence set main window current user status, automaticly set the user's presence information __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.OnSelfPresence(presence)</verbatim> __parameters__ | *presence* | | ---++++ !Map3DSystem.App.Chat.MainWnd.DrawContactNodeHandler owner draw function of the contact list treeview __syntax__ <verbatim>function Map3DSystem.App.Chat.MainWnd.DrawContactNodeHandler(_parent, treeNode)</verbatim> __parameters__ | *parent* | | | *treeNode* | | ---++ Quick chat window | *Title* | Quick chat window | | *Author(s)* | WangTian | | *Date* | 2008/6/16 | | *File* | script/kids/3DMapSystemUI/Chat/QuickChat.lua | ---+++ Description Quick chat window is shown on the bottom of the screen area, right above the application toolbar. Quich chat window is trigger by hitting enter button if not focusing on any editbox. %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/QuickChat.lua"); </verbatim> ---+++ Member Functions ---++++ !QuickChat.ShowMainWnd NPL.load("(gl)script/kids/3DMapSystem_Data.lua"); commonlib.echo("\n script/kids/3DMapSystemUI/Chat/QuickChat.lua loaded\n") local L = CommonCtrl.Locale("IDE"); local QuickChat = {}; commonlib.setfield("Map3DSystem.App.Chat.QuickChat", QuickChat); Show the Quick chat window __syntax__ <verbatim>function QuickChat.ShowMainWnd(bShow)</verbatim> __parameters__ | *bShow* | | ---++++ !QuickChat.MSGProc Message Processor of QuickChat window control __syntax__ <verbatim>function QuickChat.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++++ !QuickChat.Show show QuickChat in the parent window * _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. * _param_ __parentWindow__ : parent os window object, parent window for sending messages __syntax__ <verbatim>function QuickChat.Show(bShow, _parent, parentWindow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | | *parent* | | | *parentWindow* | parent os window object, parent window for sending messages | ---++ Quick chat page | *Title* | Quick chat page | | *Author(s)* | WangTian | | *Date* | 2008/6/26 | | *File* | script/kids/3DMapSystemUI/Chat/QuickChatPage.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/QuickChatPage.lua"); Map3DSystem.App.Chat.QuickChatPage....() </verbatim> ---+++ Member Functions ---++++ !QuickChatPage.OnInit create class local QuickChatPage = {}; commonlib.setfield("Map3DSystem.App.Chat.QuickChatPage", QuickChatPage); local page; text style to use like "style='color:#ff0000'", please note to use single quotation mark. QuickChatPage.TextStyle = nil; on init __syntax__ <verbatim>function QuickChatPage.OnInit()</verbatim> ---++++ !QuickChatPage.OnClose close quick chat __syntax__ <verbatim>function QuickChatPage.OnClose()</verbatim> ---++++ !QuickChatPage.OnShowInput show input wnd __syntax__ <verbatim>function QuickChatPage.OnShowInput()</verbatim> ---++++ !QuickChatPage.OnHideInput close input wnd __syntax__ <verbatim>function QuickChatPage.OnHideInput()</verbatim> ---++++ !QuickChatPage.OnChangeTextColor change the current text color * _param_ __textcolor__ : like "ff0000" __syntax__ <verbatim>function QuickChatPage.OnChangeTextColor(textColor)</verbatim> __parameters__ | *textColor* | | ---++++ !QuickChatPage.OnSpace check the input box for channel switch command __syntax__ <verbatim>function QuickChatPage.OnSpace()</verbatim> ---++++ !QuickChatPage.OnTab check the input box for channel target switch command __syntax__ <verbatim>function QuickChatPage.OnTab()</verbatim> ---++ Summon mode | *Title* | Summon mode | | *Author(s)* | LiXizhi | | *Date* | 2008/7/16 | | *File* | script/kids/3DMapSystemUI/Chat/SummonMode.lua | ---+++ Description The idea of summon mode is to select a few from online people. and display their avatars' agent near the current player avatar. In this case, the current user can communicate with agents face to face without compromising other people. The communication, however, is limited to chat and animation. The agent movement is usually AI based such as facing to the speaking character near it. The procedure is as below - start the summon effects on the current player - make remote requests to selects a given number of uids from a given pool (such as online users and recently BBS speaking users) - find their JIDs from their uids. - for each candidate{ if(avater with JID does not exist) then if(filter(IsFriend or JustSpeaked)) then retrieve its avatar ccs info Create a character using its JID, make it non-persistent. create the agent avatar as agent OPC in the scene. mark the agent with agent head on display Assign agent AI module to the agent OPC. (more info, please see SummonedAgent.lua) end end move the player to a location near the current character. play summon effects and animation on the agent for 2 seconds. } the context menu for agent includes - teleport to avater of the agent. - private chat. - see profile of its user. - recast as local character. - delete (ban) this candiate Whenever the user receives or sends a BBS message in public or world channels. it will search in OPC and main player and display head on text for some seconds. ---++ Additional agent functions Instead of avatars, one can also summon pets from other offline/online players and adopt them in their world. One can right click on an agent and recast(rename) it as a local character. ---++ blocking an agent call Map3DSystem.App.Chat.SummonMode.BlockAgent(JID) %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/Chat/SummonMode.lua"); Map3DSystem.App.Chat.SummonMode.Activate() </verbatim> ---+++ Member Functions ---++++ !SummonMode.OnInit create class local SummonMode = {}; commonlib.setfield("Map3DSystem.App.Chat.SummonMode", SummonMode); max summon spawning radius SummonMode.spawn_radius = 6; private: current summon candidates, mapping from uid to candidate table. local candidates = {} summon mode page init __syntax__ <verbatim>function SummonMode.OnInit()</verbatim> ---++++ !SummonMode.CallSummonEffect fire the summon effect at a given position. It is just a particle effect that moves slowly at above head position. where fromX, fromY, fromZ is position at feet height. __syntax__ <verbatim>function SummonMode.CallSummonEffect(fromX, fromY, fromZ)</verbatim> __parameters__ | *fromX* | | | *fromY* | | | *fromZ* | | ---++++ !SummonMode.Activate activate the summon mode immediately. __syntax__ <verbatim>function SummonMode.Activate()</verbatim> ---++++ !SummonMode.SelectCandidates make remote requests to selects a given number of uids from a given pool (such as online users and recently BBS speaking users) __syntax__ <verbatim>function SummonMode.SelectCandidates()</verbatim> ---++++ !SummonMode.InitAgent initialize the agent, it will try to fetch its appearance first if not fetched before. __syntax__ <verbatim>function SummonMode.InitAgent(candidate)</verbatim> __parameters__ | *candidate* | | ---++++ !SummonMode.BlockAgent we will prevent the given JID from being added as an agent. __syntax__ <verbatim>function SummonMode.BlockAgent(JID, bUnblock)</verbatim> __parameters__ | *JID* | | | *bUnblock* | | ---++++ !SummonMode.CreateAgent create a given agent avatar if it has not created before. It will fire the summon effect. * _param_ __candidate__ : a table of {JID, uid, CCSInfoStr[optional]} __syntax__ <verbatim>function SummonMode.CreateAgent(candidate)</verbatim> __parameters__ | *candidate* | a table of {JID, uid, CCSInfoStr[optional]} | %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