Mercurial > wow > turok
view Turok/Modules/Timer/Icon.lua @ 9:9400a0ff8540
Ugh
Timer:
- container update directionality
- talent update iterates over a non-volatile table to carry out updates
- index management steps organized
- talentRow status implemented, returns the spell associated with the talent chosen from that row
CombatLog:
- sort out font controls and unbork arguments
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 13:08:30 -0500 |
parents | a9b8b0866ece |
children |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 1/15/2016 6:31 PM local T, _G = Turok, _G local mod = T.modules.TimerControl local GetTime, floor, unpack, tconcat = GetTime, floor, unpack, table.concat local HIDDEN, PASSIVE, ACTIVE = 0, 1,2 --@debug@ local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool local print = function(...) if _G.Devian and _G.DevianDB.workspace ~= 1 then _G.print('Icon', ...) end end --@end-debug@ local GetPrint = function(trace) if trace then return print else return function() end end end T.defaults.spirit.icon = { combatFade = true, alpha = 1, alpha_passive = 1, alpha_active = 1, alpha_ooc_passive = 0, alpha_ooc_active = 1, alpha_ooc = 0.25, size = 48, container = 'default', strata = 'LOW', fade_in_time = 0.2, fade_out_time = 0.3, anchor = 'BOTTOM', anchorTo = 'BOTTOM', parent = 1, size = 48, width = 48, height = 48, x = 0, y = 0, strata = 'MEDIUM', padding = 3, spacing = 1, foreground_inset= 0, } local p = mod.prototype.display.icon p.type='display' p.inherits = 'TurokIconTemplate' --- if config flags need to overrided p.cvars = { enableIcon = true } --- Negotiate the config differences between different display states -- Hidden - display is or should (via fade-out) be hidden -- Passive - display is visible, but no timing information is processed -- Active - display is visible and counting time; on expiration, it will downgrade itself to passive or hidden p.Init = function(self) local print = GetPrint(self.trace) print('display.Icon.Load') local c = self.cvars if c.type == 'aura' then self.spiral:SetReverse(true) else self.spiral:SetReverse(false) end if not self.icon:IsShown() then self.icon:Show() end print('icon texture=', self.spellIcon or self.itemIcon) self.icon:SetTexture(self.spellIcon or self.itemIcon) end local function Icon_UpdateCooldown(self) self.spiral:Show() self.spiral:SetCooldown(self.charges and self.chargeStart or (self.override and self.override_start or self.start), self.charges and self.chargeDuration or (self.override and self.override_duration or self.duration)) print('spiral:Play() new', self.charges and self.chargeStart or self.start, self.charges and self.chargeDuration or self.duration) end --- Advances the display state, applying any visual transitions as necessary; -- @param self frame object -- @param newState state value; 1 for inactive, 2 for untimed active, 3 for timed active -- @param forcePrevious force the frame's lastState to this value to block off OnUpdate difference tests -- even if forced, the actual history value will still be used for method scope p.SetState = function(self, newState, forcePrevious) --print(cWord(self:GetName()), 'state change issued:', cNum(state), cType(previous)) local previous = self.displayState self.prevState = forcePrevious and forcePrevious or previous self.displayState = newState print('SetState', cNum(newState), '(from '..cType(previous)..')', cText(self.timerName)) --_G.print('Prototype.'..self.cvars.type, 'SetState', cNum(newState), '(from '..cType(previous)..')', cText(self.timerName)) --- Change transitions if newState ~= previous then print(cText(' Transition')) if newState == HIDDEN then print(cText(' to HIDDEN')) -- to HIDDEN if previous then -- has to have been ACTIVE or PASSIVE at this point if previous == ACTIVE then print(' from ACTIVE') self.spiral:StopAnimating() else print(' from PASSIVE') end self.Intro:Stop() if self.event then print(' set by event script') self.Outro:Play() else print(' non-event source') self:Hide() end end -- want to end here if HIDDEN from nil else -- to ACTIVE or PASSIVE self.Outro:Stop() -- stop any running outro if newState == ACTIVE then -- and is ACTIVE self:Show() Icon_UpdateCooldown(self) end if previous and previous ~= HIDDEN then print(cText(' from vis')) -- from visible if self.event then self.refresh = true end else print(cText(' from non-vis')) if self.event then self.Intro:Play() else self:Show() end end end else --- No-change transitions if newState == ACTIVE then -- ACTIVE to ACTIVE Icon_UpdateCooldown(self) else print(cPink('stopping spiral')) self.spiral:Hide() end -- non-HIDDEN to non-HIDDEN and not a dry fire if self.event and newState ~= HIDDEN then self.refresh = true end end if newState ~= HIDDEN then print(cText(' CVars:')) local c if newState == ACTIVE then if self.override then c = self.cvars.override print('apply override profile') else print('apply active profile') c = self.cvars.active end self.fillState = 1 else print('apply passive profile') c = self.cvars.passive self.fillState = 2 end if self.icon and c.icon then print(cText(' '), cWord('desat=')..cBool(c.icon.desaturated), cWord('color=')..cNum(tconcat(c.icon.color, ', '))) self.icon:SetVertexColor(unpack(c.icon.color)) self.icon:SetDesaturated(c.icon.desaturated) end self:UpdateAlpha(T.inCombat, self.displayState, self.fillState) end end p.Update = function(self) if self.displayState == 0 and self.prevState ~= 0 then print('flip to', self.displayState) self.prevState = self.displayState -- quietly advance state self.percent = 1 self.valueFull = 0 self.value = 0 self:SetText() elseif self.displayState == 1 and self.prevState ~= 1 then print('flip to', self.displayState) self.prevState = self.displayState -- quietly advance state self.valueFull = 0 self.value = 0 self.percent = 1 self:SetText() print(self.percent, self.duration, self.start, self.expires) elseif self.displayState == 2 then if self.prevState ~= 2 or self.refresh then print('flipped to', self.displayState) self.prevState = self.displayState -- quietly advance state self.refresh = nil end -- prevState is set externally local time = GetTime() if self.expires <= time and self.charges == self.maxCharges then print(self.cvars.type, 'timer expired, set to', (self.cvars.persist and self.flags.passive or self.flags.hidden)) self.percent = 1 self.duration = 0 self.expires = 0 self.start= 0 self.valueFull = self.duration self.value = self.duration self.elapsed = self.duration self.remaining = 0 self:SetState(self.cvars.persist and self.flags.passive or self.flags.hidden) else -- unit_aura is too ambiguous if self.override and self.override_expires < time then self.override = nil self:SetState(self.flags.active) end if self.override then self.valueFull = self.override_start + self.override_duration - time self.percent = (time - self.override_start) / self.override_duration elseif self.charges and self.charges < self.charges_max then self.valueFull = self.charge_expires - time self.percent = (time - self.charge_start) / self.charge_duration else self.valueFull = self.expires - time self.percent = (time - self.start) / self.duration end self.elapsed = time - self.start self.remaining = self.duration - time self.value = floor(self.valueFull) end --PlaySoundFile(self.cvars.sound_active) self:SetText() end end