Mercurial > wow > worldplan
changeset 5:4e1883842abf
- use of SetShown() for combat visibility toggle
author | Nenue |
---|---|
date | Tue, 18 Oct 2016 01:50:06 -0400 |
parents | 4c7e9efec4b5 |
children | 48001b6a9496 |
files | ClassPlan.lua ClassPlan.xml |
diffstat | 2 files changed, 56 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/ClassPlan.lua Mon Oct 17 12:59:24 2016 -0400 +++ b/ClassPlan.lua Tue Oct 18 01:50:06 2016 -0400 @@ -71,6 +71,12 @@ end end +MissionsHandler.OnGetItem = function(data) + if data.missionEndTime < GI_currentTime then + data.isComplete = true + end +end + MissionsHandler.FreeBlock = function(self, block) end @@ -203,11 +209,11 @@ end function core:OnLoad () - self:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player') self:RegisterEvent('PLAYER_LOGIN') self:RegisterEvent('PLAYER_ENTERING_WORLD') self:RegisterEvent('ADDON_LOADED') self:RegisterEvent('PLAYER_REGEN_ENABLED') + self:RegisterEvent('PLAYER_REGEN_DISABLED') -- Blizzard_GarrisonUI already fires a shipment data request for GARRISON_SHIPMENT_RECEIVED; this is unlikely to @@ -223,34 +229,35 @@ self:ClearAllPoints() + local anchorTo = 'TOP' self.anchorParent = UIParent for i, name in ipairs(parentFrames) do local frame = _G[name] if frame then if not BOUND_FRAMES[frame] then - BOUND_FRAMES[frame] = {visible = frame:IsVisible()} + BOUND_FRAMES[frame] = {visible = (frame:IsVisible() and frame:IsShown())} hooksecurefunc(frame, 'Show', function() BOUND_FRAMES[frame].visible = true print(frame:GetName(), 'Show', 'reanchor trigger') self:Reanchor() end) hooksecurefunc(frame, 'Hide', function() - BOUND_FRAMES[frame].visible = false + BOUND_FRAMES[frame].visible = nil print(frame:GetName(), 'Hide', 'reanchor trigger') self:Reanchor() end) end - print('f:', frame:GetName(), frame:IsVisible()) + print('f:', frame:GetName(), BOUND_FRAMES[frame].visible) if BOUND_FRAMES[frame].visible then self.anchorParent = frame + anchorTo = 'BOTTOM' break end end end - print('|cFFFF8800Using ' .. tostring(self.anchorParent:GetName()) .. ' as anchor point') + print('|cFFFF8800Using ' .. tostring(self.anchorParent:GetName()) .. '-'..anchorTo..' as anchor point') - if self:IsVisible() then - self:SetPoint('TOP', ClassPlanButton, 'BOTTOM', 0, 0) + if self:IsShown() then ClassPlanButton.Background:Show() ClassPlanButton:SetWidth(600) else @@ -258,8 +265,11 @@ ClassPlanButton:SetWidth(200) end - ClassPlanButton:SetPoint('TOP', self.anchorParent, (self.anchorPoint == UIParent) and 'TOP' or 'BOTTOM', 0, 0) + self:SetPoint('TOP', ClassPlanButton, 'BOTTOM', 0, 0) + ClassPlanButton:ClearAllPoints() + ClassPlanButton:SetPoint('TOP', self.anchorParent, anchorTo, 0, 0) + print(ClassPlanButton:GetPoint(1)) end function core:AddHandler(name, prototype) @@ -311,8 +321,10 @@ function core:OnEvent (event, ...) print(event) - if event == 'UNIT_PORTRAIT_UPDATE' then - SetPortraitTexture(self.portrait, 'player') + if event == 'PLAYER_REGEN_DISABLED' then + self:SetShown(false) + elseif event == 'PLAYER_REGEN_ENABLED' then + self:SetShown(true) elseif event == 'PLAYER_LOGIN' then if not self.initialized then self:Setup() @@ -334,11 +346,19 @@ local SetOwnerData = function(self, data) local name, realm = string.match(data.profileKey, "(.+)%-(.+)") local ownerText = '|c'.. data.classColor.colorStr .. name .. '|r' - if realm ~= GI_currentRealm then - ownerText = ownerText .. ' (' .. realm .. ')' + --if realm ~= GI_currentRealm then + --ownerText = ownerText .. ' (' .. realm .. ')' + --end + self.Owner:SetText(ownerText) + self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) + + if self.isComplete then + self.TimeLeft:SetText('Complete!') + self.Background:SetColorTexture(.25,.25,.25,1) + else + self.Background:SetColorTexture(0,0,0,0.5) end - self.Owner:SetText(ownerText) - self.Background:SetColorTexture(data.classColor.r, data.classColor.g, data.classColor.b) + end function core:RefreshItems(configKey, prototype) @@ -376,6 +396,7 @@ end end block:Refresh(data) + print(block.isComplete, block.missionEndTime, block.name) SetOwnerData(block, data) block:Show() @@ -408,14 +429,14 @@ end function core:Toggle() - if self:IsVisible() then + if self:IsShown() then self:Hide() else self:Show() end if self.data then - self.data.IsShown = self:IsVisible() + self.data.IsShown = self:IsShown() end end @@ -483,7 +504,7 @@ end function MissionsHandler:OnComplete() - self.isComplete = true + print('flagging complete', self.name) self:Refresh() end @@ -517,12 +538,12 @@ local r,g,b = 1, 1, 1 if self.isRare then r,g,b = 0.1, 0.4, 1 + self.IconBorder:SetVertexColor(r, g, b, 1) end --self.missionData = data - self.Label:SetText(self.name) - self.Label:SetTextColor(r, g, b) + self.Name:SetText(self.name) if #self.rewards >= 1 then self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID)) @@ -530,11 +551,6 @@ else self.Icon:SetAtlas(self.typeAtlas, false) end - if self.isComplete then - self.TimeLeft:SetText('Complete!') - end - - self.Background:SetAlpha(self.isComplete and 1 or 0.1) end
--- a/ClassPlan.xml Mon Oct 17 12:59:24 2016 -0400 +++ b/ClassPlan.xml Tue Oct 18 01:50:06 2016 -0400 @@ -28,6 +28,13 @@ <Size x="32" y="16"/> </Texture> </Layer> + <Layer level="OVERLAY"> + <FontString parentKey="Label" inherits="ClassPlanFont"> + <Anchors> + <Anchor point="BOTTOMLEFT" x="2" y="2" /> + </Anchors> + </FontString> + </Layer> <Layer level="HIGHLIGHT"> <Texture setAllPoints="true" alphaMode="ADD"> <Color a="0.25" r="1" g="1" b="1" /> @@ -72,7 +79,7 @@ <Button name="ClassPlanBlock" mixin="ClassPlanBlockMixin" virtual="true" hidden="true"> - <Size x="400" y="32" /> + <Size x="400" y="24" /> <Scripts> <OnUpdate method="OnUpdate" /> <OnShow method="OnShow" /> @@ -87,7 +94,7 @@ </Layer> <Layer level="ARTWORK"> <Texture name="$parentIcon" parentKey="Icon"> - <Size x="32" y="32" /> + <Size x="24" y="24" /> <Anchors> <Anchor point="TOPLEFT" /> </Anchors> @@ -95,14 +102,14 @@ </Texture> </Layer> <Layer level="OVERLAY"> - <FontString name="$parentLabel" inherits="ClassPlanFont" parentKey="Label" text="base text"> + <FontString name="$parentName" inherits="ClassPlanFont" parentKey="Name" text="base text"> <Anchors> - <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeKey="$parent.Icon" x="4" y="-2" /> + <Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Icon" x="4" y="0" /> </Anchors> </FontString> <FontString name="$parentTimeLeft" inherits="ClassPlanNumberFont" parentKey="TimeLeft" text="base text"> <Anchors> - <Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeKey="$parent.Label" x="4" y="-2" /> + <Anchor point="RIGHT" x="-4" y="0" /> </Anchors> </FontString> </Layer> @@ -112,7 +119,7 @@ </Texture> <FontString name="$parentOwner" inherits="ClassPlanFont" parentKey="Owner" text="base text"> <Anchors> - <Anchor point="TOPRIGHT" x="-2" y="-2" /> + <Anchor point="RIGHT" relativePoint="LEFT" x="-4" y="0" relativeKey="$parent.TimeLeft" /> </Anchors> </FontString> </Layer> @@ -143,9 +150,9 @@ </Layer> <Layer level="BORDER"> <Texture parentKey="Done" atlas="GarrLanding-ShipmentCompleteGlow"> - <Size x="32" y="32" /> + <Size x="24" y="24" /> <Anchors> - <Anchor point="LEFT"/> + <Anchor point="BOTTOMLEFT"/> </Anchors> </Texture> </Layer> @@ -165,7 +172,7 @@ </FontString> <FontString parentKey="Count" inherits="WorldPlanFont" justifyH="CENTER"> <Anchors> - <Anchor point="BOTTOM" relativeKey="$parent.Icon" x="0" y="0"/> + <Anchor point="BOTTOMRIGHT" relativeKey="$parent.Icon" x="0" y="0"/> </Anchors> </FontString> </Layer>