Commit 01d3faecb96bfc7fee278bb552d37b53924e237b

Authored by dg
1 parent 7ad5c87b

Chat log can now be scrolled

Clicking on a channel name will popup a big scrollable chat log


git-svn-id: http://svn.net-core.org/repos/t-engine4@3572 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -33,7 +33,7 @@ function _M:init()
33 33 self.channels_changed = true
34 34 self.cur_channel = "global"
35 35 self.channels = {}
36   - self.max = 50
  36 + self.max = 500
37 37 end
38 38
39 39 --- Hook up in the current running game
... ... @@ -136,6 +136,7 @@ function _M:selectChannel(channel)
136 136 self.cur_channel = channel
137 137 self.channels_changed = true
138 138 self.changed = true
  139 + self.scroll = 0
139 140 self:updateChanList(true)
140 141 end
141 142
... ... @@ -201,6 +202,18 @@ end
201 202 -- UI Section
202 203 ----------------------------------------------------------------
203 204
  205 +--- Make a dialog popup with the full log
  206 +function _M:showLogDialog(title, shadow)
  207 + local log = {}
  208 + if self.channels[self.cur_channel] then
  209 + for _, i in ipairs(self.channels[self.cur_channel].log) do
  210 + log[#log+1] = ("<%s> %s"):format(i.name, i.msg)
  211 + end
  212 + end
  213 + local d = require("engine.dialogs.ShowLog").new(title or "Chat Log", shadow, {log=log})
  214 + game:registerDialog(d)
  215 +end
  216 +
204 217 --- Resize the display area
205 218 function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
206 219 self.color = color or {255,255,255}
... ... @@ -241,7 +254,9 @@ function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
241 254 self.mouse.delegate_offset_x = self.display_x
242 255 self.mouse.delegate_offset_y = self.display_y
243 256 self.mouse:registerZone(0, 0, self.w, self.h, function(button, x, y, xrel, yrel, bx, by, event)
244   - if event == "button" and button == "left" and y <= self.frame.h then
  257 + if button == "wheelup" then self:scrollUp(1)
  258 + elseif button == "wheeldown" then self:scrollUp(-1)
  259 + elseif event == "button" and button == "left" and y <= self.frame.h then
245 260 local w = 0
246 261 local last_ok = nil
247 262 for i = 1, #self.display_chans do
... ... @@ -250,7 +265,11 @@ function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
250 265 w = w + item.w + 4
251 266 if w > x then break end
252 267 end
253   - if last_ok then self:selectChannel(last_ok.name) end
  268 + if last_ok then
  269 + local old = self.cur_channel
  270 + self:selectChannel(last_ok.name)
  271 + if old == self.cur_channel then self:showLogDialog(nil, self.shadow) end
  272 + end
254 273 else
255 274 if not self.on_mouse or not self.dlist then return end
256 275 local citem = nil
... ... @@ -357,8 +376,10 @@ end
357 376 --- Scroll the zone
358 377 -- @param i number representing how many lines to scroll
359 378 function _M:scrollUp(i)
  379 + local log = {}
  380 + if self.channels[self.cur_channel] then log = self.channels[self.cur_channel].log end
360 381 self.scroll = self.scroll + i
361   - if self.scroll > #self.log - 1 then self.scroll = #self.log - 1 end
  382 + if self.scroll > #log - 1 then self.scroll = #log - 1 end
362 383 if self.scroll < 0 then self.scroll = 0 end
363 384 self.changed = true
364 385 end
... ...
... ... @@ -191,10 +191,15 @@ function _M:init(t, no_default)
191 191 atk=1, apr=0,
192 192 physcrit=0,
193 193 physspeed =1,
194   - dammod= { str=1 },
  194 + dammod = { str=1 },
195 195 damrange=1.1,
196 196 talented = "unarmed",
197 197 }
  198 + -- Insures we have certain values for gloves to modify
  199 + self.combat.damrange = self.combat.damrange or 1.1
  200 + self.combat.physspeed = self.combat.physspeed or 1
  201 + self.combat.dammod = self.combat.dammod or {str=0.6}
  202 +
198 203 self.talents[self.T_ATTACK] = self.talents[self.T_ATTACK] or 1
199 204
200 205 self:resetCanSeeCache()
... ...
... ... @@ -51,8 +51,10 @@ function _M:event(e)
51 51 if not data then return end
52 52 if data.kind == "object-link" then
53 53 self.chat:addMessage(e.channel, e.login, e.name, "#ANTIQUE_WHITE#has linked an item: #WHITE# "..data.name, {mode="tooltip", tooltip=data.desc})
  54 + game.logChat("#LIGHT_BLUE#%s has linked an item <%s>", e.name, data.name)
54 55 elseif data.kind == "actor-link" then
55 56 self.chat:addMessage(e.channel, e.login, e.name, "#ANTIQUE_WHITE#has linked a creature: #WHITE# "..data.name, {mode="tooltip", tooltip=data.desc})
  57 + game.logChat("#LIGHT_BLUE#%s has linked a creature <%s>", e.name, data.name)
56 58 end
57 59 end
58 60 end
... ...