Convert UI controls to Lua only

Sasky [03-25-15 - 06:19]
Convert UI controls to Lua only
Filename
CyrHUD.lua
CyrHUD.txt
CyrHUD.xml
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 1706b80..a62f682 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -50,18 +50,6 @@ function CyrHUD:error(val)
 end

 ----------------------------------------------
--- Score
-----------------------------------------------
-function CyrHUD.updateScore()
-    local cID = GetCurrentCampaignId()
-    local time = CyrHUD.formatTime(GetSecondsUntilCampaignScoreReevaluation(cID), true)
-    CyrHUD_UI_Time:SetText(time)
-    CyrHUD_UI_AD:SetText("+" .. GetCampaignAlliancePotentialScore(cID, ALLIANCE_ALDMERI_DOMINION))
-    CyrHUD_UI_DC:SetText("+" .. GetCampaignAlliancePotentialScore(cID, ALLIANCE_DAGGERFALL_COVENANT))
-    CyrHUD_UI_EP:SetText("+" ..  GetCampaignAlliancePotentialScore(cID, ALLIANCE_EBONHEART_PACT))
-end
-
-----------------------------------------------
 -- Events
 ----------------------------------------------
 function CyrHUD.eventAttackChange(_, keepID, battlegroundContext, underAttack)
@@ -167,12 +155,12 @@ end
 CyrHUD.visible = false
 function CyrHUD:init()
     local _, pt, relTo, relPt = CyrHUD_UI:GetAnchor()
-    CyrHUD_UI:ClearAnchors()
-    CyrHUD_UI:SetAnchor(pt, relTo, CyrHUD.cfg.anchPoint or relPt, CyrHUD.cfg.xoff, CyrHUD.cfg.yoff)
+    self.ui:ClearAnchors()
+    self.ui:SetAnchor(pt, relTo, CyrHUD.cfg.anchPoint or relPt, CyrHUD.cfg.xoff, CyrHUD.cfg.yoff)

     --Init UI
     self:disableQuestTrackers()
-    CyrHUD_UI:SetHidden(false)
+    self.ui:SetHidden(false)


     --Get initial scan
@@ -190,7 +178,6 @@ function CyrHUD:init()
     end)
     EVENT_MANAGER:RegisterForUpdate("CyrHUDUIUpdate", 1000, function()
         self:printAll()
-        self:updateScore()
     end)
     EVENT_MANAGER:RegisterForEvent("CyrHUDAttackChange", EVENT_KEEP_UNDER_ATTACK_CHANGED, self.eventAttackChange)
     self.visible = true
@@ -244,6 +231,15 @@ SLASH_COMMANDS["/cyrhud"] = CyrHUD.toggle
 function CyrHUD.playerInit()
     local self = CyrHUD
     if not self.initLAM then
+        --Create UI
+        self.ui = WINDOW_MANAGER:CreateTopLevelWindow("CyrHUD_UI")
+        self.ui:SetWidth(280)
+        self.ui:SetResizeToFitDescendents(true)
+        self.ui:SetMouseEnabled(true)
+        self.ui:SetMovable(true)
+        self.ui:SetClampedToScreen(true)
+        self.ui:SetHandler("OnMoveStop", self.saveWindowPosition)
+        --Create settings menu
         local LAM = LibStub("LibAddonMenu-2.0")
         LAM:RegisterAddonPanel("CyrHUD-LAM", self.menuPanel)
         LAM:RegisterOptionControls("CyrHUD-LAM", self.menuOptions)
diff --git a/CyrHUD.txt b/CyrHUD.txt
index 4e07c99..d5e526c 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -28,4 +28,3 @@ classes/ScoringBar.lua
 CyrHUD.lua
 menu.lua
 bindings.xml
-CyrHUD.xml
diff --git a/CyrHUD.xml b/CyrHUD.xml
deleted file mode 100644
index 3a26609..0000000
--- a/CyrHUD.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<GuiXml>
-    <Controls>
-        <TopLevelControl name="CyrHUD_UI" mouseEnabled="true" movable="true"  clampedToScreen="true" hidden="true" >
-            <Dimensions x="280" y="30" />
-            <Anchor point="TOPRIGHT" offsetX="-10" offsetY="60" />
-
-            <OnMoveStop>
-                CyrHUD.saveWindowPosition( self )
-            </OnMoveStop>
-
-            <Controls>
-                <Label name="$(parent)_Time" font="ZoFontGameShadow" color="EEEEEE"
-                       wrapMode="ELLIPSIS" text="50m 30s" horizontalAlignment="RIGHT">
-                    <Anchor point="TOPLEFT" offsetX="10" />
-                </Label>
-
-                <Texture name="$(parent)_FlagDC" textureFile="/esoui/art/ava/ava_allianceflag_daggerfall.dds">
-                    <Dimensions x="20" y="40" />
-                    <Anchor point="TOPLEFT" offsetX="80" />
-                </Texture>
-
-                <Label name="$(parent)_DC" font="ZoFontGameShadow" color="688fb2"
-                       wrapMode="ELLIPSIS" text="" horizontalAlignment="CENTER">
-                    <Anchor point="TOPLEFT" offsetX="100" />
-                </Label>
-
-                <Texture name="$(parent)_FlagEP" textureFile="/esoui/art/ava/ava_allianceflag_ebonheart.dds">
-                    <Dimensions x="20" y="40" />
-                    <Anchor point="TOPLEFT" offsetX="150" />
-                </Texture>
-
-                <Label name="$(parent)_EP" font="ZoFontGameShadow" color="de5c4f"
-                       wrapMode="ELLIPSIS" text="" horizontalAlignment="CENTER">
-                    <Anchor point="TOPLEFT" offsetX="170" />
-                </Label>
-
-                <Texture name="$(parent)_FlagAD" textureFile="/esoui/art/ava/ava_allianceflag_aldmeri.dds">
-                    <Dimensions x="20" y="40" />
-                    <Anchor point="TOPLEFT" offsetX="220" />
-                </Texture>
-
-                <Label name="$(parent)_AD" font="ZoFontGameShadow" color="c3aa4a"
-                       wrapMode="ELLIPSIS" text="" horizontalAlignment="LEFT" opacity="0.85">
-                    <Anchor point="TOPLEFT" offsetX="240" />
-                </Label>
-<!--
-                <Control name="CyrHUD_Label" virtual="true">
-                    <Backdrop name="$(parent)Main" centerColor="0000005A" edgeColor="00000000">
-                        <Anchor point="TOPLEFT" relativeTo="$(parent)" />
-                        <Dimensions x="280" y="35" />
-                    </Backdrop>
-
-                    <Texture name="$(parent)Icon" layer="OVERLAY">
-                        <Dimensions x="40" y="40" />
-                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$(parent)Main" offsetX="35" offsetY="5" />
-                    </Texture>
-                </Control>
--->
-            </Controls>
-        </TopLevelControl>
-    </Controls>
-</GuiXml>
\ No newline at end of file