Skip to content
Snippets Groups Projects
Commit 01989721 authored by dg's avatar dg
Browse files

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@2899 51575b47-30f0-44d4-a5cc-537603b46e54
parent fe1cc783
No related branches found
No related tags found
No related merge requests found
......@@ -551,6 +551,7 @@ function _M:currentCharacter(module, title, uuid)
if not self.auth then return end
core.profile.pushOrder(table.serialize{o="CurrentCharacter",
module=module,
mod_short=(game and type(game)=="table") and game.__mod_info.short_name or "unknown",
title=title,
valid=self.hash_valid,
uuid=uuid,
......
......@@ -21,6 +21,7 @@ require "engine.class"
require "engine.ui.Base"
local KeyBind = require "engine.KeyBind"
local Mouse = require "engine.Mouse"
local Dialog = require "engine.ui.Dialog"
local Slider = require "engine.ui.Slider"
--- Module that handles multiplayer chats
......@@ -79,6 +80,7 @@ function _M:event(e)
if type(game) == "table" and game.logNoNotify and e.channel == self.cur_channel then
game.logNoNotify("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.login, e.channel)
end
self:updateChanList()
elseif e.se == "Part" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = nil
......@@ -87,6 +89,7 @@ function _M:event(e)
if type(game) == "table" and game.logNoNotify and e.channel == self.cur_channel then
game.logNoNotify("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.login, e.channel)
end
self:updateChanList()
elseif e.se == "UserInfo" then
local info = e.data:unserialize()
if not info then return end
......@@ -101,6 +104,8 @@ function _M:event(e)
cur_char=user.cur_char and user.cur_char.title or "unknown",
module=user.cur_char and user.cur_char.module or "unknown",
valid=user.cur_char and user.cur_char.valid and "validate" or "not validated",
char_link=user.cur_char and user.char_link,
profile=user.cur_char and user.profile,
}
end
self.channels_changed = true
......@@ -132,17 +137,12 @@ function _M:talk(msg)
core.profile.pushOrder(string.format("o='ChatTalk' channel=%q msg=%q", self.cur_channel, msg))
end
function _M:getUserInfo(user)
if not profile.auth then return end
if not user then return end
core.profile.pushOrder(string.format("o='ChatUserInfo' user=%q", user))
end
--- Request a line to send
-- TODO: make it better than a simple dialog
function _M:talkBox()
if not profile.auth then return end
local d = require("engine.dialogs.GetText").new("Talk", self.cur_channel, 0, 250, function(text)
local GetText = require "engine.dialogs.GetText"
local d = GetText.new("Talk", self.cur_channel, 0, 250, function(text)
self:talk(text)
end)
d.key:addBind("EXIT", function() game:unregisterDialog(d) end)
......@@ -153,13 +153,36 @@ function _M:talkBox()
end
function _M:updateChanList(force)
local time = core.game.getTime()
if force or not self.last_chan_update or self.last_chan_update + 60000 < time then
local time = os.time()
if force or not self.last_chan_update or self.last_chan_update + 60 < time then
self.last_chan_update = time
core.profile.pushOrder(string.format("o='ChatChannelList' channel=%q", self.cur_channel))
end
end
--- Display user infos
function _M:showUserInfo(login)
if not profile.auth then return end
local popup = Dialog:simplePopup("Requesting...", "Requesting user info...", nil, true)
popup.__showup = nil
core.display.forceRedraw()
core.profile.pushOrder(string.format("o='ChatUserInfo' login=%q", login))
local data = nil
profile:waitEvent("UserInfo", function(e) data=e.data end)
game:unregisterDialog(popup)
if not data then
Dialog:simplePopup("Error", "The server does not know about this player.")
return
end
data = zlib.decompress(data):unserialize()
local UserInfo = require "engine.dialogs.UserInfo"
game:registerDialog(UserInfo.new(data))
end
----------------------------------------------------------------
-- UI Section
----------------------------------------------------------------
......@@ -212,7 +235,7 @@ function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
end
if last_ok then self:selectChannel(last_ok.name) end
else
if not self.on_mouse then return end
if not self.on_mouse or not self.dlist then return end
local citem = nil
for i = 1, #self.dlist do
local item = self.dlist[i]
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Dialog = require "engine.ui.Dialog"
local Button = require "engine.ui.Button"
local Textzone = require "engine.ui.Textzone"
module(..., package.seeall, class.inherit(Dialog))
function _M:init(data)
Dialog.init(self, "User: "..data.name, 1,1)
data.current_char = data.current_char or {}
local str = tstring{{"color","GOLD"}, {"font","bold"}, data.name, {"color","LAST"}, {"font","normal"}, true, true}
str:add({"color","ANTIQUE_WHITE"}, "Currently playing: ", {"color", "LAST"})
if data.char_link then
str:add({"font","italic"},{"color","LIGHT_BLUE"},data.current_char.title or "unknown",{"font","normal"},{"color","LAST"},true)
else
str:add(data.current_char or "unknown",true)
end
str:add({"color","ANTIQUE_WHITE"}, "Game: ", {"color", "LAST"}, data.current_char.module or "unknown", true)
str:add({"color","ANTIQUE_WHITE"}, "Validation: ", {"color", "LAST"}, data.current_char.valid and "Game has been validated by the server" or "Game is not validated by the server", true)
self.c_desc = Textzone.new{width=400, height=1, auto_height=true, text=str}
local b_profile = require("engine.ui.Button").new{text="Go to online profile", fct=function() util.browserOpenUrl(data.profile) end}
local b_char = require("engine.ui.Button").new{text="Go to online charsheet", fct=function() util.browserOpenUrl(data.char_link) end}
local ui = {
{left=0, top=0, ui=self.c_desc},
{left=0, bottom=0, ui=b_profile},
}
if data.char_link then ui[#ui+1] = {right=0, bottom=0, ui=b_char} end
self:loadUI(ui)
self:setupUI(not rw, not rh)
self.key:addBinds{
ACCEPT = accept_key and "EXIT",
EXIT = function()
game:unregisterDialog(self)
if on_exit then on_exit() end
end,
}
end
......@@ -1155,11 +1155,17 @@ function _M:setupMouse(reset)
end)
-- Chat tooltips
profile.chat:onMouse(function(user, button, event)
self.tooltip:displayAtMap(nil, nil, self.w, self.h, tstring{
{"color","GOLD"}, {"font","bold"}, user.name, {"color","LAST"}, {"font","normal"}, true,
{"color","ANTIQUE_WHITE"}, "Playing: ", {"color", "LAST"}, user.cur_char,true,
{"color","ANTIQUE_WHITE"}, "Game: ", {"color", "LAST"}, user.module, "(", user.valid, ")",true,
})
local str = tstring{{"color","GOLD"}, {"font","bold"}, user.name, {"color","LAST"}, {"font","normal"}, true}
str:add({"color","ANTIQUE_WHITE"}, "Playing: ", {"color", "LAST"}, user.current_char,true)
if user.char_link then
str:add({"font","italic"},{"color","LIGHT_BLUE"},user.char_link,{"font","normal"},{"color","LAST"},true)
end
str:add({"color","ANTIQUE_WHITE"}, "Game: ", {"color", "LAST"}, user.module, "(", user.valid, ")",true)
self.tooltip:displayAtMap(nil, nil, self.w, self.h, str)
if button == "left" and event == "button" then
profile.chat:showUserInfo(user.login)
end
end)
if not reset then self.mouse:setCurrent() end
end
......
......@@ -336,13 +336,15 @@ function _M:orderChatPart(o)
end
function _M:orderChatUserInfo(o)
self:command("UINF", o.user)
self:command("UINF", o.login)
if self:read("200") then
local _, _, size = self.last_line:find("^([0-9]+)")
size = tonumber(size)
if not size or size < 1 then return end
local body = self:receive(size)
cprofile.pushEvent(string.format("e='Chat' se='UserInfo' user=%q data=%q", o.user, body))
cprofile.pushEvent(string.format("e='UserInfo' login=%q data=%q", o.login, body))
else
cprofile.pushEvent(string.format("e='UserInfo' unknown=true login=%q", o.login))
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment