Moved it up to overlay

Wobin [05-03-14 - 03:42]
Moved it up to overlay
Now has progress text on what's being moved
Filename
Roomba.lua
Roomba.xml
diff --git a/Roomba.lua b/Roomba.lua
index d8fa115..a75a5b5 100644
--- a/Roomba.lua
+++ b/Roomba.lua
@@ -8,15 +8,16 @@ Roomba = ZO_Object:Subclass()

 function Roomba:New(...)
     local roomba = ZO_Object.New(self)
-    roomba:Initialize(...)
+    roomba:Initialise(...)
     return roomba
 end

-function Roomba:Initialize(control)
+function Roomba:Initialise(control)
 	self.control = control
-	control.ref = self
-	self:InitializeFrame()
-	self:InitializeSettings()
+
+	self:InitialiseFrame()
+	self:InitialiseSettings()
+	self:InitaliseEvents()
 end

 local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")
@@ -59,7 +60,7 @@ local function ClearGuildDetails(guildId)
 			}
 end

-function TableEntryCount(t)
+local function TableEntryCount(t)
 	local i = next(t)
 	local c = 0
 	while i do
@@ -70,8 +71,7 @@ function TableEntryCount(t)
 end

 -- Who is your Guild and what do they do
-function Roomba:GetGuildDetails()
-	d("Wiping Guilds")
+local function GetGuildDetails(self)
 	for guildIndex = 1, GetNumGuilds()	do
 		local guildId = GetGuildId(guildIndex)
 		if DoesGuildHavePrivilege(guildId, GUILD_PRIVILEGE_BANK_DEPOSIT) then
@@ -96,11 +96,16 @@ local checkingBank = false

 -- Bank is ready! Find those duplicates!
 function Roomba:RoombaReady()
+	-- Are we in the process of checking the bank?
 	if not checkingBank then checkingBank = true else return end
-	local bank = self.guildInfo[GetSelectedGuildBankId()]
-	if not bank then return end
-	self.guildInfo[GetSelectedGuildBankId()] = ClearGuildDetails(GetSelectedGuildBankId())
-	bank = self.guildInfo[GetSelectedGuildBankId()]
+
+	local selectedBankId = GetSelectedGuildBankId()
+
+	if not self.guildInfo[selectedBankId] then return end
+
+	self.guildInfo[selectedBankId] = ClearGuildDetails(selectedBankId)
+	local bank = self.guildInfo[selectedBankId]
+
 	self:dmsg("Bank is ready")
     -- We only need to store A) slots with items
 	for index, slot in ipairs(GUILDBANK) do
@@ -117,7 +122,7 @@ function Roomba:RoombaReady()
                     bank.lookUp[id] = {} -- It's a new item!
                 end
                 -- Now group all items by id
-                table.insert(bank.lookUp[id], {slot = slot.data.slotIndex, count = count, texture = slot.data.iconFile})
+                table.insert(bank.lookUp[id], {slot = slot.data.slotIndex, count = count, texture = slot.data.iconFile, name = slot.data.name})
             end
         end
     end
@@ -167,7 +172,7 @@ function Roomba:ReturnItemsToBank(...)
     local error = ...
     local slot
 	-- Now that we've stacked it all lets move it back
-    self:dmsg("Getting next to move back to bank")
+    self:dmsg("Getting next to move back to bank")
     currentReturnIndex, slot = next(inBagCollection)
     if slot then
         if error then
@@ -176,6 +181,7 @@ function Roomba:ReturnItemsToBank(...)
         end
         if FindSlot(BACKPACK, slot.bagSlot) then
             self:dmsg("Moving stuff back from ".. slot.bagSlot)
+            self.text:SetText("Returning restacked " .. cSlot.name .. " to the Guild Bank")
             return TransferToGuildBank(INVENTORY_BACKPACK, slot.bagSlot)
         else
             -- we have a space, move to next
@@ -211,6 +217,7 @@ function Roomba:StartStacking()
 	self:dmsg("Found an item to stack")
 	baseSlot = nil
     EVENT_MANAGER:UnregisterForEvent("RoombaInventoryAdded", EVENT_INVENTORY_SINGLE_SLOT_UPDATE)
+    self.text:SetText("Stacking " .. cSlot.name .. " in inventory")
 	for _,slot in pairs(inBagCollection) do
 		if not baseSlot then
 			-- We want to stack everything on this
@@ -238,7 +245,7 @@ function Roomba:StartStacking()
     -- These events will loop the move back to the guild bank
 	EVENT_MANAGER:RegisterForEvent("RoombaGuildBankError", EVENT_GUILD_BANK_TRANSFER_ERROR, function(...) self:ReturnItemsToBank() end)
 	EVENT_MANAGER:RegisterForEvent("RoombaGuildBankSuccess", EVENT_GUILD_BANK_ITEM_ADDED, function(...) self:BankItemsReceived(...) end)
-    return zo_callLater(function(...) self:ReturnItemsToBank() end, 1000)
+    return zo_callLater(function(...) self:ReturnItemsToBank() end, DELAY)
 end


@@ -282,7 +289,7 @@ function Roomba:BeginProcess()
     self.control:SetHidden(false)
     local index = TableEntryCount(currentRun)
     local total = TableEntryCount(bank.duplicates)
-    ZO_StatusBar_SmoothTransition(self.speedRow.bar, index , total, FORCE_VALUE)
+    ZO_StatusBar_SmoothTransition(self.speedRow.bar, index , total, FORCE_VALUE)
     self.speedRow.name:SetText(string.format(format, (index/total)*100) .. "%")


@@ -300,12 +307,13 @@ function Roomba:BeginProcess()
         if not FindSlot(GUILDBANK, cSlot.slot) then return zo_callLater(function() self:BeginProcess() end, DELAY) end

         EVENT_MANAGER:RegisterForEvent("RoombaInventoryAdded", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, function(...) self:ReceiveItems(...) end)
+        self.text:SetText("Retrieving " .. cSlot.name .. " from Guild Bank")
         TransferFromGuildBank(cSlot.slot)
     else
         self:dmsg("Nothing to restack")
         -- Now rescan and show/hide roomba button
         self.control:SetHidden(true)
-
+        self.text:SetText("Complete")
         self:RoombaReady()
         return false
     end
@@ -321,7 +329,7 @@ local function RoombaLoaded(eventCode, addOnName)
 	local defaults = {
 		Debugging = true
 	}
-	ROOMBA:GetGuildDetails()
+
 	ZO_CreateStringId("SI_BINDING_NAME_RUN_ROOMBA", "Run Roomba")
 	ZO_CreateStringId("SI_BINDING_NAME_RESCAN_ROOMBA", "Rescan Bank")
 	settings = ZO_SavedVars:New("Roomba_Settings", 3, nil, defaults)
@@ -329,10 +337,11 @@ local function RoombaLoaded(eventCode, addOnName)

 end

-function Roomba:InitializeSettings()
+function Roomba:InitialiseSettings()

 	self.guildInfo = {}
 	self.currentBank = 1
+	GetGuildDetails(self)

 	self.runDescriptor = {
 		alignment = KEYBIND_STRIP_ALIGN_LEFT,
@@ -353,33 +362,41 @@ function Roomba:InitializeSettings()
 		    icon = [[Roomba\media\RoombaSearch.dds]],
 		},
 	}
-	local bGroup = self.runDescriptor

+end
+
+function Roomba:InitaliseEvents()
     -- Guild bank is evented to be ready, but wait a short while before processing.
 	EVENT_MANAGER:RegisterForEvent("RoombaReady", EVENT_GUILD_BANK_ITEMS_READY, function() zo_callLater(function() self:RoombaReady() end, 1000) end)
 	-- Clear the flag when swapping banks
 	EVENT_MANAGER:RegisterForEvent("RoombaSelected", EVENT_GUILD_BANK_SELECTED, function(...) self:SelectGuildBank(...) end)
+
+	local bGroup = self.runDescriptor
+
 	EVENT_MANAGER:RegisterForEvent("RoombaGuildBankOpen", EVENT_OPEN_GUILD_BANK, function()
-		if not KEYBIND_STRIP:HasKeybindButtonGroup(bGroup) then
-			KEYBIND_STRIP:AddKeybindButtonGroup(bGroup)
-		end	end)
+																	if not KEYBIND_STRIP:HasKeybindButtonGroup(bGroup) then
+																		KEYBIND_STRIP:AddKeybindButtonGroup(bGroup)
+																	end	end)
 	EVENT_MANAGER:RegisterForEvent("RoombaGuildBankClose", EVENT_CLOSE_GUILD_BANK, function()
-		if KEYBIND_STRIP:HasKeybindButtonGroup(bGroup) then
-			KEYBIND_STRIP:RemoveKeybindButtonGroup(bGroup)
-		end
-		self.control:SetHidden(true)
-		end)
+																	if KEYBIND_STRIP:HasKeybindButtonGroup(bGroup) then
+																		KEYBIND_STRIP:RemoveKeybindButtonGroup(bGroup)
+																	end
+																	self.control:SetHidden(true)
+																	ResetAll()
+																	end)
 end

-function Roomba:InitializeFrame()
+function Roomba:InitialiseFrame()
 	self.speedRow = self.control:GetNamedChild("SpeedRow")
     self.speedRow.name:SetText("                     0%")
     self.icon = self.control:GetNamedChild("Icon")
+    self.text = self.control:GetNamedChild("Description")
+    self.text:SetText("...")
     ZO_StatusBar_SetGradientColor(self.speedRow.bar, ZO_XP_BAR_GRADIENT_COLORS)
     ZO_StatusBar_SmoothTransition(self.speedRow.bar, 0, 20, FORCE_VALUE)
 end

-function Roomba_Initialize(control)
+function Roomba_Initialise(control)
     ROOMBA = Roomba:New(control)
 end

diff --git a/Roomba.xml b/Roomba.xml
index bcf29a8..3e13c71 100644
--- a/Roomba.xml
+++ b/Roomba.xml
@@ -1,11 +1,11 @@
 <GuiXml>
     <Controls>
-        <TopLevelControl name="RoombaWindow" hidden="true" mouseEnabled="true">
+        <TopLevelControl name="RoombaWindow" hidden="true" mouseEnabled="true" drawLayer="DL_OVERLAY">
           <Dimensions x="565" />
             <Anchor point="TOPLEFT" relativeTo="ZO_SharedRightPanelBackground" offsetY="90" />
             <Anchor point="BOTTOMLEFT" relativeTo="ZO_SharedRightPanelBackground" offsetY="-20" />
             <OnInitialized>
-                Roomba_Initialize(self)
+                Roomba_Initialise(self)
             </OnInitialized>
             <Controls>
                 <Texture name="$(parent)BG" textureFile="EsoUI/Art/Miscellaneous/listItem_backdrop.dds">
@@ -16,7 +16,10 @@
                     <Dimensions x="80" y="80" />
                     <Anchor point="BOTTOM" relativePoint="CENTER" offsetX="20" offsetY="-40" />
                 </Texture>
-
+                <Label name="$(parent)Description" inherits="ZO_TooltipIfTruncatedLabel" font="ZoFontGameMedium" color="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_SECOND_CONTRAST" horizontalAlignment="CENTER">
+                    <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="BOTTOM" offsetY="5" offsetX="-300"/>
+                    <Dimensions x="600" y="40" />
+                </Label>
                 <Control name="$(parent)SpeedRow" inherits="ZO_StableAttributeRow">
                     <Anchor point="TOP" relativeTo="$(parent)Icon" relativePoint="BOTTOM" offsetY="30" offsetX="30"/>
                 </Control>