Skip to content
Snippets Groups Projects
Commit 80728974 authored by DarkGod's avatar DarkGod
Browse files

can now talk to your friends from the main menu

parent 2240c3e1
No related branches found
No related tags found
No related merge requests found
......@@ -361,8 +361,6 @@ end
function _M:addFriend(login, id)
core.profile.pushOrder(table.serialize{o="AddFriend", id=id})
-- CRASH ON ADD
end
function _M:removeFriend(login, id)
......@@ -442,11 +440,11 @@ function _M:achievement(name, huge, first)
end
--- Request a line to send
function _M:talkBox(on_end)
function _M:talkBox(on_end, only_friends)
if not profile.auth then return end
local Talkbox = require "engine.dialogs.Talkbox"
local d = Talkbox.new(self, on_end)
game:registerDialog(d)
local d = Talkbox.new(self, on_end, only_friends)
if not d.nobody then game:registerDialog(d) end
self:updateChanList()
end
......
......@@ -27,7 +27,7 @@ local Textzone = require "engine.ui.Textzone"
module(..., package.seeall, class.inherit(Dialog))
function _M:init(chat, on_end)
function _M:init(chat, on_end, only_friends)
chat:getChannelCode("----------------")
self.on_end = on_end
......@@ -35,6 +35,7 @@ function _M:init(chat, on_end)
self.min = 2
self.max = 300
self.absolute = absolute
self.only_friends = self.only_friends
Dialog.init(self, self:getTitle(), 320, 110, nil, nil, nil, nil, false)
......@@ -46,7 +47,16 @@ function _M:init(chat, on_end)
local ok = Button.new{text="Accept", fct=function() self:okclick() end}
local cancel = Button.new{text="Cancel", fct=function() self:cancelclick() end}
local list = self:getTargets()
local list = self:getTargets(only_friends)
if #list == 0 then self.nobody = true end
if only_friends and #list > 0 then
local type, name = self.chat:getCurrentTarget()
if type ~= "whisper" then
self.chat:setCurrentTarget(false, list[1].id)
end
end
self.c_list_text = Textzone.new{auto_width=true, auto_height=true, text="Target: "}
self.c_list = Dropdown.new{width=250, fct=function(item) if not item then return end self:checkTarget(item.id..":") self:setFocus(c_box) end, list=list, nb_items=math.min(#list, 10), scrollbar=true}
......@@ -84,12 +94,20 @@ function _M:init(chat, on_end)
end)
end
function _M:getTargets()
function _M:on_register()
self:updateTitle(self:getTitle())
end
function _M:getTargets(only_friends)
local list = {}
for name, _ in pairs(self.chat.channels) do list[#list+1] = {name="Channel: "..name, id=name} end
if not only_friends then
for name, _ in pairs(self.chat.channels) do list[#list+1] = {name="Channel: "..name, id=name} end
end
local name_added = {}
for login, data in pairs(self.chat.friends) do list[#list+1] = {name="Friend: "..data.name, id=data.name} name_added[data.name] = true end
if self.chat.channels[self.chat.cur_channel] then
if not only_friends and self.chat.channels[self.chat.cur_channel] then
for login, data in pairs(self.chat.channels[self.chat.cur_channel].users) do if not name_added[data.name] then list[#list+1] = {name="User: "..data.name, id=data.name} name_added[data.name] = true end end
end
return list
......
......@@ -25,6 +25,7 @@ local ButtonImage = require "engine.ui.ButtonImage"
local Textzone = require "engine.ui.Textzone"
local Textbox = require "engine.ui.Textbox"
local Separator = require "engine.ui.Separator"
local KeyBind = require "engine.KeyBind"
module(..., package.seeall, class.inherit(Dialog))
......@@ -113,17 +114,9 @@ function _M:updateUI()
end
end)
self.key:addBind("SCREENSHOT", function() game:saveScreenshot() end)
self.key:addBind("USERCHAT_TALK", function() print("<<<") profile.chat:talkBox() end)
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================")
print("==================================<")
KeyBind:load("chat")
self.key:bindKeys() -- Make sure it updates
self.key:addBind("USERCHAT_TALK", function() profile.chat:talkBox(nil, true) end)
end
function _M:uiLogin(uis)
......
......@@ -23,7 +23,7 @@ local UserChat = require "profile-thread.UserChat"
module(..., package.seeall, class.make)
local debug = false
local debug = true
local mport = debug and 2259 or 2257
local pport = debug and 2260 or 2258
......
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