Mercurial > wow > buffalo2
comparison Modules/PaperDoll.lua @ 80:bb6b532c5d2f
- added "world state" frame for zone-specific currencies and context-based artifact/experience progress
| author | Nenue |
|---|---|
| date | Tue, 11 Oct 2016 08:03:41 -0400 |
| parents | 83b3cdaae6a5 |
| children | 65ec88b30eb8 |
comparison
equal
deleted
inserted
replaced
| 79:0784b87f9722 | 80:bb6b532c5d2f |
|---|---|
| 1 -- Veneer | 1 -- Veneer |
| 2 -- PaperDoll.lua | 2 -- PaperDoll.lua |
| 3 -- Created: 8/16/2016 8:18 AM | 3 -- Created: 8/16/2016 8:18 AM |
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 -- Displays item levels by equipment slots | 5 -- Displays the item level and modifications of character sheet equipment, including artifact power |
| 6 -- Requires tooltip scraping to obtain these numbers, meaning any currently active tooltip will be cleared. | |
| 7 | 6 |
| 8 local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) | 7 local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) |
| 9 local vn, print = LibStub("LibKraken").register(Veneer, plugin) | 8 local vn, print = LibStub("LibKraken").register(Veneer, plugin) |
| 10 | 9 |
| 11 local slot_anchors = { | 10 local slot_anchors = { |
| 52 local ticker | 51 local ticker |
| 53 local vnslot = {} | 52 local vnslot = {} |
| 54 local pendingSlots = {} | 53 local pendingSlots = {} |
| 55 | 54 |
| 56 | 55 |
| 56 local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo | |
| 57 local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank | |
| 58 local tooltip = CreateFrame('GameTooltip', 'VeneerTooltip', UIParent, 'GameTooltipTemplate') | |
| 57 local jewel = {} | 59 local jewel = {} |
| 60 | |
| 61 local artifactBar_OnEvent = function (self) | |
| 62 local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() | |
| 63 if not itemID then | |
| 64 self:Hide() | |
| 65 return | |
| 66 end | |
| 67 | |
| 68 local numRelicSlots = C_ArtifactUI.GetNumRelicSlots() or 0; | |
| 69 | |
| 70 | |
| 71 local pointsAvailable = 0 | |
| 72 local nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 | |
| 73 | |
| 74 while totalXP >= nextRankCost do | |
| 75 totalXP = totalXP - nextRankCost | |
| 76 pointsAvailable = pointsAvailable + 1 | |
| 77 nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 | |
| 78 end | |
| 79 self.Header:SetText(name) | |
| 80 self.Level:SetText(pointsSpent) | |
| 81 self.ProgressText:SetFormattedText("|cFF00FFFF%d|r / %d", totalXP, nextRankCost) | |
| 82 | |
| 83 self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()*(totalXP/nextRankCost), 0) | |
| 84 self.ProgressBar:SetColorTexture(1,.5,0) | |
| 85 | |
| 86 self:Show() | |
| 87 end | |
| 88 | |
| 89 | |
| 90 local artifactBar = CreateFrame('Frame', 'VnPaperDollArtifact', CharacterModelFrame, 'VeneerStatusBarTemplate') | |
| 91 artifactBar:ClearAllPoints() | |
| 92 artifactBar:SetHeight(28) | |
| 93 artifactBar:SetPoint('LEFT', CharacterModelFrame, 'LEFT', 30, 0) | |
| 94 artifactBar:SetPoint('RIGHT', CharacterModelFrame, 'RIGHT', -30, 0) | |
| 95 artifactBar:SetPoint('BOTTOM', CharacterMainHandSlotFrame, 'TOP', 0, 1) | |
| 96 artifactBar.ProgressBG:SetColorTexture(0.5, 0.5, 0.5) | |
| 97 artifactBar.Header:Show() | |
| 98 artifactBar:RegisterEvent('ARTIFACT_UPDATE') | |
| 99 artifactBar:SetScript('OnEvent', artifactBar_OnEvent) | |
| 100 | |
| 101 plugin.artifactBar = artifactBar | |
| 102 print(CharacterMainHandSlotFrame:GetPoint(1)) | |
| 103 print(artifactBar:GetPoint(3)) | |
| 104 | |
| 105 for i = 1, 3 do | |
| 106 local relicSlot = CreateFrame('Frame', 'VnPaperDollRelic'..i, artifactBar) | |
| 107 relicSlot:SetSize(40,40) | |
| 108 relicSlot:SetPoint('BOTTOM', artifactBar, 'TOP', (i-2)*40, 24) | |
| 109 relicSlot.relicArt = relicSlot:CreateTexture(nil, 'BACKGROUND') | |
| 110 artifactBar['RelicSlot'..i] = relicSlot | |
| 111 end | |
| 112 | |
| 113 | |
| 114 artifactBar:EnableMouse(true) | |
| 115 artifactBar:SetScript('OnMouseUp', function() | |
| 116 SocketInventoryItem(16) | |
| 117 end) | |
| 118 | |
| 58 local UpdateVeneer = function(itemslot, frame) | 119 local UpdateVeneer = function(itemslot, frame) |
| 59 local slot = itemslot:GetID() | 120 local slot = itemslot:GetID() |
| 60 if itemslot.hasItem then | 121 if itemslot.hasItem then |
| 61 frame.link = GetInventoryItemLink('player', slot) | 122 local unit = frame.target.unit or 'player' |
| 62 | 123 frame.link = GetInventoryItemLink(unit, slot) |
| 63 local name, link, something, ilevel = GetItemInfo(frame.link) | 124 tooltip:SetOwner(frame, 'ANCHOR_NONE') |
| 64 frame.label:SetText(ilevel) | 125 tooltip:SetInventoryItem(unit, slot) |
| 65 -- todo: test GetExtendedItemInfo() | 126 tooltip:Show() |
| 66 | 127 --print(tooltip:NumLines()) |
| 67 local item = {strsplit(":", link)} | 128 if tooltip:NumLines() >= 3 then |
| 68 local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId, | 129 |
| 69 uniqueId, linkLevel, specializationID, instanceDifficultyId, numBonusIds, bonusId1, bonusId2, upgradeValue | 130 local ilvl |
| 70 | 131 if _G['VeneerTooltipTextLeft2'] then |
| 71 specializationID, instanceDifficultyId, numBonusIds = item[11], item[12], item[13] | 132 ilvl = _G['VeneerTooltipTextLeft2']:GetText():match("Item Level (%d+)") |
| 72 jewel[1], jewel[2], jewel[3], jewel[4] = item[4], item[5], item[6], item[7] | 133 --print('l2', ilvl) |
| 73 --vn:print(jewelId1, jewelId2, jewelId3, jewelId4) | 134 end |
| 74 for i = 1, 4 do | 135 |
| 75 local gemslot = frame.gemslot[i] | 136 if _G['VeneerTooltipTextLeft3'] then |
| 76 if tonumber(jewel[i]) ~= nil then | 137 if not ilvl then |
| 77 if not gemslot then | 138 ilvl = _G['VeneerTooltipTextLeft3']:GetText():match("Item Level (%d+)") |
| 78 gemslot = frame:CreateTexture(itemslot:GetName()..'Gem'..i, 'ARTWORK') | 139 --print('l3', ilvl) |
| 79 gemslot:SetSize(16,16) | |
| 80 local posx = 3 + (i-1)*16 | |
| 81 if slot_anchors[slot]:match('RIGHT') then | |
| 82 posx = posx * -1 | |
| 83 end | |
| 84 gemslot:SetPoint(slot_anchors[slot], frame.label, slot_relative[slot], posx, 0) | |
| 85 frame.gemslot[i] = gemslot | |
| 86 end | 140 end |
| 87 gemslot:SetTexture(GetItemIcon(jewel[i])) | |
| 88 gemslot:Show() | |
| 89 else | |
| 90 if gemslot then | |
| 91 gemslot:Hide() | |
| 92 end | |
| 93 | |
| 94 end | 141 end |
| 95 end | 142 |
| 96 --[[ | 143 if ilvl then |
| 97 print(link) | 144 frame.label:SetText(ilvl) |
| 98 local difftag = '?' | |
| 99 if tonumber(numBonusIds) ~= nil then | |
| 100 local name, groupType, isHeroic, isChallengeMode, displayHeroic, displayMythic, toggleDifficultyID = GetDifficultyInfo(numBonusIds) | |
| 101 difftag = (name or '??') .. (isHeroic and ' (Heroic)' or '') | |
| 102 end | |
| 103 | |
| 104 print(instanceDifficultyId, '|cFF00FFFF', difftag, numBonusIds) | |
| 105 --if tonumber(numBonusIds) ~= nil then | |
| 106 for i = 8, #item do | |
| 107 print(i..'-', item[i]) | |
| 108 end | 145 end |
| 109 --end | 146 end |
| 110 | 147 |
| 111 --]] | 148 local quality = GetInventoryItemQuality(unit, slot) |
| 149 if slot == 16 and quality == LE_ITEM_QUALITY_ARTIFACT then | |
| 150 artifactBar_OnEvent(plugin.artifactBar) | |
| 151 end | |
| 152 | |
| 153 | |
| 154 | |
| 112 | 155 |
| 113 frame:Show() | 156 frame:Show() |
| 114 else | 157 else |
| 115 frame:Hide() | 158 frame:Hide() |
| 116 end | 159 end |
| 140 local name = self:GetName() | 183 local name = self:GetName() |
| 141 local slot = self:GetID() | 184 local slot = self:GetID() |
| 142 if not slot_anchors[slot] then | 185 if not slot_anchors[slot] then |
| 143 return | 186 return |
| 144 end | 187 end |
| 145 | 188 print(self:GetName()) |
| 146 | 189 |
| 147 local frame = _G[name .. 'Veneer'] | 190 local frame = _G[name .. 'Veneer'] |
| 148 | 191 |
| 149 if not frame then | 192 if not frame then |
| 150 | 193 |
| 152 vnslot[slot] = frame | 195 vnslot[slot] = frame |
| 153 | 196 |
| 154 frame.label = frame:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFont') | 197 frame.label = frame:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFont') |
| 155 frame.gemslot = {} | 198 frame.gemslot = {} |
| 156 | 199 |
| 157 local anchor, relative, x, y = slot_anchors[slot], slot_relative[slot], 8, -4 | 200 |
| 158 if anchor:match('RIGHT') then | 201 frame.target = self |
| 159 x = -x | |
| 160 end | |
| 161 if anchor:match('BOTTOM') then | |
| 162 y = 4 | |
| 163 end | |
| 164 | |
| 165 frame.gemslot = {} | 202 frame.gemslot = {} |
| 166 frame:SetPoint(anchor, self, relative, x, y) | 203 frame:SetAllPoints(self) |
| 167 frame:SetSize(200,24) | 204 frame:SetParent(self) |
| 168 frame.label:ClearAllPoints() | 205 frame.label:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 2, 2) |
| 169 frame.label:SetPoint(slot_anchors[slot], frame, slot_anchors[slot]) | |
| 170 | 206 |
| 171 tinsert(pendingSlots, frame) | 207 tinsert(pendingSlots, frame) |
| 172 end | 208 end |
| 173 | 209 |
| 174 end | 210 UpdateVeneer(self, frame) |
| 175 | 211 |
| 212 end | |
| 213 | |
| 214 local PaperDollFrame_UpdateStats = function() | |
| 215 | |
| 216 end | |
| 176 | 217 |
| 177 | 218 |
| 178 | 219 |
| 179 plugin.event = function(self, event, ...) | 220 plugin.event = function(self, event, ...) |
| 180 print(self, event, flag, slot) | 221 print(self, event, ...) |
| 181 | 222 |
| 182 if event == 'PLAYER_EQUIPMENT_CHANGED' then | 223 if event == 'PLAYER_EQUIPMENT_CHANGED' then |
| 183 local slot, hasItem = ... | 224 local slot, hasItem = ... |
| 184 if vnslot[slot] then | 225 if vnslot[slot] then |
| 185 UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot]) | 226 UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot]) |
| 186 plugin.ticker() | 227 |
| 187 end | 228 end |
| 188 | 229 |
| 189 elseif event == 'PLAYER_ENTERING_WORLD' then | 230 elseif event == 'PLAYER_ENTERING_WORLD' then |
| 190 UpdateAll() | 231 UpdateAll() |
| 191 | 232 |
| 192 end | 233 end |
| 193 | 234 |
| 235 end | |
| 236 local artifactBarCreated | |
| 237 plugin.init = function() | |
| 238 LoadAddOn('Blizzard_ArtifactUI') | |
| 194 end | 239 end |
| 195 | 240 |
| 196 --plugin:SetScript('OnEvent', plugin.event) | 241 --plugin:SetScript('OnEvent', plugin.event) |
| 197 plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') | 242 plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') |
| 198 plugin:RegisterEvent('PLAYER_ENTERING_WORLD') | 243 plugin:RegisterEvent('PLAYER_ENTERING_WORLD') |
| 199 | 244 |
| 200 | 245 |
| 201 --hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) | 246 hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) |
| 247 | |
| 248 hooksecurefunc("PaperDollFrame_UpdateStats", PaperDollFrame_UpdateStats) |
