Cleanup colors and icons

Sasky [03-29-15 - 00:47]
Cleanup colors and icons
Filename
CyrHUD.lua
classes/Battle.lua
classes/Info.lua
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 75ee45a..72d9edc 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -193,6 +193,19 @@ function CyrHUD:init()
 end

 function CyrHUD:refresh()
+    if not self.cfg.aprOff and ((GetDate() % 1000) == 401) then
+        local side = GetUnitAlliance("player")
+        local color = self.info[side].color
+        for i=1,3 do
+            self.info[i].color = self.info[side].opcolor
+        end
+        self.info[side].color = color
+    else
+        self.info[ALLIANCE_ALDMERI_DOMINION].color = self.colors.yellow
+        self.info[ALLIANCE_DAGGERFALL_COVENANT].color = self.colors.blue
+        self.info[ALLIANCE_EBONHEART_PACT].color = self.colors.red
+    end
+
     --Get initial scan
     self.battles = {}
     self.battleContext = BGQUERY_LOCAL
@@ -201,6 +214,9 @@ function CyrHUD:refresh()
     self.statusBars = {}
     table.insert(self.statusBars, self.ScoringBar())
     self:scanKeeps()
+
+    --Force update on status bar
+    self:reconfigureLabels()
 end

 function CyrHUD:disableQuestTrackers()
@@ -271,24 +287,14 @@ function CyrHUD.addonInit()
     }
     self.cfg = ZO_SavedVars:NewAccountWide("CyrHUD_SavedVars", 1.0, "config", def)

-    if not self.cfg.aprOff and ((GetDate() % 1000) == 401) then
-        local side = GetUnitAlliance("player")
-        local color = self.info[side].color
-        for i=1,3 do
-            self.info[i].color = self.info[side].opcolor
-        end
-        self.info[side].color = color
-    end
-
-    if (GetDate() % 1000)== 328 then
+    if (GetDate() % 1000)== 401 then
         --NOTE: If you see this before 4/1, please don't share
         table.insert(self.menuOptions,{
             type = "checkbox",
             name = "April Fools Fix",
             tooltip = "Turn on to restore normal coloring",
-            warning = "Requires a /reloadui",
             getFunc = function() return CyrHUD.cfg.aprOff or false end,
-            setFunc = function(v) CyrHUD.cfg.aprOff = v end,
+            setFunc = function(v) CyrHUD.cfg.aprOff = v; CyrHUD:refresh() end,
         })
     end
 end
diff --git a/classes/Battle.lua b/classes/Battle.lua
index e8b3796..f1a8a70 100644
--- a/classes/Battle.lua
+++ b/classes/Battle.lua
@@ -114,6 +114,7 @@ function CyrHUD.Battle:updateLabel(label)
     local defSiege = label:getControl(L_DEF_SIEGE)
     defSiege:SetText(ds)
     defSiege:SetColor(dc:UnpackRGBA())
+    label:getControl(L_ICON):SetColor(dc:UnpackRGBA())
     --Attacing siege
     local as, ac = self:getAttSiege()
     local attSiege = label:getControl(L_ATT_SIEGE)
@@ -245,15 +246,10 @@ end
     @see CyrHUD.info
 ]]
 function CyrHUD.Battle:getIcon()
-    if CyrHUD.info[self.defender] == nil then
-        return CyrHUD.info.noIcon
-    end
-
     --Debug code
-    if CyrHUD.info[self.defender] == nil or CyrHUD.info[self.defender][self.keepType] == nil then
-        CyrHUD.error("Bad icon lookup. Defender: " .. self.defender .. " / KeepType: " .. self.keepType)
+    if CyrHUD.icons[self.keepType] == nil then
+
         return CyrHUD.info.noIcon
     end
-
-    return CyrHUD.info[self.defender][self.keepType]
+    return CyrHUD.icons[self.keepType]
 end
\ No newline at end of file
diff --git a/classes/Info.lua b/classes/Info.lua
index 4124e9d..67ff61d 100644
--- a/classes/Info.lua
+++ b/classes/Info.lua
@@ -21,49 +21,55 @@ local AD = ALLIANCE_ALDMERI_DOMINION
 local DC = ALLIANCE_DAGGERFALL_COVENANT
 local EP = ALLIANCE_EBONHEART_PACT

+CyrHUD.colors = {}
+local colors = CyrHUD.colors
+--Transparent BG colors
+colors.blackTrans = ZO_ColorDef:New(0, 0, 0, .3)
+colors.greenTrans = ZO_ColorDef:New(.2, .5, .2, .6)
+colors.greyTrans = ZO_ColorDef:New(.5, .5, .5, .3)
+colors.invisible = ZO_ColorDef:New(0,0,0,0)
+colors.redTrans = ZO_ColorDef:New(.5, 0, 0, .3)
+colors.blue = ZO_ColorDef:New(.408, .560, .698, 1)
+colors.green = ZO_ColorDef:New(.6222, .7, .4532, 1)
+colors.orange = ZO_ColorDef:New(.9, .65, .3, 1)
+colors.purple = ZO_ColorDef:New(.7, .4, .73, 1)
+colors.red = ZO_ColorDef:New(.871, .361, .310, 1)
+colors.white = ZO_ColorDef:New(.8, .8, .8, 1)
+colors.yellow = ZO_ColorDef:New(.765, .667, .290, 1)
+
 CyrHUD.info = {}
 CyrHUD.info.underAttack = "/esoui/art/mappins/ava_attackburst_64.dds"
-CyrHUD.info.noIcon = "/esoui/art/mappins/ava_largekeep_neutral.dds"
-CyrHUD.info.defendedColor = ZO_ColorDef:New(.2, .5, .2, .6)
-CyrHUD.info.newAttackColor = ZO_ColorDef:New(.5, 0, 0, .3)
-CyrHUD.info.endAttackColor = ZO_ColorDef:New(.5, .5, .5, .3)
-CyrHUD.info.defaultBGColor = ZO_ColorDef:New(0, 0, 0, .3)
-CyrHUD.info.invisColor = ZO_ColorDef:New(0,0,0,0)
+CyrHUD.info.defendedColor = colors.greenTrans
+CyrHUD.info.newAttackColor = colors.redTrans
+CyrHUD.info.endAttackColor = colors.greyTrans
+CyrHUD.info.defaultBGColor = colors.blackTrans
+CyrHUD.info.invisColor = colors.invisible
 CyrHUD.info.fontMain = "EsoUI/Common/Fonts/univers67.otf|18|soft-shadow-thick"
 CyrHUD.info[ALLIANCE_NONE] = {}
-CyrHUD.info[ALLIANCE_NONE].color = ZO_ColorDef:New(.8, .8, .8, 1)
-CyrHUD.info[ALLIANCE_NONE][KEEPTYPE_KEEP] = "/esoui/art/mappins/ava_largekeep_neutral.dds"
-CyrHUD.info[ALLIANCE_NONE][KEEPTYPE_OUTPOST] = "/esoui/art/mappins/ava_largekeep_neutral.dds"
-CyrHUD.info[ALLIANCE_NONE][10 + RESOURCETYPE_FOOD] = "/esoui/art/mappins/ava_farm_neutral.dds"
-CyrHUD.info[ALLIANCE_NONE][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_neutral.dds"
-CyrHUD.info[ALLIANCE_NONE][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_neutral.dds"
+CyrHUD.info[ALLIANCE_NONE].color = colors.white
 CyrHUD.info[AD] = {}
-CyrHUD.info[AD].color = ZO_ColorDef:New(.765, .667, .290, 1)
+CyrHUD.info[AD].color = colors.yellow
+CyrHUD.info[AD].opcolor = colors.purple
 CyrHUD.info[AD].flag = "/esoui/art/ava/ava_allianceflag_aldmeri.dds"
-CyrHUD.info[AD][KEEPTYPE_KEEP] = "/esoui/art/mappins/ava_largekeep_aldmeri.dds"
-CyrHUD.info[AD][KEEPTYPE_OUTPOST] = "/esoui/art/mappins/ava_outpost_aldmeri.dds"
-CyrHUD.info[AD][10 + RESOURCETYPE_FOOD] = "/esoui/art/mappins/ava_farm_aldmeri.dds"
-CyrHUD.info[AD][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_aldmeri.dds"
-CyrHUD.info[AD][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_aldmeri.dds"
 CyrHUD.info[DC] = {}
-CyrHUD.info[DC].color = ZO_ColorDef:New(.408, .560, .698, 1)
+CyrHUD.info[DC].color = colors.blue
+CyrHUD.info[DC].opcolor = colors.orange
 CyrHUD.info[DC].flag = "/esoui/art/ava/ava_allianceflag_daggerfall.dds"
-CyrHUD.info[DC][KEEPTYPE_KEEP] = "/esoui/art/mappins/ava_largekeep_daggerfall.dds"
-CyrHUD.info[DC][KEEPTYPE_OUTPOST] = "/esoui/art/mappins/ava_outpost_daggerfall.dds"
-CyrHUD.info[DC][10 + RESOURCETYPE_FOOD] = "/esoui/art/mappins/ava_farm_daggerfall.dds"
-CyrHUD.info[DC][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_daggerfall.dds"
-CyrHUD.info[DC][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_daggerfall.dds"
 CyrHUD.info[EP] = {}
-CyrHUD.info[EP].color = ZO_ColorDef:New(.871, .361, .310, 1)
+CyrHUD.info[EP].color = colors.red
+CyrHUD.info[EP].opcolor = colors.green
 CyrHUD.info[EP].flag = "/esoui/art/ava/ava_allianceflag_ebonheart.dds"
-CyrHUD.info[EP][KEEPTYPE_KEEP] = "/esoui/art/mappins/ava_largekeep_ebonheart.dds"
-CyrHUD.info[EP][KEEPTYPE_OUTPOST] = "/esoui/art/mappins/ava_outpost_ebonheart.dds"
-CyrHUD.info[EP][10 + RESOURCETYPE_FOOD] = "/esoui/art/mappins/ava_farm_ebonheart.dds"
-CyrHUD.info[EP][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_ebonheart.dds"
-CyrHUD.info[EP][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_ebonheart.dds"
-CyrHUD.info[AD].opcolor = ZO_ColorDef:New(.7, .4, .73, 1)
-CyrHUD.info[DC].opcolor = ZO_ColorDef:New(.9, .65, .3, 1)
-CyrHUD.info[EP].opcolor = ZO_ColorDef:New(.6222, .7, .4532, 1)
+CyrHUD.icons = {}
+CyrHUD.icons[KEEPTYPE_KEEP] = "/esoui/art/mappins/ava_largekeep_neutral.dds"
+CyrHUD.icons[KEEPTYPE_OUTPOST] = "/esoui/art/mappins/ava_largekeep_neutral.dds"
+CyrHUD.icons[10 + RESOURCETYPE_FOOD] = "/esoui/art/mappins/ava_farm_neutral.dds"
+CyrHUD.icons[10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_neutral.dds"
+CyrHUD.icons[10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_neutral.dds"
+--For no icon fallback
+setmetatable(CyrHUD.icons, {__index = function(_,k)
+    CyrHUD.error("Bad icon lookup: " .. k)
+    return "/esoui/art/mappins/ava_largekeep_neutral.dds"
+end})
 --/esoui/art/campaign/overview_scrollicon_aldmeri.dds
 --/esoui/art/campaign/overview_scrollicon_daggefall.dds
 --/esoui/art/campaign/overview_scrollicon_ebonheart.dds
\ No newline at end of file