Skip to content

Commit

Permalink
Update Ace libraries to TWW versions. Bump TOC. Search all realms and…
Browse files Browse the repository at this point in the history
… factions now that we can use the warbank to exchange between all our characters.
  • Loading branch information
Kenneth Porter committed Aug 21, 2024
1 parent f3458b6 commit 291a269
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Libs/AceAddon-3.0/AceAddon-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-- end
-- @class file
-- @name AceAddon-3.0.lua
-- @release $Id$
-- @release $Id: AceAddon-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $

local MAJOR, MINOR = "AceAddon-3.0", 13
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
Expand Down
2 changes: 1 addition & 1 deletion Libs/AceConsole-3.0/AceConsole-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-- make into AceConsole.
-- @class file
-- @name AceConsole-3.0
-- @release $Id$
-- @release $Id: AceConsole-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $
local MAJOR,MINOR = "AceConsole-3.0", 7

local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
Expand Down
2 changes: 1 addition & 1 deletion Libs/AceGUI-3.0/AceGUI-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-- f:AddChild(btn)
-- @class file
-- @name AceGUI-3.0
-- @release $Id$
-- @release $Id: AceGUI-3.0.lua 1288 2022-09-25 14:19:00Z funkehdude $
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 41
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)

Expand Down
92 changes: 68 additions & 24 deletions Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--[[-----------------------------------------------------------------------------
ColorPicker Widget
-------------------------------------------------------------------------------]]
local Type, Version = "ColorPicker", 25
local Type, Version = "ColorPicker", 28
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

Expand All @@ -11,13 +11,24 @@ local pairs = pairs
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent

-- Unfortunately we have no way to realistically detect if a client uses inverted alpha
-- as no API will tell you. Wrath uses the old colorpicker, era uses the new one, both are inverted
local INVERTED_ALPHA = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE)

--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function ColorCallback(self, r, g, b, a, isAlpha)
if INVERTED_ALPHA and a then
a = 1 - a
end
if not self.HasAlpha then
a = 1
end
-- no change, skip update
if r == self.r and g == self.g and b == self.b and a == self.a then
return
end
self:SetColor(r, g, b, a)
if ColorPickerFrame:IsVisible() then
--colorpicker is still open
Expand Down Expand Up @@ -50,30 +61,63 @@ local function ColorSwatch_OnClick(frame)
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
ColorPickerFrame:SetClampedToScreen(true)

ColorPickerFrame.func = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = 1 - OpacitySliderFrame:GetValue()
ColorCallback(self, r, g, b, a)
end

ColorPickerFrame.hasOpacity = self.HasAlpha
ColorPickerFrame.opacityFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = 1 - OpacitySliderFrame:GetValue()
ColorCallback(self, r, g, b, a, true)
end

local r, g, b, a = self.r, self.g, self.b, self.a
if self.HasAlpha then
ColorPickerFrame.opacity = 1 - (a or 0)
end
ColorPickerFrame:SetColorRGB(r, g, b)

ColorPickerFrame.cancelFunc = function()
ColorCallback(self, r, g, b, a, true)
if ColorPickerFrame.SetupColorPickerAndShow then -- 10.2.5 color picker overhaul
local r2, g2, b2, a2 = self.r, self.g, self.b, (self.a or 1)
if INVERTED_ALPHA then
a2 = 1 - a2
end

local info = {
swatchFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = ColorPickerFrame:GetColorAlpha()
ColorCallback(self, r, g, b, a)
end,

hasOpacity = self.HasAlpha,
opacityFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = ColorPickerFrame:GetColorAlpha()
ColorCallback(self, r, g, b, a, true)
end,
opacity = a2,

cancelFunc = function()
ColorCallback(self, r2, g2, b2, a2, true)
end,

r = r2,
g = g2,
b = b2,
}

ColorPickerFrame:SetupColorPickerAndShow(info)
else
ColorPickerFrame.func = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = OpacitySliderFrame:GetValue()
ColorCallback(self, r, g, b, a)
end

ColorPickerFrame.hasOpacity = self.HasAlpha
ColorPickerFrame.opacityFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = OpacitySliderFrame:GetValue()
ColorCallback(self, r, g, b, a, true)
end

local r, g, b, a = self.r, self.g, self.b, 1 - (self.a or 1)
if self.HasAlpha then
ColorPickerFrame.opacity = a
end
ColorPickerFrame:SetColorRGB(r, g, b)

ColorPickerFrame.cancelFunc = function()
ColorCallback(self, r, g, b, a, true)
end

ColorPickerFrame:Show()
end

ColorPickerFrame:Show()
end
AceGUI:ClearFocus()
end
Expand Down
2 changes: 1 addition & 1 deletion Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--[[ $Id$ ]]--
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1272 2022-08-29 15:56:35Z nevcairiel $ ]]--

local AceGUI = LibStub("AceGUI-3.0")

Expand Down
2 changes: 1 addition & 1 deletion Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--[[ $Id$ ]]--
--[[ $Id: AceGUIWidget-DropDown.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]--
local AceGUI = LibStub("AceGUI-3.0")

-- Lua APIs
Expand Down
12 changes: 8 additions & 4 deletions Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--[[-----------------------------------------------------------------------------
EditBox Widget
-------------------------------------------------------------------------------]]
local Type, Version = "EditBox", 28
local Type, Version = "EditBox", 29
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

Expand All @@ -10,7 +10,7 @@ local tostring, pairs = tostring, pairs

-- WoW APIs
local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G

Expand Down Expand Up @@ -76,12 +76,16 @@ end

local function EditBox_OnReceiveDrag(frame)
local self = frame.obj
local type, id, info = GetCursorInfo()
local type, id, info, extra = GetCursorInfo()
local name
if type == "item" then
name = info
elseif type == "spell" then
name = GetSpellInfo(id, info)
if C_Spell and C_Spell.GetSpellName then
name = C_Spell.GetSpellName(extra)
else
name = GetSpellInfo(id, info)
end
elseif type == "macro" then
name = GetMacroInfo(id)
end
Expand Down
12 changes: 8 additions & 4 deletions Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local Type, Version = "MultiLineEditBox", 32
local Type, Version = "MultiLineEditBox", 33
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

-- Lua APIs
local pairs = pairs

-- WoW APIs
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G

Expand Down Expand Up @@ -100,9 +100,13 @@ local function OnMouseUp(self)
end

local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local type, id, info = GetCursorInfo()
local type, id, info, extra = GetCursorInfo()
if type == "spell" then
info = GetSpellInfo(id, info)
if C_Spell and C_Spell.GetSpellName then
info = C_Spell.GetSpellName(extra)
else
info = GetSpellInfo(id, info)
end
elseif type ~= "item" then
return
end
Expand Down
63 changes: 24 additions & 39 deletions PotentialDarkmoonDecks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,9 @@ local function isDMCard(itemLink)
return cardInfo
end

local function GetCharacterGuild(account, realm, guildName)
local guildKey = DataStore:GetGuild(guildName, realm, account)
if guildKey then
return DataStore_Containers.db.global.Guilds[guildKey]
end
end

local function _IterateGuildBankSlots(guild, callback)
for tabID, tab in pairs(guild.Tabs) do
if tab.name then
for slotID = 1, 98 do
local itemID, itemLink, itemCount, isBattlePet = DataStore:GetSlotInfo(tab, slotID)

-- Callback only if there is an item in that slot
if itemID then
local location = format("%s, %s - col %d/row %d)", GUILD_BANK, tab.name, floor((slotID-1)/7)+1, ((slotID-1)%7)+1)

callback(location, itemID, itemLink, itemCount, isBattlePet)
end
end
end
end
end

local function AddCard(cards, cardInfo)
local function AddCard(cards, cardInfo, source)
local suit = cardInfo.suit
-- addon:Print("AddCard " .. cardInfo.rank .. " of " .. suit)
-- addon:Print("AddCard " .. cardInfo.rank .. " of " .. suit .. " from " .. source)
if not cards[suit] then
cards[suit] = {}
end
Expand All @@ -107,37 +83,46 @@ local function AddCard(cards, cardInfo)
end
end

-- with TWW and the warbank, we can now look on "disconnected realms" and both factions
local isRetail = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE)
local searchAllRealms = isRetail

local function FindCards()
local connectedRealms = GetAutoCompleteRealms()
local connectedRealms
if not searchAllRealms then connectedRealms = GetAutoCompleteRealms() end
local currentFaction = UnitFactionGroup("player")
local guilds = {}
local cards = {}
for account in pairs(DataStore:GetAccounts()) do
for realm in pairs(DataStore:GetRealms(account)) do
if contains(connectedRealms, realm) then
if not connectedRealms or contains(connectedRealms, realm) then
for characterName, character in pairs(DataStore:GetCharacters(realm, account)) do
if DataStore:GetCharacterFaction(character) == currentFaction then
if searchAllRealms or (DataStore:GetCharacterFaction(character) == currentFaction) then
local characterNameWithRealm = characterName .. "-" .. realm
-- check this character's inventory
-- addon:Print("checking inventory " .. characterName)
-- addon:Print("checking inventory " .. characterNameWithRealm)
DataStore:IterateContainerSlots(character, function(containerName, itemID, itemLink, itemCount, isBattlePet)
local cardInfo = isDMCard(itemLink)
if cardInfo then
AddCard(cards, cardInfo)
AddCard(cards, cardInfo, characterNameWithRealm .. " inventory")
end
end)
-- check this character's guild bank
-- addon:Print("checking guild vault " .. characterName)
local guildName = DataStore:GetGuildInfo(character)
local guildName = DataStore:GetGuildName(character)
-- addon:Print(characterNameWithRealm .. "(" .. tostring(character) .. ") is in guild " .. tostring(guildName))
if guildName and not contains(guilds, guildName) then
local guild = GetCharacterGuild(account, realm, guildName)
if guild then
-- addon:Print("checking guild vault " .. guildName .. " for " .. characterNameWithRealm)
-- local guild = GetCharacterGuild(account, realm, guildName)
-- if guild then
local guildID = DataStore:GetCharacterGuildID(character)
if guildID then
-- addon:Print("checking guild bank " .. guildName)
table.insert(guilds, guildName)
_IterateGuildBankSlots(guild, function(location, itemID, itemLink, itemCount, isBattlePet)
local cardInfo = isDMCard(itemLink)
local guild = account .. "." .. realm .. "." .. guildName
DataStore:IterateGuildBankSlots(guild, function(location, itemID, itemLink, itemCount, isBattlePet)
local cardInfo = isDMCard(itemLink, true)
if cardInfo then
AddCard(cards, cardInfo)
-- addon:Print(guildName .. " has card " .. itemLink)
AddCard(cards, cardInfo, "guild bank " .. guildName)
end
end)
end
Expand Down
4 changes: 2 additions & 2 deletions PotentialDarkmoonDecks.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Interface: 100207
## Interface: 110002
## Title: PotentialDarkmoonDecks
## Notes: Display Darkmoon cards
## Author: SpareSimian
## Version: 0.7
## Version: 0.8
## Dependencies: DataStore, DataStore_Containers, DataStore_Characters
## IconTexture: Interface\Icons\Inv_inscription_darkmooncard_putrescence_a
## AddonCompartmentFunc: pddgui_OnAddonCompartmentClick
Expand Down

0 comments on commit 291a269

Please sign in to comment.