Add resources and outposts

Scott Yeskie [06-05-14 - 06:50]
Add resources and outposts
Filename
CyrHUD.lua
classes/Battle.lua
classes/Info.lua
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 523db12..dcccc3d 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -48,7 +48,7 @@ end
 -- Events
 ----------------------------------------------
 function CyrHUD.eventAttackChange(_, keepID, battlegroundContext, underAttack)
-    if underAttack and GetKeepType(keepID) == KEEPTYPE_KEEP then
+    if underAttack then
         CyrHUD.add(keepID)
     elseif CyrHUD.battles[keepID] ~= nil then
         CyrHUD.battles[keepID]:update()
@@ -73,10 +73,16 @@ CyrHUD.createEntry = function()
     entry.main:SetCenterColor( 0, 0, 0, .3 )
     entry.main:SetEdgeColor( 0, 0, 0, 0 )

-    --TODO - set entry.main as root visual
     entry.icon = WINDOW_MANAGER:CreateControl(entryName .. "icon", entry.main, CT_TEXTURE)
     entry.icon:SetAnchor(TOPLEFT, entry.main, TOPLEFT, -2, -2)
     entry.icon:SetDimensions(40,40)
+    entry.icon:SetDrawLayer(2)
+
+    entry.ua = WINDOW_MANAGER:CreateControl(entryName .. "ua", entry.main, CT_TEXTURE)
+    entry.ua:SetAnchor(TOPLEFT, entry.main, TOPLEFT, -2, -2)
+    entry.ua:SetDimensions(40,40)
+    entry.ua:SetTexture("/esoui/art/mappins/ava_attackburst_64.dds")
+    entry.ua:SetDrawLayer(1)

     local fontMain = "EsoUI/Common/Fonts/univers67.otf|18|soft-shadow-thick"
     entry.name = WINDOW_MANAGER:CreateControl(entryName .. "name", entry.main, CT_LABEL)
@@ -137,6 +143,7 @@ CyrHUD.print = function(battle)
     entry.attSiege:SetColor(ac.r, ac.g, ac.b)
     local r,g,b,a = battle:getBGColor()
     entry.main:SetCenterColor(r,g,b,a)
+    entry.ua:SetHidden(not battle.keepUA)
 end

 CyrHUD.printAll = function()
@@ -151,7 +158,6 @@ end
 ----------------------------------------------
 CyrHUD.battles = {}
 CyrHUD.add = function(keepID)
-    --TODO: Need to resume battle if ends before fade
     if CyrHUD.battles[keepID] == nil then
         d("Adding " .. GetKeepName(keepID))
         CyrHUD.battles[keepID] = CyrHUD.Battle(keepID)
@@ -178,8 +184,7 @@ CyrHUD.updateAll = function()
     end
 end

---TODO: This should be called on init and alow rate (10-15s). Rest should be event based
---TODO: Add outposts and resources
+--TODO: Add outposts
 CyrHUD.scanKeeps = function()
     for i=3,20 do
         CyrHUD.checkAdd(i)
diff --git a/classes/Battle.lua b/classes/Battle.lua
index 2ceff71..d06776f 100644
--- a/classes/Battle.lua
+++ b/classes/Battle.lua
@@ -28,6 +28,14 @@ CyrHUD.Battle.new = function(keepID)
     self.keepID = keepID
     self.keepName = GetKeepName(keepID)
     self.keepType = GetKeepType(keepID)
+    if self.keepType == KEEPTYPE_RESOURCE then
+        self.keepType = 10 + GetKeepResourceType(keepID)
+        local name = self.keepName:gsub("Castle ","")
+        name = name:gsub("Fort ","")
+        name = name:gsub("Keep ","")
+        name = name:gsub("Lumber ","")
+        self.keepName = name
+    end
     self.siege = {}
     self:update()
     return self
@@ -146,9 +154,5 @@ end
     @see CyrHUD.info
 ]]
 function CyrHUD.Battle:getIcon()
-    if self.keepUA then
-        return CyrHUD.info[self.defender][self.keepType].iconua
-    else
-        return CyrHUD.info[self.defender][self.keepType].icon
-    end
+    return CyrHUD.info[self.defender][self.keepType]
 end
\ No newline at end of file
diff --git a/classes/Info.lua b/classes/Info.lua
index 3a3aad1..09504dc 100644
--- a/classes/Info.lua
+++ b/classes/Info.lua
@@ -9,28 +9,29 @@ if CyrHUD == nil then
     CyrHUD = {}
 end

+local AD = ALLIANCE_ALDMERI_DOMINION
+local DC = ALLIANCE_DAGGERFALL_COVENANT
+local EP = ALLIANCE_EBONHEART_PACT
+
 CyrHUD.info = {}
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION] = {}
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION].color = { hex = "B2B222", r = .698, g = .698, b = .133 }
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_KEEP] = {}
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_KEEP].icon = "/esoui/art/mappins/ava_largekeep_aldmeri.dds"
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_KEEP].iconua = "/esoui/art/mappins/ava_largekeep_aldmeri_underattack.dds"
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_OUTPOST] = {}
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_OUTPOST].icon = "/esoui/art/mappins/ava_outpost_aldmeri.dds"
-CyrHUD.info[ALLIANCE_ALDMERI_DOMINION][KEEPTYPE_OUTPOST].iconua = "/esoui/art/mappins/ava_outpost_aldmeri.dds"
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT] = {}
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT].color = { hex = "6666EE", r = .4, g = .4, b = .933 }
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_KEEP] = {}
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_KEEP].icon = "/esoui/art/mappins/ava_largekeep_daggerfall.dds"
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_KEEP].iconua = "/esoui/art/mappins/ava_largekeep_daggerfall_underattack.dds"
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_OUTPOST] = {}
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_OUTPOST].icon = "/esoui/art/mappins/ava_outpost_daggerfall.dds"
-CyrHUD.info[ALLIANCE_DAGGERFALL_COVENANT][KEEPTYPE_OUTPOST].iconua = "/esoui/art/mappins/ava_outpost_daggerfall.dds"
-CyrHUD.info[ALLIANCE_EBONHEART_PACT] = {}
-CyrHUD.info[ALLIANCE_EBONHEART_PACT].color = { hex = "B22222", r = .698, g = .133, b = .133 }
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_KEEP] = {}
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_KEEP].icon = "/esoui/art/mappins/ava_largekeep_ebonheart.dds"
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_KEEP].iconua = "/esoui/art/mappins/ava_largekeep_ebonheart_underattack.dds"
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_OUTPOST] = {}
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_OUTPOST].icon = "/esoui/art/mappins/ava_outpost_ebonheart.dds"
-CyrHUD.info[ALLIANCE_EBONHEART_PACT][KEEPTYPE_OUTPOST].iconua = "/esoui/art/mappins/ava_outpost_ebonheart.dds"
+CyrHUD.info[AD] = {}
+CyrHUD.info[AD].color = { hex = "B2B222", r = .698, g = .698, b = .133 }
+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/ava/ava_keepstatus_icon_food_aldmeri.dds"
+CyrHUD.info[AD][10 + RESOURCETYPE_ORE] = "/esoui/art/ava/ava_keepstatus_icon_ore_aldmeri.dds"
+CyrHUD.info[AD][10 + RESOURCETYPE_WOOD] = "/esoui/art/ava/ava_keepstatus_icon_wood_aldmeri.dds"
+CyrHUD.info[DC] = {}
+CyrHUD.info[DC].color = { hex = "6666EE", r = .4, g = .4, b = .933 }
+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/ava/ava_keepstatus_icon_food_daggerfall.dds"
+CyrHUD.info[DC][10 + RESOURCETYPE_ORE] = "/esoui/art/ava/ava_keepstatus_icon_ore_daggerfall.dds"
+CyrHUD.info[DC][10 + RESOURCETYPE_WOOD] = "/esoui/art/ava/ava_keepstatus_icon_wood_daggerfall.dds"
+CyrHUD.info[EP] = {}
+CyrHUD.info[EP].color = { hex = "B22222", r = .698, g = .133, b = .133 }
+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/ava/ava_keepstatus_icon_food_ebonheart.dds"
+CyrHUD.info[EP][10 + RESOURCETYPE_ORE] = "/esoui/art/ava/ava_keepstatus_icon_ore_ebonheart.dds"
+CyrHUD.info[EP][10 + RESOURCETYPE_WOOD] = "/esoui/art/ava/ava_keepstatus_icon_wood_ebonheart.dds"