# HG changeset patch
# User Nenue
# Date 1476694652 14400
# Node ID 65ec88b30eb88cdba5fa3d07fa2ee8ea07dc0d8f
# Parent bb6b532c5d2fc4a4178defc295b22adc0f804819
- OrderHall plugin converted to a general world state cluster. Includes:
- Suramar ancient mana
- Artifact power/XP progress
- OrderHall bar shrinker
diff -r bb6b532c5d2f -r 65ec88b30eb8 .idea/uiDesigner.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/uiDesigner.xml Mon Oct 17 04:57:32 2016 -0400
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff -r bb6b532c5d2f -r 65ec88b30eb8 Modules/OrderHall.lua
--- a/Modules/OrderHall.lua Tue Oct 11 08:03:41 2016 -0400
+++ b/Modules/OrderHall.lua Mon Oct 17 04:57:32 2016 -0400
@@ -5,58 +5,91 @@
--
VeneerWorldStateCurrencyMixin = {}
-VeneerWorldStateMixin = {}
+VeneerWorldStateProgressMixin = {}
+VeneerWorldStateMixin = {
+ detectedFrames = {}
+}
local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop
function VeneerWorldStateMixin:Setup()
- hooksecurefunc(OrderHallCommandBar,'Show', function()
- self:Refresh()
- end)
self:Refresh()
--DEFAULT_CHAT_FRAME:AddMessage('Loaded')
+ print('All:Setup()')
+
+ self.modules = self.modules or {self:GetChildren()}
+ for i, frame in ipairs(self.modules) do
+ if frame.Setup then
+ frame:Setup()
+ end
+ end
end
function VeneerWorldStateMixin:Refresh()
- OrderHallCommandBar:ClearAllPoints()
- OrderHallCommandBar:SetPoint('TOP')
- OrderHallCommandBar:SetWidth(600)
- OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5)
- OrderHallCommandBar.WorldMapButton:Hide()
- OrderHallCommandBar:EnableMouse(false)
+ if OrderHallCommandBar then
+ if not self.detectedFrames[OrderHallCommandBar] then
+ self.detectedFrames[OrderHallCommandBar] = true
+ hooksecurefunc(OrderHallCommandBar,'Show', function()
+ self:Refresh()
+ end)
+ end
+
+
+ OrderHallCommandBar:ClearAllPoints()
+ OrderHallCommandBar:SetPoint('TOP')
+ OrderHallCommandBar:SetWidth(600)
+ OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5)
+ OrderHallCommandBar.WorldMapButton:Hide()
+ OrderHallCommandBar:EnableMouse(false)
+ end
+
end
local initialized
function VeneerWorldStateMixin:OnEvent(event, arg)
print(event, arg)
- if OrderHallCommandBar and not initialized then
- initialized = true
+
+ if event == 'PLAYER_LOGIN' and not initialized then
+ if IsLoggedIn() then
+ initialized = true
self:Setup()
- self:UnregisterEvent('ADDON_LOADED')
+ self:UnregisterEvent('PLAYER_LOGIN')
+ end
end
if event == 'PLAYER_ENTERING_WORLD' then
self:Update()
+ elseif event == 'PLAYER_REGEN_ENABLED' then
+ self:Show()
+ elseif event == 'PLAYER_REGEN_DISABLED' then
+ self:Hide()
end
end
function VeneerWorldStateMixin:Update()
- local frames = {self:GetChildren()}
+ self.modules = self.modules or {self:GetChildren()}
print('|cFFFFFF00All:Update()|r')
- for i, frame in ipairs(frames) do
+ self.maxHeight = 0
+ for i, frame in ipairs(self.modules) do
if frame.Update then
print(frame:GetName())
frame:Update()
+ if frame:IsVisible() then
+ self.maxHeight = max(self.maxHeight, frame.maxHeight)
+ end
end
end
+ self:SetHeight(self.maxHeight)
end
function VeneerWorldStateMixin:OnLoad ()
+ self:RegisterEvent('PLAYER_LOGIN')
self:RegisterEvent('ADDON_LOADED')
self:RegisterEvent('ARTIFACT_UPDATE')
self:RegisterEvent('ARTIFACT_XP_UPDATE')
self:RegisterEvent('PLAYER_ENTERING_WORLD')
-
+ self:RegisterEvent('PLAYER_REGEN_ENABLED')
+ self:RegisterEvent('PLAYER_REGEN_DISABLED')
end
function VeneerWorldStateCurrencyMixin:OnLoad ()
@@ -73,9 +106,9 @@
function VeneerWorldStateCurrencyMixin:Update()
- local mapID = GetCurrentMapAreaID()
+
print('currency refresh: zone =', mapID)
- if mapID == 1033 then
+ if GetZoneText() == 'Suramar' then
local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(1155)
self.Icon:SetTexture(texture)
@@ -85,4 +118,118 @@
else
self:Hide()
end
+
+ self.maxHeight = self:GetHeight()
+end
+
+function VeneerWorldStateProgressMixin:OnLoad()
+ self:RegisterEvent('PLAYER_XP_UPDATE')
+ self:RegisterEvent('PLAYER_LEVEL_UP')
+ self:RegisterEvent('PLAYER_UPDATE_RESTING')
+ self:RegisterEvent('ENABLE_XP_GAIN')
+ self:RegisterEvent('DISABLE_XP_GAIN')
+ self:RegisterEvent('PLAYER_LOGIN')
+ self:RegisterEvent('ARTIFACT_UPDATE')
+ self:RegisterEvent('ARTIFACT_XP_UPDATE')
+
+end
+
+function VeneerWorldStateProgressMixin:Setup()
+ self:UpdateXPGain()
+ if UnitLevel('player') < GetMaxPlayerLevel() then
+ self.mode = 'xp'
+ else
+ self.mode = 'artifact'
+ end
+ print('setup mode:', self.mode)
+ self:Update()
+end
+
+function VeneerWorldStateProgressMixin:OnEvent(event)
+ if event == 'ENABLE_XP_GAIN' or event == 'DISABLE_XP_GAIN' then
+ self:UpdateXPGain()
+ elseif event == 'ARTIFACT_XP_UPDATE' or event == 'ARTIFACT_UPDATE' then
+ self.mode = 'artifact'
+ elseif event == 'PLAYER_XP_UPDATE' or 'PLAYER_LEVEL_UP' then
+ self.mode = 'xp'
+ end
+
+
+ self:Update()
+
+end
+function VeneerWorldStateProgressMixin:UpdateXPGain()
+ if IsXPUserDisabled() then
+ self.ProgressBar:SetColorTexture(0.75,0.75,0.75)
+ self.mode = nil
+ else
+ self.ProgressBar:SetColorTexture(1,1,1)
+ end
+end
+
+local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo
+local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank
+function VeneerWorldStateProgressMixin:Update()
+
+ if not self.mode then
+ if UnitLevel('player') < GetMaxPlayerLevel() then
+ self.mode = 'xp'
+ else
+ self.mode = 'artifact'
+ end
+ end
+
+
+ self.progressPercent = 0
+ self.progressAmount = 0
+ self.progressMax = 1
+ self.progressOverflow = 0
+ if self.mode == 'xp' then
+ local xp = UnitXP('player')
+ local xpMax = UnitXPMax('player')
+ local bonusXP = GetXPExhaustion()
+ if xp then
+ self.progressPercent = xp / xpMax
+ end
+ elseif self.mode == 'artifact' then
+
+ local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo()
+ if not itemID then
+ self:Hide()
+ return
+ end
+
+ local pointsAvailable = 0
+
+ local nextRankCost = GetCostForPointAtRank(pointsSpent) or 0
+
+ self.progressAmount = totalXP
+ self.progressMax = nextRankCost
+ if totalXP > nextRankCost then
+ self.progressPercent = 1
+ self.progressOverflow = totalXP - nextRankCost
+ else
+ self.progressPercent = totalXP / nextRankCost
+ end
+
+ self.progressText = name .. ' ('..pointsSpent .. '): '.. totalXP .. ' / ' .. nextRankCost
+ else
+ self:Hide()
+ return
+ end
+
+ print(self.progressPercent, floor(self.ProgressBG:GetWidth()* self.progressPercent))
+
+ if self.progressPercent > 0 then
+ self.ProgressBar:Show()
+ self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self.ProgressBG:GetWidth()* self.progressPercent , 0)
+
+ self.Label:SetText(self.progressText)
+ else
+ self.ProgressBar:Hide()
+ end
+
+
+
+ self.maxHeight = self:GetHeight()
end
\ No newline at end of file
diff -r bb6b532c5d2f -r 65ec88b30eb8 Modules/PaperDoll.lua
--- a/Modules/PaperDoll.lua Tue Oct 11 08:03:41 2016 -0400
+++ b/Modules/PaperDoll.lua Mon Oct 17 04:57:32 2016 -0400
@@ -77,7 +77,7 @@
nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0
end
self.Header:SetText(name)
- self.Level:SetText(pointsSpent)
+ self.Level:SetText((pointsAvailable >= 1) and (pointsSpent .. ' ('.. pointsAvailable..')') or (pointsSpent))
self.ProgressText:SetFormattedText("|cFF00FFFF%d|r / %d", totalXP, nextRankCost)
self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()*(totalXP/nextRankCost), 0)
diff -r bb6b532c5d2f -r 65ec88b30eb8 Veneer.xml
--- a/Veneer.xml Tue Oct 11 08:03:41 2016 -0400
+++ b/Veneer.xml Mon Oct 17 04:57:32 2016 -0400
@@ -219,7 +219,7 @@
-
+
@@ -238,11 +238,11 @@
-
+
-
+
-
+