annotate Modules/Frames.lua @ 77:a8fc802b42ba

Changed the QuickAuctions decider to consider the number already owned and only calculate based on what needs to be crated. Fixed the QuickAuctions decider to return the number of items to be created instead of the number of times to create. This makes a difference with things like Runescroll of Fortitude where 5 are created at once.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sun, 01 Aug 2010 08:42:29 -0700
parents 32d53abee666
children f37ab41f1928
rev   line source
Asa@63 1 local ItemAuditor = select(2, ...)
Asa@63 2 local Frames = ItemAuditor:NewModule("Frames")
Asa@58 3
Asa@58 4 local AceGUI = LibStub("AceGUI-3.0")
Asa@58 5
Asa@58 6 local tabs = {}
Asa@58 7
Asa@65 8 function Frames.RegisterTab(text, value, callback)
Asa@59 9 tabs[value] = {text=text, callback=callback}
Asa@58 10 end
Asa@58 11
Asa@58 12 local displayFrame = false
Asa@58 13 local currentContent = false
Asa@58 14 local function switchTab(container, event, group)
Asa@58 15 if tabs[group] == nil then
Asa@58 16 error(format("Invaid tab name: %s", tostring(group)))
Asa@58 17 end
Asa@58 18 local cb = tabs[group].callback
Asa@58 19
Asa@58 20 container:ReleaseChildren()
Asa@58 21
Asa@58 22 if currentContent then
Asa@58 23 currentContent:Hide()
Asa@58 24 if displayFrame then
Asa@58 25 displayFrame:SetStatusText('')
Asa@58 26 end
Asa@58 27 end
Asa@59 28
Asa@58 29 currentContent = cb(container)
Asa@58 30 end
Asa@58 31
Asa@65 32 function Frames.CreateFrame(selectedTab)
Asa@59 33
Asa@58 34 if not displayFrame then
Asa@58 35 -- Create the frame container
Asa@58 36 displayFrame = AceGUI:Create("Frame")
Asa@58 37 ItemAuditor:RegisterFrame(displayFrame)
Asa@58 38 local window = displayFrame.frame;
Asa@58 39 -- I have no idea why AceGUI insists on using FULLSCREEN_DIALOG by default.
Asa@58 40 window:SetFrameStrata("MEDIUM")
Asa@58 41 displayFrame:SetTitle("ItemAuditor")
Asa@58 42 displayFrame:SetStatusText("")
Asa@58 43
Asa@58 44 displayFrame:SetLayout("Fill")
Asa@58 45
Asa@58 46 window:SetHeight(500);
Asa@58 47
Asa@58 48 local tabSet = {}
Asa@58 49 for key, data in pairs(tabs) do
Asa@58 50 tinsert(tabSet, {text=data['text'], value=key})
Asa@58 51 -- Default to the first tab.
Asa@58 52 if not selectedTab then
Asa@58 53 selectedTab = key
Asa@58 54 end
Asa@58 55 end
Asa@58 56 -- Each tab can adjust the width as needed.
Asa@58 57 window:SetWidth(300);
Asa@58 58
Asa@58 59 displayFrame.tab = AceGUI:Create("TabGroup")
Asa@58 60 displayFrame.tab:SetLayout("Flow")
Asa@58 61 displayFrame.tab:SetTabs(tabSet)
Asa@58 62 displayFrame.tab:SetCallback("OnGroupSelected", switchTab)
Asa@58 63
Asa@58 64
Asa@58 65 displayFrame:AddChild(displayFrame.tab)
Asa@58 66 end
Asa@58 67
Asa@58 68 if not selectedTab then
Asa@58 69 for key in pairs(tabs) do
Asa@58 70 selectedTab = key
Asa@58 71 break
Asa@58 72 end
Asa@58 73 end
Asa@58 74
Asa@58 75 displayFrame.tab:SelectTab(selectedTab)
Asa@58 76 displayFrame:Show()
Asa@58 77 end
Asa@58 78
Asa@65 79 function Frames.UpdateStatusText(message)
Asa@58 80 if displayFrame then
Asa@58 81 displayFrame:SetStatusText(message)
Asa@58 82 end
Asa@65 83 end
Asa@65 84
Asa@65 85 function ItemAuditor:UpdateStatusText(message)
Asa@65 86 return Frames.UpdateStatusText(message)
Asa@65 87 end
Asa@65 88
Asa@65 89 function ItemAuditor:RegisterTab(text, value, callback)
Asa@65 90 return Frames.RegisterTab(text, value, callback)
Asa@65 91 end
Asa@65 92
Asa@65 93 function ItemAuditor:CreateFrame(selectedTab)
Asa@65 94 Frames.CreateFrame(selectedTab)
Asa@65 95 end