Skip to content

Commit

Permalink
Cataclysm update
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaoky authored May 13, 2024
1 parent f825050 commit f010717
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 192 deletions.
7 changes: 5 additions & 2 deletions Altoholic_Grids/Altoholic_Grids.toc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Interface: 30403
## Interface: 40400
## Title: Altoholic_Grids
## IconTexture: Interface\Icons\inv_drink_13

## Notes: Altoholic's Grids Tab
## Author: Thaoky (EU-Marécages de Zangar)
## Version: 3.4.012
## Version: 4.4.001
## Dependencies: Altoholic, DataStore, DataStore_Characters
## SavedVariables: Altoholic_GridsTab_Options, Altoholic_GridsTab_Columns
## LoadOnDemand: 1
## X-Category: Interface Enhancements

Expand Down
74 changes: 40 additions & 34 deletions Altoholic_Grids/Grid_Currencies.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local addonName = "Altoholic"
local addon = _G[addonName]

local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local L = DataStore:GetLocale(addonName)

local WHITE = "|cFFFFFFFF"
local GREEN = "|cFF00FF00"
Expand All @@ -14,23 +14,22 @@ local currentDDMText
local dropDownFrame

local function GetUsedHeaders()
local account, realm = AltoholicTabGrids:GetRealm()
-- local account, realm = AltoholicTabGrids:GetRealm()

local usedHeaders = {}
local isHeader, name, num
-- local usedHeaders = {}
-- local isHeader, name

for _, character in pairs(DataStore:GetCharacters(realm, account)) do -- all alts on this realm
num = DataStore:GetNumCurrencies(character) or 0
-- for _, character in pairs(DataStore:GetCharacters(realm, account)) do -- all alts on this realm

for i = 1, num do
isHeader, name = DataStore:GetCurrencyInfo(character, i) -- save ech header found in the table
if isHeader then
usedHeaders[name] = true
end
end
end
-- for i = 1, (DataStore:GetNumCurrencies(character) or 0) do
-- isHeader, name = DataStore:GetCurrencyInfo(character, i) -- save ech header found in the table
-- if isHeader then
-- usedHeaders[name] = true
-- end
-- end
-- end

return DataStore:HashToSortedArray(usedHeaders)
return DataStore:HashToSortedArray(DataStore_Currencies_Headers.Set)
end

local function GetUsedTokens(header)
Expand All @@ -39,24 +38,30 @@ local function GetUsedTokens(header)
local account, realm = AltoholicTabGrids:GetRealm()

local tokens = {}
local useData -- use data for a specific header or not
-- local useData -- use data for a specific header or not

for _, character in pairs(DataStore:GetCharacters(realm, account)) do -- all alts on this realm
local num = DataStore:GetNumCurrencies(character) or 0
for i = 1, num do
local isHeader, name = DataStore:GetCurrencyInfo(character, i)
for i = 1, (DataStore:GetNumCurrencies(character) or 0) do

local name, _, _, category = DataStore:GetCurrencyInfo(character, i)

if isHeader then
if header and name ~= header then -- if a specific header (filter) was set, and it's not the one we chose, skip
useData = nil
else
useData = true -- we'll use data in this category
end
else
if useData then -- mark it as used
tokens[name] = true
end
end
if not header or (category == header) then
tokens[name] = true
end

-- local isHeader, name = DataStore:GetCurrencyInfo(character, i)

-- if isHeader then
-- if header and name ~= header then -- if a specific header (filter) was set, and it's not the one we chose, skip
-- useData = nil
-- else
-- useData = true -- we'll use data in this category
-- end
-- else
-- if useData then -- mark it as used
-- tokens[name] = true
-- end
-- end
end
end

Expand All @@ -71,8 +76,9 @@ end
local function OnTokenChange(self)
dropDownFrame:Close()

currentTokenType = self.value
currentDDMText = currentTokenType
local categoryId = self.value
currentTokenType = categoryId
currentDDMText = DataStore_Currencies_Headers.List[categoryId]
AltoholicTabGrids:SetViewDDMText(currentDDMText)

isViewValid = nil
Expand All @@ -92,8 +98,8 @@ end

local function DropDown_Initialize(frame)

for _, header in ipairs(GetUsedHeaders()) do -- and add them to the DDM
frame:AddButton(header, header, OnTokenChange)
for header, categoryId in pairs(DataStore_Currencies_Headers.Set) do -- and add them to the DDM
frame:AddButton(header, categoryId, OnTokenChange)
end
frame:AddButton(L["All-in-one"], nil, OnTokensAllInOne)
frame:AddCloseMenu()
Expand Down Expand Up @@ -123,7 +129,7 @@ local callbacks = {
button.Background:SetTexCoord(0, 1, 0, 1)

local token = view[dataRowID]
local count, currencyID = DataStore:GetCurrencyInfoByName(character, token)
local _, count, currencyID = DataStore:GetCurrencyInfoByName(character, token)
button.count = count

if count then
Expand Down
39 changes: 25 additions & 14 deletions Altoholic_Grids/Grid_Dungeons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local addon = _G[addonName]
local colors = addon.Colors
local icons = addon.Icons

local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local L = DataStore:GetLocale(addonName)

-- *** Dungeons ***
local Dungeons = {
Expand All @@ -25,19 +25,34 @@ local Dungeons = {
local view
local isViewValid

local OPTION_XPACK = "UI.Tabs.Grids.Dungeons.CurrentXPack"
local OPTION_RAIDS = "UI.Tabs.Grids.Dungeons.CurrentRaids"

local currentDDMText
local currentTexture
local dropDownFrame

-- ** Options **
local OPTION_XPACK = "Dungeons.CurrentXPack"
local OPTION_RAIDS = "Dungeons.CurrentRaids"

local function SetOptions(xPack, raids)
local options = Altoholic_GridsTab_Options

options[OPTION_XPACK] = xPack
options[OPTION_RAIDS] = raids
end

local function GetOptions()
local options = Altoholic_GridsTab_Options

return options[OPTION_XPACK], options[OPTION_RAIDS]
end


local function BuildView()
view = view or {}
wipe(view)

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentRaids = addon:GetOption(OPTION_RAIDS)

local currentXPack, currentRaids = GetOptions()

for index, raidList in ipairs(Dungeons[currentXPack][currentRaids]) do
table.insert(view, raidList) -- insert the table pointer
Expand All @@ -49,8 +64,7 @@ end
local function OnRaidListChange(self, xpackIndex, raidListIndex)
dropDownFrame:Close()

addon:SetOption(OPTION_XPACK, xpackIndex)
addon:SetOption(OPTION_RAIDS, raidListIndex)
SetOptions(xpackIndex, raidListIndex)

local raidList = Dungeons[xpackIndex][raidListIndex]
currentDDMText = raidList.name
Expand All @@ -65,8 +79,7 @@ local function DropDown_Initialize(frame, level)

local info = frame:CreateInfo()

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentRaids = addon:GetOption(OPTION_RAIDS)
local currentXPack, currentRaids = GetOptions()

if level == 1 then
for xpackIndex = 1, #Dungeons do
Expand Down Expand Up @@ -98,8 +111,7 @@ local callbacks = {
BuildView()
end

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentRaids = addon:GetOption(OPTION_RAIDS)
local currentXPack, currentRaids = GetOptions()

AltoholicTabGrids:SetStatus(format("%s / %s", Dungeons[currentXPack].name, Dungeons[currentXPack][currentRaids].name))
end,
Expand Down Expand Up @@ -187,8 +199,7 @@ local callbacks = {
frame:Show()
title:Show()

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentRaids = addon:GetOption(OPTION_RAIDS)
local currentXPack, currentRaids = GetOptions()

currentDDMText = Dungeons[currentXPack][currentRaids].name

Expand Down
2 changes: 1 addition & 1 deletion Altoholic_Grids/Grid_Equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local addonName = "Altoholic"
local addon = _G[addonName]
local colors = addon.Colors

local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local L = DataStore:GetLocale(addonName)

-- Class constants, for readability, these values match the ones in Altoholic.Classes (altoholic.lua)
local CLASS_MAGE = "MAGE"
Expand Down
53 changes: 37 additions & 16 deletions Altoholic_Grids/Grid_Reputations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ local addon = _G[addonName]
local colors = addon.Colors
local icons = addon.Icons

local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local L = DataStore:GetLocale(addonName)
local PARAGON_LABEL = "Paragon"

local TEXTURE_PATH = "Interface\\Icons\\"
local LOCAL_TEXTURE_PATH = "Interface\\Addons\\Altoholic_Grids\\Textures\\"
Expand Down Expand Up @@ -155,24 +156,38 @@ local VertexColors = {
[FACTION_STANDING_LABEL6] = { r = 0.0, g = 0.6, b = 0.6 }, -- honored
[FACTION_STANDING_LABEL7] = { r = 0.9, g = 0.3, b = 0.9 }, -- revered
[FACTION_STANDING_LABEL8] = { r = 1.0, g = 1.0, b = 1.0 }, -- exalted
[PARAGON_LABEL] = { r = 1.0, g = 1.0, b = 1.0 }, -- Paragon
}

local view
local isViewValid

local OPTION_XPACK = "UI.Tabs.Grids.Reputations.CurrentXPack"
local OPTION_FACTION = "UI.Tabs.Grids.Reputations.CurrentFactionGroup"

local currentFaction
local currentDDMText
local dropDownFrame

-- ** Options **
local OPTION_XPACK = "Reputations.CurrentXPack"
local OPTION_FACTION = "Reputations.CurrentFactionGroup"

local function SetOptions(xPack, faction)
local options = Altoholic_GridsTab_Options

options[OPTION_XPACK] = xPack
options[OPTION_FACTION] = faction
end

local function GetOptions()
local options = Altoholic_GridsTab_Options

return options[OPTION_XPACK], options[OPTION_FACTION]
end

local function BuildView()
view = view or {}
wipe(view)

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentFactionGroup = addon:GetOption(OPTION_FACTION)
local currentXPack, currentFactionGroup = GetOptions()

if (currentXPack ~= CAT_ALLINONE) then
for index, faction in ipairs(Factions[currentXPack][currentFactionGroup]) do
Expand Down Expand Up @@ -205,8 +220,7 @@ end
local function OnFactionChange(self, xpackIndex, factionGroupIndex)
dropDownFrame:Close()

addon:SetOption(OPTION_XPACK, xpackIndex)
addon:SetOption(OPTION_FACTION, factionGroupIndex)
SetOptions(xpackIndex, factionGroupIndex)

local factionGroup = Factions[xpackIndex][factionGroupIndex]
currentDDMText = factionGroup.name
Expand All @@ -218,8 +232,8 @@ end

local function OnAllInOneSelected(self)
dropDownFrame:Close()
addon:SetOption(OPTION_XPACK, CAT_ALLINONE)
addon:SetOption(OPTION_FACTION, 1)

SetOptions(CAT_ALLINONE, 1)

currentDDMText = L["All-in-one"]
AltoholicTabGrids:SetViewDDMText(currentDDMText)
Expand All @@ -232,8 +246,7 @@ local function DropDown_Initialize(frame, level)

local info = frame:CreateInfo()

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentFactionGroup = addon:GetOption(OPTION_FACTION)
local currentXPack, currentFactionGroup = GetOptions()

if level == 1 then
for xpackIndex = 1, (CAT_ALLINONE - 1) do
Expand Down Expand Up @@ -272,8 +285,7 @@ local callbacks = {
BuildView()
end

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentFactionGroup = addon:GetOption(OPTION_FACTION)
local currentXPack, currentFactionGroup = GetOptions()

if (currentXPack == CAT_ALLINONE) then
AltoholicTabGrids:SetStatus(L["All-in-one"])
Expand Down Expand Up @@ -310,10 +322,20 @@ local callbacks = {
button.Background:SetDesaturated(false)

local status, _, _, rate = DataStore:GetReputationInfo(character, faction.name)

if status and rate then
local text
if status == FACTION_STANDING_LABEL8 then -- If exalted ..
text = icons.ready -- .. just show the green check
elseif status == PARAGON_LABEL then -- Else if paragon levels..
if rate >= 100 then
text = icons.waiting
else
button.Name:SetFontObject("NumberFontNormalSmall")
button.Name:SetJustifyH("RIGHT")
button.Name:SetPoint("BOTTOMRIGHT", 0, 0)
text = format("%2d%%", floor(rate))
end
else
button.Background:SetDesaturated(true)
button.Name:SetFontObject("NumberFontNormalSmall")
Expand Down Expand Up @@ -396,8 +418,7 @@ local callbacks = {
frame:Show()
title:Show()

local currentXPack = addon:GetOption(OPTION_XPACK)
local currentFactionGroup = addon:GetOption(OPTION_FACTION)
local currentXPack, currentFactionGroup = GetOptions()

if (currentXPack ~= CAT_ALLINONE) then
currentDDMText = Factions[currentXPack][currentFactionGroup].name
Expand Down
Loading

0 comments on commit f010717

Please sign in to comment.