From 8f47bc360981cd291f9b9382f5c30b9fd3aa7a9d Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:24:34 +0100 Subject: [PATCH 01/10] Updated Utils:UnitName. Improved cache. Fixed potential issues. Names ending with '-' won't be cached. --- .specs/Classes/Utils/Utils.spec.lua | 238 +++++++++++++++++----------- Utils/Utils.lua | 18 ++- 2 files changed, 160 insertions(+), 96 deletions(-) diff --git a/.specs/Classes/Utils/Utils.spec.lua b/.specs/Classes/Utils/Utils.spec.lua index fa720969..b8cdedeb 100644 --- a/.specs/Classes/Utils/Utils.spec.lua +++ b/.specs/Classes/Utils/Utils.spec.lua @@ -1,102 +1,156 @@ -require "busted.runner"() +require "busted.runner" () dofile(".specs/AddonLoader.lua").LoadToc("RCLootCouncil.toc") local Utils describe("#Utils :CheckOutdatedVersion", function() - - before_each(function() - Utils = RCLootCouncil.Utils - end) - - it("should exist", function() - assert.is.Function(Utils.CheckOutdatedVersion) - end) - - it("should not crash", function() - assert.has_no.errors(function() Utils:CheckOutdatedVersion("","") end) - end) - - it("should report equal version", function() - local res = Utils:CheckOutdatedVersion("2.15.0","2.15.0") - assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) - res = Utils:CheckOutdatedVersion("2.15.1","2.15.1") - assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) - res = Utils:CheckOutdatedVersion("3.0.0","3.0.0") - assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) - res = Utils:CheckOutdatedVersion("999.999.999","999.999.999") - assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should default to addon version", function() - RCLootCouncil.version = "2.14.0" - assert.are.equal(Utils:CheckOutdatedVersion(nil, "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should report not-outdated versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.14.1", "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("2.15.1", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should report outdated versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.14.3"), RCLootCouncil.VER_CHECK_CODES[2]) - assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.15.1"), RCLootCouncil.VER_CHECK_CODES[2]) - assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "3.0.0"), RCLootCouncil.VER_CHECK_CODES[2]) - end) - - it("should handle test versions", function() - assert.has_no.errors(function() Utils:CheckOutdatedVersion("2.0.0", "2.1.0", "Alpha.1", "Alpha.1") end) - end) - - it("should handles outdated test versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.2"), RCLootCouncil.VER_CHECK_CODES[3]) - assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Beta.1"), RCLootCouncil.VER_CHECK_CODES[3]) - end) - - it("should handle non-outdated test versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.2", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Beta.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should handle equal test versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.10", "Alpha.10"), RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should not treat test versions as newer despite of main version", function() - assert.are.equal(Utils:CheckOutdatedVersion("2.19.3", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1]) - assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1]) - end) - - it("should handle releases of former test versions", function() - assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", "Beta.1", nil), RCLootCouncil.VER_CHECK_CODES[2]) - end) - - it("should handle newer test versions", function() - assert.are.equal(RCLootCouncil.VER_CHECK_CODES[1], Utils:CheckOutdatedVersion("3.0.1", "3.0.0", "Alpha.1", nil)) - end) + before_each(function() + Utils = RCLootCouncil.Utils + end) + + it("should exist", function() + assert.is.Function(Utils.CheckOutdatedVersion) + end) + + it("should not crash", function() + assert.has_no.errors(function() Utils:CheckOutdatedVersion("", "") end) + end) + + it("should report equal version", function() + local res = Utils:CheckOutdatedVersion("2.15.0", "2.15.0") + assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) + res = Utils:CheckOutdatedVersion("2.15.1", "2.15.1") + assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) + res = Utils:CheckOutdatedVersion("3.0.0", "3.0.0") + assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) + res = Utils:CheckOutdatedVersion("999.999.999", "999.999.999") + assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should default to addon version", function() + RCLootCouncil.version = "2.14.0" + assert.are.equal(Utils:CheckOutdatedVersion(nil, "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should report not-outdated versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.14.1", "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("2.15.1", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should report outdated versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.14.3"), RCLootCouncil.VER_CHECK_CODES[2]) + assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.15.1"), RCLootCouncil.VER_CHECK_CODES[2]) + assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "3.0.0"), RCLootCouncil.VER_CHECK_CODES[2]) + end) + + it("should handle test versions", function() + assert.has_no.errors(function() Utils:CheckOutdatedVersion("2.0.0", "2.1.0", "Alpha.1", "Alpha.1") end) + end) + + it("should handles outdated test versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.2"), + RCLootCouncil.VER_CHECK_CODES[3]) + assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Beta.1"), + RCLootCouncil.VER_CHECK_CODES[3]) + end) + + it("should handle non-outdated test versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.2", "Alpha.1"), + RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Beta.1", "Alpha.1"), + RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should handle equal test versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.1"), + RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.1", "Alpha.1"), + RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.10", "Alpha.10"), + RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should not treat test versions as newer despite of main version", function() + assert.are.equal(Utils:CheckOutdatedVersion("2.19.3", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1]) + assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1]) + end) + + it("should handle releases of former test versions", function() + assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", "Beta.1", nil), RCLootCouncil.VER_CHECK_CODES[2]) + end) + + it("should handle newer test versions", function() + assert.are.equal(RCLootCouncil.VER_CHECK_CODES[1], Utils:CheckOutdatedVersion("3.0.1", "3.0.0", "Alpha.1", nil)) + end) end) describe("#Utils functions", function() - describe("DiscardWeaponCorruption", function() - it("should remove correct bonusID", function() - local itemWith = "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:6513:::|h[Sk'shuul~`Vaz]|h|r" - local itemWithout = "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:::|h[Sk'shuul~`Vaz]|h|r" - assert.are.equal(itemWithout, Utils:DiscardWeaponCorruption(itemWith)) - end) - - it("shouldn't touch others", function() - local item = "|cffa335ee|Hitem:174117::::::::120:256::5:5:4823:1502:4786:6509:4775:::|h[Spaulders of Miasmic Mycelia]|h|r" - assert.are.equal(item, Utils:DiscardWeaponCorruption(item)) - end) - - it("should handle nils", function() - assert.has_no.errors(function() - assert.is_nil(Utils:DiscardWeaponCorruption(nil)) - end) - end) - end) + before_each(function() + Utils = RCLootCouncil.Utils + end) + + describe("DiscardWeaponCorruption", function() + it("should remove correct bonusID", function() + local itemWith = + "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:6513:::|h[Sk'shuul~`Vaz]|h|r" + local itemWithout = + "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:::|h[Sk'shuul~`Vaz]|h|r" + assert.are.equal(itemWithout, Utils:DiscardWeaponCorruption(itemWith)) + end) + + it("shouldn't touch others", function() + local item = + "|cffa335ee|Hitem:174117::::::::120:256::5:5:4823:1502:4786:6509:4775:::|h[Spaulders of Miasmic Mycelia]|h|r" + assert.are.equal(item, Utils:DiscardWeaponCorruption(item)) + end) + + it("should handle nils", function() + assert.has_no.errors(function() + assert.is_nil(Utils:DiscardWeaponCorruption(nil)) + end) + end) + end) + + describe("UnitName", function() + local potdisc + + setup(function() + potdisc = "Potdisc-Ravencrest" + end) + + before_each(function() + RCLootCouncil.realmName = "Ravencrest" + Utils.unitNameLookup = {} + end) + it("should handle full name-realm", function() + assert.equals(potdisc, Utils:UnitName(potdisc)) + end) + + it("should handle missing realm", function() + assert.equals(potdisc, Utils:UnitName("Potdisc")) + assert.equals(potdisc, Utils:UnitName("Potdisc-")) + end) + + it("should cache found player names", function() + Utils:UnitName("potdisc") + assert.are.same(potdisc, Utils.unitNameLookup["potdisc"]) + Utils:UnitName(potdisc) + assert.are.same(potdisc, Utils.unitNameLookup[potdisc]) + end) + + it("should not cache names ending with '-'", function() + RCLootCouncil.realmName = "" + Utils:UnitName("potdisc") + Utils:UnitName("potdisc-") + assert.are.same({}, Utils.unitNameLookup) + end) + + it("can handle missing param", function() + assert.has_no.errors(function () + Utils:UnitName() + end) + end) + end) end) diff --git a/Utils/Utils.lua b/Utils/Utils.lua index ae35b43a..514fbc86 100644 --- a/Utils/Utils.lua +++ b/Utils/Utils.lua @@ -174,6 +174,15 @@ function Utils:GetNumSpecializationsForClassID(classID) end Utils.unitNameLookup = {} +---@param key string +---@param name string +local function cacheUnitName(key, name) + local find = strfind(name, "-", nil, true) + if find and find < #name then + Utils.unitNameLookup[key] = name + end + return name +end --- Gets a unit's name formatted with realmName. --- If the unit contains a '-' it's assumed it belongs to the realmName part. @@ -182,6 +191,7 @@ Utils.unitNameLookup = {} --- @return string @Titlecased "unitName-realmName" function Utils:UnitName(input_unit) if self.unitNameLookup[input_unit] then return self.unitNameLookup[input_unit] end + if not input_unit or input_unit == "" then return "" end -- First strip any spaces local unit = gsub(input_unit, " ", "") -- Then see if we already have a realm name appended @@ -190,7 +200,9 @@ function Utils:UnitName(input_unit) -- Let's give it same treatment as below so we're sure it's the same local name, realm = strsplit("-", unit, 2) name = name:lower():gsub("^%l", string.upper) - return name .. "-" .. realm + return cacheUnitName(input_unit, name .. "-" .. realm) + elseif find and find == #unit then -- trailing '-' + unit = string.sub(unit,1,-2) end -- Apparently functions like GetRaidRosterInfo() will return "real" name, while UnitName() won't -- always work with that (see ticket #145). We need this to be consistant, so just lowercase the unit: @@ -203,9 +215,7 @@ function Utils:UnitName(input_unit) end -- Below won't work without name -- We also want to make sure the returned name is always title cased (it might not always be! ty Blizzard) name = name:lower():gsub("^%l", string.upper) - local ret = name and name .. "-" .. realm - self.unitNameLookup[input_unit] = ret - return ret + return cacheUnitName(input_unit, name and name .. "-" .. realm) end --- Creates Name-Realm based off seperate name and realm. From cbb769b5fd25e83cb74314ec405866ffea8a2ee8 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:24:55 +0100 Subject: [PATCH 02/10] 3.10.2-alpha.1 --- RCLootCouncil.toc | 4 ++-- core.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RCLootCouncil.toc b/RCLootCouncil.toc index 49282dd0..e7cff0e5 100644 --- a/RCLootCouncil.toc +++ b/RCLootCouncil.toc @@ -1,8 +1,8 @@ ## Author: Potdisc ## Interface: 100200 -## Notes: Interface for running a Loot Council v3.10.1 +## Notes: Interface for running a Loot Council v3.10.2 ## Title: RCLootCouncil -## Version: 3.10.1 +## Version: 3.10.2 ## SavedVariables: RCLootCouncilDB, RCLootCouncilLootDB ## OptionalDeps: LibStub, CallbackHandler-1.0, Ace3, lib-st, LibWindow-1.1, LibDialog-1.0 ## X-Curse-Project-ID: 39928 diff --git a/core.lua b/core.lua index f8193f30..438adec4 100644 --- a/core.lua +++ b/core.lua @@ -119,7 +119,7 @@ function RCLootCouncil:OnInitialize() self.version = GetAddOnMetadata("RCLootCouncil", "Version") self.nnp = false self.debug = false - self.tVersion = nil -- String or nil. Indicates test version, which alters stuff like version check. Is appended to 'version', i.e. "version-tVersion" (max 10 letters for stupid security) + self.tVersion = "alpha.1" -- String or nil. Indicates test version, which alters stuff like version check. Is appended to 'version', i.e. "version-tVersion" (max 10 letters for stupid security) self.playerClass = select(2, UnitClass("player")) -- TODO: Remove - contained in self.player self.guildRank = L["Unguilded"] From 90ac01ac46f3a97a71766fd56f45c9da7d30b745 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:46:42 +0100 Subject: [PATCH 03/10] CheckInteractDistance is now combat restricted --- Modules/TradeUI.lua | 13 +++++++++++-- changelog.md | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Modules/TradeUI.lua b/Modules/TradeUI.lua index 434b126a..8de98174 100644 --- a/Modules/TradeUI.lua +++ b/Modules/TradeUI.lua @@ -408,7 +408,7 @@ function TradeUI:GetFrame() f.st.frame:SetPoint("TOPLEFT",f,"TOPLEFT",10,-20) f.st:RegisterEvents({ ["OnClick"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) - if CheckInteractDistance(Ambiguate(data[realrow].winner, "short"), 2) then -- 2 for trade distance + if addon.inCombat or CheckInteractDistance(Ambiguate(data[realrow].winner, "short"), 2) then -- 2 for trade distance InitiateTrade(Ambiguate(data[realrow].winner, "short")) else addon.Log:d("TradeUI row OnClick - unit not in trade distance") @@ -430,8 +430,17 @@ function TradeUI:GetFrame() return f end +local colors = { + red = { r = 1, g = 0, b = 0, a = 1, }, + yellow = { r = 1, g = 1, b = 0, a = 1, }, + green = { r = 0, g = 1, b = 0, a = 1 }, +} + function TradeUI:GetTradeLabelColor(target) - return CheckInteractDistance(Ambiguate(target, "short"), 2) and {r=0,g=1,b=0,a=1} or {r=1,g=0,b=0,a=1} + if addon.inCombat then + return {colors.yellow:GetRGBA()} + end + return CheckInteractDistance(Ambiguate(target, "short"), 2) and colors.green or colors.red end function TradeUI.SetCellDelete(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...) diff --git a/changelog.md b/changelog.md index 6db6b340..0ac2400c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +# 3.10.2 + +## Changes + +### TradeUI + +Addons can no longer check whether people are in trade range during combat, so now the labels are yellow in combat. Clicking the yellow label will attempt to open trade. + # 3.10.1 ## Changes From 1910270824a2636661dda5ef8e8bd3e2c03ef27c Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:26:06 +0100 Subject: [PATCH 04/10] Added note column in loot history --- Modules/History/lootHistory.lua | 22 ++++++++++++++++++++++ changelog.md | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/Modules/History/lootHistory.lua b/Modules/History/lootHistory.lua index a8c4b7ea..64f4f142 100644 --- a/Modules/History/lootHistory.lua +++ b/Modules/History/lootHistory.lua @@ -61,6 +61,7 @@ function LootHistory:OnInitialize() {name = "", width = ROW_HEIGHT, }, -- Item icon {name = L["Item"], width = 250, comparesort = self.ItemSort, defaultsort = 1, sortnext = 2}, -- Item string {name = L["Reason"], width = 220, comparesort = self.ResponseSort, defaultsort = 1, sortnext = 2}, -- Response aka the text supplied to lootDB...response + { name = L["Notes"], width = 40, }, {name = "", width = ROW_HEIGHT}, -- Delete button } filterMenu = _G.MSA_DropDownMenu_Create("RCLootCouncil_LootHistory_FilterMenu", UIParent) @@ -229,6 +230,7 @@ function LootHistory:BuildData() {DoCellUpdate = self.SetCellGear, args={i.lootWon}}, {value = i.lootWon}, {DoCellUpdate = self.SetCellResponse, args = {color = i.color, response = i.response, responseID = i.responseID or 0, isAwardReason = i.isAwardReason}}, + { DoCellUpdate = self.SetCellNote }, {DoCellUpdate = self.SetCellDelete}, } } @@ -492,6 +494,26 @@ function LootHistory.SetCellResponse(rowFrame, frame, data, cols, row, realrow, end end +function LootHistory.SetCellNote(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...) + if not data then return end + local row = data[realrow] + local note = lootDB[row.name][row.num].note + local f = frame.noteBtn or CreateFrame("Button", nil, frame) + f:SetSize(ROW_HEIGHT, ROW_HEIGHT) + f:SetPoint("CENTER", frame, "CENTER") + if note then + f:SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Up.png") + f:SetScript("OnEnter", function() addon:CreateTooltip(_G.LABEL_NOTE, note) end) -- _G.LABEL_NOTE == "Note" in English + f:SetScript("OnLeave", function() addon:HideTooltip() end) + data[realrow].cols[column].value = 1 -- Set value for sorting compability + else + f:SetScript("OnEnter", nil) + f:SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Disabled.png") + data[realrow].cols[column].value = 0 + end + frame.noteBtn = f +end + function LootHistory.SetCellDelete(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...) if not frame.created then frame:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up") diff --git a/changelog.md b/changelog.md index 0ac2400c..4bc2f90a 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ ## Changes +### Loot History + +Added a column for notes. + ### TradeUI Addons can no longer check whether people are in trade range during combat, so now the labels are yellow in combat. Clicking the yellow label will attempt to open trade. From 526f5fedc906416b703165c66b34e3f9f198b095 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:26:57 +0100 Subject: [PATCH 05/10] Added 'hist' as shorthand for history cmd -Barrow --- core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.lua b/core.lua index 438adec4..4c6ef8c6 100644 --- a/core.lua +++ b/core.lua @@ -430,7 +430,7 @@ function RCLootCouncil:ChatCommand(msg) self:CallModule("version") end - elseif input == "history" or input == string.lower(_G.HISTORY) or input == "h" or input == "his" then + elseif input == "history" or input == string.lower(_G.HISTORY) or input == "h" or input == "his" or input == "hist" then self:CallModule("history") -- @debug@ elseif input == "nnp" then From 069f2662d8ae54fe057130e2f18cbda81e447a69 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:25:16 +0100 Subject: [PATCH 06/10] Restore session frame after cinematic --- Modules/sessionFrame.lua | 15 +++++++++++++++ changelog.md | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/Modules/sessionFrame.lua b/Modules/sessionFrame.lua index ddbd248c..06da05b5 100644 --- a/Modules/sessionFrame.lua +++ b/Modules/sessionFrame.lua @@ -39,6 +39,9 @@ end function RCSessionFrame:OnEnable() addon.Log("RCSessionFrame enabled") self:RegisterMessage("RCLootStatusReceived", "UpdateLootStatus") + addon:RegisterEvent("CINEMATIC_START", self.OnCinematicStart, self) + addon:RegisterEvent("CINEMATIC_STOP", self.OnCinematicStop, self) + self.showAfterCinematic = false ml = addon:GetActiveModule("masterlooter") end @@ -47,6 +50,7 @@ function RCSessionFrame:OnDisable() self.frame.rows = {} self:UnregisterMessage("RCLootStatusReceived") awardLater = false + self.showAfterCinematic = false addon.Log("RCSessionFrame disabled") end @@ -91,6 +95,17 @@ function RCSessionFrame:IsRunning() return self.frame and self.frame:IsVisible() end +function RCSessionFrame:OnCinematicStart() + self.showAfterCinematic = self.frame:IsVisible() +end + +function RCSessionFrame:OnCinematicStop() + if self.showAfterCinematic then + self.frame:Show() + self.showAfterCinematic = false + end +end + -- Data should be unmodified lootTable from ml_core function RCSessionFrame:ExtractData(data) -- Clear any rowdata diff --git a/changelog.md b/changelog.md index 4bc2f90a..9dc1ecbe 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ Added a column for notes. +### Session frame + +Will now be shown automatically after a cinematic if it was hidden because of it. + + ### TradeUI Addons can no longer check whether people are in trade range during combat, so now the labels are yellow in combat. Clicking the yellow label will attempt to open trade. From e20fa514cda21af755933655ba623acfd0ad2c98 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:26:04 +0100 Subject: [PATCH 07/10] ErrorHandler: Log nil guard --- Classes/Services/ErrorHandler.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Services/ErrorHandler.lua b/Classes/Services/ErrorHandler.lua index 5fce81f2..e31421d3 100644 --- a/Classes/Services/ErrorHandler.lua +++ b/Classes/Services/ErrorHandler.lua @@ -90,7 +90,7 @@ function private:SanitizeLine (line) end function private:DoesErrorExist (err) - for _, v in ipairs(self.log) do + for _, v in ipairs(self.log or {}) do if v.msg == err then return v end end return false From 01717470e1f08b17a98626f658ad7b8f503db09b Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:26:54 +0100 Subject: [PATCH 08/10] Delay group loot a bit --- Classes/Utils/GroupLoot.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Utils/GroupLoot.lua b/Classes/Utils/GroupLoot.lua index 3d812d39..035becdf 100644 --- a/Classes/Utils/GroupLoot.lua +++ b/Classes/Utils/GroupLoot.lua @@ -72,7 +72,7 @@ end function GroupLoot:RollOnLoot(rollID, rollType) -- Delay execution in case other addons have modified the loot frame -- and haven't had a change to fully load. - addon:ScheduleTimer(RollOnLoot, 0, rollID, rollType) + addon:ScheduleTimer(RollOnLoot, 0.05, rollID, rollType) --ConfirmLootRoll(rollID, rollType) end From 08d9b1649b1cf94d2e1318f9e84c30b1ad8ab286 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:38:09 +0100 Subject: [PATCH 09/10] GroupLoot: Auto hide default loot frames --- .specs/Classes/Utils/GroupLoot.spec.lua | 14 +++++------ Classes/Utils/GroupLoot.lua | 32 +++++++++++++++++++++++++ changelog.md | 5 +++- core.lua | 3 +++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.specs/Classes/Utils/GroupLoot.spec.lua b/.specs/Classes/Utils/GroupLoot.spec.lua index 3d7df729..2058ce88 100644 --- a/.specs/Classes/Utils/GroupLoot.spec.lua +++ b/.specs/Classes/Utils/GroupLoot.spec.lua @@ -120,14 +120,14 @@ describe("#GroupLoot", function() assert.spy(s).was_not_called() end) end) -end) -function _G.GetLootRollItemLink(rollID) - if GroupLoot.IgnoreList[rollID] then - return "item:"..rollID..":" + function _G.GetLootRollItemLink(rollID) + if GroupLoot.IgnoreList[rollID] then + return "item:" .. rollID .. ":" + end + return _G.Items_Array[math.random(#_G.Items_Array)] end - return _G.Items_Array[math.random(#_G.Items_Array)] -end +end) function _G.GetNumGroupMembers() return 10 @@ -144,7 +144,7 @@ function _G.GetLootThreshold() end function _G.GetLootRollItemInfo(rollID) - + end function SetupML() diff --git a/Classes/Utils/GroupLoot.lua b/Classes/Utils/GroupLoot.lua index 035becdf..af317242 100644 --- a/Classes/Utils/GroupLoot.lua +++ b/Classes/Utils/GroupLoot.lua @@ -24,6 +24,9 @@ GroupLoot.IgnoreList = { function GroupLoot:OnInitialize() self.Log = addon.Require "Utils.Log":New "GroupLoot" addon:RegisterEvent("START_LOOT_ROLL", self.OnStartLootRoll, self) + self.OnLootRoll:subscribe(function (_, rollID) + pcall(self.HideGroupLootFrameWithRollID, self, rollID) -- REVIEW: pcall because I haven't actually tested it in game. + end) -- addon:RegisterEvent("LOOT_HISTORY_ROLL_CHANGED", self.OnLootHistoryRollChanged, self) end @@ -93,3 +96,32 @@ function GroupLoot:OnLootHistoryRollChanged(event, itemId, playerId) self.Log:d("GetItem:", C_LootHistory.GetItem(itemId)) self.Log:d("GetPlayerInfo:", C_LootHistory.GetPlayerInfo(itemId, playerId)) end + +local NUM_LOOT_FRAMES = 4 +--- Hides any visible default group loot frames +function GroupLoot:HideGroupLootFrames() + local hidden = false + for i = 1, NUM_LOOT_FRAMES do + local frame = _G["GroupLootFrame" .. i] + if frame and frame:IsShown() then + frame:Hide() + hidden = true + end + end + if hidden then + self.Log:D("Hided default group loot frames") + end +end + +---Hides a visiable default group loot frame with a particular rollID +---@param rollID integer RollID of the frame to hide. +function GroupLoot:HideGroupLootFrameWithRollID(rollID) + if not rollID then return end + for i = 1, NUM_LOOT_FRAMES do + local frame = _G["GroupLootFrame" .. i] + if frame and frame:IsShown() and frame.rollID == rollID then + frame:Hide() + self.Log:D("Hide group loot frame with rollID", i, rollID) + end + end +end \ No newline at end of file diff --git a/changelog.md b/changelog.md index 9dc1ecbe..94e86859 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ ## Changes +### Group Loot + +Default WoW group loot frames is now forced hidden after being rolled on by RCLootCouncil. + ### Loot History Added a column for notes. @@ -10,7 +14,6 @@ Added a column for notes. Will now be shown automatically after a cinematic if it was hidden because of it. - ### TradeUI Addons can no longer check whether people are in trade range during combat, so now the labels are yellow in combat. Clicking the yellow label will attempt to open trade. diff --git a/core.lua b/core.lua index 4c6ef8c6..b7adbbd4 100644 --- a/core.lua +++ b/core.lua @@ -483,6 +483,9 @@ function RCLootCouncil:ChatCommand(msg) self:Print(L["You cannot use this command without being the Master Looter"]) end + elseif input == "hidelootframe" or input == "hidelootframes" then + self.Require "Utils.GroupLoot":HideGroupLootFrames() + elseif input == "reset" or input == string.lower(_G.RESET) then for k, v in pairs(db.UI) do -- We can't easily reset due to the wildcard in defaults if k == "lootframe" then -- Loot Frame is special From c60784a6455ac170e07d3696ebffa605a6c8565a Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:38:57 +0100 Subject: [PATCH 10/10] v3.10.2 --- core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.lua b/core.lua index b7adbbd4..3c3dcfa0 100644 --- a/core.lua +++ b/core.lua @@ -119,7 +119,7 @@ function RCLootCouncil:OnInitialize() self.version = GetAddOnMetadata("RCLootCouncil", "Version") self.nnp = false self.debug = false - self.tVersion = "alpha.1" -- String or nil. Indicates test version, which alters stuff like version check. Is appended to 'version', i.e. "version-tVersion" (max 10 letters for stupid security) + self.tVersion = nil -- String or nil. Indicates test version, which alters stuff like version check. Is appended to 'version', i.e. "version-tVersion" (max 10 letters for stupid security) self.playerClass = select(2, UnitClass("player")) -- TODO: Remove - contained in self.player self.guildRank = L["Unguilded"]