# HG changeset patch # User Nenue # Date 1456061573 18000 # Node ID a9b8b0866ece1d6599d325fa0edeca3a16c721fd # Parent 8a9a6637f082072ed720509197ca99b2ca988013 clear out log jam diff -r 8a9a6637f082 -r a9b8b0866ece .pkgmeta --- a/.pkgmeta Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -externals: - Libs/LibStub: - url: svn://svn.wowace.com/wow/libstub/mainline/trunk - tag: latest - Libs/CallbackHandler-1.0: - url: svn://svn.wowace.com/wow/callbackhandler/mainline/trunk/CallbackHandler-1.0 - tag: latest - Libs/AceAddon-3.0: - url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceAddon-3.0 - tag: latest - - -ignore: - - Debug.lua - - Turok.iml - - .idea - -enable-nolib-creation: no \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Equip.lua --- a/Equip.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ --- User: Krakyn --- Created: 12/4/2015 11:20 PM --- Equipment, spec, etc. -local T = LibStub("AceAddon-3.0"):GetAddon("Turok") -local mod = T:NewModule("Equip", "AceEvent-3.0") ---setprinthandler(function (...) T:debug('Equip', nil, ...) end) - -local t18_slots = { - [INVSLOT_HEAD] = 124296, -- head - [INVSLOT_SHOULDER] = 124307, -- shoulders - [INVSLOT_CHEST] = 124284, -- chest - [INVSLOT_LEGS] = 124301, -- legs - [INVSLOT_HAND] = 124292, -- hands -} - - -local use_slots = { - [INVSLOT_FINGER1] = 1, - [INVSLOT_FINGER2] = 2, - [INVSLOT_TRINKET1] = 3, - [INVSLOT_TRINKET2] = 4, - -} -function mod:OnEnable() - self.equipped = {} - self:RegisterEvent('COMBAT_RATING_UPDATE', 'UpdateCombatRatings') - self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED', 'UpdateEquipment') - self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'UpdateSpec') -end - -function mod:UpdateEquipment (_, slot, hasItem) - -- ratings event will handle the rest - if not t18_slots[slot] or use_slots[slot] then - return - end - -- debug - local link = GetInventoryItemID('player', slot) - print('|cFF00FFFFequipment ', slot, hasItem, link) - -- /debug - - if t18_slots[slot] then - t18_count = 0 - for slot, itemID in pairs(t18_slots) do - if GetInventoryItemID(slot) == itemID then - t18_count = t18_count + 1 - end - end - if t18 >= 4 then - T.stats.aimedshot = s.gcd - else - T.stats.aimedshot = 2 * T.stats.castingmod - end - T.statstext =string.format('%.2f', s.aimedshot) - end - - if use_slots[slot] then - if hasItem then - local itemID = GetInventoryItemID('player', slot) - self.equipped[slot] = itemID - T:GetModule("Spirit").item_watch[itemID] = {GetInventoryItemCooldown('player', slot) } - else - if self.equipped[slot] then - self.equipped[slot] = nil - end - - end - end - -end - - -function mod:UpdateCombatRatings() - local s = T.stats - s.haste = UnitSpellHaste('player') - s.focusregen = 4 * (1 + s.haste/100) - s.castingmod = 1+ s.haste/1000 - s.gcd = 1.5 * s.castingmod - T.statstext = { - haste = string.format('%.2f', s.haste), - focusregen = string.format('%.2f', s.focusregen), - castingmod = string.format('%.2f', s.castingmod), - } - local t = T.statstext - - print('|cFF00FFFFCOMBAT_RATING_UPDATE:|r', 'haste:', t.haste, 'regen:', t.focusregen) -end - -function mod:UpdateSpec (e, unit) - if unit ~= 'player' then - return - end - - T.stats.focusmax = UnitPowerMax('player') -end \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Fog.lua --- a/Fog.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,325 +0,0 @@ --- User: Krakyn --- Created: 12/4/2015 11:13 PM ---[[ --- Core tools, mostly frame handling business. It's an interface script after all. --- Types: --- StatusFrame --- Primary container for status data, carries primary value information by default --- FIELDS --- value = exact primary value represented by frame --- min = exact minimum for primary value --- max = exact maximum for primary value --- percent = value / max --- alpha = base frame alpha level, set when a fade animation has completed --- fadeTo = when set, the frame will begin fading to this level --- fadeDuration = set with fadeTo when the transition needs to be time-adjusted for unpredictable alpha states --- fadeTime = set with fadeTo when the transition has an explicit desired timing --- throttle_rate = animation frame delay --- --- METHODS --- Update() = Runs the frame's Update script, and calls UpdateText() --- UpdateText() = Iterates over frame children and calls Update() if it is a StatusText frame --- --- StatusText --- Sub-container for individual text elements, carries string output values, controlled by from Update(). By default --- these are derived from the parent's primary value data, but is mostly overridden in module code. --- FIELDS --- text = WoW FontString object housing text data --- format = a format string for expressing complex data (timer bars, etc.) --- METHODS --- SetText() = shortcut for text:SetText(...) --- SetJustifyH() = shortcut for text:SetJustifyH(...) --- Implements: --- frame = CreateBar(name, config root) --- Creates and displays a generic bar frame with progress textures and default updater, based on the variables from --- the smart config table. Seeded with methods Update() and UpdateText(). --- Update() will refresh the entire frame and tail call UpdateText() --- UpdateText() will iterate over the contents of frame:GetChildren() and call Update() --- NEVER CREATE A CHILD FRAME WITHOUT Update() DEFINED --- NEVER INVOKE METHODS FROM A GetParent() RETURN --- --- Bar_SetUpdateHandler(frame, function) --- Takes the desired OnUpdate script and wraps it inside frame throttling logic, then does SetScript --- --- frame = AddLabel(frame, config root, name) --- Constructs a text display and adds it to the frame's list of internal text objects. Contains method Update(), which --- refreshed text. --- --- HANDLERS --- Bar_Update([value, min/duration, max/end]) --- Default handler for any non-timed bar (where isTimer = false in config vars. Invoked by frame:Update() -]] -local T = LibStub("AceAddon-3.0"):GetAddon("Turok") -local LSM = LibStub("LibSharedMedia-3.0") -local TL = 'Fog' -local print = function(...) - _G.print(TL, ...) -end ---setprinthandler(function (...) T:debug('Fog', nil, ...) end) -local FADE_OUT_TIME = 1 -- duration per 1-0 alpha transition -local FADE_IN_TIME = 0.4 -- duration per 0-1 alpha transition - -local inset_factor = { - ['TOPLEFT'] = {-1, 1}, - ['TOP'] = {0, 1}, - ['TOPRIGHT'] = {1, 1}, - ['RIGHT'] = {1, 0}, - ['BOTTOMRIGHT'] = {1, -1}, - ['BOTTOM'] = {0, -1}, - ['BOTTOMLEFT'] = {-1,-1}, - ['LEFT'] = {-1, 0} -} - -T.anchor_inverse = { ['LEFT'] = 'RIGHT', ['RIGHT'] = 'LEFT', ['UP'] = 'DOWN', ['DOWN'] = 'UP' } -- directional inverse -T.direction_coord = { ['LEFT'] = {1, 0}, ['RIGHT'] = {-1,0}, ['UP'] = {0, -1}, ['DOWN'] = {0, 1 } } -- directional derivatives -T.anchor_direction = { ['LEFT'] = 'RIGHT', ['RIGHT'] = 'LEFT', ['UP'] = 'BOTTOM', ['DOWN'] = 'TOP'} -- directional anchors - -function T:CreateBar(name, config) - local parent = type(config.parent) == 'string' and _G[config.parent] or parent - if not parent then - parent = CreateFrame('Frame', config.parent, UIParent) - print('creating dry frame |cFFDDDDDD' .. config.parent .. '|r for |cFFFFFF00' .. name .. '|r') - end - - local f - if _G[name] and _G[name].GetFrameType and _G[name].GetFrameType() == 'Frame' then - f = _G[name] - print('found existing table |cFFFFFF00' .. name .. '|r') - else - print('creating statusbar '.. name, config.anchor, parent:GetName(), config.anchorTo, config.posX, config.posY) - end - - - f = CreateFrame('Frame', name, UIParent) - f.db = config - - -- state vars - f.combat = InCombatLockdown() - f.min = 0 - f.max = 1 - f.value = 0 - f.percent = 0 - f.alpha = f.combat and config.alpha or config.alpha_ooc - f:SetAlpha(f.combat and config.alpha or config.alpha_ooc) - f:SetPoint(config.anchor, config.parent, config.anchorTo, config.posX, config.posY) - f:SetSize(config.width, config.height) - f:SetFrameStrata(config.strata) - self:CreateStatusTextures(f, config) - - f.throttle_rate = 0.0166666666 -- ~60fps - f.throttle_point = GetTime() - - -- default handler - f.Update = T.Bar_Update - f.UpdateText = T.Bar_UpdateText - T:Bar_SetUpdateHandler(f, T.Bar_Update) - - return f -end - -function T:CreateStatusTextures(region, c) - c = c and c or region.db - print('STATUSTEX_make', region:GetName(), c.background_texture, c.background_color, c.foreground_texture, c.foreground_color) - region.background = region:CreateTexture('background', 'BACKGROUND') - region.background:SetAllPoints(region) - if c.background_texture then - region.background:SetTexture(LSM:Fetch('statusbar', c.background_texture)) - region.background:SetVertexColor(unpack(c.background_color)) - else - region.background:SetTexture(unpack(c.background_color)) - end - region.background:SetBlendMode(c.background_blend) - - region.foreground = region:CreateTexture('foreground', 'ARTWORK') - region.foreground:SetPoint('TOPLEFT', region, 'TOPLEFT', 0-c.foreground_inset, c.foreground_inset) - region.foreground:SetPoint('BOTTOMRIGHT', region, 'BOTTOMRIGHT', c.foreground_inset, 0-c.foreground_inset) - if c.foreground_texture then - region.foreground:SetTexture(LSM:Fetch('statusbar', c.foreground_texture)) - region.foreground:SetVertexColor(unpack(c.foreground_color)) - else - region.foreground:SetTexture(unpack(c.foreground_color)) - end - region.foreground:SetBlendMode(c.foreground_blend) -end - -function T:CreateStatusIcon(region, c) - local file = type(c) == 'string' and c or region.icon - if type(c) ~= 'table' then - c = region.db - end - print('STATUSICON', region:GetName(), file, c.icon_show) - -end - --- Sets the OnUpdate handler within a timing scheme -function T:Bar_SetUpdateHandler(bar, func) - bar:SetScript('OnUpdate', function(bar) - if GetTime() < bar.throttle_point then - return - end - - bar.throttle_point = bar.throttle_point + bar.throttle_rate - if type(func) == 'string' then - if type(bar[func]) ~= 'function' then - error('TurokBar:SetUpdateScript(); string "' ..func.. '" is not a valid method name') - return - end - elseif type(func) ~= 'function' then - error('TurokBar:SetUpdateScript(function or string); got '.. type(func) .. 'instead') - return - end - - func(bar) - end) -end - --- Default update loop -function T:Bar_Update (value, min, max) - - if value ~= nil then -- could be 0 - self.value = value - end - if (min ~= nil and max ~= nil) then - if self.isTimer then - self.duration = min - self.endTime = max - else - self.min = min - self.max = max - self.duration = max - end - end - - if self.combat ~= InCombatLockdown() then - self.combat = InCombatLockdown() - if self.combat then - self.fadeTo = self.db.alpha - self.fadeDuration = FADE_IN_TIME - else - self.fadeTo = self.db.alpha_ooc - self.fadeDuration = FADE_OUT_TIME - end - end - - -- we need the time for something - if self.isTimer or self.fadeTo ~= nil then - local time = GetTime() - - -- start doing fade animation things - if self.fadeTo ~= nil then - - if not self.fadeFrom then - self.fadeFrom = self:GetAlpha() - end - - -- fadeDuration missing, fill it in - if not self.fadeDuration then - self.fadeDuration = self.fadeFrom > self.fadeTo and FADE_OUT_TIME or FADE_IN_TIME - end - - -- fadeTime missing, - if not self.fadeTime then - local fadeRatio = 1 - if self.fadeFrom ~= self.alpha then - fadeRatio = (self.fadeTo - self.fadeFrom) / (self.fadeTo - self.alpha) -- target delta - end - --print(fadeRatio, self.fadeDuration) - self.fadeTime = time + fadeRatio * self.fadeDuration -- fixed rate of change - end - - -- are we done? - if time >= self.fadeTime then - self:SetAlpha(self.fadeTo) - self.alpha = self.fadeTo - self.fadeTo = nil - self.fadeFrom = nil - self.fadeDuration = nil - self.fadeTime = nil - else --nope - local remaining = (self.fadeTime - time) / self.fadeDuration - local fadeTotal = (self.fadeTo - self.fadeFrom) - --print(self.fadeTo - (fadeTotal * remaining), fadeTotal * remaining) - self:SetAlpha(self.fadeTo - (fadeTotal * remaining)) - end - end - - -- termination check - if self.isTimer then - if time >= self.endTime and self.fadeTo == nil then - self:Hide() - return - else - self.percent = (self.endTime - time) / self.duration - end - end - - else - self.percent = (self.value - self.min) / (self.max - self.min) - end - - self:UpdateText() - self.foreground:SetPoint('BOTTOMRIGHT', self, 'BOTTOMLEFT', self.db.width * self.percent + self.db.foreground_inset, 0-self.db.foreground_inset) -end - -function T:Bar_UpdateText() - local c = {self:GetChildren()} - for _, rl in ipairs(c) do - if rl.text then - rl.format = self.db.label_string - rl:Update() - end - end -end - --- addon:AddLabel --- Constructs a text display and adds it to that region --- -function T:AddLabel (region, config, labelname) - assert(region:IsObjectType('Frame'), "T:CreateLabel(table, table [, string])") - labelname = (labelname or string.format('%x', GetTime() % 1000000)) - print('assigning frame for text object |cFFFF9922'..labelname..'|r to '..region:GetName()) - - local lf = CreateFrame('Frame', region:GetName()..'_'..labelname, region) - local ft = lf:CreateFontString(labelname, 'OVERLAY') - local lx, ly, lp = 0,0, config.label_point - if config.label_inset ~= 0 and lp ~= 'CENTER' then - lx = config.label_inset * inset_factor[lp][1] - ly = config.label_inset * inset_factor[lp][2] - end - - lf:SetPoint(lp, region, lp, lx, ly) - lf:SetSize(region:GetWidth(), region:GetHeight()) - lf:SetFrameStrata(config.label_strata) - - ft:SetFont(LSM:Fetch('font', config.label_font), config.label_size, config.label_outline) - ft:SetAllPoints(lf) - ft:SetJustifyH(config.label_justifyH or (config.label_point:find('LEFT') and 'LEFT' or (config.label_point:find('RIGHT') and 'RIGHT' or 'CENTER'))) - ft:SetJustifyV(config.label_justifyV or (config.label_point:find('TOP') and 'TOP' or (config.label_point:find('BOTTOM') and 'BOTTOM' or 'MIDDLE'))) - ft:SetTextColor(1, 1, 1) - ft:SetText('SET ME!') - - lf.Update = region.isTimer and T.Label_UpdateFormat or T.Label_Update - lf.SetJustifyH = function(self, justify) ft:SetJustifyH(justify) end - lf.SetText = function(self, text) ft:SetText(text) end - - lf.text = ft - region[labelname] = lf - return lf -end - --- one of two possible assignments for label:Update() -function T:Label_UpdateFormat() - local region = self:GetParent() - if self.format then - self.value = string.gsub(self.format, '%%p', string.format('%.1f', region.value)) - self.value = string.gsub(self.value, '%%d', region.duration) - if region.name then - self.value = string.gsub(self.value, '%%n', region.name) - end - end - self.text:SetText(self.value) -end -function T:Label_Update() - self.text:SetText(self:GetParent().value) -end - diff -r 8a9a6637f082 -r a9b8b0866ece Lost.lua --- a/Lost.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,218 +0,0 @@ --- User: Krakyn --- Created: 12/14/2015 3:03 PM -local T = LibStub("AceAddon-3.0"):GetAddon("Turok") -local TL = 'Lost' -local print = function(...) _G.print(TL, ...) end -local LSM = LibStub("LibSharedMedia-3.0") -local mod = T:NewModule(TL, "AceTimer-3.0") -local time = _G.ct -local spell_trunc = {} -local inv = T.anchor_inverse -local d = T.direction_coord -local a = T.anchor_direction - -mod.encounter_start = { - ['Aspect'] = { - type = 'buff', - - Test = function() - local res = UnitBuff('player', 'Aspect of the Pack', nil, 'PLAYER') - return (res ~= nil) - end, - sound = LSM:Fetch('sound', 'Wilhelm Scream'), - }, - ['Rune'] = { - Test = function() - local res = UnitBuff('player', 'Hyper Augmentation', nil, 'PLAYER') - return (res ~= nil) - end - } -} - -function mod:OnEnable() - self.raidbuffs_active = {} -- active raid buffs - self.raidbuffs_text = {} -- raid buff text - self.raidbuffs_avail = {} -- availability info - self.raidbuffs_display = {} -- buff list ordering info - self.unit_cache = {} -- remember GUIDs we've seen before - self.raidbuffs_shown = NUM_LE_RAID_BUFF_TYPES - - - local db = _G.TurokData - db.raidbuff = { - parent = 'UIParent', - anchor = 'BOTTOMRIGHT', anchorTo = 'BOTTOMRIGHT', - posX = -300, posY = 300, - height = 24*9, width = 72, - raidbuff_width = 72, - raidbuff_height = 24, - label_size = 11, - label_font = 'ArchivoNarrow-Bold', - } - - - - local rw = CreateFrame('Frame', 'TkRaidWatch', UIParent) - local c = db.raidbuff - self.raidbuffs_frame = rw - rw:SetPoint(c.anchor, c.parent, c.anchorTo, c.posX, c.posY) - rw:SetSize(c.width, c.height) - rw:SetMovable(true) - local bd = rw:CreateTexture() - bd:SetTexture(1,1,1,1) - bd:SetGradient('VERTICAL', 0,0,0,1,1,1) - bd:SetBlendMode('MOD') - bd:SetPoint('TOPLEFT',rw,'TOPLEFT', -2, 2) - bd:SetPoint('BOTTOMRIGHT',rw,'BOTTOMRIGHT', 2, -2) - - -- seed raid buff analyzer assets - self.num_raidbuff_columns = math.floor(c.width / c.raidbuff_width) - for i = 1, 9 do - local icon = rw:CreateTexture('TkRaidWatchButton'..i, 'ARTWORK') - icon:SetSize(c.raidbuff_width,c.raidbuff_height) - icon:SetTexCoord(0.15, 0.85, 0.15, 0.85) - - - self.raidbuffs_active[i] = icon - rw:EnableMouse(true) - rw:SetScript('OnMouseDown', function(self) self:StartMoving() end) - rw:SetScript('OnMouseUp', function(self) self:StopMovingOrSizing() end) - - local text = rw:CreateFontString('TkRaidWatchText'.. i, 'OVERLAY') - text:SetPoint('CENTER', icon, 'CENTER') - text:SetFont(LSM:Fetch('font', c.label_font), c.label_size, 'OUTLINE') - text:SetText(i) - self.raidbuffs_text[i] = text - end - - db.raidevent = {} - - - self:RegisterEvent('PARTY_MEMBERS_CHANGED') - self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') - self:RegisterEvent('ENCOUNTER_START') - self:RegisterEvent('INSPECT_READY') - self:RegisterEvent('UNIT_AURA', 'RaidBuffScan') - - self:RaidBuffScan() - self:RosterScan() -end -function mod:PLAYER_REGEN_ENABLED(e,...) end -function mod:PLAYER_REGEN_DISABLED(e, ...) end - -function mod:INSPECT_READY() -end -function mod:PLAYER_SPECIALIZATION_CHANGED(e,unit) - local specID - print(e, unit) - if unit == 'player' then - specID = GetSpecializationInfo(GetSpecialization()) - else - --NotifyInspect(unit) - specID = GetInspectSpecialization() - end - - print(GetSpecializationInfoByID(specID)) - self:RosterScan() -end - -function mod:PARTY_MEMBERS_CHANGED(e, ...) - if IsInRaid() or IsInGroup() then - self.raidbuffs_frame:Show() - self:RaidBuffScan() - end -end - -function mod:ENCOUNTER_START(e,...) - for k, v in pairs(self.encounter_start) do - local test, info = v.Test() - if test == true then - print(v.type, k, 'doing a thing') - else - print(v.type, k, info) - end - end -end - --- Updates available raid/party buffs -function mod:RaidBuffScan(unit) - if self.hiding then - return - end - local c = T.db.raidbuff - - -- search for unit data - -- update raidbuffs - - -- set our number of things to track - - local k = 1 - for i = 1, NUM_LE_RAID_BUFF_TYPES do - local rb = self.raidbuffs_active[i] - local rt = self.raidbuffs_text[i] - local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i) - if name then - rb:Hide() - rt:Hide() - self.raidbuffs_display[i] = nil - else - rb:Show() - rt:Show() - if self.raidbuffs_avail[i] then - rb:SetTexture(0.5,0.5,0.5,0.1) - rb:SetBlendMode('MOD') - else - rb:SetTexture(1,0.2,0,0.5) - rb:SetBlendMode('ADD') - end - self.raidbuffs_text[i]:SetText(string.sub(_G['RAID_BUFF_'..i],0,2)) - - if not self.raidbuffs_display[i] or self.raidbuffs_display[i] ~= k then - self.raidbuffs_display[i] = k - local pn = k-1 -- need (n-1) for lua grid math - local py = math.floor(pn / self.num_raidbuff_columns) * c.raidbuff_height - local px = (pn * c.raidbuff_width) % c.width -- x-offset - print('buff slot '..i..' (draw slot '..k..')', pn, py, px) - rb:SetPoint('BOTTOMLEFT', TkRaidWatch, 'BOTTOMLEFT', px, py) - end - - k = k + 1 - end - end -end - -function mod:RosterScan() - local lim = 1 - if IsInRaid() then - lim = 40 - elseif IsInGroup() then - lim = 5 - end - - for i = 1, lim do - local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i) - local realm - if name then - if string.find(name,'-') then - name, realm = string.match(name, "(.+)-(.+)") - else - realm = GetRealmName() - end - - local GUID = UnitGUID('raid' .. i) - if not self.unit_cache[GUID] then - self.unit_cache[GUID] = { - name = name, - realm = realm, - } - end - - pl = self.unit_cache[GUID] - - - print(i, name, class, role) - end - - end - -end \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Spirit.lua --- a/Spirit.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,276 +0,0 @@ --- User: Krakyn --- Created: 12/8/2015 7:30 PM -local T = LibStub("AceAddon-3.0"):GetAddon("Turok") -local TL = 'Spirit' -local print = function(...) _G.print(TL, ...) end -local LSM = LibStub("LibSharedMedia-3.0") -local mod = T:NewModule("Spirit", "AceTimer-3.0") -local time = _G.ct -local auras = { - 168811, -- sniper training - 168809, -- sniper training: recently moved - 13159, -- aspect of the pack, - 187615, -- Maalus -} -local spells = { - 3045, -- rapid fire, - 26297, -- berserking, - 121818, -- stampede, - -} -local FRAME_PREFIX = 'TkSpirit' -local FADE_TIME = 0.5 --- local repetitive tasks -local function FindSpirit(id) - local db = T.db - local c = db.spirit - local isIcon = false - if db.spirit.progressbar[id] then - c = db.spirit.progressbar[id] - elseif db.spirit.icon[id] then - c = db.spirit.icon[id] - isIcon = true - end - local name, rank, icon, castingTime, minRange, maxRange, spellID = GetSpellInfo(id) - local s = { - name = name, - rank = rank, - icon = icon, - castingTime = castingTime, - minRange = minRange, - maxRange = maxRange, - spellID = spellID - } - - return s, c, isIcon -end - -function mod:OnEnable() - local db = _G.TurokData - self.aura_watch = {} - self.cooldown_watch = {} - self.item_watch = {} - self.myGUID = UnitGUID('player') - - - db.spirit = { - foreground_color = {1, 1, 1, 0.7}, - foreground_texture = 'Cilo', - foreground_blend = 'BLEND', - foreground_inset = -1, - background_color = {0, 0, 0, 0.7}, - background_blend = 'BLEND', - background_texture = 'Cilo', - icon_show = true, - width = 250, height = 20, - anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', - posX = 0, posY = -150, - label_color = {1, 1, 1, 1}, - label_font = 'turok', - label_size = 14, - label_inset = -2, - label_point = 'LEFT', - label_outline = 'OUTLINE', - label_string = '%n %p', - label_strata = 'HIGH', - expire_sound = LSM:Fetch('sound'), - strata = 'LOW', - icon = { - [13159] = { -- Aspect of the Pack - posX = 20, posY = 20, width = 140, height = 140, - }, - [3045] = { - parent = 13159, anchor = 'RIGHT', anchorTo = 'LEFT', - posx = 0, posY = 0, width = 64, height = 64, - } - }, - progressbar = { - [168811] = { -- Sniper Training (duration) - background_color = {0,0,0,0}, - foreground_color = {1,0,0,1}, - anchor = 'BOTTOMLEFT', parent = 'TkFocusBar', anchorTo = 'TOPLEFT', - posX = 0, posY = 0, height = 16, width = 250, - label_string = '', - label_point = 'TOPLEFT', - strata = 'LOW', - attach = {{ - width_relative = 0.5, - height_relative = 1, - background_color = {1,0,0,1}, - foreground_color = {1,1,0.5, 1}, - background_blend = 'ADD', - foreground_blend = 'ADD', - - anchor = 'LEFT', - anchorTo = 'LEFT', - strata = 'MEDIUM', - }} - }, - [168809] = { -- Sniper Training: Recently Moved - background_color = {0,0,0,0 }, - foreground_color = {1,1,1,1}, - foreground_blend = 'ADD', - anchor = 'BOTTOMLEFT', parent = 'TkFocusBar', anchorTo = 'TOPLEFT', - strata = 'HIGH', - posX = 0, posY = 0, height = 16, width = 125, - icon_show = false, - label_string = '', - exceptions = { - function(aura) - return (mod.aura_watch[168811].expires < aura.expires) - end - }, - }, - }, - } - - for _, id in pairs(auras) do - -- store spellinfo fetch - self.aura_watch[id] = self:CreateSpiritFrame(id) - self.aura_watch[id].count = 0 - self.aura_watch[id].duration = 0 - self.aura_watch[id].expires = 0 - self.aura_watch[id].caster = 0 - print('AURA', id, self.aura_watch[id].name) - end - - for _, id in ipairs(spells) do - self.cooldown_watch[id] = self:CreateSpiritFrame(id) - print('COOLDOWN', id, self.cooldown_watch[id].name) - end - - self:SpiritScan() - self:RegisterEvent('UNIT_AURA') - self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') - self:RegisterEvent('PLAYER_REGEN_DISABLED') - self:RegisterEvent('PLAYER_REGEN_ENABLED') -end - --- StatusBar factory -function mod:CreateSpiritFrame(id) - local s, c, isIcon = FindSpirit(id) - - -- how much frame do we need? - local f - if isIcon then - f = CreateFrame('Frame', FRAME_PREFIX..id, UIParent) - f.db = c - function f:Update() end - else - f = T:CreateBar('TkAuraBar'..id, c) - f.isTimer = true - if (c.label_string ~= '') then - print('has label, add it', id) - T:AddLabel(f, c) - end - end - f:Hide() - - -- general display - f:SetPoint(c.anchor, c.parent, c.anchorTo, c.posX, c.posY) - f:SetSize(c.width, c.height) - f:SetFrameStrata(c.strata) - - -- icon? - f.icon = s.icon - T:CreateStatusIcon(f) - - -- attachment frames? - if c.attach then - for i, e in ipairs(c.attach) do - local ef = CreateFrame('Frame', 'TkExtra'..id, f) - f[i] = ef - ef:SetPoint(e.anchor, f, e.anchorTo) - ef:SetSize(c.width * e.width_relative or e.width, c.height * e.height_relative or e.height) - ef:SetFrameStrata(e.strata or c.strata) - T:CreateStatusTextures(ef, e) - end - end - - -- setup suppression checking - if c.exceptions then - function s:ExceptionCheck () - for i, func in ipairs(c.exceptions) do - if not func(self) then - return false, i - end - end - return true - end - else - function s:ExceptionCheck () return true end - end - - -- access linkage - f.format = c.label_string - f.spirit = s - f.name = s.name - s.frame = f - return s -end - -function mod:UNIT_AURA(e, unit) - if unit == 'player' then - self:SpiritScan() - end -end - --- Updates aura watches -function mod:SpiritScan() - local db = _G.TurokData - for id, aura in pairs(self.aura_watch) do - local c = aura.conf - local f = aura.frame - - local name, _, _, count, _, duration, expires, caster = UnitAura('player', aura.name) - - if name then - aura.duration = duration - aura.expires = expires - aura.caster = caster - aura.count = count - local test, i = aura:ExceptionCheck() - print(name, duration, expires) - if not test then - print('suppressing '..aura.name..' (failed test #'..i..')') - else - f.name = name - f:Update(nil, duration, expires) - f:Show() - end - end - end -end - -function mod:PLAYER_REGEN_ENABLED() - for id, aura in pairs(self.aura_watch) do - print('non-combat alpha for #', id, aura.name, 'is', aura.frame.db.alpha_ooc) - aura.frame.fadeTo = aura.frame.db.alpha_ooc - aura.frame.fadeDuration = FADE_TIME - end -end - -function mod:PLAYER_REGEN_DISABLED() - for id, aura in pairs(self.aura_watch) do - print('combat alpha for #', id, aura.name, 'is', aura.frame.db.alpha) - aura.frame.fadeTo = aura.frame.db.alpha - aura.frame.fadeDuration = FADE_TIME - end -end - --- This is the most reliable way of catching item and spell uses, other events are delayed or too vague to be useful -function mod:COMBAT_LOG_EVENT_UNFILTERED(e, ...) - local timestamp, combatEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = - ...; -- Those arguments appear for all combat event variants. - local eventPrefix, eventSuffix = combatEvent:match("^(.-)_?([^_]*)$"); - if eventPrefix ~= 'SPELL_' or sourceGUID ~= self.myGUID then - return - end - - local spellid, name, count, type = select(13, select('#', ...), ...) - local kc = '' - for i=1,4 do - kc = kc .. string.format('%X',((string.byte(eventSuffix,i) % 8) + 8)) - end - print('|cFFFF'..kc..eventSuffix..'|r', sourceName, destName, spellid, name) -end \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Tek.lua --- a/Tek.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,404 +0,0 @@ -addon, T_ = ... --- User: Krakyn --- Created: 12/4/2015 11:17 PM -local T = LibStub("AceAddon-3.0"):GetAddon("Turok") -local db = T.db -local TL = 'Tek' -local mod = T:NewModule("Tek") -local print = function(...) - _G.print('Tek', ...) -end -local time = _G.ct - --- events & units -local TRACKED_UNITS = {'player', 'target', 'focus', 'pet'} -local TRACKED_EVENTS = {'UNIT_SPELLCAST_START', 'UNIT_SPELLCAST_DELAYED', 'UNIT_SPELLCAST_STOP', 'UNIT_SPELLCAST_FAILED', 'UNIT_SPELLCAST_FAILED_QUIET', - 'UNIT_SPELLCAST_INTERRUPTED', 'UNIT_SPELLCAST_SUCCEEDED', 'UNIT_SPELLCAST_CHANNEL_START', 'UNIT_SPELLCAST_CHANNEL_STOP', 'UNIT_SPELLCAST_CHANNEL_UPDATE' } - --- animations are a little different here -local FADE_OUT_TIME, FADE_IN_TIME = 1000, 200 - --- values MUST be in chronological order -local CHANNEL_START, CAST_START, CAST_INTERRUPTED, CAST_SUCCEEDED, CAST_STOPPED, CAST_FAILED, CHANNEL_STOPPED = 1, 2, 3, 4, 5, 6, 7 -local TEXTURE_SUFFIX = { - [CHANNEL_START] = '_channeling', - [CAST_START] = '_casting', - [CAST_INTERRUPTED] = '_interrupted', - [CAST_SUCCEEDED] = '_finished', - [CAST_STOPPED] = '_failed', - [CAST_FAILED] = '_failed', - [CHANNEL_STOPPED] = '' -} - --- defaults -db.castbar = { - --T.defaults.castbar = { - width = 300, height = 24, - anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', - posX = 0, posY = 0, - foreground_casting = {0.80784313725, 0.87843137254, 0.0156862745, 1}, - background_casting = {0,0,0,0.4}, - background_interrupted = {1,0,0,1}, - background_failed = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - foreground_interrupted = {1, 0.5, 0, 1}, - foreground_failed = {0,0,0,1}, - foreground_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - background_finished = {0.60784313725, 0.87843137254, 0.0156862745, 1}, - foreground_inset = -1, - fill_direction = 'RIGHT', - fill_inverse = false, - glow_texture = "Tooltip-BigBorder", - glow_size = 2, - spark_texture = "Tooltip-BigBorder", - spark_size = 2, - ['player'] = { - width = 400, height = 36, - anchor = 'TOP', parent = 'TkFocusBar', anchorTo = 'BOTTOM', - posX = 0, posY = 2, - }, - ['target'] = { - width = 400, height = 36, - anchor = 'BOTTOMLEFT', parent = 'TkplayerCastBar', anchorTo = 'TOPRIGHT', - posX = -30, posY = 4, - }, - ['focus'] = { - width = 200, height = 36, - anchor = 'TOPLEFT', parent = 'TkplayerCastBar', anchorTo='BOTTOMRIGHT', - posX = 2, posY = -2 - }, - ['pet'] = { - width = 300, height = 24, - anchor = 'TOPRIGHT', parent = 'TkFocusBar', anchorTo='TOPLEFT', - posX = -2, posY = 0 - }, -} - -local inv = T.anchor_inverse -local d = T.direction_coord -local a = T.anchor_direction -local c = {} --- c[unit]=nil is used by frame update, thus any indexing from a valid frame is implied to be for new casting info -setmetatable(c, { - __index = function(t,k) - t[k] = {} - return t[k] - end -}) - -function mod:OnEnable() - local db = T.db - - self.casting = c - self.castbar = {} - - - for _, unit in pairs(TRACKED_UNITS) do - local cdb = db.castbar[unit] - print('|cFFFF44FF' .. unit .. '|r castbar creation') - - - -- State info - c[unit] = {} - - -- Set frames - local fn = 'Tk' .. unit .. 'CastBar' - self.castbar[unit] = T:CreateBar(fn, cdb) - local pc = self.castbar[unit] - pc:Hide() - pc:SetAlpha(0) - - T:AddLabel(pc, cdb, 'spelltext') - local casttime = T:AddLabel(pc, cdb, 'casttime') - pc.foreground:SetWidth(0) - - casttime:SetPoint('RIGHT', pc, 'RIGHT') - casttime:SetJustifyH('RIGHT') - - if unit == 'player' then - local lb = pc:CreateTexture('latency', 'OVERLAY') - local lt = T:AddLabel(pc, cdb, 'latency') - lt:SetPoint('TOPRIGHT', pc.casttime, 'BOTTOMRIGHT') - lt:SetJustifyH('RIGHT') - pc.latency = lb - lb.text = lt - end - - pc.transpt = a[cdb.fill_direction] - pc.xtrans = function() return math.min((cdb.width + cdb.foreground_inset) * pc.percent * d[pc.transpt][1], cdb.width) end - pc.ytrans = function() return math.min((cdb.height + cdb.foreground_inset) * pc.percent * d[pc.transpt][2], cdb.height) end - - pc.movement_x = 1 - pc.moving_end = 'LEFT' - - local glow = pc:CreateTexture('glow', 'OVERLAY') - glow:SetTexture(CASTBAR_TAILGLOW) - glow:SetPoint('TOPLEFT', pc, 'TOPLEFT', -5, 5) - glow:SetPoint('BOTTOMRIGHT', pc, 'BOTTOMRIGHT', 5, -5) - pc.glow = glow - - local icon = pc:CreateTexture('icon', 'ARTWORK') - icon:SetPoint('RIGHT', pc, 'LEFT', -2, 0) - icon:SetWidth(pc.foreground:GetHeight()) - icon:SetHeight(pc.foreground:GetHeight()) - icon:SetTexture(0,0,0,1) - pc.icon = icon - - pc.unit = unit - T:Bar_SetUpdateHandler(pc, self.TekUpdate) - end - - -- Casting table events - for i, event in pairs(TRACKED_EVENTS) do - print('listening to |cFF00FFFF' .. event .. '|r') - self:RegisterEvent(event, 'TekEvent') - end - - -- Extra events - self:RegisterEvent('PLAYER_TARGET_CHANGED') - self:RegisterEvent('PLAYER_FOCUS_CHANGED') - - -- kill default casting bar - -- T.cbscripts = {CastingBarFrame:GetScript('OnUpdate'), CastingBarFrame:GetScript('OnEvent')} - CastingBarFrame:SetScript('OnUpdate', nil) - CastingBarFrame:SetScript('OnEvent', nil) - CastingBarFrame:Hide() -end - --- Update handler for castbar -function mod:TekUpdate() - local glow = self.glow - local foreground = self.foreground - local background = self.background - local latency = self.latency - local time = GetTime() * 1000 - local spelltext = self.spelltext - local timetext = self.timetext - local cdb = self.db - if mod.casting[self.unit] ~= nil then - - local u = self.unit - local s = mod.casting[u] - local alpha = self:GetAlpha() - - -- is something casting at all? - if s.casting <= CAST_START then - - -- start = true whenever a new spell cast could be active (i.e. target switching) - if s.init then - print('|cFFDD77DD'..u..'|r init_cast (spell='..s.displayName..', startTime='..s.startTime..', endTime='..s.endTime..', channel=',s.channel,')') - print(self:GetName(), self:IsVisible(), self:IsShown()) - - if u == 'player' then - self.latency.text:SetText(s.latency) - end - - -- update translation point - if s.casting == CHANNEL_START and not cdb.fill_inverse then - self.transpt = inv[a[cdb.fill_direction]] - else - self.transpt = a[cdb.fill_direction] - end - - -- update frame contents - foreground:SetTexture(unpack(cdb['foreground' .. TEXTURE_SUFFIX[s.casting]] and cdb['foreground' .. TEXTURE_SUFFIX[s.casting]] or cdb.foreground_color)) - background:SetTexture(unpack(cdb['background' .. TEXTURE_SUFFIX[s.casting]] and cdb['background' .. TEXTURE_SUFFIX[s.casting]] or cdb.background_color)) - - self.icon:SetTexture(s.texture) - spelltext:SetText(s.displayName) - self.duration = s.endTime - s.startTime - self.fadeIn = s.startTime + (1-alpha) * FADE_IN_TIME - self.fadeOut = s.endTime + FADE_OUT_TIME -- needs to exist for target changes - - print(s.startTime, self.fadeIn, self.fadeIn - s.startTime) - -- clear 'start' - s.init = nil - end - - -- if we're checking this and start was never flipped, then something happened - if time <= self.fadeIn then - alpha = 1- ((self.fadeIn - time) / FADE_IN_TIME) - self:SetAlpha(alpha) - elseif alpha ~= 1 then - self:SetAlpha(1) - end - self.value = time - s.startTime - self.percent = self.value / self.duration - self.casttime:SetText(format("%.1f", self.value / 1000)) - - -- s.casting is nil when the spellcast has finished - else - -- something set a term flag - if s.casting < CHANNEL_STOPPED and s.fade then - print(TL, '|cFFDD77DD'..u..'|r init_fadeout (spell='..s.displayName..', startTime='..s.startTime..', endTime='..s.endTime..', channel=',s.channel,')') - self.fadeOut = time + FADE_OUT_TIME - foreground:SetTexture(unpack(cdb['foreground' .. TEXTURE_SUFFIX[s.casting]] and cdb['foreground' .. TEXTURE_SUFFIX[s.casting]] or cdb.foreground_color)) - background:SetTexture(unpack(cdb['background' .. TEXTURE_SUFFIX[s.casting]] and cdb['background' .. TEXTURE_SUFFIX[s.casting]] or cdb.background_color)) - s.fade = nil - self.value = self.duration - self.percent = 1 - end - - if time < self.fadeOut then - alpha = (self.fadeOut - time) / FADE_OUT_TIME - self:SetAlpha(alpha) - else - alpha = 0 - self:Hide() - self:SetAlpha(alpha) - self.casttime:SetText(nil) - self.spelltext:SetText(nil) - self.debugged = false - self.percent = 0 - if u == 'player' then - self.latency.text:SetText(nil) - end - mod.casting[self.unit] = nil - print('|cFFDD77DD'..u..'|r work complete, hiding...') - end - -- hide and wait until we're pulled out again - end - self.foreground:SetPoint('RIGHT', self, self.transpt, self.xtrans(), self.ytrans()) - end -end - - --- event stub, filters out unwanted cast events -function mod:TekEvent(e, unit, ...) - if not self.castbar[unit] then - return - end - if not self[e] then - error('No method signature for event ' .. tostring(e)) - end - print('popped |cFF00FFFF' .. e .. '|r: ', unit, ...) - self[e](self, e, unit, ...) -end - -function mod:PLAYER_TARGET_CHANGED (e, cause) - print(e) - self:UpdateUnit('target') -end -function mod:PLAYER_FOCUS_CHANGED (e, cause) - print(e) - self:UpdateUnit('focus') -end -function mod:UpdateUnit(unit) - if UnitCastingInfo(unit) then - mod:UNIT_SPELLCAST_START('UNIT_SPELLCAST_START', unit) - elseif UnitChannelInfo(unit) then - mod:UNIT_SPELLCAST_CHANNEL_START('UNIT_SPELLCAST_CHANNEL_START', unit) - else - mod.castbar[unit]:Hide() - end -end - --- Spell event handlers -function mod:UNIT_SPELLCAST_SENT(e, unit, spellname, rank, target) - -- triggered an action buttton tied to a cast - c[unit].sentTime = math.floor(GetTime() * 1000) - print('|cFF44FF44',e,':|r', unit, spellname, c[unit].sentTime) - c[unit].spell = spellname - c[unit].rank = rank - c[unit].target = target -end - -function mod:UNIT_SPELLCAST_START(e, unit) -- Server says: someone started casting - local spellname, rank, displayName, texture, startTime, endTime, isTradeSkill, castID, nonInterruptible = UnitCastingInfo(unit) - print('casting['..unit..'] state updated (=start): spellname='.. spellname ..', startTime='.. startTime ..', endTime='.. endTime) - - c[unit].castID = castID - c[unit].spell = spellname - c[unit].rank = rank - c[unit].displayName = displayName - c[unit].texture = texture - c[unit].startTime = startTime - c[unit].endTime = endTime - c[unit].nonInterruptible = nonInterruptible - c[unit].isTradeSkill = isTradeSkill - if c[unit].sentTime then - c[unit].latency = c[unit].startTime - c[unit].sentTime - end - - -- set state and show - c[unit].casting = CAST_START - c[unit].init = true - self.castbar[unit]:Show() -end - -function mod:UNIT_SPELLCAST_DELAYED(e, unit, spellname, rank, castID, target) -- Server says: they're still casting but it'll take longer - local spellname, rank, displayName, texture, startTime, endTime, isTradeSkill, castID, nonInterruptible = UnitCastingInfo(unit) - print('casting['..unit..'] state updated (=delayed): spellname='.. spellname ..', startTime='.. startTime ..', endTime='.. endTime) - c[unit].castID = castID - c[unit].channel = false - c[unit].startTime = startTime - c[unit].endTime = endTime - -- just update timing data, frame script will adjust -end - --- set exit states -function mod:UNIT_SPELLCAST_STOP(e, unit, spellname, rank, castID, target) -- Server says: someone stopped casting for some reason - --c[unit].casting = CAST_STOPPED -end - -function mod:UNIT_SPELLCAST_INTERRUPTED(e, unit, spellname, rank, castID, target) -- Server says: someone got interrupted - c[unit].casting = CAST_INTERRUPTED - c[unit].fade = true -end - -function mod:UNIT_SPELLCAST_SUCCEEDED(e, unit, spellname, rank, castID, target) -- Server says: they stopped because they're done - - if c[unit].castID == castID and c[unit].casting ~= CHANNEL_START then - c[unit].casting = CAST_SUCCEEDED - c[unit].fade = true - end -end - -function mod:UNIT_SPELLCAST_FAILED(e, unit, spellname, rank, castID, target) -- Server says: someone tried to cast something but they weren't allowed - if c[unit].castID ~= castID then -- can fire from keybind spam - return - end - c[unit].casting = CAST_FAILED - c[unit].fade = true -end - -function mod:UNIT_SPELLCAST_FAILED_QUIET(e, unit, spellname, rank, castID, target) -- Server says: someone tried to cast something but they weren't allowed - if c[unit].castID == castID and c[unit].casting == CAST_START then - c[unit].casting = CAST_FAILED - end -end - -function mod:UNIT_SPELLCAST_INTERRUPTIBLE(e, unit) - c[unit].notInterruptible = false -end -function mod:UNIT_SPELLCAST_NOT_INTERRUPTIBLE(e, unit) - c[unit].notInterruptible = true -end - -function mod:UNIT_SPELLCAST_CHANNEL_START(e, unit, spellname, rank, castID, spellID) - local spellname, rank, displayName, texture, startTime, endTime, isTradeSkill, nonInterruptible = UnitChannelInfo(unit) - displayName = spellname -- channels sometimes just appear as 'Channeling' according to Quartz author - print('casting['..unit..'] state updated (=start, channel): spellname='.. spellname ..', startTime='.. startTime ..', endTime='.. endTime) - c[unit].casting = CHANNEL_START - c[unit].spellname = spellname - c[unit].rank = rank - c[unit].displayName = displayName - c[unit].texture = texture - c[unit].startTime = startTime - c[unit].endTime = endTime - c[unit].nonInterruptible = nonInterruptible - c[unit].isTradeSkill = isTradeSkill - c[unit].init = true - mod.castbar[unit]:Show() -end -- start up -function mod:UNIT_SPELLCAST_CHANNEL_STOP(e, unit, spellname, rank, castID, spellID) - c[unit].casting = CHANNEL_STOPPED -end -function mod:UNIT_SPELLCAST_CHANNEL_UPDATE(e, unit, spellname, rank, castID, spellID) - spellname, rank, displayName, texture, startTime, endTime, isTradeSkill, nonInterruptible = UnitChannelInfo(unit) - displayName = spellname -- channels sometimes just appear as 'Channeling' according to Quartz author - c[unit].channel = true -end -- recalc - - - - diff -r 8a9a6637f082 -r a9b8b0866ece Turok.iml --- a/Turok.iml Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok.lua --- a/Turok.lua Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +0,0 @@ - --- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList -local T = LibStub("AceAddon-3.0"):NewAddon("Turok", "AceConsole-3.0", "AceEvent-3.0") -local _G = _G -local rawset = _G.rawset -_G.Turok = T -local print = function(...) - --_G.print('Core', ...) -end - - -T.mods = {} -T:SetDefaultModuleState(true) -T:SetDefaultModuleLibraries("AceEvent-3.0") -T:SetDefaultModulePrototype({OnInitialize = function(mod) - print('CORE', mod:GetName().. ' found') -end}) - --- propagates parameter data around -function T:LinkTable(parent, child, pname, cname) - local mt = { - __index = function(t,k) - if parent[k] then - t[k] = parent[k] - end - print('|cFFFF8800'.. pname ..'.' .. cname .. '|r.|cFFFFFF00'.. k ..'|r inheriting value at |cFFFF8800' .. pname ..'|r.|cFFFFFF00'.. k..'|r') - return parent[k] - end, - __newindex = function (t, k, v) - rawset(t,k,v) - if type(v) == 'table' then - T:LinkTable(child, v, pname, k) - print('|cFFFF8800'.. pname ..'.' .. cname .. '|r.|cFFFFFF00'.. k ..'|r sub-table created') - end - end - } - print('|cFFFF8800'.. pname ..'.|cFFFFFF00'.. cname ..'|r sub-tables will be retconned') - setmetatable(child, mt) - for k, v in pairs(child) do - if type(v) == 'table' then - T:LinkTable(child, v, cname, k) - end - end -end - -function T:OnInitialize() - - local defaults = { - background_color = {0,0,0,0}, - background_blend = 'BLEND', - foreground_color = {1,1,1,0.5}, - foreground_blend = 'BLEND', - foreground_inset = -1, - width = 250, - height = 100, - alpha = 1, - alpha_ooc = 0.1, - strata = 'LOW', - label_strata = 'HIGH', - label_justifyH = 'LEFT', - label_color = {1, 1, 1, 1}, - label_font = 'turok', - label_size = 14, - label_inset = -2, - label_point = 'LEFT', - label_outline = 'OUTLINE', - anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', - focusbar = { - foreground_color = {1, 1, 1, 0.7}, - background_color = {0,0,0,0.8}, - width = 300, height = 24, - posX = 0, posY = -150, - }, - } - _G.TurokData = defaults - if not _G.TurokData then - _G.TurokData = defaults - end - - T.db = _G.TurokData - local db = T.db - for k, v in pairs(db) do - if type(v) == 'table' then - T:LinkTable(db, v, 'db', k) - end - end - setmetatable(db, - {__newindex = function (t, k, v) - rawset(t,k,v) - if type(v) == 'table' then - T:LinkTable(db, v, 'db', k) - print('CFG', '|cFFFF0000db|r.|cFF00FFFF' .. k ..'|r created at bottom level') - end - end}) - - options = { - type = 'group', - name = 'Turok', - handler = T, - set = function(info,value) - local k = db[info[1]] - for i = 2, #info-1 do - if type(k[i]) ~= 'table' then - print('fart') - end - - k = k[i] - end - k[info[#info]] = value - end, - get = function(info) - local k = db[info[1]] - for i = 2, #info-1 do - if type(k[i]) ~= 'table' then - print('fart') - end - - k = k[i] - end - return k[info[#info]] - end, - desc = '"Dinosaur" Hunter', - args = { - background_color = { - type = 'color', - name = 'Background Color', - hasAlpha = true, - } - } - } - LibStub("AceConfig-3.0"):RegisterOptionsTable('Turok', options, {"tk"}) - -end - - -function T:OnEnable() - local db = _G.TurokData - - print('I... am Turok') - - self.stats = { - maxpower = UnitPowerMax('player') - } - - - T.focusbar = T:CreateBar('TkFocusBar', db.focusbar) - local fb = T.focusbar - T:AddLabel(fb, db.focusbar) - fb:Update(UnitPower("player"), 0, UnitPowerMax("player")) - T:Bar_SetUpdateHandler(fb, function(self) - local pp = UnitPower("player") - if pp == T.stats.maxpower and not T.stats.capped then - T.stats.capped = true - elseif T.stats.capped then - T.stats.capped = false - end - T.Bar_Update(fb, pp) - end) -end diff -r 8a9a6637f082 -r a9b8b0866ece Turok.toc --- a/Turok.toc Tue Dec 15 10:10:22 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -## Interface: 60200 -## Title: Turok -## Notes: Dinosaur Huntin' -## Author: Krakyn -## Version: 1.0 -## SavedVariables: TurokData -## OptionalDep: Ace3 - -Libs\LibStub\LibStub.lua -Libs\AceConsole-3.0\AceConsole-3.0.xml -Libs\AceAddon-3.0\AceAddon-3.0.xml -Libs\AceConfig-3.0\AceConfig-3.0.xml -Libs\AceEvent-3.0\AceEvent-3.0.xml -Libs\AceTimer-3.0\AceTimer-3.0.xml -Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml -Libs\LibSharedMedia-3.0\lib.xml -Media\Manifest.lua -Turok.lua -Fog.lua -Tek.lua -Equip.lua -Spirit.lua -Lost.lua \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok/.pkgmeta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/.pkgmeta Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,19 @@ +externals: + Libs/LibStub: + url: svn://svn.wowace.com/wow/libstub/mainline/trunk + tag: latest + Libs/CallbackHandler-1.0: + url: svn://svn.wowace.com/wow/callbackhandler/mainline/trunk/CallbackHandler-1.0 + tag: latest + Libs/AceAddon-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceAddon-3.0 + tag: latest + Libs/LibGroupInSpecT-1.1: + Libs/LibGroupInSpecT-1.1: svn://svn.wowace.com/wow/libgroupinspect/mainline/trunk + +ignore: + - Debug.lua + - Turok.iml + - .idea + +enable-nolib-creation: no \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok/Init.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Init.lua Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,287 @@ +--- ${PACKAGE_NAME} +-- @file-author@ +-- @project-revision@ @project-hash@ +-- @file-revision@ @file-hash@ +-- Created: 12/28/2015 6:40 AM +--- Core load sequence goes here. +--@debug@ +local ADDON, TurokEnv = ... +local _G = _G +--@end-debug@ +--GLOBALS: Turok, LibStub, GetAddOnMetadata +local setmetatable, rawset, rawget, pairs, type, unpack, tostring, tinsert = setmetatable, rawset, rawget, pairs, type, unpack, tostring, table.insert +Turok = LibStub("AceAddon-3.0"):NewAddon('Turok', 'AceEvent-3.0', 'AceTimer-3.0', 'AceConsole-3.0') +Turok:SetDefaultModuleState(true) +TurokEnv.Addon = Turok +TurokEnv.LSM = LibStub("LibSharedMedia-3.0") +TurokEnv.LGIST = LibStub("LibGroupInSpecT-1.1") +local T = Turok +--@debug@ +local print = function(...) + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('DB', ...) + end +end +local cTypes = { ['function'] = 'FF9922', ['table'] = '00FFAA', ['number'] = '77FF00', ['string'] = '00AAFF', ['hl'] = 'FF0088', ['field'] = '00FFFF', + ['boolean'] = 'CC88FF', ['false'] = 'FF7700', ['true'] = '44FF66', ['nil'] = 'FFFF00',} + +local Debuggers = { + cType = function(s) return '|cFF' .. tostring(cTypes[type(s)]) .. tostring(s) .. '|r' end, + cText = function(s) return '|cFF'..cTypes.string..tostring(s)..'|r' end, + cNum = function(n) return '|cFF'..cTypes.number .. tostring(n) .. '|r' end, + cWord = function(w) return '|cFF'..cTypes.table .. tostring(w) .. '|r' end, + cKey = function(k) return '|cFF'..cTypes.field .. tostring(k) .. '|r' end, + cPink = function(s) return '|cFF'..cTypes.hl .. tostring(s) .. '|r' end, + cBool = function(s) return '|cFF'..cTypes[tostring((not not s))] .. tostring(s) .. '|r' end, +} +for fname, func in pairs(Debuggers) do + _G[fname] = func +end +local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool +--@end-debug@ + +T.db = {} +T.versionString = GetAddOnMetadata("Turok", "Version") + +function T:OnModuleCreated(mod) + if mod.events then + print('Module', unpack(mod.events)) + end +end +--- RegisterEvent embedded to module tables +function T:RegisterCallback(event, func, ...) + if not T.dispatchQueue[event] then + T.dispatchQueue[event] = {} + end + + if not T.dispatchQueue[event][T.ID] then + T.dispatchQueue[event][T.ID] = T:GetName() + end + + if (type(func) == 'function') then + if type(T[event]) == 'function' then + local oldfunc = T[event] + T[event] = function(...) + oldfunc(...) + return func(...) + end + else + T[event] = func + end + end + --@debug@ + print(cText('Adding listener for'), cKey(self:GetName()), cText('on'), cKey(event))--@end-debug@ +end + +--- Default settings base +T.defaults = { + char = {}, + + lefttext = { + parent = 2, -- in an overlay frame + anchor = 'LEFT', + anchorTo = 'LEFT', + size = 18, + x = 5, y = 0, + justifyH = 'LEFT', + justifyV = 'MIDDLE', + }, + + righttext = { + parent = 2, -- in an overlay frame + anchor = 'RIGHT', + anchorTo = 'RIGHT', + x = -5, + y = 0, + size = 18, + justifyH = 'RIGHT', + justifyV = 'MIDDLE', + }, + + alpha = 1, + alpha_ooc = 1, + alpha_fade_in = 0.2, + alpha_fade_out = 0.2, + border_color = {0,0,0,1}, + + background_color = {0,.0,0,1}, + background_blend = 'BLEND', + + foreground_texture = [[Interface\Addons\Turok\Media\statusbar\Minimalist.tga]], + foreground_color = {0,.475,.95,1}, + foreground_blend = 'BLEND', + + foreground_inset = 0, + padding = 2, + spacing = 0, + fill_direction = 'RIGHT', + + anchor = 'CENTER', parent = 'UIParent', anchorTo = 'CENTER', + x = 0, y = 0, + inset = -3, + width = 250, + height = 100, + strata = 'LOW', + font = "Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", + size = 14, + text_color = {1, 1, 1, 1}, + justifyH = 'LEFT', + outline = 'OUTLINE', + combatFade = true, + + battle_noise_start = [[Interface\Addons\Turok\Media\sound\Low_Beep-Public_D-136_hifi.mp3]], + battle_noise_end = [[Interface\Addons\Turok\Media\sound\Electro_-S_Bainbr-7955_hifi.mp3]], +} + + +T.events = { + 'PLAY_MOVIE', + 'PLAYER_TARGET_CHANGED', + 'PLAYER_FOCUS_CHANGED', + 'PLAYER_EQUIPMENT_CHANGED', + 'PLAYER_REGEN_DISABLED', + 'PLAYER_REGEN_ENABLED', + 'SPELL_UDPATE_COOLDOWN', + 'SPELL_UPDATE_USABLE', + 'UNIT_AURA', + 'UNIT_PET', + 'UNIT_POWER_FREQUENT', + 'UNIT_SPELL_HASTE', + 'UNIT_SPELLCAST_SENT', + 'UNIT_SPELLCAST_START', + 'UNIT_SPELLCAST_DELAYED', + 'UNIT_SPELLCAST_STOP', + 'UNIT_SPELLCAST_CHANNEL_START', + 'UNIT_SPELLCAST_CHANNEL_UPDATE', + 'UNIT_SPELLCAST_CHANNEL_STOP', + 'UNIT_SPELLCAST_FAILED', + 'UNIT_SPELLCAST_INTERRUPTED', + 'UNIT_SPELLCAST_INTERRUPTIBLE', + 'UNIT_SPELLCAST_SUCCEEDED', + 'UNIT_SPELLCAST_UNINTERRUPTIBLE', +} +T.previousSpec = {} +T.talents = { {}, {}} +T.changedTalents = {{}, {} } +T.talentInfo = {} +T.auras = {} +T.spells = {} +T.spellevent = {} +T.channeling = {} +T.casting = {} +T.sent = {} +T.prototype = {} +T.spellBook = {} +T.equipped = {} + +--- player-restricted unit info and text representations +T.player = {} +T.playertext = {} +T.pet = {} + +--- holds non-restricted unit information +T.unit = { + player = {}, + target = {}, + focus = {}, + pet = {}, +} + +-- index of frames with conditional visual properties +T.control_regions = {} + +-- index of frames generated by the lua +T.frames = {} + +-- units +T.units = {} +T.unitsBySlot = {} +setmetatable(T.unitsBySlot, {__mode="v"}) + + + +T.TrueVal = function (self,k) + return rawget(self,k) +end +--- Sets an index hierarchy for db vars and propagates config dialog info +T.LinkTable = function (over, under, pname, cname) + local mt = { + __index = function(t,k) + if type(over[k]) ~= nil then + --t[k] = over[k] + --@debug@ + --print('up-referencing '.. STACK_COLOR2 .. pname ..'|r.'.. STACK_COLOR3.. tostring(k)..'|r -> '.. STACK_COLOR3.. pname ..'.' .. cname .. '|r.'..STACK_COLORN.. tostring(k) ..'|r', over[k])--@end-debug@ + end + return over[k] + end, + __newindex = function (t, k, v) + rawset(t,k,v) + if type(v) == 'table' then + --@debug@ + --print('parenting '.. STACK_COLOR2.. pname ..'|r to created table '.. STACK_COLOR3.. cname ..'|r')--@end-debug@ + T.LinkTable(under, v, pname, k) + end + end + } + --under.TrueVal = T.TrueVal + setmetatable(under, mt) + for k, v in pairs(under) do + if type(v) == 'table' then + --@debug@ + --print('linking '..STACK_COLOR1.. pname ..'|r to '..STACK_COLOR2.. cname ..'|r')--@end-debug@ + T.LinkTable(under, v, pname ..'.'.. cname, k) + end + end +end + + +--- Merges values of table B into table A, and copies over nested values of tables matching the keywords list +local masked = {name = true, virtual = true} +T.Config_Push = function(cvars, push , root, rkey) + local results = {} + root = root or cvars + for k, v in pairs(push) do + if not masked[k] then + if type(v) == 'table' and v ~= root then + cvars[k] = {} + T.Config_Push(cvars[k], v, root) + else + print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k)) + cvars[k] = v + tinsert(results, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k)) + end + end + end + return cvars, results +end +T.Config_Merge = function(cvars, merge, root, rkey) + local diff = {} + root = root or cvars + rkey = rkey or '0' + for k, v in pairs(merge) do + if masked[k] or cvars[k] then + tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k)) + print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cText(k), '=', cvars[k]) + --cvars[k] = cvars[k] + else + if type(v) == 'table' then + if type(cvars[k]) == 'nil' then + cvars[k] = {} + end + if type(cvars[k]) == 'table' then + print(' |cFFFFFF00A+B|r '.. tostring(rkey)..'.'..cWord(k)) + cvars[k] = T.Config_Merge(cvars[k], v, root, tostring(rkey)..'.'..tostring(k)) + end + elseif cvars[k] == nil then + tinsert(diff, ' |cFFFF0088B|r '.. tostring(rkey)..'.'..cKey(k)) + print(' |cFFFF0088B|r ', tostring(rkey)..'.'..cKey(k)) + cvars[k] = v + else + tinsert(diff, ' |cFF00FF00A|r '.. tostring(rkey)..'.'..cWord(k)) + print(' |cFF00FF00A|r ', tostring(rkey)..'.'..cWord(k)) + --cvars[k] = cvars[k] + end + end + end + return cvars, diff +end \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok/Layout/Dialog.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Layout/Dialog.lua Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,186 @@ +--- Dialog Generator +-- @file-author@ +-- @project-revision@ @project-hash@ +-- @file-revision@ @file-hash@ +-- Created: 1/1/2016 3:37 PM +--- Framescript template for generating intelligible dialog panels +--[[ +-- Frame << TkListFrame +-- { +-- Frame << TkListItem <-- Any number of list item frames with parentArray="rows" +-- { + :GetRow(row, values, id, offset) <-- Populates the uiobjects that make up the given row, with data from values[id], on display row offset + <-- Any layered region of child frame with parentArray=opts" + } + Button <-- Any frame with parentArray="buttons" + + .Click (button, list) <-- Defines results of using a control button + .Check (button, row, list) <-- Defines results of operating a row widget + .Wheel (list, delta) <-- Defines response to mousewheel action over the list panel + } + + Globals: + TkList_Init ( object, values, offset, numRows ) + Takes the return from CreateFrame and a table of values and establishes a scrollable list interface. + + TkPanel_Init ( object ) + TkList_Init without the scrollable list operations. Lines up control buttons and nothing else. +--]] +local TK_LIST_SPACING = 1 +local TK_LIST_PADDING = 3 +local TK_LIST_HEADING_SIZE = 26 +local TK_LIST_ITEM_HEIGHT = 24 +local TK_LIST_DISPLAY_ITEMS = 10 + +local print = function(...) + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('Xui', ...) + end +end +-- GLOBALS: TkList_SetView, TkList_Init, Turok +local type, error, pairs, ipairs, tonumber, max, CreateFrame = type, error, pairs, ipairs, tonumber, math.max, CreateFrame +local checkval = function(valtype, t, fallback) + return (type(t) == valtype) and t or (fallback or error('Expected table reference, got '..type(t))) +end +local tableval = function(t, fallback) + return checkval('table', t, fallback or {}) +end +local funcval = function(f, fallback) + return checkval('function', f, fallback or function() end) +end + +--- Orders list row +-- Does an ipairs iteration over self.opts and distributes the referenced objects along the horizontal axis of 'self' +-- Note that members are only aligned horizontally; no column alignment is done. Widths can be set by datafunc to accomplish that. +local function TkListItem_Init (listrow) + if not listrow.opts then + print('no options to enumerate') + return + end + local rwidth = TK_LIST_PADDING*2 + for i, z in pairs(listrow.opts) do + if i > 1 then + z:SetPoint('LEFT', listrow.opts[i-1], 'RIGHT', TK_LIST_SPACING, 0) + else + z:SetPoint('LEFT', listrow, 'LEFT', TK_LIST_PADDING, 0) + end + rwidth = rwidth + z:GetWidth()+TK_LIST_SPACING + z:Show() + end + listrow:SetSize(rwidth-TK_LIST_PADDING*2,TK_LIST_ITEM_HEIGHT) + listrow:Show() + print(rwidth) + return rwidth +end + + +--- +local function TkControls_Init(self) + local buttonsize = (self._dwidth - (#self.buttons -1) * TK_LIST_SPACING - TK_LIST_PADDING*2) / #self.buttons + for n, b in ipairs(self.buttons) do + --print('Spirit', buttonsize) + b:SetWidth(buttonsize) + b:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', buttonsize* (n-1) + TK_LIST_SPACING * (n-1) + TK_LIST_PADDING, -TK_LIST_PADDING) + end + self.controls:SetHeight(self.buttons[1]:GetHeight()+ TK_LIST_PADDING*2) +end + +--- Populates the list frame with items +function TkList_SetView(self, start_num, num_rows) + print(self, start_num, num_rows) + if not start_num then + start_num = self.offset + end + + if not num_rows then + num_rows = self.num_rows + end + + if start_num > #self.info then + start_num = #self.info - #self.info % num_rows + elseif start_num < 1 then + start_num = 1 + end + + print(' ', self:GetName(), start_num, num_rows, #self.info) + self.offset = start_num + + for draw_num = 1, num_rows do + local actual_row = draw_num + start_num - 1 + if not self.rows[draw_num] then + self.rows[draw_num] = CreateFrame('Frame', self:GetName()..'_Option_'..draw_num, self, 'TurokListItem') + self.rows[draw_num]:SetHeight(TK_LIST_ITEM_HEIGHT) + self.rows[draw_num].row_num = draw_num + end + self.rows[draw_num].actual_row = actual_row + local row = self.rows[draw_num] + if self.info[actual_row] then + print( actual_row, draw_num) + self.GetRow(row, self.info, actual_row, draw_num) + row:Show() + else + print('|cFF888888'..actual_row, draw_num) + row:Hide() + end + row:SetParent(self) + end +end + +--- Prime TkListFrame template-spawn for use +-- @param self frame object to list-ify +-- @param info array of list item values +-- @param datafunc function that takes 1) frame object 2) info table 3) index number 4) row number +-- @param offset starting offset for initial view +function TkList_Init (self, info, offset, num_rows) + -- error checking + --[[if type(info) ~= 'table' then + error('arg #2 info must be an associative array') + end + if type(datafunc) ~= 'function' then + error('arg #3 needs a funcref or method name from the frame object') + end + --]] + self.GetRow = funcval(self.GetRow, function() end) + self.info = tableval(info, {}) + for i, v in ipairs(info) do + print('Main', i, '=', v.spellName, v.spellTab) + self.max_row = i + end + print('Main', 'last row #', self.max_row) + + + -- obtain data contents + self._dwidth = 0 + self.rows = {} + self.offset = offset and offset or 1 + self.num_rows = (tonumber(num_rows) ~= nil) and num_rows or TK_LIST_DISPLAY_ITEMS + self.name:SetHeight(TK_LIST_HEADING_SIZE) + TkList_SetView(self, offset) + + -- sort out the proper width + local rwidth = 1 + local k = 0 + for n, item in ipairs(self.rows) do + print(item:GetName()) + if item:IsShown() then + if n > 1 then + item:SetPoint('TOPLEFT', self.rows[n-1], 'BOTTOMLEFT', 0, - TK_LIST_SPACING) + else + item:SetPoint('TOPLEFT', self, 'TOPLEFT', TK_LIST_PADDING, -(TK_LIST_PADDING+TK_LIST_HEADING_SIZE+TK_LIST_SPACING)) + end + k = k+1 + self._dwidth = max(self._dwidth, TkListItem_Init(item)) + end + end + + TkControls_Init(self) + + self:SetSize(self._dwidth , (k*TK_LIST_ITEM_HEIGHT)+(TK_LIST_PADDING*2)+(k*TK_LIST_SPACING)+TK_LIST_HEADING_SIZE) +end + +--- Set up for a non-list-style panel, no iterative controls +function TkPanel_Init(self) + self._dwidth = self:GetWidth() + TkControls_Init(self) + --self:SetSize(self._dwidth , (k*TK_LIST_ITEM_HEIGHT)+(TK_LIST_PADDING*2)+(k*TK_LIST_SPACING)+TK_LIST_HEADING_SIZE) +end diff -r 8a9a6637f082 -r a9b8b0866ece Turok/Layout/Dialog.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Layout/Dialog.xml Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok/Modules/Utilities/Toast.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Modules/Utilities/Toast.lua Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,372 @@ +--- ${PACKAGE_NAME} +-- @file-author@ +-- @project-revision@ @project-hash@ +-- @file-revision@ @file-hash@ +-- Created: 2/2/2016 12:09 AM + +local mod = Turok:NewModule("Toast", "AceTimer-3.0") +local _G = _G +local db +local T, tostring, type, max, tinsert, UIParent, loadstring = _G.Turok, tostring, type, max, table.insert, _G.UIParent, loadstring +--@debug@ +local DEBUG = true +--@end-debug@ +local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool +local print = function(...) + if not DEBUG then return end + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('Toast', ...) + end +end + +-- GLOBALS:BossBanner_OnEvent, BossBanner +-- kill off the default BossBanner +local old_bb = BossBanner_OnEvent +BossBanner_OnEvent = function(self, event, ...) + T:Print(event, ...) +end + +T.defaults.toast = { + alert_hold = 2, + alert_fade = 1, + alert_flash = .6, + anchor = 'TOP', + parent = 'UIParent', + anchorTo = 'TOP', + x = 0, y= -56, + loot = { + background_color = {}, + } +} + +mod.events = { + "ACHIEVEMENT_EARNED", + "CRITERIA_EARNED", + "LFG_COMPLETION_REWARD", + "GUILD_CHALLENGE_COMPLETED", + "CHALLENGE_MODE_COMPLETED", + "LOOT_ITEM_ROLL_WON", + "SHOW_LOOT_TOAST", + "SHOW_LOOT_TOAST_UPGRADE", + "SHOW_PVP_FACTION_LOOT_TOAST", + "PET_BATTLE_CLOSE", + "STORE_PRODUCT_DELIVERED", + "GARRISON_BUILDING_ACTIVATABLE", + "GARRISON_MISSION_FINISHED", + "GARRISON_FOLLOWER_ADDED", + "GARRISON_RANDOM_MISSION_ADDED", + "BOSS_KILL", + "ENCOUNTER_LOOT_RECEIVED", +} + +mod.events_args = { + ['ACHIEVEMENT_EARNED'] = {12, false}, + ['ACHIEVEMENT_EARNED'] = {12, true}, + ['LFG_COMPLETED_REWARD'] = {}, +} +local y_factor = -1 +local x_factor = 0 +local tkAlerts = TkAlertContainer +local AlertFrame_FixPosition = function(alertFrame) + print(' pos:', alertFrame.order, cKey(alertFrame.x), cWord(alertFrame.y)) + alertFrame:SetPoint('TOPLEFT', tkAlerts, 'TOPLEFT', alertFrame.x, alertFrame.y) +end + +--- Goes through the alert container index and fixes the frame positions +-- used before and after an alert frame changes visibility +local AlertContainer_Update = function(self) + local anum = 1 + local offset = 0 + for i, alert in ipairs(tkAlerts.alerts) do + if alert:IsShown() then + alert.x = offset * x_factor + alert.y = offset * y_factor + alert.drawHeight = alert.ename:GetStringHeight()+ alert.desc:GetStringHeight() + alert.order = anum + anum = anum + 1 + offset = offset + alert.drawHeight + print(' draw height:', i, cText(alert.drawHeight)) + print(' position:', i, cPink(offset)) + AlertFrame_FixPosition(alert) + print('index', i, 'shifted from position', cNum(alert.order), 'to', cNum(anum), ' at draw point', alert.y) + print(' draw distance update ', cNum(0), 'x', cNum(offset)) + else + print('index', i, 'is not visible') + end + end + self:SetHeight(offset) +end + +--- config mode blocking command +local AlertFrame_Block = function(alertFrame) + -- only do stuff when configMode is on + if not mod.configMode then + return + end +end + +--- if not config mode, then fire at the end of fadeIn animation to queue fadeOut +local AlertFrame_Pin = function(alertFrame) + if not mod.configMode then + alertFrame.fadeOut.a1:SetStartDelay(db.alert_hold) + alertFrame.fadeOut:Play() + end +end + +--- if not config mode, then fire at the end of fadeOut to remove the frame from view and trigger positions update +local AlertFrame_Remove = function(alertFrame) + mod.num_events = mod.num_events - 1 + alertFrame:Hide() + print(mod.num_events) + AlertContainer_Update(tkAlerts) +end + +--- orders all visible frames to fadeOut +-- @param stagger forces the spacing of startDelay times for each frame +local AlertContainer_Clear = function(self, stagger) + stagger = stagger or 0.1 + for i = #self.alerts, 1, -1 do + print('clear check', i) + local alert = self.alerts[i] + if alert:IsShown() and not alert.fadeOut:IsPlaying() then + alert.fadeOut.a1:SetStartDelay((#self.alerts-i)* stagger) + alert.fadeOut:Play() + end + end +end +local AlertContainer_Unlock = function() +end + +--- Displays a new alert +-- @param name text naming the class of event that occurred +-- @param text alert subtext describing basic info about the event +-- @order order (optional) sets display slot of the alert +local function AlertContainer_ShowAlert(self, name, text, order) + local db = TurokData.toast + mod.num_events = mod.num_events + 1 + + local alertFrame + if not order then + local i = 1 + while i <= #self.alerts and not alertFrame do + if not self.alerts[i]:IsShown() then + alertFrame = self.alerts[i] + print('re-using alert frame #', i) + end + i = i +1 + end + else + alertFrame = self.alerts[order] + end + + if not alertFrame then + alertFrame = CreateFrame('Frame', 'TkAlertPanel'..(order or #self.alerts+1), self, 'TkAlertFrame') + self.alerts[#self.alerts+1] = alertFrame + print('creating new alert frame', #self.alerts) + + alertFrame.Pin = AlertFrame_Pin + alertFrame.Remove = AlertFrame_Remove + end + + alertFrame.ename:SetText(name) + local height1 = alertFrame.ename:GetStringHeight() + alertFrame.desc:SetText(text) + local height2 = height1+ alertFrame.desc:GetStringHeight() + alertFrame.desc:SetPoint('TOPLEFT', alertFrame, 'TOPLEFT', 0, -height1) + + alertFrame.order = order or mod.num_events + alertFrame:SetSize(300, height2) + alertFrame:Show() + --alertFrame.flashIn.a1:SetDuration(db.alert_flash/2) + --alertFrame.flashIn.a2:SetDuration(db.alert_flash/2) + alertFrame.flashIn:Play() + if not mod.configMode then + AlertContainer_Update(tkAlerts) + end +end + + +--- updates the completed missions index and returns info on the mission ID if passed +local completedMissions +local Garrison_UpdateCompleteMissions = function(missionID) + completedMissions = C_Garrison.GetCompleteMissions() + --- slide entries around for reference + for i, set in ipairs(completedMissions) do + if i ~= set.missionID then + completedMissions[set.missionID] = set + completedMissions[i] = nil + end + end + + if missionID and completedMissions[missionID] then + local m = completedMissions[missionID] + return m.name, m.location, m.locPrefix, m.isRare, m.followers, m.rewards, m.state + else + return false + end +end +--- container events handler +local AlertContainer_OnEvent = function (self, event, ...) + print(event, ...) + tkAlerts:Show() + if event == 'SHOW_LOOT_TOAST' then + local typeIdentifier, itemLink, quantity, specID, sex, isPersonal, lootSource = ...; + if typeIdentifier == "currency" then + AlertContainer_ShowAlert(self, itemLink, 'x'..quantity) + elseif typeIdentifier == "item" then + local _, _, _, ilvl, _, _, _, _, equipSlot = GetItemInfo(itemLink) + AlertContainer_ShowAlert(self, itemLink, tostring(ilvl)..' '..tostring(_G[equipSlot])) + end + elseif event == 'GARRISON_MISSION_FINISHED' then + local missionID = ... + local name, location, locPrefix, isRare, followers, rewards = Garrison_UpdateCompleteMissions(missionID) + local mission_info = { + (isRare and ('|cFF44BBFF') or ('|cFFFFFF00')..name.. '|r'), + } + + if followers then + for i, guid in ipairs(followers) do + print(C_Garrison.GetFollowerInfo(guid)) + end + end + + --'|T:'..icon..':0 + + + AlertContainer_ShowAlert(self, 'Mission Complete') + elseif event == 'GARRISON_BUILDING_ACTIVATABLE' then + local missionID = ... + elseif event == 'ACHIEVEMENT_EARNED' then + elseif event == 'LFG_COMPLETION_REWARD' then + local name, typeID, subtypeID, textureFilename, moneyBase, moneyVar, experienceBase, experienceVar, numStrangers, numRewards = GetLFGCompletionReward() + local _, _, _, _, hasBonusStep, isBonusStepComplete = C_Scenario.GetInfo(); + + end +end + +local AlertContainer_Test = function() + if not mod.configMode then + print('starting test mode') + tkAlerts:Show() + mod.configMode = true + + tkAlerts.configBG:Show() + tkAlerts.configBG:SetTexture(0,0.5,0,0.5) + tkAlerts:RegisterForDrag('LeftButton') + tkAlerts:EnableMouse(true) + + for i, frame in ipairs(tkAlerts.tools) do + frame:Show() + end + -- test fillers + local _,_, offset, range = GetSpellTabInfo(2) + print(offset, range) + + for i, event in ipairs(mod.events) do + --print(i, event) + local _, id = GetSpellBookItemInfo(math.random(offset, offset+range), 'spell') + print(id) + + local name = GetSpellLink(id) + local text = GetSpellDescription(id) + if not tkAlerts.alerts[i] then + print('creating alert frame #', i) + AlertContainer_ShowAlert(tkAlerts, name, text, i) + else + print('updating alert frame #', i) + local alert = tkAlerts.alerts[i] + alert:Show() + alert.order = i + alert.ename:SetText(name) + alert.desc:SetText(text) + if alert.fadeOut:IsPlaying() then + alert.fadeOut:Stop() + alert.backdrop:SetAlpha(0.5) + end + + alert.flashIn:Play() + end + end + AlertContainer_Update(tkAlerts) + else + tkAlerts:EnableMouse(false) + tkAlerts.configBG:Hide() + mod.configMode = nil + for i, frame in ipairs(tkAlerts.tools) do + frame:Hide() + end + for i, alert in ipairs(tkAlerts.alerts) do + for j, frame in ipairs(alert.tools) do + frame:Hide() + end + alert.fadeOut.a1:SetStartDelay(i*0.2) + alert.fadeOut:Play() + end + + end +end + +mod.OnEnable = function() + db = TurokData.toast + + --- find the closest frame to the center bottom and anchor to that + + local cX, cY = (GetScreenWidth() / 2), (GetScreenHeight() / 2) + local min_skewness = cX + local max_centrality, center_frame + for n, f in ipairs({UIParent:GetChildren()}) do + if type(f) == 'table' and f.GetObjectType and f.GetName then + if f.IsForbidden and f:IsForbidden() then + print(n, 'is a forbidden object') + else + local name = f:GetName() + + if f:IsVisible() and f:IsMouseEnabled() then + print(name and name or tostring(f):sub(8), 'is a frame!') + local x = f:GetCenter() + local y = f:GetTop() -- Y need center top position + if (x and y) and (y <= cY) then + x = math.abs(x - cX) -- X works in either direction + + -- distance of current - distant of record / max to get ratio of 1 where direct center results in 1 + local skewness_factor = (cX - x) / cX + local vertness_factor = y / cY + local centrality = skewness_factor * vertness_factor + print('result: (', floor(x), floor(y), ') = ', skewness_factor, 'skew,', vertness_factor, 'vertness.\nTotal score:', cNum(centrality)) + if (not max_centrality) or max_centrality < centrality then + center_frame = f + max_centrality = centrality + print(cWord(name and name or tostring(f):sub(8)),cPink(' is the new record!')) + end + + end + end + end + end + end + + mod.num_events = 0 + tkAlerts.alerts = {} + for i, event in ipairs(mod.events) do + tkAlerts:RegisterEvent(event) + end + + tkAlerts.Clear = AlertContainer_Clear + tkAlerts.Unlock = AlertContainer_Unlock + tkAlerts.Close = AlertContainer_Test + + tkAlerts:ClearAllPoints() + tkAlerts:SetPoint(db.anchor, db.parent, db.anchorTo, db.x, db.y) + tkAlerts.x = db.x + tkAlerts.y = db.y + tkAlerts.parent = db.parent + tkAlerts.anchor = db.anchor + tkAlerts.anchorTo = db.anchorTo + tkAlerts:EnableMouse(false) + + tkAlerts:SetScript('OnEvent', AlertContainer_OnEvent) + T:RegisterChatCommand("alert", AlertContainer_Test) + T:RegisterChatCommand("atest", function() + AlertContainer_OnEvent(tkAlerts, 'GARRISON_MISSION_FINISHED', 327) + end) +end \ No newline at end of file diff -r 8a9a6637f082 -r a9b8b0866ece Turok/Modules/Utilities/Utilities.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Modules/Utilities/Utilities.xml Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,252 @@ + + + + + self.cx = self:GetLeft() + self.cy = self:GetTop() + self:StartMoving() + + + self:StopMovingOrSizing() + self.x = self.x + self:GetLeft() - self.cx + self.y = self.y + self:GetTop() - self.cy + self:ClearAllPoints() + self:SetPoint(self.anchor, self.parent, self.anchorTo, self.x, self.y) + + + + + + + + + + + + + + + + + + + + self:GetParent().flashBG:Show() + + + self:GetParent().flashBG:Hide() + + + + + + + + + + + + + + + + + + + + + print(self:GetParent():GetParent():GetName()) + print(self:GetParent():GetParent().num_events) + + + self:GetParent():Pin() + + + + + + + + + self:GetParent():Remove() + + + + + + + + + + + self:GetParent():GetParent().flare:Show() + + + self:GetParent():GetParent().flare:Hide() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + print(self:GetName(), self.spellID, 'enter') + GameTooltip:SetOwner(self, 'ANCHOR_TOP') + --GameTooltip:SetPetAction(self.spellID) + GameTooltip:Show() + + + print(self:GetName(), 'leave') + GameTooltip:Hide() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:GetParent():Show() + self:GetParent():SetAlpha(0) + + + + + + + + + self:GetParent():Hide() + + + + + + + + + +