Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Sep 12, 2024
2 parents 8a25425 + 9972d9b commit 1f7427f
Show file tree
Hide file tree
Showing 24 changed files with 264 additions and 61 deletions.
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ read_globals = {
"GarrisonShipyardFollowerTooltip",
"GetAchievementInfo",
"GetArchaeologyRaceInfoByID",
"GetCategoryNumAchievements",
"GetCVarBool",
"GetGuildCategoryList",
"GetInstanceInfo",
"GetLFGCompletionReward",
"GetLFGCompletionRewardItem",
Expand Down Expand Up @@ -132,6 +134,7 @@ read_globals = {
"INVSLOT_TRINKET2",
"INVSLOT_WAIST",
"INVSLOT_WRIST",
"IsInGuild",
"IsLoggedIn",
"IsModifiedClick",
"IsShiftKeyDown",
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## Version 110002.01

- Added a workaround for buggy guild achievement spam. If your character is in a guild, the addon will add already
completed guild achievements to the blacklist on log in, you still will be able to see guild achievements if they're
earned for the first time. If you join a guild at some point, reload the UI, the achievement API is super laggy, so I
avoid rebuilding the blacklist during the actual game session.
- Added an option to disable tooltips on mouseover.

## Version 110000.02

- Fixed "[DNT] Worldsoul Memory Score" toasts.
Expand Down
6 changes: 5 additions & 1 deletion ls_Toasts/core/changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ local _G = getfenv(0)

-- Mine
E.CHANGELOG = [[
- Fixed "[DNT] Worldsoul Memory Score" toasts.
- Added a workaround for buggy guild achievement spam. If your character is in a guild, the addon will add already
completed guild achievements to the blacklist on log in, you still will be able to see guild achievements if they're
earned for the first time. If you join a guild at some point, reload the UI, the achievement API is super laggy, so I
avoid rebuilding the blacklist during the actual game session.
- Added an option to disable tooltips on mouseover.
]]
4 changes: 2 additions & 2 deletions ls_Toasts/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function P:CreateConfig()
[5] = ITEM_QUALITY_COLORS[5].hex .. ITEM_QUALITY5_DESC .. "|r",
},
},
}
},
},
font = {
order = 21,
Expand All @@ -206,7 +206,7 @@ function P:CreateConfig()
C.db.profile.font.name = value

P:UpdateFont()
end
end,
},
size = {
order = 2,
Expand Down
39 changes: 38 additions & 1 deletion ls_Toasts/embeds/AceDB-3.0/AceDB-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
-- @class file
-- @name AceDB-3.0.lua
-- @release $Id$
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 29
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 30
local AceDB = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)

if not AceDB then return end -- No upgrade needed
Expand Down Expand Up @@ -525,6 +525,17 @@ function DBObjectLib:DeleteProfile(name, silent)
end
end

-- remove from unloaded namespaces
if self.sv.namespaces then
for nsname, data in pairs(self.sv.namespaces) do
if self.children and self.children[nsname] then
-- already a mapped namespace
elseif data.profiles then
data.profiles[name] = nil
end
end
end

-- switch all characters that use this profile back to the default
if self.sv.profileKeys then
for key, profile in pairs(self.sv.profileKeys) do
Expand Down Expand Up @@ -570,6 +581,20 @@ function DBObjectLib:CopyProfile(name, silent)
end
end

-- copy unloaded namespaces
if self.sv.namespaces then
for nsname, data in pairs(self.sv.namespaces) do
if self.children and self.children[nsname] then
-- already a mapped namespace
elseif data.profiles then
-- reset the current profile
data.profiles[self.keys.profile] = {}
-- copy data
copyTable(data.profiles[name], data.profiles[self.keys.profile])
end
end
end

-- Callback: OnProfileCopied, database, sourceProfileKey
self.callbacks:Fire("OnProfileCopied", self, name)
end
Expand All @@ -596,6 +621,18 @@ function DBObjectLib:ResetProfile(noChildren, noCallbacks)
end
end

-- reset unloaded namespaces
if self.sv.namespaces and not noChildren then
for nsname, data in pairs(self.sv.namespaces) do
if self.children and self.children[nsname] then
-- already a mapped namespace
elseif data.profiles then
-- reset the current profile
data.profiles[self.keys.profile] = nil
end
end
end

-- Callback: OnProfileReset, database
if not noCallbacks then
self.callbacks:Fire("OnProfileReset", self)
Expand Down
2 changes: 0 additions & 2 deletions ls_Toasts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ E:RegisterEvent("ADDON_LOADED", function(arg1)
AddonCompartmentFrame:RegisterAddon({
text = L["LS_TOASTS"],
icon = "Interface\\AddOns\\ls_Toasts\\assets\\logo-32",
notCheckable = true,
registerForAnyClick = true,
func = function()
if not InCombatLockdown() then
LibStub("AceConfigDialog-3.0"):Open(addonName)
Expand Down
1 change: 1 addition & 0 deletions ls_Toasts/locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ L["SHOW_QUEST_ITEMS"] = "Show Quest Items"
L["SHOW_QUEST_ITEMS_DESC"] = "Show quest items regardless of their quality."
L["TAINT_WARNING"] = "Enabling this option may cause errors when opening or closing certain UI panels while in combat."
L["THRESHOLD"] = "Threshold"
L["TOOLTIPS"] = "Tooltips"
L["TRANSMOG_ADDED"] = "Appearance Added"
L["TRANSMOG_REMOVED"] = "Appearance Removed"
L["TYPE_ACHIEVEMENT"] = "Achievement"
Expand Down
1 change: 1 addition & 0 deletions ls_Toasts/locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ L["SHOW_QUEST_ITEMS"] = "Показывать кв. пр."
L["SHOW_QUEST_ITEMS_DESC"] = "Показывать квестовые предметы независимо от их качества."
L["TAINT_WARNING"] = "Включение данной настройки может вызвать ошибки при открытии или закрытии определенных панелей интерфейса в бою."
L["THRESHOLD"] = "Порог"
L["TOOLTIPS"] = "Подсказки"
L["TRANSMOG_ADDED"] = "Модель добавлена"
L["TRANSMOG_REMOVED"] = "Модель удалена"
L["TYPE_ACHIEVEMENT"] = "Достижение"
Expand Down
4 changes: 2 additions & 2 deletions ls_Toasts/ls_Toasts.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 110000, 110002
## Interface: 110002, 110005
## Author: lightspark
## Version: 110000.02
## Version: 110002.01
## Title: LS: |cff00cc99Toasts|r
## Notes: Better toasts, cheers!
## IconTexture: Interface\AddOns\ls_Toasts\assets\logo-64
Expand Down
74 changes: 64 additions & 10 deletions ls_Toasts/systems/achievement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@ local E, L, C = addonTable.E, addonTable.L, addonTable.C

-- Lua
local _G = getfenv(0)
local next = _G.next

-- Mine
local guildAchievements = {}

local function updateGuildAchievementList()
if not IsInGuild() then
return
end

for _, categoryID in next, GetGuildCategoryList() do
for i = 1, (GetCategoryNumAchievements(categoryID)) do
local id, _, _, completed = GetAchievementInfo(categoryID, i)
if id then
guildAchievements[id] = completed
end
end
end
end

local function Toast_OnClick(self)
if self._data.ach_id and not InCombatLockdown() then
if not AchievementFrame then
Expand Down Expand Up @@ -37,13 +55,22 @@ local function Toast_OnEnter(self)
end
end

local function Toast_SetUp(event, achievementID, flag, isCriteria)
local toast = E:GetToast()
local function Toast_SetUp(event, achievementID, eventArg, isCriteria) -- eventArg is alreadyEarned or criteriaString
local _, name, points, _, _, _, _, _, _, icon, _, isGuildAchievement = GetAchievementInfo(achievementID)
if isGuildAchievement then
eventArg = guildAchievements[achievementID]
guildAchievements[achievementID] = true

if eventArg then
return
end
end

local toast = E:GetToast()

if isCriteria then
toast.Title:SetText(L["ACHIEVEMENT_PROGRESSED"])
toast.Text:SetText(flag)
toast.Text:SetText(eventArg)

toast.IconText1:SetText("")
else
Expand All @@ -54,7 +81,7 @@ local function Toast_SetUp(event, achievementID, flag, isCriteria)
toast:ShowLeaves()
end

if flag then
if eventArg then
toast.IconText1:SetText("")
else
if C.db.profile.colors.border then
Expand All @@ -76,8 +103,11 @@ local function Toast_SetUp(event, achievementID, flag, isCriteria)
toast._data.event = event
toast._data.ach_id = achievementID

if C.db.profile.types.achievement.tooltip then
toast:HookScript("OnEnter", Toast_OnEnter)
end

toast:HookScript("OnClick", Toast_OnClick)
toast:HookScript("OnEnter", Toast_OnEnter)
toast:Spawn(C.db.profile.types.achievement.anchor, C.db.profile.types.achievement.dnd)
end

Expand All @@ -89,33 +119,52 @@ local function CRITERIA_EARNED(achievementID, criteriaString)
Toast_SetUp("CRITERIA_EARNED", achievementID, criteriaString, true)
end

local function PLAYER_ENTERING_WORLD(isInitialLogin)
-- the achievement data might not be available before the initial login, but it's fully available after /reload
if isInitialLogin then
updateGuildAchievementList()
end

E:UnregisterEvent("PLAYER_ENTERING_WORLD", PLAYER_ENTERING_WORLD)
end

local function Enable()
if C.db.profile.types.achievement.enabled then
updateGuildAchievementList()

E:RegisterEvent("ACHIEVEMENT_EARNED", ACHIEVEMENT_EARNED)
E:RegisterEvent("CRITERIA_EARNED", CRITERIA_EARNED)
E:RegisterEvent("PLAYER_ENTERING_WORLD", PLAYER_ENTERING_WORLD)
end
end

local function Disable()
E:UnregisterEvent("ACHIEVEMENT_EARNED", ACHIEVEMENT_EARNED)
E:UnregisterEvent("CRITERIA_EARNED", CRITERIA_EARNED)
E:UnregisterEvent("PLAYER_ENTERING_WORLD", PLAYER_ENTERING_WORLD)
end

local function Test()
-- new, Shave and a Haircut
Toast_SetUp("ACHIEVEMENT_TEST", 545, false)

-- earned, Ten Hit Tunes
Toast_SetUp("ACHIEVEMENT_TEST", 9828, true)
-- earned, Reach Level 10
Toast_SetUp("ACHIEVEMENT_TEST", 6, true)

-- guild, Everyone Needs a Logo
local old = guildAchievements[5362]
guildAchievements[5362] = false

Toast_SetUp("ACHIEVEMENT_TEST", 5362)

-- guild, It All Adds Up
Toast_SetUp("ACHIEVEMENT_TEST", 4913, false)
guildAchievements[5362] = old
end

E:RegisterOptions("achievement", {
enabled = true,
anchor = 1,
dnd = false,
tooltip = true,
}, {
name = L["TYPE_ACHIEVEMENT"],
get = function(info)
Expand All @@ -137,14 +186,19 @@ E:RegisterOptions("achievement", {
else
Disable()
end
end
end,
},
dnd = {
order = 2,
type = "toggle",
name = L["DND"],
desc = L["DND_TOOLTIP"],
},
tooltip = {
order = 3,
type = "toggle",
name = L["TOOLTIPS"],
},
test = {
type = "execute",
order = 99,
Expand Down
2 changes: 1 addition & 1 deletion ls_Toasts/systems/activities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ E:RegisterOptions("activities", {
else
Disable()
end
end
end,
},
dnd = {
order = 2,
Expand Down
19 changes: 14 additions & 5 deletions ls_Toasts/systems/archaeology.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end
------
local NO_GAIN_SOURCE = Enum.CurrencySource.Last

-- https://wow.tools/dbc/?dbc=currencytypes#colFilter[3]=82
-- https://wago.tools/db2/CurrencyTypes?filter%5BCategoryID%5D=82
local WHITELIST = {
-- 82 (Archaeology)
[ 384] = true, -- Dwarf Archaeology Fragment
Expand Down Expand Up @@ -98,11 +98,14 @@ local function FragmentToast_SetUp(event, link, quantity)
toast._data.count = quantity
toast._data.event = event
toast._data.link = link
toast._data.sound_file = C.db.profile.types.loot_currency.sfx and 31578 -- SOUNDKIT.UI_EPICLOOT_TOAST
toast._data.sound_file = C.db.profile.types.archaeology.sfx and 31578 -- SOUNDKIT.UI_EPICLOOT_TOAST
toast._data.tooltip_link = link

toast:HookScript("OnEnter", Toast_OnEnter)
toast:Spawn(C.db.profile.types.loot_currency.anchor, C.db.profile.types.loot_currency.dnd)
if C.db.profile.types.archaeology.tooltip then
toast:HookScript("OnEnter", Toast_OnEnter)
end

toast:Spawn(C.db.profile.types.archaeology.anchor, C.db.profile.types.archaeology.dnd)
else
toast:Recycle()
end
Expand Down Expand Up @@ -175,6 +178,7 @@ E:RegisterOptions("archaeology", {
anchor = 1,
dnd = false,
sfx = true,
tooltip = true,
}, {
name = L["TYPE_ARCHAEOLOGY"],
get = function(info)
Expand All @@ -196,7 +200,7 @@ E:RegisterOptions("archaeology", {
else
Disable()
end
end
end,
},
dnd = {
order = 2,
Expand All @@ -209,6 +213,11 @@ E:RegisterOptions("archaeology", {
type = "toggle",
name = L["SFX"],
},
tooltip = {
order = 4,
type = "toggle",
name = L["TOOLTIPS"],
},
test = {
type = "execute",
order = 99,
Expand Down
2 changes: 1 addition & 1 deletion ls_Toasts/systems/collection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ E:RegisterOptions("collection", {
else
Disable()
end
end
end,
},
dnd = {
order = 3,
Expand Down
Loading

0 comments on commit 1f7427f

Please sign in to comment.