Fix issue with campaign population bars updating
Scott Yeskie [07-25-16 - 20:51]
Fix issue with campaign population bars updating
QueryCampaignSelectionData() needs to be called to update the population bars.
Setting to call every 3 minutes.
diff --git a/classes/ScoringBar.lua b/classes/ScoringBar.lua
index 50e4c8b..18bb508 100644
--- a/classes/ScoringBar.lua
+++ b/classes/ScoringBar.lua
@@ -37,31 +37,45 @@ function CyrHUD.ScoringBar.new(campaign)
end
function bar:determineCampaignIndex()
- d("Calling findCampaignIndex for " .. self.campaign)
+ --d("Calling findCampaignIndex for " .. self.campaign)
self.campaignIndex = 0
for i = 1, GetNumSelectionCampaigns() do
local id = GetSelectionCampaignId(i)
if self.campaign == id then
- d("Result: " .. i)
+ --d("Result: " .. i)
self.campaignIndex = i
end
end
if self.campaignIndex == 0 then
- d("No campaign index. Running QueryCampaignSelectionData()")
+ --d("No campaign index. Running QueryCampaignSelectionData()")
QueryCampaignSelectionData()
zo_callLater(function() self:determineCampaignIndex() end, 2000)
end
end
+local slowUpdate = 0
function bar:update()
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.campaignIndex, AD)
- self.dc_pop = GetSelectionCampaignPopulationData(self.campaignIndex, DC)
- self.ep_pop = GetSelectionCampaignPopulationData(self.campaignIndex, EP)
+ if CyrHUD.cfg.showPopBars then
+ -- Main update is every 5s
+ -- Only refresh population bar data once every 3min
+ slowUpdate = slowUpdate + 1
+ if slowUpdate == 36 then
+ QueryCampaignSelectionData()
+ slowUpdate = 0
+ end
+
+ -- Delayed 1 cycle so the query data has time to come into effect
+ if slowUpdate == 1 then
+ self.ad_pop = GetSelectionCampaignPopulationData(self.campaignIndex, AD)
+ self.dc_pop = GetSelectionCampaignPopulationData(self.campaignIndex, DC)
+ self.ep_pop = GetSelectionCampaignPopulationData(self.campaignIndex, EP)
+ end
+ end
end
local TEXT_TIME = "txt4"