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

Status effects are now shown as icons, just like talents

git-svn-id: http://svn.net-core.org/repos/t-engine4@4546 51575b47-30f0-44d4-a5cc-537603b46e54
parent b61ce2f8
No related branches found
No related tags found
No related merge requests found
Showing
with 83 additions and 22 deletions
......@@ -26,14 +26,13 @@ _M.tempeffect_def = {}
--- Defines actor temporary effects
-- Static!
function _M:loadDefinition(file)
local f, err = loadfile(file)
if not f and err then error(err) end
setfenv(f, setmetatable({
function _M:loadDefinition(file, env)
local f, err = util.loadfilemods(file, setmetatable(env or {
DamageType = require "engine.DamageType",
newEffect = function(t) self:newEffect(t) end,
load = function(f) self:loadDefinition(f) end
load = function(f) self:loadDefinition(f, getfenv(2)) end
}, {__index=_G}))
if not f and err then error(err) end
f()
end
......
......@@ -30,6 +30,7 @@ function _M:init(x, y, w, h, bgcolor, font, size)
self.w, self.h = w, h
self.bgcolor = bgcolor
self.font = core.display.newFont(font, size)
self.fontbig = core.display.newFont(font, size * 2)
self.mouse = Mouse.new()
self:resize(x, y, w, h)
end
......@@ -56,6 +57,10 @@ function _M:resize(x, y, w, h)
self.portrait = {core.display.loadImage("/data/gfx/ui/party-portrait.png"):glTexture()}
self.portrait_unsel = {core.display.loadImage("/data/gfx/ui/party-portrait-unselect.png"):glTexture()}
self.icon_green = { core.display.loadImage("/data/gfx/ui/talent_frame_ok.png"):glTexture() }
self.icon_yellow = { core.display.loadImage("/data/gfx/ui/talent_frame_sustain.png"):glTexture() }
self.icon_red = { core.display.loadImage("/data/gfx/ui/talent_frame_cooldown.png"):glTexture() }
self.items = {}
end
......@@ -141,6 +146,55 @@ function _M:makePortrait(a, current, x, y)
self.items[#self.items+1] = item
end
function _M:makeEntityIcon(e, tiles, x, y, desc, gtxt, frame)
self:mouseTooltip(desc, 40, 40, x, y)
local item = function(dx, dy)
e:toScreen(tiles, dx+x+4, dy+y+4, 32, 32)
if gtxt then
gtxt._tex:toScreenFull(dx+x+4+2 + (40 - gtxt.fw)/2, dy+y+4+2 + (40 - gtxt.fh)/2, gtxt.w, gtxt.h, gtxt._tex_w, gtxt._tex_h, 0, 0, 0, 0.7)
gtxt._tex:toScreenFull(dx+x+4 + (40 - gtxt.fw)/2, dy+y+4 + (40 - gtxt.fh)/2, gtxt.w, gtxt.h, gtxt._tex_w, gtxt._tex_h)
end
frame[1]:toScreenFull(dx+x, dy+y, 40, 40, frame[2] * 40 / frame[6], frame[3] * 40 / frame[7], 255, 255, 255, 255)
end
self.items[#self.items+1] = item
end
function _M:handleEffect(eff_id, e, p, ex, h)
local dur = p.dur + 1
local name = e.desc
local desc = nil
local eff_subtype = table.concat(table.keys(e.subtype), "/")
if e.display_desc then name = e.display_desc(self, p) end
if p.save_string and p.amount_decreased and p.maximum and p.total_dur then
desc = ("#{bold}##GOLD#%s\n(%s: %s)#WHITE##{normal}#\n"):format(name, e.type, eff_subtype)..e.long_desc(player, p).." "..("%s reduced the duration of this effect by %d turns, from %d to %d."):format(p.save_string, p.amount_decreased, p.maximum, p.total_dur)
else
desc = ("#{bold}##GOLD#%s\n(%s: %s)#WHITE##{normal}#\n"):format(name, e.type, eff_subtype)..e.long_desc(player, p)
end
if config.settings.tome.hotkey_icons and e.display_entity then
local txt = nil
if e.decrease > 0 then
dur = tostring(dur)
txt = self.fontbig:draw(dur, 40, colors.WHITE.r, colors.WHITE.g, colors.WHITE.b, true)[1]
txt.fw, txt.fh = self.fontbig:size(dur)
end
self:makeEntityIcon(e.display_entity, game.hotkeys_display_icons.tiles, ex, h, desc, txt, e.status ~= "detrimental" and self.icon_green or self.icon_red)
ex = ex + 40
if ex + 40 >= self.w then ex = 0 h = h + 40 end
else
if e.status == "detrimental" then
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_RED#%s(%d)"):format(name, dur) or ("#LIGHT_RED#%s"):format(name), x, h, 255, 255, 255)) h = h + self.font_h
else
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_GREEN#%s(%d)"):format(name, dur) or ("#LIGHT_GREEN#%s"):format(name), x, h, 255, 255, 255)) h = h + self.font_h
end
ex = 0
end
return ex, h
end
-- Displays the stats
function _M:display()
local player = game.player
......@@ -336,33 +390,41 @@ function _M:display()
end
h = h + self.font_h
local ex = 0
for tid, act in pairs(player.sustain_talents) do
if act then
local t = player:getTalentFromId(tid)
local displayName = t.name
if t.getDisplayName then displayName = t.getDisplayName(player, t, player:isTalentActive(tid)) end
local desc = "#GOLD##{bold}#"..displayName.."#{normal}##WHITE#\n"..tostring(player:getTalentFullDescription(t))
self:mouseTooltip(desc, self:makeTexture(("#LIGHT_GREEN#%s"):format(displayName), x, h, 255, 255, 255)) h = h + self.font_h
if config.settings.tome.hotkey_icons and t.display_entity then
self:makeEntityIcon(t.display_entity, game.hotkeys_display_icons.tiles, ex, h, desc, txt, self.icon_yellow)
ex = ex + 40
if ex + 40 >= self.w then ex = 0 h = h + 40 end
else
self:mouseTooltip(desc, self:makeTexture(("#LIGHT_GREEN#%s"):format(displayName), x, h, 255, 255, 255)) h = h + self.font_h
ex = 0
end
end
end
h = h + 40 ex = 0
local good_e, bad_e = {}, {}
for eff_id, p in pairs(player.tmp) do
local e = player.tempeffect_def[eff_id]
local dur = p.dur + 1
local name = e.desc
local desc = nil
local eff_subtype = table.concat(table.keys(e.subtype), "/")
if e.display_desc then name = e.display_desc(self, p) end
if p.save_string and p.amount_decreased and p.maximum and p.total_dur then
desc = ("#{bold}##GOLD#%s\n(%s: %s)#WHITE##{normal}#\n"):format(name, e.type, eff_subtype)..e.long_desc(player, p).." "..("%s reduced the duration of this effect by %d turns, from %d to %d."):format(p.save_string, p.amount_decreased, p.maximum, p.total_dur)
else
desc = ("#{bold}##GOLD#%s\n(%s: %s)#WHITE##{normal}#\n"):format(name, e.type, eff_subtype)..e.long_desc(player, p)
end
if e.status == "detrimental" then
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_RED#%s(%d)"):format(name, dur) or ("#LIGHT_RED#%s"):format(name), x, h, 255, 255, 255)) h = h + self.font_h
else
self:mouseTooltip(desc, self:makeTexture((e.decrease > 0) and ("#LIGHT_GREEN#%s(%d)"):format(name, dur) or ("#LIGHT_GREEN#%s"):format(name), x, h, 255, 255, 255)) h = h + self.font_h
end
if e.status == "detrimental" then bad_e[eff_id] = p else good_e[eff_id] = p end
end
for eff_id, p in pairs(good_e) do
local e = player.tempeffect_def[eff_id]
ex, h = self:handleEffect(eff_id, e, p, ex, h)
end
h = h + 40 ex = 0
for eff_id, p in pairs(bad_e) do
local e = player.tempeffect_def[eff_id]
ex, h = self:handleEffect(eff_id, e, p, ex, h)
end
if game.level and game.level.arena then
h = h + self.font_h
local arena = game.level.arena
......
......@@ -28,7 +28,7 @@ newChat{ id="welcome",
#{italic}#"Rokzan krilt copru."#{normal}#]] or [[#WHITE#*#{italic}#"Insert control rod."#{normal}#]]),
answers = {
{"[Examine the orb]", jump="examine", cond=has_rod},
-- {"[Fly the fortress]", action=function(npc, player) player:hasQuest("shertul-fortress"):fly() end},
{"[Fly the fortress]", action=function(npc, player) player:hasQuest("shertul-fortress"):fly() end},
{"[Begin the Lichform ceremory]", cond=function(npc, player) local q = player:hasQuest("lichform") return q and q:check_lichform(player) end, action=function(npc, player) player:setQuestStatus("lichform", engine.Quest.COMPLETED) end},
{"[Leave the orb alone]"},
}
......
game/modules/tome/data/gfx/effects/all_stat.png

5.39 KiB

game/modules/tome/data/gfx/effects/bane_blinded.png

7.17 KiB

game/modules/tome/data/gfx/effects/bane_confused.png

8.08 KiB

game/modules/tome/data/gfx/effects/blinded.png

5.63 KiB

game/modules/tome/data/gfx/effects/confused.png

7 KiB

game/modules/tome/data/gfx/effects/crippling_poison.png

3.87 KiB

game/modules/tome/data/gfx/effects/cut.png

5.52 KiB

game/modules/tome/data/gfx/effects/dazed.png

8.75 KiB

game/modules/tome/data/gfx/effects/default.png

2.94 KiB

game/modules/tome/data/gfx/effects/elemental_harmony.png

8.47 KiB

game/modules/tome/data/gfx/effects/empowered_healing.png

6.38 KiB

game/modules/tome/data/gfx/effects/fed_upon.png

5.38 KiB

game/modules/tome/data/gfx/effects/free_action.png

5.86 KiB

game/modules/tome/data/gfx/effects/frenzy.png

3.57 KiB

game/modules/tome/data/gfx/effects/gloom_confused.png

4.99 KiB

game/modules/tome/data/gfx/effects/gloom_slow.png

4.25 KiB

game/modules/tome/data/gfx/effects/gloom_stunned.png

3.8 KiB

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