Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Mar 10, 2024
2 parents 7bdb876 + b1d2b42 commit 845f716
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 43 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## Version 100205.03

### Action Bars

- Reworked the instance lockout tooltip. Instances and world bosses are now grouped by the lockout expiration time.
Instance names and difficulties are also properly sorted. This should greatly increase its readability.

![Imgur](https://i.imgur.com/KTfGHNU.png)

## Version 100205.02

- Fixed an issue where the options sub-addon wouldn't load.
Expand Down
7 changes: 3 additions & 4 deletions ls_UI/core/changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ local _G = getfenv(0)

-- Mine
E.CHANGELOG = [[
- Fixed an issue where the options sub-addon wouldn't load.
### Action Bars
### Tooltips
- Fixed an issue where unit tooltips would get stuck on the screen if the shift key was pressed.
- Reworked the instance lockout tooltip. Instances and world bosses are now grouped by the lockout expiration time.
Instance names and difficulties are also properly sorted. This should greatly increase its readability.
]]
1 change: 0 additions & 1 deletion ls_UI/locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ L["TARGET"] = _G.TARGET
L["TOTAL"] = _G.TOTAL
L["UNIT_FRAME"] = _G.UNITFRAME_LABEL
L["UNKNOWN"] = _G.UNKNOWN
L["WORLD_BOSS"] = _G.RAID_INFO_WORLD_BOSS
L["ZONE"] = _G.ZONE

-- Require translation
Expand Down
2 changes: 1 addition & 1 deletion ls_UI/ls_UI.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 100205
## Author: lightspark
## Version: 100205.02
## Version: 100205.03
## Title: LS: |cff1a9fc0UI|r
## Notes: Yet another UI, but this one is a bit special...
## IconTexture: Interface\AddOns\ls_UI\assets\logo-64
Expand Down
152 changes: 115 additions & 37 deletions ls_UI/modules/bars/micromenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local MODULE = P:GetModule("Bars")
-- Lua
local _G = getfenv(0)
local hooksecurefunc = _G.hooksecurefunc
local ipairs = _G.ipairs
local m_abs = _G.math.abs
local next = _G.next
local select = _G.select
local t_insert = _G.table.insert
Expand Down Expand Up @@ -654,53 +656,48 @@ end

local ej_button_proto = {}
do
function ej_button_proto:OnEnter()
button_proto.OnEnter(self)
local isInfoRequested = false

if self:IsEnabled() then
RequestRaidInfo()
local lockouts = {}
local instanceNames = {}
local instanceResets = {}

local savedInstances = GetNumSavedInstances()
local savedWorldBosses = GetNumSavedWorldBosses()
local EXPIRATION_FORMAT = _G.RAID_INSTANCE_EXPIRES .. ":"
local WORLD_BOSS = _G.RAID_INFO_WORLD_BOSS
local WORLD_BOSS_ID = 172
local WORLD_BOSS_PROGRESS = "1 / 1"

if savedInstances + savedWorldBosses == 0 then return end
local function difficultySortFunc(a, b)
return a[1] < b[1]
end

local instanceName, instanceReset, difficultyName, numEncounters, encounterProgress
local gray = C.db.global.colors.gray
local red = C.db.global.colors.red
local color
local hasTitle
function ej_button_proto:OnEnter()
button_proto.OnEnter(self)

for i = 1, savedInstances + savedWorldBosses do
if i <= savedInstances then
instanceName, _, instanceReset, _, _, _, _, _, _, difficultyName, numEncounters, encounterProgress = GetSavedInstanceInfo(i)
if self:IsEnabled() then
if not isInfoRequested then
RequestRaidInfo()

if instanceReset > 0 then
if not hasTitle then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(L["RAID_INFO_COLON"])
isInfoRequested = true
end

hasTitle = true
end
local gray = C.db.global.colors.gray

color = encounterProgress == numEncounters and red or C.db.global.colors.green
for _, instanceReset in next, instanceResets do
GameTooltip:AddLine(" ")
GameTooltip:AddLine(EXPIRATION_FORMAT:format(SecondsToTime(instanceReset, true, nil, 3)))

GameTooltip:AddDoubleLine(instanceName, encounterProgress .. " / " .. numEncounters, 1, 1, 1, color.r, color.g, color.b)
GameTooltip:AddDoubleLine(difficultyName, SecondsToTime(instanceReset, true, nil, 3), gray.r, gray.g, gray.b, gray.r, gray.g, gray.b)
end
else
instanceName, _, instanceReset = GetSavedWorldBossInfo(i - savedInstances)
for _, instanceName in ipairs(instanceNames) do
local resetData = lockouts[instanceReset][instanceName]
if resetData then
GameTooltip:AddLine(instanceName, 1, 1, 1)

if instanceReset > 0 then
if not hasTitle then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(L["RAID_INFO_COLON"])
-- it's easier to sort on demand here
t_sort(resetData, difficultySortFunc)

hasTitle = true
for _, difficultyData in ipairs(resetData) do
GameTooltip:AddDoubleLine(difficultyData[2], difficultyData[3], gray.r, gray.g, gray.b, difficultyData[4].r, difficultyData[4].g, difficultyData[4].b)
end

GameTooltip:AddDoubleLine(instanceName, "1 / 1", 1, 1, 1, red.r, red.g, red.b)
GameTooltip:AddDoubleLine(L["WORLD_BOSS"], SecondsToTime(instanceReset, true, nil, 3), gray.r, gray.g, gray.b, gray.r, gray.g, gray.b)
end
end
end
Expand All @@ -711,14 +708,94 @@ do

function ej_button_proto:OnEventHook(event)
if event == "UPDATE_INSTANCE_INFO" then
if GameTooltip:IsOwned(self) then
GameTooltip:Hide()
local savedInstances = GetNumSavedInstances()
local savedWorldBosses = GetNumSavedWorldBosses()

if savedInstances + savedWorldBosses > 0 then
t_wipe(lockouts)
t_wipe(instanceNames)
t_wipe(instanceResets)

for i = 1, savedInstances + savedWorldBosses do
if i <= savedInstances then
local instanceName, _, instanceReset, difficultyID, _, _, _, _, _, difficultyName, numEncounters, encounterProgress = GetSavedInstanceInfo(i)
if instanceReset > 0 then
if not lockouts[instanceReset] then
lockouts[instanceReset] = {}

t_insert(instanceResets, instanceReset)
end

if not lockouts[instanceReset][instanceName] then
lockouts[instanceReset][instanceName] = {}

-- the same instance can have multiple resets because heroics reset daily, but mythics reset weekly
if not instanceNames[instanceName] then

instanceNames[instanceName] = true
t_insert(instanceNames, instanceName)
end
end

t_insert(lockouts[instanceReset][instanceName], {
difficultyID,
difficultyName,
encounterProgress .. " / " .. numEncounters,
encounterProgress == numEncounters and C.db.global.colors.red or C.db.global.colors.green,
})
end
else
local instanceName, _, instanceReset = GetSavedWorldBossInfo(i - savedInstances)
if instanceReset > 0 then
-- there's some desync between instance and WB reset timers, sometimes it can be as bad as 600s
for _, reset in next, instanceResets do
if m_abs(reset - instanceReset) <= 600 then
instanceReset = reset

break
end
end

if not lockouts[instanceReset] then
lockouts[instanceReset] = {}

t_insert(instanceResets, instanceReset)
end

if not lockouts[instanceReset][instanceName] then
lockouts[instanceReset][instanceName] = {}

if not instanceNames[instanceName] then

instanceNames[instanceName] = true
t_insert(instanceNames, instanceName)
end
end

t_insert(lockouts[instanceReset][instanceName], {
WORLD_BOSS_ID,
WORLD_BOSS,
WORLD_BOSS_PROGRESS,
C.db.global.colors.red,
})
end
end
end

t_sort(instanceNames)
t_sort(instanceResets)
end

if GameTooltip:IsOwned(self) then
self:OnEnter()
end
end
end

function ej_button_proto:OnLeaveHook()
isInfoRequested = false
end

function ej_button_proto:Update()
button_proto.Update(self)

Expand Down Expand Up @@ -970,6 +1047,7 @@ function MODULE:CreateMicroMenu()
elseif id == "ej" then
Mixin(button, ej_button_proto)
button:HookScript("OnEvent", button.OnEventHook)
button:HookScript("OnLeave", button.OnLeaveHook)
-- -- elseif id == "store" then
elseif id == "main" then
Mixin(button, main_button_proto)
Expand Down

0 comments on commit 845f716

Please sign in to comment.