Skip to content

Commit

Permalink
Frames renamed & Bank Cache fix
Browse files Browse the repository at this point in the history
* Renamed all frames to something less generic to avoid global collisions. The recent fix for the addon "Mail" wasn't enough.

* Fixed an event issue where a function was clearing characters bank cache upon close.
  • Loading branch information
Dyaxler committed Feb 8, 2018
1 parent 0fa0e1e commit 320f789
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 75 deletions.
56 changes: 35 additions & 21 deletions Altoholic/Altoholic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ local LEVEL_CAP = 60
Altoholic.Menu = {
{ name = L["Account Summary"], isCollapsed = false,
subMenu = {
{ name = L["Characters"], OnClick = function() Altoholic:ActivateMenuItem("AccountSummary") end },
{ name = L["Bag Usage"], OnClick = function() Altoholic:ActivateMenuItem("BagUsage") end },
{ name = SKILLS, OnClick = function() Altoholic:ActivateMenuItem("Skills") end },
{ name = L["Reputations"], OnClick = function() Altoholic:ActivateMenuItem("Reputations") end }
{ name = L["Characters"], OnClick = function() Altoholic:ActivateMenuItem("AltoSummary") end },
{ name = L["Bag Usage"], OnClick = function() Altoholic:ActivateMenuItem("AltoBags") end },
{ name = SKILLS, OnClick = function() Altoholic:ActivateMenuItem("AltoSkills") end },
{ name = L["Reputations"], OnClick = function() Altoholic:ActivateMenuItem("AltoReputations") end }
},
OnClick = function() Altoholic:Menu_Update(MENU_SUMMARY) end
},
Expand Down Expand Up @@ -307,14 +307,14 @@ function Altoholic:OnEnable()
Altoholic:DropDownSlot_Initialize();
end)
-- *** Create Scroll Frames' children lines ***
self:CreateScrollLines("AccountSummary", "CharacterSummaryTemplate", 14);
self:CreateScrollLines("BagUsage", "BagUsageTemplate", 14);
self:CreateScrollLines("Containers", "ContainerTemplate", 7, 14);
self:CreateScrollLines("AltoSummary", "CharacterSummaryTemplate", 14);
self:CreateScrollLines("AltoBags", "BagUsageTemplate", 14);
self:CreateScrollLines("AltoContainers", "ContainerTemplate", 7, 14);
self:CreateScrollLines("AltoMail", "MailEntryTemplate", 7);
self:CreateScrollLines("Search", "SearchEntryTemplate", 7);
self:CreateScrollLines("Equipment", "EquipmentEntryTemplate", 7, 10);
self:CreateScrollLines("AltoSearch", "SearchEntryTemplate", 7);
self:CreateScrollLines("AltoEquipment", "EquipmentEntryTemplate", 7, 10);
-- Manually fill the reputation frame
local repFrame = "Reputations"
local repFrame = "AltoReputations"
f = CreateFrame("Button", repFrame .. "Entry" .. 1, getglobal(repFrame), "ReputationEntryTemplate")
f:SetPoint("TOPLEFT", repFrame .. "ScrollFrame", "TOPLEFT", 0, -45)
for i = 2, 11 do
Expand All @@ -331,9 +331,9 @@ function Altoholic:OnEnable()
for j=9, 1, -1 do
getglobal(repFrame.."ClassesItem" .. j):SetPoint("BOTTOMRIGHT", repFrame.."ClassesItem" .. (j + 1), "BOTTOMLEFT", -5, 0);
end
self:CreateScrollLines("Skills", "SkillsTemplate", 14);
self:CreateScrollLines("Quests", "QuestEntryTemplate", 14);
self:CreateScrollLines("Recipes", "RecipesEntryTemplate", 14);
self:CreateScrollLines("AltoSkills", "SkillsTemplate", 14);
self:CreateScrollLines("AltoQuests", "QuestEntryTemplate", 14);
self:CreateScrollLines("AltoRecipes", "RecipesEntryTemplate", 14);
self:CreateScrollLines("AltoAuctions", "AuctionEntryTemplate", 7);
self:CheckExpiredMail()
self:BuildContainersSubMenu()
Expand Down Expand Up @@ -409,7 +409,7 @@ function Altoholic:OnShow()
end
self:BuildFactionsTable()
self:BuildCharacterInfoTable()
self:ActivateMenuItem("AccountSummary")
self:ActivateMenuItem("AltoSummary")
self:Menu_Update()
end

Expand Down Expand Up @@ -929,8 +929,8 @@ function Altoholic:BuildContainersSubMenu()
OnClick = function(self)
Altoholic:SelectAlt(altID)
Altoholic:UpdateContainerCache()
Altoholic:ClearScrollFrame(getglobal("ContainersScrollFrame"), "ContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("Containers")
Altoholic:ClearScrollFrame(getglobal("AltoContainersScrollFrame"), "AltoContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("AltoContainers")
end
} )
i = i + 1
Expand Down Expand Up @@ -988,7 +988,7 @@ function Altoholic:BuildEquipmentSubMenu()
subMenu = {},
OnClick = function(self)
Altoholic:SelectAlt(altID)
Altoholic:ActivateMenuItem("Equipment")
Altoholic:ActivateMenuItem("AltoEquipment")
end
} )
n = n + 1
Expand Down Expand Up @@ -1017,7 +1017,7 @@ function Altoholic:BuildQuestsSubMenu()
id = (n*100)+i,
OnClick = function(self)
Altoholic:SelectAlt(altID)
Altoholic:ActivateMenuItem("Quests")
Altoholic:ActivateMenuItem("AltoQuests")
end
} )
i = i + 1
Expand Down Expand Up @@ -1069,7 +1069,7 @@ function Altoholic:BuildRecipesSubMenu()
id = floor(id / 100)
Altoholic:SelectAlt(altID)
Altoholic:SelectProfession(skillID)
Altoholic:ActivateMenuItem("Recipes")
Altoholic:ActivateMenuItem("AltoRecipes")
end
} )
end
Expand Down Expand Up @@ -1247,7 +1247,7 @@ function Altoholic:ClearScrollFrame(name, entry, lines, height)
for i=1, lines do
getglobal(entry..i):Hide()
end
FauxScrollFrame_Update( name, lines, lines, height);
FauxScrollFrame_Update(name, lines, lines, height);
end

function Altoholic:CreateScrollLines(parentFrame, inheritsFrom, numLines, numItems)
Expand Down Expand Up @@ -1825,6 +1825,21 @@ function Altoholic:WhoKnowsRecipe(tooltip, ttype)
end
end

function Altoholic:GetCraftFromRecipe(link)
local _, _, _, recipeName = Altoholic:strsplit("|", link)
local craftName
local pos = string.find(recipeName, L["Transmute"])
if pos then
return string.sub(recipeName, pos, -2)
else
_, _, _, craftName = Altoholic:strsplit(":", recipeName)
end
if craftName == nil then
return string.sub(recipeName, 3, -2)
end
return string.sub(craftName, 2, -2)
end

function Altoholic:ProcessTooltip(tooltip, ttype, link, bagID, slotID)
local itemID
if bagID == "player" then
Expand Down Expand Up @@ -1989,7 +2004,6 @@ function Altoholic:BANKFRAME_OPENED()
end

function Altoholic:BANKFRAME_CLOSED()
self:UpdatePlayerBank()
V.isBankOpen = nil
if self:IsEventRegistered("PLAYERBANKSLOTS_CHANGED") then
self:UnregisterEvent("PLAYERBANKSLOTS_CHANGED")
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Altoholic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Notes-zhTW: 讓你即時撿閱你所有角色的資料
## Notes-zhCN: 能让你全面掌握你的所有角色的信息。
## Author: Dyaxler
## Version: 1.0.7
## Version: 1.0.8
## OptionalDeps: Ace2, LibBabble-Zone-3.0, LibBabble-Boss-3.0, LibBabble-Inventory-3.0, LibBabble-Faction-3.0, LibBabble-Class-3.0, DewdropLib, FuBarPlugin-2.0
## SavedVariables: AltoholicDB, AltoholicFuDB
## X-Category: Interface Enhancements
Expand Down
22 changes: 11 additions & 11 deletions Altoholic/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Altoholic.CharacterInfo = {}
Altoholic.BagIndices = {}
Altoholic.MenuCache = {}
Altoholic.vars = {}
Altoholic.vars.version = "v1.0.7"
Altoholic.vars.version = "v1.0.8"
local G = AceLibrary("Gratuity-2.0")
local L = AceLibrary("AceLocale-2.2"):new("Altoholic")
local V = Altoholic.vars
Expand Down Expand Up @@ -48,18 +48,18 @@ local options = {
}

Altoholic.Categories = {
"AccountSummary",
"BagUsage",
"Containers",
"AltoSummary",
"AltoBags",
"AltoContainers",
"AltoMail",
"Search",
"Equipment",
"Reputations",
"AltoOptions", -- renamed from "Options" to "AltoOptions", to prevent collisions with other addons.
"Quests",
"Recipes",
"AltoSearch",
"AltoEquipment",
"AltoReputations",
"AltoOptions",
"AltoQuests",
"AltoRecipes",
"AltoAuctions",
"Skills"
"AltoSkills"
}

Altoholic.RecipesBooks = {
Expand Down
14 changes: 7 additions & 7 deletions Altoholic/Frames/AccountSummary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local GREEN = "|cFF00FF00"

function Altoholic:AccountSummary_Update()
local VisibleLines = 14
local frame = "AccountSummary"
local frame = "AltoSummary"
local entry = frame.."Entry"
if table.getn(self.CharacterInfo) == 0 then
self:ClearScrollFrame(getglobal(frame.."ScrollFrame"), entry, VisibleLines, 18)
Expand Down Expand Up @@ -179,8 +179,8 @@ function Altoholic_AccountSummaryLevel_OnClick(button, id)
V.CurrentFaction, V.CurrentRealm = Altoholic:GetCharacterInfo(line)
V.CurrentAlt = s.name
Altoholic:UpdateContainerCache()
Altoholic:ClearScrollFrame(getglobal("ContainersScrollFrame"), "ContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("Containers")
Altoholic:ClearScrollFrame(getglobal("AltoContainersScrollFrame"), "AltoContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("AltoContainers")
end
end

Expand Down Expand Up @@ -218,12 +218,12 @@ function Altoholic_ViewAltInfo()
V.CurrentAlt = Altoholic.CharacterInfo[line].name
if this.value == 1 then -- bags
Altoholic:UpdateContainerCache()
Altoholic:ClearScrollFrame(getglobal("ContainersScrollFrame"), "ContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("Containers")
Altoholic:ClearScrollFrame(getglobal("AltoContainersScrollFrame"), "AltoContainersEntry", 7, 41)
Altoholic:ActivateMenuItem("AltoContainers")
elseif this.value == 2 then -- mailbox
Altoholic:ActivateMenuItem("AltoMail")
elseif this.value == 3 then -- quest log
Altoholic:ActivateMenuItem("Quests")
Altoholic:ActivateMenuItem("AltoQuests")
elseif this.value == 4 then -- auctions
V.AuctionType = "auctions"
Altoholic.Auctions_Update = Altoholic.Auctions_Update_Auctions
Expand Down Expand Up @@ -280,6 +280,6 @@ function Altoholic_DeleteAlt()
Altoholic:BuildAuctionsSubMenu()
Altoholic:BuildBidsSubMenu()
Altoholic:BuildFactionsTable()
Altoholic:ActivateMenuItem("AccountSummary")
Altoholic:ActivateMenuItem("AltoSummary")
DEFAULT_CHAT_FRAME:AddMessage(TEAL .. "Altoholic: " .. WHITE .. L["Character "] .. AltName .. L[" successfully deleted"])
end
4 changes: 2 additions & 2 deletions Altoholic/Frames/AccountSummary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</Frames>
</Button>

<Frame name="AccountSummary" parent="AltoholicFrame">
<Frame name="AltoSummary" parent="AltoholicFrame">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -216,7 +216,7 @@
</Frames>
<Scripts>
<OnShow>
AccountSummaryScrollFrame:Show()
AltoSummaryScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Frames/BagUsage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local CYAN = "|cFF1CFAFE"

function Altoholic:BagUsage_Update()
local VisibleLines = 14
local frame = "BagUsage"
local frame = "AltoBags"
local entry = frame.."Entry"

if table.getn(self.CharacterInfo) == 0 then
Expand Down
4 changes: 2 additions & 2 deletions Altoholic/Frames/BagUsage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
</Frames>
</Button>

<Frame name="BagUsage" parent="AltoholicFrame" hidden="true">
<Frame name="AltoBags" parent="AltoholicFrame" hidden="true">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -194,7 +194,7 @@
</Frames>
<Scripts>
<OnShow>
BagUsageScrollFrame:Show()
AltoBagsScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Frames/Containers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local V = Altoholic.vars

function Altoholic:Containers_Update()
local VisibleLines = 7
local frame = "Containers"
local frame = "AltoContainers"
local entry = frame.."Entry"
if table.getn(self.BagIndices) == 0 then
self:ClearScrollFrame(getglobal(frame.."ScrollFrame"), entry, VisibleLines, 41)
Expand Down
4 changes: 2 additions & 2 deletions Altoholic/Frames/Containers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</Frames>
</Button>

<Frame name="Containers" parent="AltoholicFrame" hidden="true">
<Frame name="AltoContainers" parent="AltoholicFrame" hidden="true">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -84,7 +84,7 @@
</Frames>
<Scripts>
<OnShow>
ContainersScrollFrame:Show()
AltoContainersScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
4 changes: 2 additions & 2 deletions Altoholic/Frames/Equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local CLASS_PRIEST = 9

function Altoholic:Equipment_Update()
local VisibleLines = 7
local frame = "Equipment"
local frame = "AltoEquipment"
local entry = frame.."Entry"
-- ** draw class icons **
local i = 1
Expand Down Expand Up @@ -276,5 +276,5 @@ function Altoholic_FindEquipmentUpgrade(self)
return a.iLvl < b.iLvl
end)
end
Altoholic:ActivateMenuItem("Search")
Altoholic:ActivateMenuItem("AltoSearch")
end
4 changes: 2 additions & 2 deletions Altoholic/Frames/Equipment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</Frames>
</Button>

<Frame name="Equipment" parent="AltoholicFrame" hidden="true">
<Frame name="AltoEquipment" parent="AltoholicFrame" hidden="true">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -106,7 +106,7 @@
</Frames>
<Scripts>
<OnShow>
EquipmentScrollFrame:Show()
AltoEquipmentScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Frames/Mails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</Frames>
<Scripts>
<OnShow>
MailScrollFrame:Show()
AltoMailScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Frames/Quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local TEAL = "|cFF00FF9A"
function Altoholic:Quests_Update()
local c = self.db.account.data[V.CurrentFaction][V.CurrentRealm].char[V.CurrentAlt]
local VisibleLines = 14
local frame = "Quests"
local frame = "AltoQuests"
local entry = frame.."Entry"
if table.getn(c.questlog) == 0 then
getglobal("AltoholicFrame_Status"):SetText("|cFFFFD700" .. V.CurrentAlt .. " of ".. V.CurrentRealm .. " |cFFFFFFFF" .. "No quests found")
Expand Down
4 changes: 2 additions & 2 deletions Altoholic/Frames/Quests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</Frames>
</Button>

<Frame name="Quests" parent="AltoholicFrame" hidden="true">
<Frame name="AltoQuests" parent="AltoholicFrame" hidden="true">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -181,7 +181,7 @@
</Frames>
<Scripts>
<OnShow>
QuestsScrollFrame:Show()
AltoQuestsScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
2 changes: 1 addition & 1 deletion Altoholic/Frames/Recipes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local TEAL = "|cFF00FF9A"
function Altoholic:Recipes_Update()
local c = self.db.account.data[V.CurrentFaction][V.CurrentRealm].char[V.CurrentAlt] -- current alt
local VisibleLines = 14
local frame = "Recipes"
local frame = "AltoRecipes"
local entry = frame.."Entry"
if c.recipes[V.CurrentProfession].ScanFailed then
getglobal("AltoholicFrame_Status"):SetText(L["No data: "] .. V.CurrentProfession .. L[" scan failed for "] ": |cFFFFD700" .. V.CurrentAlt .. " of ".. V.CurrentRealm)
Expand Down
4 changes: 2 additions & 2 deletions Altoholic/Frames/Recipes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</Frames>
</Button>

<Frame name="Recipes" parent="AltoholicFrame" hidden="true">
<Frame name="AltoRecipes" parent="AltoholicFrame" hidden="true">
<Size>
<AbsDimension x="615" y="306"/>
</Size>
Expand Down Expand Up @@ -239,7 +239,7 @@
</Frames>
<Scripts>
<OnShow>
RecipesScrollFrame:Show()
AltoRecipesScrollFrame:Show()
</OnShow>
</Scripts>
</Frame>
Expand Down
Loading

0 comments on commit 320f789

Please sign in to comment.