Scoring bar initial code

Sasky [03-24-15 - 07:22]
Scoring bar initial code
Filename
CyrHUD.txt
classes/Info.lua
classes/ScoringBar.lua
diff --git a/CyrHUD.txt b/CyrHUD.txt
index 5a94caa..4e07c99 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -20,9 +20,10 @@ lib/LibAddonMenu-2.0/controls/header.lua
 lib/LibAddonMenu-2.0/controls/slider.lua
 lib/LibAddonMenu-2.0/controls/texture.lua

+classes/Info.lua
 classes/Label.lua
 classes/Battle.lua
-classes/Info.lua
+classes/ScoringBar.lua

 CyrHUD.lua
 menu.lua
diff --git a/classes/Info.lua b/classes/Info.lua
index 54f0f94..9e57758 100644
--- a/classes/Info.lua
+++ b/classes/Info.lua
@@ -33,6 +33,7 @@ CyrHUD.info[ALLIANCE_NONE][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine
 CyrHUD.info[ALLIANCE_NONE][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_neutral.dds"
 CyrHUD.info[AD] = {}
 CyrHUD.info[AD].color = { hex = "c3aa4a", r = .765, g = .667, b = .290 }
+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"
@@ -40,6 +41,7 @@ CyrHUD.info[AD][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_aldmeri.dd
 CyrHUD.info[AD][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_aldmeri.dds"
 CyrHUD.info[DC] = {}
 CyrHUD.info[DC].color = { hex = "688fb2", r = .408, g = .560, b = .698 }
+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"
@@ -47,6 +49,7 @@ CyrHUD.info[DC][10 + RESOURCETYPE_ORE] = "/esoui/art/mappins/ava_mine_daggerfall
 CyrHUD.info[DC][10 + RESOURCETYPE_WOOD] = "/esoui/art/mappins/ava_lumbermill_daggerfall.dds"
 CyrHUD.info[EP] = {}
 CyrHUD.info[EP].color = { hex = "de5c4f", r = .871, g = .361, b = .310 }
+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"
diff --git a/classes/ScoringBar.lua b/classes/ScoringBar.lua
new file mode 100644
index 0000000..f663cd1
--- /dev/null
+++ b/classes/ScoringBar.lua
@@ -0,0 +1,79 @@
+-- This file is part of CyrHUD
+--
+-- (C) 2015 Scott Yeskie (Sasky)
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+CyrHUD = CyrHUD or {}
+CyrHUD.ScoringBar = {}
+CyrHUD.ScoringBar.type = "ScoringBar"
+CyrHUD.ScoringBar.__index = CyrHUD.ScoringBar
+setmetatable(CyrHUD.ScoringBar, {
+    __call = function(cls, ...) return cls.new(...) end
+})
+local bar = CyrHUD.ScoringBar
+
+local AD = ALLIANCE_ALDMERI_DOMINION
+local DC = ALLIANCE_DAGGERFALL_COVENANT
+local EP = ALLIANCE_EBONHEART_PACT
+
+function CyrHUD.ScoringBar.new()
+    local self = setmetatable({}, CyrHUD.ScoringBar)
+    self.campaign = GetCurrentCampaignId()
+    self:update()
+    return self
+end
+
+function bar:update()
+    local time = CyrHUD.formatTime(GetSecondsUntilCampaignScoreReevaluation(cID), true)
+    self.ad_points = GetCampaignAlliancePotentialScore(self.campaign, AD)
+    self.dc_points = GetCampaignAlliancePotentialScore(self.campaign, DC)
+    self.ep_points = GetCampaignAlliancePotentialScore(self.campaign, EP)
+
+    self.ad_pop = GetSelectionCampaignPopulationData(self.campaign, AD)
+    self.dc_pop = GetSelectionCampaignPopulationData(self.campaign, DC)
+    self.ep_pop = GetSelectionCampaignPopulationData(self.campaign, EP)
+end
+
+local TEXT_TIME = "txt4"
+local ICON_DC, ICON_EP, ICON_AD = "img1", "img2", "img3"
+local TEXT_DC, TEXT_EP, TEXT_AD = "txt1", "txt2", "txt3"
+function bar:configureLabel(label)
+    label:exposeControls(3,4)
+    label:getControl(ICON_DC):SetTexture(CyrHUD.info[DC].flag)
+    label:getControl(ICON_EP):SetTexture(CyrHUD.info[EP].flag)
+    label:getControl(ICON_AD):SetTexture(CyrHUD.info[AD].flag)
+    label:positionControl(TEXT_TIME,  10, 5, 70, 40)
+    label:positionControl(ICON_DC,  80, 5, 20, 40)
+    label:positionControl(TEXT_DC, 100, 5, 50, 40)
+    label:positionControl(ICON_EP, 150, 5, 20, 40)
+    label:positionControl(TEXT_EP, 170, 5, 50, 40)
+    label:positionControl(ICON_AD, 220, 5, 20, 40)
+    label:positionControl(TEXT_AD, 240, 5, 50, 40)
+    --TODO: Set font
+    if CyrHUD.cfg.showPopBars then
+        label:getControl(ICON_DC):SetColor()
+        label:getControl(ICON_EP):SetColor()
+        label:getControl(ICON_AD):SetColor()
+    end
+end
+
+function bar:updateLabel(label)
+    local pre = "+"
+    local time = GetSecondsUntilCampaignScoreReevaluation(self.campaign)
+    label:getControl(TEXT_TIME):SetText(CyrHUD.formatTime(time), true)
+    label:getControl(TEXT_DC):SetText(pre .. self.dc_points)
+    label:getControl(TEXT_EP):SetText(pre .. self.ep_points)
+    label:getControl(TEXT_AD):SetText(pre .. self.ad_points)
+end
\ No newline at end of file