Skip to content
Snippets Groups Projects
Commit f5a5e849 authored by Ryan Yappert's avatar Ryan Yappert
Browse files

Pulls the actual parsing of a hotkey into its display out into its own...

Pulls the actual parsing of a hotkey into its display out into its own function so it can be superloaded.
parent 0f35340e
No related branches found
No related tags found
1 merge request!691Pulls the actual parsing of a hotkey into an icon out into its own function
......@@ -152,140 +152,150 @@ function _M:display()
self.items = {}
local w, h = self.frames.w, self.frames.h
for page = bpage, #page_to_hotkey do for i = 1, 12 do
local ts = nil
local bi = i
local j = i + (12 * (page - 1))
if a.hotkey[j] and a.hotkey[j][1] == "talent" then
ts = {a.hotkey[j][2], j, "talent", i, page, i + (12 * (page - bpage))}
elseif a.hotkey[j] and a.hotkey[j][1] == "inventory" then
ts = {a.hotkey[j][2], j, "inventory", i, page, i + (12 * (page - bpage))}
end
for page = bpage, #page_to_hotkey do
for i = 1, 12 do
local ts = nil
local bi = i
local j = i + (12 * (page - 1))
if a.hotkey[j] and a.hotkey[j][1] == "talent" then
ts = {a.hotkey[j][2], j, "talent", i, page, i + (12 * (page - bpage))}
elseif a.hotkey[j] and a.hotkey[j][1] == "inventory" then
ts = {a.hotkey[j][2], j, "inventory", i, page, i + (12 * (page - bpage))}
end
x = self.frames.w * col
y = self.frames.h * row
self.dragclics[j] = {x,y,w,h}
if ts then
local s
local i = ts[2]
local lpage = ts[5]
local color, angle, txt = nil, 0, nil
local display_entity = nil
local frame = "ok"
if ts[3] == "talent" then
local tid = ts[1]
local t = a:getTalentFromId(tid)
if t then
display_entity = t.display_entity
if a:isTalentCoolingDown(t) then
if not a:preUseTalent(t, true, true) then
color = {190,190,190}
frame = "disabled"
else
frame = "cooldown"
color = {255,0,0}
angle = 360 * (1 - (a.talents_cd[t.id] / a:getTalentCooldown(t)))
end
txt = tostring(math.ceil(a:isTalentCoolingDown(t)))
elseif a:isTalentActive(t.id) then
color = {255,255,0}
frame = "sustain"
elseif not a:preUseTalent(t, true, true) then
x = self.frames.w * col
y = self.frames.h * row
self.dragclics[j] = {x,y,w,h}
self:displayHotkey(page, i, x, y, ts)
if orient == "down" or orient == "up" then
col = col + 1
if col >= self.max_cols then
col = 0
row = row + 1
if row >= self.max_rows then return end
end
elseif orient == "left" or orient == "right" then
row = row + 1
if row >= self.max_rows then
row = 0
col = col + 1
if col >= self.max_cols then return end
end
end
end
end
end
function _M:displayHotkey(page, i, x, y, ts)
local bi = i
local w, h = self.frames.w, self.frames.h
local a = self.actor
if ts then
local s
local i = ts[2]
local lpage = ts[5]
local color, angle, txt = nil, 0, nil
local display_entity = nil
local frame = "ok"
if ts[3] == "talent" then
local tid = ts[1]
local t = a:getTalentFromId(tid)
if t then
display_entity = t.display_entity
if a:isTalentCoolingDown(t) then
if not a:preUseTalent(t, true, true) then
color = {190,190,190}
frame = "disabled"
else
frame = "cooldown"
color = {255,0,0}
angle = 360 * (1 - (a.talents_cd[t.id] / a:getTalentCooldown(t)))
end
end
elseif ts[3] == "inventory" then
local o = a:findInAllInventories(ts[1], {no_add_name=true, force_id=true, no_count=true})
local cnt = 0
if o then cnt = o:getNumber() end
if cnt == 0 then
txt = tostring(math.ceil(a:isTalentCoolingDown(t)))
elseif a:isTalentActive(t.id) then
color = {255,255,0}
frame = "sustain"
elseif not a:preUseTalent(t, true, true) then
color = {190,190,190}
frame = "disabled"
end
display_entity = o
if o and o.use_talent and o.use_talent.id then
local t = a:getTalentFromId(o.use_talent.id)
display_entity = t and t.display_entity
end
if o and o.talent_cooldown then
local t = a:getTalentFromId(o.talent_cooldown)
angle = 360
if t and a:isTalentCoolingDown(t) then
color = {255,0,0}
angle = 360 * (1 - (a.talents_cd[t.id] / a:getTalentCooldown(t)))
frame = "cooldown"
txt = tostring(math.ceil(a:isTalentCoolingDown(t)))
end
elseif o and (o.use_talent or o.use_power) then
angle = 360 * ((o.power / o.max_power))
end
elseif ts[3] == "inventory" then
local o = a:findInAllInventories(ts[1], {no_add_name=true, force_id=true, no_count=true})
local cnt = 0
if o then cnt = o:getNumber() end
if cnt == 0 then
color = {190,190,190}
frame = "disabled"
end
display_entity = o
if o and o.use_talent and o.use_talent.id then
local t = a:getTalentFromId(o.use_talent.id)
display_entity = t and t.display_entity
end
if o and o.talent_cooldown then
local t = a:getTalentFromId(o.talent_cooldown)
angle = 360
if t and a:isTalentCoolingDown(t) then
color = {255,0,0}
local cd = o:getObjectCooldown(a)
if cd and cd > 0 then
frame = "cooldown"
txt = tostring(cd)
elseif not cd then
frame = "disabled"
end
angle = 360 * (1 - (a.talents_cd[t.id] / a:getTalentCooldown(t)))
frame = "cooldown"
txt = tostring(math.ceil(a:isTalentCoolingDown(t)))
end
if o and o.wielded then
frame = "sustain"
elseif o and (o.use_talent or o.use_power) then
angle = 360 * ((o.power / o.max_power))
color = {255,0,0}
local cd = o:getObjectCooldown(a)
if cd and cd > 0 then
frame = "cooldown"
txt = tostring(cd)
elseif not cd then
frame = "disabled"
end
if o and o.wielded and o.use_talent and o.use_talent.id then
local t = a:getTalentFromId(o.use_talent.id)
if not a:preUseTalent(t, true, true, true) then
angle = 0
color = {190,190,190}
frame = "disabled"
end
end
if o and o.wielded then
frame = "sustain"
end
if o and o.wielded and o.use_talent and o.use_talent.id then
local t = a:getTalentFromId(o.use_talent.id)
if not a:preUseTalent(t, true, true, true) then
angle = 0
color = {190,190,190}
frame = "disabled"
end
end
end
self.font:setStyle("bold")
local ks = game.key:formatKeyString(game.key:findBoundKeys("HOTKEY_"..page_to_hotkey[page]..bi))
local key = self.font:draw(ks, self.font:size(ks), colors.ANTIQUE_WHITE.r, colors.ANTIQUE_WHITE.g, colors.ANTIQUE_WHITE.b, true)[1]
self.font:setStyle("normal")
local gtxt = nil
if txt then
gtxt = self.fontbig:draw(txt, w, colors.WHITE.r, colors.WHITE.g, colors.WHITE.b, true)[1]
gtxt.fw, gtxt.fh = self.fontbig:size(txt)
end
self.font:setStyle("bold")
local ks = game.key:formatKeyString(game.key:findBoundKeys("HOTKEY_"..page_to_hotkey[page]..bi))
local key = self.font:draw(ks, self.font:size(ks), colors.ANTIQUE_WHITE.r, colors.ANTIQUE_WHITE.g, colors.ANTIQUE_WHITE.b, true)[1]
self.font:setStyle("normal")
self.items[#self.items+1] = {i=i, x=x, y=y, e=display_entity or self.default_entity, color=color, angle=angle, key=key, gtxt=gtxt, frame=frame, pagesel=lpage==spage}
self.clics[i] = {x,y,w,h}
else
local i = i + (12 * (page - 1))
local angle = 0
local color = {190,190,190}
local frame = "disabled"
self.font:setStyle("bold")
local ks = game.key:formatKeyString(game.key:findBoundKeys("HOTKEY_"..page_to_hotkey[page]..bi))
local key = self.font:draw(ks, self.font:size(ks), colors.ANTIQUE_WHITE.r, colors.ANTIQUE_WHITE.g, colors.ANTIQUE_WHITE.b, true)[1]
self.font:setStyle("normal")
self.items[#self.items+1] = {show_on_drag=true, i=i, x=x, y=y, e=nil, color=color, angle=angle, key=key, gtxt=nil, frame=frame}
self.clics[i] = {x,y,w,h, fake=true}
local gtxt = nil
if txt then
gtxt = self.fontbig:draw(txt, w, colors.WHITE.r, colors.WHITE.g, colors.WHITE.b, true)[1]
gtxt.fw, gtxt.fh = self.fontbig:size(txt)
end
if orient == "down" or orient == "up" then
col = col + 1
if col >= self.max_cols then
col = 0
row = row + 1
if row >= self.max_rows then return end
end
elseif orient == "left" or orient == "right" then
row = row + 1
if row >= self.max_rows then
row = 0
col = col + 1
if col >= self.max_cols then return end
end
end
end end
self.items[#self.items+1] = {i=i, x=x, y=y, e=display_entity or self.default_entity, color=color, angle=angle, key=key, gtxt=gtxt, frame=frame, pagesel=lpage==a.hotkey_page}
self.clics[i] = {x,y,w,h}
else
local i = i + (12 * (page - 1))
local angle = 0
local color = {190,190,190}
local frame = "disabled"
self.font:setStyle("bold")
local ks = game.key:formatKeyString(game.key:findBoundKeys("HOTKEY_"..page_to_hotkey[page]..bi))
local key = self.font:draw(ks, self.font:size(ks), colors.ANTIQUE_WHITE.r, colors.ANTIQUE_WHITE.g, colors.ANTIQUE_WHITE.b, true)[1]
self.font:setStyle("normal")
self.items[#self.items+1] = {show_on_drag=true, i=i, x=x, y=y, e=nil, color=color, angle=angle, key=key, gtxt=nil, frame=frame}
self.clics[i] = {x,y,w,h, fake=true}
end
end
--- Our toScreen override
......
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