- TitanBag : Fix option to open bags
urnati [01-15-23 - 20:39]
- TitanBag : Fix option to open bags
diff --git a/TitanBag/TitanBag.lua b/TitanBag/TitanBag.lua
index 49d4b82..0550232 100644
--- a/TitanBag/TitanBag.lua
+++ b/TitanBag/TitanBag.lua
@@ -95,15 +95,8 @@ local bag_data = {} -- to hold the user bag data
local function ToggleBags()
if TitanGetVar(TITAN_BAG_ID, "OpenBags") then
- TitanPrint(""
- .." "..tostring("Feature :")..""
- .." "..tostring(OPENING or "Opening of")..""
- .." "..tostring(INVTYPE_BAG or "Bags")..""
- .." "..tostring(ADDON_DISABLED or "Disabled")..""
- .." "..tostring("Until taint is fixed or work around found.")..""
- , "warning")
+ ToggleAllBags()
else
- -- nop
end
end
@@ -122,6 +115,21 @@ local function GetBagData(id)
for bag_slot = MIN_BAGS, MAX_BAGS do -- assuming 0 (Backpack) will not be a profession bag
local slots = C_Container.GetContainerNumSlots(bag_slot)
+ -- Ensure a blank structure exists
+-- if bag_data[bag_slot] then
+ -- This has been processed at least once
+-- else
+ bag_data[bag_slot] = {
+ has_bag = false,
+ name = "",
+ maxi_slots = 0,
+ free_slots = 0,
+ used_slots = 0,
+ style = "",
+ color = "",
+ }
+-- end
+
if slots > 0 then
bag_data[bag_slot].has_bag = true
@@ -217,9 +225,6 @@ TitanDebug("T Bag: info"
bagRichText = bagRichText --..bagRichTextProf[1]..bagRichTextProf[2]..bagRichTextProf[3]..bagRichTextProf[4]..bagRichTextProf[5];
---[[
-TitanDebug("GetButtonText: <<<")
---]]
return L["TITAN_BAG_BUTTON_LABEL"], bagRichText
end
@@ -259,6 +264,7 @@ function TitanPanelBagButton_OnLoad(self)
};
self:RegisterEvent("PLAYER_ENTERING_WORLD");
+
end
--[[ plugin
@@ -267,24 +273,25 @@ end
-- DESC : Parse events registered to plugin and act on them
-- **************************************************************************
--]]
-function TitanPanelBagButton_OnEvent(self, event, ...)
- if (event == "PLAYER_ENTERING_WORLD") and (not self:IsEventRegistered("BAG_UPDATE")) then
-
- -- init local structure to known values
- for bag = MIN_BAGS, MAX_BAGS do
- bag_data[bag] = {
- has_bag = false,
- name = "",
- maxi_slots = 0,
- free_slots = 0,
- used_slots = 0,
- style = "",
- color = "",
- }
- end
+function TitanPanelBagButton_OnEvent(self, event, a1, a2, ...)
+ if event == "PLAYER_ENTERING_WORLD" then
+ -- Register for bag updates and update the plugin text
self:RegisterEvent("BAG_UPDATE")
TitanPanelButton_UpdateButton(TITAN_BAG_ID);
+
+ if a1 == true then
+ -- initial login
+
+ TitanPrint(""
+ .." "..tostring("Feature :")..""
+ .." "..tostring(OPENING or "Opening of")..""
+ .." "..tostring(INVTYPE_BAG or "Bags")..""
+ .." "..tostring(ADDON_DISABLED or "Disabled")..""
+ .." "..tostring("Until taint is fixed or work around found.")..""
+ , "warning")
+ else
+ end
end
if event == "BAG_UPDATE" then
@@ -309,11 +316,7 @@ end
--]]
function TitanPanelBagButton_OnClick(self, button)
if (button == "LeftButton") then
- if TitanGetVar(TITAN_BAG_ID, "OpenBags") then
- ToggleBags();
- else
- -- nop
- end
+ ToggleBags();
end
end
@@ -355,7 +358,7 @@ TitanDebug("T Bag: TT"
.." "..tostring(bag_data[bag].free_slots)..""
)
--]]
- if bag_data[bag].has_bag then
+ if bag_data[bag] and bag_data[bag].has_bag then
if (TitanGetVar(TITAN_BAG_ID, "ShowUsedSlots")) then
bagText = format(L["TITAN_BAG_FORMAT"], bag_data[bag].used_slots, bag_data[bag].maxi_slots);
else