Skip to content

Commit

Permalink
workaround for C_AreaPoiInfo.GetAreaPOISecondsLeft not returning a ti…
Browse files Browse the repository at this point in the history
…me anymore
  • Loading branch information
TheKrowi committed Aug 18, 2022
1 parent 0c861f0 commit 812afed
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## 39.2 - 2022-08-xx
### Fixed
- Workaround untill Blizzard fixes C_AreaPoiInfo.GetAreaPOISecondsLeft not returning seconds left anymore; handled by adding active events and showing no time data

## 39.1 - 2022-08-17
### Fixed
- Achievements that were never obtainable or only once (Realm First!) should be flagged correct again
Expand Down
5 changes: 4 additions & 1 deletion Changelogs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
- Added translations for all missing texts in English, German and Chinese (Simplified)

### Fixed (39.1)
- Achievements that were never obtainable or only once (Realm First!) should be flagged correct again
- Achievements that were never obtainable or only once (Realm First!) should be flagged correct again

### Fixed (39.2)
- Workaround untill Blizzard fixes C_AreaPoiInfo.GetAreaPOISecondsLeft not returning seconds left anymore; handled by adding active events and showing no time data
41 changes: 10 additions & 31 deletions Data/EventData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,47 +126,34 @@ function eventData.GetActiveWorldEvents()
end

function GetSavedWorldEvents(activeWorldEvents, currentDate)
for id, event in next, EventDetails.WorldEvents do
local deltaT = math.floor((event.EndTime - currentDate) / (3600 * 24));
-- diagnostics.Debug(id .. " - " .. event.Name .. " - " .. tostring(deltaT));
if deltaT < 0 or not addon.Options.db.EventReminders.WorldEvents[id] then
for id, _ in next, EventDetails.WorldEvents do
local event = data.WorldEvents[id];
local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(event.MapID, event.ID);
if poiInfo == nil or not addon.Options.db.EventReminders.WorldEvents[id] then
EventDetails.WorldEvents[id] = nil;
end
end

for id, event in next, data.WorldEvents do
if EventDetails.WorldEvents[id] then
event.EventDetails = EventDetails.WorldEvents[id];
-- diagnostics.Debug("Existing event active:" .. event.ID .. " - " .. event.EventDetails.Name .. " - " .. tostring(deltaT));
tinsert(activeWorldEvents, event);
end
end
end

function GetNewWorldEvents(activeWorldEvents)
-- print("GetNewWorldEvents(activeWorldEvents)")
for _, event in next, data.WorldEvents do
-- print(event.Id, event.ID, event.Icon, event.Name, event.MapID, event.TotalDuration);
if event.EventDetails == nil and addon.Options.db.EventReminders.WorldEvents[event.ID] then
if event.EventDetails == nil and addon.Options.db.EventReminders.WorldEvents[event.Id] then
local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(event.MapID, event.ID);
-- print(poiInfo);
if poiInfo then -- The event is active
local secondsLeft = C_AreaPoiInfo.GetAreaPOISecondsLeft(event.ID);
-- diagnostics.Debug(secondsLeft);
if secondsLeft == nil or secondsLeft == 0 then
-- print("problem", event.Id)
return; -- C_AreaPoiInfo is not yet properly loaded
local startTime, endTime;
if secondsLeft ~= nil and secondsLeft ~= 0 then
startTime, endTime = GetStartAndEndTime(secondsLeft, event.TotalDuration or 0);
end

local startTime, endTime = GetStartAndEndTime(secondsLeft, event.TotalDuration or 0);
-- diagnostics.Debug(startTime);
-- diagnostics.Debug(endTime);

event.EventDetails = {StartTime = startTime, EndTime = endTime, Name = event.Name};
-- diagnostics.Debug(event.ID .. " - " .. event.EventDetails.Name .. " - " ..
-- date("%Y/%m/%d %H:%M", event.EventDetails.StartTime) .. " - " .. date("%Y/%m/%d %H:%M", event.EventDetails.EndTime));

-- diagnostics.Debug("New event active:" .. event.ID .. " - " .. event.EventDetails.Name .. " - " .. tostring(deltaT));
EventDetails.WorldEvents[event.ID] = event.EventDetails;
tinsert(activeWorldEvents, event);
else
Expand Down Expand Up @@ -211,29 +198,21 @@ end

function GetNewWidgetEvents(activeWidgetEvents)
for _, event in next, data.WidgetEvents do
if event.EventDetails == nil and addon.Options.db.EventReminders.WidgetEvents[event.ID] then
local widgetInfo = C_UIWidgetManager.GetTextWithStateWidgetVisualizationInfo(event.ID);
if event.EventDetails == nil and addon.Options.db.EventReminders.WidgetEvents[event.Id] then
local widgetInfo = C_UIWidgetManager.GetTextWithStateWidgetVisualizationInfo(event.Id);
if widgetInfo and widgetInfo.shownState == 1 then -- The event is active
local secondsLeft = event.TotalDuration;
if secondsLeft == 604800 then
secondsLeft = C_DateAndTime.GetSecondsUntilWeeklyReset();
else
secondsLeft = nil;
end
-- diagnostics.Debug(secondsLeft);
if secondsLeft == nil or secondsLeft == 0 then
return; -- Widget time not yet supported
end

local startTime, endTime = GetStartAndEndTime(secondsLeft, event.TotalDuration or 0);
-- diagnostics.Debug(startTime);
-- diagnostics.Debug(endTime);

event.EventDetails = {StartTime = startTime, EndTime = endTime, Name = event.Name};
-- diagnostics.Debug(event.ID .. " - " .. event.EventDetails.Name .. " - " ..
-- date("%Y/%m/%d %H:%M", event.EventDetails.StartTime) .. " - " .. date("%Y/%m/%d %H:%M", event.EventDetails.EndTime));

-- diagnostics.Debug("New event active:" .. event.ID .. " - " .. event.EventDetails.Name .. " - " .. tostring(deltaT));
EventDetails.WidgetEvents[event.ID] = event.EventDetails;
tinsert(activeWidgetEvents, event);
else
Expand Down
5 changes: 5 additions & 0 deletions GUI/Misc/AlertFrame/AlertFrameMixin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ KrowiAF_AlertFrameMixin = {};
function KrowiAF_AlertFrameMixin:UpdateEventRuntime()
local line1, line2, timeLeft;

if self.Event.EventDetails.StartTime == nil or self.Event.EventDetails.EndTime == nil then
self.Unlocked:SetText(addon.L["No time data available"]);
return;
end

if addon.Options.db.EventReminders.TimeDisplay.Line1 == 3 or addon.Options.db.EventReminders.TimeDisplay.Line2 == 4 then -- Time Left
local secondsLeft = self.Event.EventDetails.EndTime - time();
local days = floor(secondsLeft / 86400);
Expand Down
9 changes: 8 additions & 1 deletion GUI/Misc/SideButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ end

local function OnShow(self, otherButtons)
self:UpdateEventRuntime();
if self.Event.EventDetails.EndTime - time() < 0 then -- Event finished so remove button and reorder rest
local eventElapsed;
if self.Event.MapID then -- Handle the world events different, elapsed if not visible on the map
local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(self.Event.MapID, self.Event.Id);
eventElapsed = poiInfo == nil;
else
eventElapsed = self.Event.EventDetails.EndTime - time() < 0;
end
if eventElapsed then -- Event finished so remove button and reorder rest
for i = 1, #otherButtons, 1 do
if otherButtons[i].Event.ID == self.Event.ID then -- Found this button
if i == 1 and i + 1 <= #otherButtons then -- Button is the 1st and there are more
Expand Down
2 changes: 1 addition & 1 deletion Krowi_AchievementFilter.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 90207
## Title: Krowi's |cFF1D92C2Achievement Filter|r
## Version: 39.1
## Version: 39.2-alpha1
## Author: Krowi-Frostmane EU
## SavedVariables: Options, SavedData, Filters, EventDetails, Test
## Notes: Filters your achievements.
Expand Down
2 changes: 1 addition & 1 deletion Krowi_AchievementFilter_Wrath.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 30400
## Title: Krowi's |cFF1D92C2Achievement Filter|r
## Version: 39.1
## Version: 39.2-alpha1
## Author: Krowi-Frostmane EU
## SavedVariables: Options, SavedData, Filters, EventDetails, Test
## Notes: Filters your achievements.
Expand Down

0 comments on commit 812afed

Please sign in to comment.