changeset 56:94ae80d58903

Settling in on a layout I like
author John@Yosemite-PC
date Sun, 25 Mar 2012 13:09:31 -0400
parents 59829ae918eb
children 93acdcd6ace5
files Core.lua Gui.lua
diffstat 2 files changed, 183 insertions(+), 198 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Sun Mar 25 13:09:07 2012 -0400
+++ b/Core.lua	Sun Mar 25 13:09:31 2012 -0400
@@ -52,7 +52,7 @@
 
 function OnEnable()
     CreateWorkingStateFromChanges(db.profile.changes)
-    --CreateGUI()
+    CreateGUI()
 end
 
 function HandleCommand(paramIn)
--- a/Gui.lua	Sun Mar 25 13:09:07 2012 -0400
+++ b/Gui.lua	Sun Mar 25 13:09:31 2012 -0400
@@ -10,220 +10,205 @@
 local getn=getn
 setfenv(1,bsk)
 
-local ChangeTab = function(container, event, group)
-    container:ReleaseChildren()
-    if group == "tab2" then
-        local desc = AceGUI:Create("Label")
-        desc:SetText("This is Tab 1")
-        desc:SetFullWidth(true)
-        container:AddChild(desc)
+local copy = function(t)
+    local c = {}
+    if not t then return c end
+    for i,v in pairs(t) do c[i] = v end
+    return c
+end
+local colorize = function(str,color)
+    if str==nil or str=="" then return "" end
+    if type(color) == "table" then
+        color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
+    end
+    if color == nil then return str end
+    return "|cff"..tostring(color or "ffffff")..str.."|r"
+end
 
-        local button = AceGUI:Create("Button")
-        button:SetText("Tab 1 Button")
-        button:SetWidth(200)
-        container:AddChild(button)
-    elseif group == "tab1" then
-        --local leftGroup = AceGUI:Create("InlineGroup")
-        --leftGroup:SetFullHeight()
-        --leftGroup:SetWidth(200)
-
-        local rightGroup = AceGUI:Create("InlineGroup")
-        rightGroup:SetTitle("title")
-        --rightGroup:SetWidth(600)
-        --rightGroup:SetHeight(200)
-        rightGroup.width = 'fill'
-        --rightGroup:SetFullWidth()
-        --rightGroup.alignoffset = 25
-        rightGroup:SetLayout("Flow")
-
-        --local desc = AceGUI:Create("Label")
-        --desc:SetText("This is Tab 1")
-        --desc:SetFullWidth(true)
-        --container:AddChild(desc)
-        local icon = AceGUI:Create("Icon")
-        icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
-        local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
-        icon:SetWidth(sz,sz)
-        icon:SetHeight(sz,sz)
-        icon:SetImageSize(sz,sz)
-        icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT");  _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end )
-        icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
-        rightGroup:AddChild(icon)
-
-        for i=1,12 do
-            icon = AceGUI:Create("Icon")
-            icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
-            local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
-            icon:SetWidth(sz,sz)
-            icon:SetHeight(sz,sz)
-            icon:SetImageSize(sz,sz)
-            icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT");  _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end )
-            icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
-            rightGroup:AddChild(icon)
-        end
-
-        local item2 = {string="item2!", color = {r=1,g=0,b=0.5} }
-        local itemList = {"Item1", "item2", "Item3", "Item4"}
-        for i=5,29 do
-           table.insert(itemList,"Item"..i)
-        end
-
-        local colorize = function(str,color)
-            if str==nil or str=="" then return "" end
-            if type(color) == "table" then
-                color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
-            end
-            if color == nil then return str end
-            return "|cff"..tostring(color or "ffffff")..str.."|r"
-        end
-
-        PersonList:RefreshRaidList() -- todo: this should be elsewhere
-
-        scroller = AceGUI:Create("ScrollFrame")
-        scroller:SetLayout("List")
-        scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
-        scroller:SetFullHeight(true)
-        scroller:SetFullWidth(true)
-
-        local label = AceGUI:Create("InteractiveLabel")
-        label:SetText("fucking hell\n")
-        scroller:AddChild(label)
-        scroller:AddChild(rightGroup)
-
-        treecontrol = AceGUI:Create("TreeGroup")
-        treecontrol:EnableButtonTooltips(false)
-        treecontrol:SetFullWidth(true)
-        treecontrol:SetFullHeight(true)
-        treecontrol:SetAutoAdjustHeight(false)
-
-        treecontrol:AddChild(scroller)
-
-        local pulldown = AceGUI:Create("Dropdown")
-        local pull = {}
-        local ltemp = 0
-        local lids = LootLists:GetAllIds()
-        for _,v in pairs(lids) do
-            local l = LootLists:Select(v)
-            pull[l:GetId()] = l:GetName()
-            --local entry = {value=i,text=v.name}
-            if l:GetLength() > 0 then
-                pulldown:SetItemDisabled(i,true)
-                if ltemp == 0 then
-                    ltemp = l:GetId()
-                end
+local CreateListSelector = function(OnValueChanged)
+    PersonList:RefreshRaidList()
+    local pulldown = AceGUI:Create("Dropdown")
+    local pull = {}
+    local ltemp = 0
+    local lids = LootLists:GetAllIds()
+    for _,v in pairs(lids) do
+        local l = LootLists:Select(v)
+        pull[l:GetId()] = l:GetName()
+        --local entry = {value=i,text=v.name}
+        if l:GetLength() > 0 then
+            pulldown:SetItemDisabled(i,true)
+            if ltemp == 0 then
+                ltemp = l:GetId()
             end
         end
-        pulldown:SetWidth(175)
-        pulldown:SetList(pull)
-        --for i,v in pairs(lists) do
-        --    if getn(v) == 0 then
-        --        pulldown:SetItemDisabled(i,true)
-        --    end
-        --end
-        local ovc = function(_,_,value)
-            --treecontrol:ReleaseChildren()
-            local tree = {}
-            local l = LootLists:Select(value)
-            for le in l:OrderedListEntryIter() do
-                local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
-                line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
-                if not PersonList:IsActive(le:GetId()) then
-                    line.disabled = true
-                else
-                    line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
-                end
-                table.insert(tree,line)
-            end
-            treecontrol:SetTree(tree)
-        end
-        pulldown:SetCallback("OnValueChanged", ovc)
-        if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
-
-        container:AddChild(pulldown)
-        container:AddChild(treecontrol)
-
-        --pulldown:EnableButtonTooltips(false)
-        --pulldown:SetFullWidth(true)
-        --pulldown:SetFullHeight(true)
-        --pulldown:SetAutoAdjustHeight(false)
-
-        --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) print("OGS: uniquevalue: "..uniquevalue)
-        --end)
-        --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) print("Onclick: uniquevalue: " .. uniquevalue) end)
-        --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) print("OnButtonEnter: value: " .. value) end)
-
-
     end
+    pulldown:SetWidth(175)
+    pulldown:SetList(pull)
+    pulldown:SetCallback("OnValueChanged", OnValueChanged)
+    if ltemp > 0 then pulldown:SetValue(ltemp); OnValueChanged(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
+    return pulldown
 end
 
---local myhook = function(tooltip, spellid)
---tooltip:AddLine("MSS was here", 1, 1, 1)
---tooltip:Show()
---end
---if GameTooltip:GetScript("OnTooltipSetSpell") then
---GameTooltip:HookScript("OnTooltipSetSpell", myhook)
---else
---GameTooltip:SetScript("OnTooltipSetSpell", myhook)
---end
+local tree = {}
+local ovc = function(t1,value)
+    tree = {}
+    local l = LootLists:Select(value)
+    for le in l:OrderedListEntryIter() do
+        local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
+        line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
+        line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
+        line.disabled = not PersonList:IsActive(le:GetId()) 
+        table.insert(tree,line)
+    end
+    t1:SetList(tree)
+end
 
 function CreateGUI()
+    local admin = bsk.admin
+    local f = AceGUI:Create("Frame")
 
-    -- Create a container frame
-    frame = AceGUI:Create("Frame")
-    frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
-    frame:SetTitle("BSK")
-    frame:SetLayout("Flow")
-    frame:SetHeight(700) 
-    frame:SetWidth(700)
+    f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
+    f:SetTitle("BSK")
+    f:SetLayout("Flow")
+    f:SetHeight(680) 
+    f:SetWidth(580)
 
-    --local opts = 
-    --{
-         
-    --}
+    local left = AceGUI:Create("InlineGroup")
+    left:SetLayout("List")
+    left:SetWidth(175)
+    left:SetFullHeight(true)
+    left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114
 
+    local right = AceGUI:Create("InlineGroup")
+    right:SetLayout("Flow")
+    right:SetWidth(700-175-160)
+    right:SetFullHeight(true)
+    right.alignoffset=0.25
 
+    local t1 = AceGUI:Create("SelectorList")
+    t1:SetNumLines(25)
+    t1:SetFullWidth(true)
+    t1:SetInteractive(admin)
 
+    local listChange = function(_,_,value)
+        ovc(t1,value)
+    end
+    local p1 = CreateListSelector(listChange)
+    p1:SetFullWidth(true)
 
+    left:AddChild(p1)
+    left:AddChild(t1)
 
+    local t2 = AceGUI:Create("SelectorList")
+    t2:SetNumLines(7)
+    t2:SetFullWidth(true)
+    t2:EnableButtonTooltips(true)
+    t2:SetList({
+        {
+            value=1, 
+            text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
+            link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
+        },
+        {
+            value=2,
+            text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r",
+            link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r"
+        },
+        {
+            value=3,
+            text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r",
+            link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r"
+        },
+        {
+            value=4,
+            text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r",
+            link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"
+        },
+        {
+            value=5,
+            text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r",
+            link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r"
+        },
+    })
 
-    --local tab = AceGUI:Create("TabGroup")
-    --tab:SetLayout("Flow")
-    --tab:SetTabs(
-    --   {
-    --       {
-    --           text="Tab 1",
-    --           value="tab1"
-    --       },
+    local alb1 = AceGUI:Create("Button")
+    alb1:SetWidth(100)
+    alb1:SetText("Open Bids")
+    local alb2 = AceGUI:Create("Button")
+    alb2:SetWidth(100)
+    alb2:SetText("Assign")
+    local alb3 = AceGUI:Create("Button")
+    alb3:SetWidth(100)
+    alb3:SetText("Suicide")
 
-    --       {
-    --           text="Tab 2",
-    --           value="tab2"
-    --       },
-    --       {
-    --           text="Tab 3",
-    --           value="tab3"
-    --       },
-    --       {
-    --           text="Tab 4",
-    --           value="tab4"
-    --       }
-    --   }
-    --)
-    --tab.width = "fill"
-    --tab.height = "fill"
+    local spacer = AceGUI:Create("Label")
+    spacer:SetText(" ")
+    spacer:SetFullWidth(true)
+    local spacer2 = AceGUI:Create("Label")
+    spacer2:SetText(" ")
+    spacer2:SetFullWidth(true)
 
-    --tab:SetCallback("OnGroupSelected",ChangeTab)
-    --tab:SelectTab("tab1")
-    --frame:AddChild(tab)
-    ChangeTab(frame,0,"tab1")
+    local biddingZone = AceGUI:Create("SimpleGroup")
+    biddingZone:SetLayout("Flow")
+    biddingZone:SetFullWidth(true)
 
-    -- Create a button
-    --local btn = AceGUI:Create("Button")
-    --btn:SetWidth(170)
-    --btn:SetText("Button !")
-    --btn:SetCallback("OnClick", function() Print("Click!") end)
-    -- Add the button to the container
-    --frame:AddChild(btn)
+    local label = AceGUI:Create("Label")
+    label:SetText("Bidding now open for ...")
+    local biddingOn = AceGUI:Create("InteractiveLabel")
+    biddingOn:SetText( "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r")
+    biddingOn:SetFullWidth(true)
+    biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT");  _G.GameTooltip:SetHyperlink("|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"); _G.GameTooltip:Show() end )
+    biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
+    local b1 = AceGUI:Create("SelectorList")
+    b1:SetNumLines(6)
+    b1:SetInteractive(admin)
+    local dummydata = {copy(tree[1]),copy( tree[2] ),copy( tree[3] )}
+    for i,v in pairs(dummydata) do v.disabled = false end
+    dummydata[2].text = dummydata[2].text .. " (roll 73)"
+    b1:SetList(dummydata)
+    local bidTitle = AceGUI:Create("Label")
+    bidTitle:SetText("Current bids")
+    bidTitle:SetFullWidth(true)
+
+
+    local bidRetractButton = AceGUI:Create("Button")
+    bidRetractButton:SetText("Place Bid")
+    bidRetractButton:SetWidth(100)
+    local rollButton = AceGUI:Create("Button")
+    rollButton:SetText("Offset Roll")
+    rollButton:SetWidth(100)
+
+    b1.alignoffset = 0.25 -- or else g1 won't align well
+    local g1 = AceGUI:Create("SimpleGroup")
+    g1.alignoffset = 0.25
+    g1:SetWidth(120)
+    g1:SetLayout("List")
+    local adminForce = AceGUI:Create("Button")
+    adminForce:SetText("Force bid")
+    adminForce:SetWidth(100)
+    local adminRetract = AceGUI:Create("Button")
+    adminRetract:SetText("Retract bid")
+    adminRetract:SetWidth(100)
+    g1:AddChildren(adminForce,adminRetract)
+
+
+
+    local suicideSelected = AceGUI:Create("Button")
+    suicideSelected:SetFullWidth(true)
+    suicideSelected:SetText("Suicide")
+    local undo = AceGUI:Create("Button")
+    undo:SetText("Undo")
+    undo:SetFullWidth(true)
+    local filter = AceGUI:Create("CheckBox")
+    filter:SetLabel("Only show active")
+    filter:SetFullWidth(true)
+
+    left:AddChildren(filter)
+    if admin then left:AddChildren(suicideSelected,undo) end
+    biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1)
+    if admin then biddingZone:AddChildren(g1) end
+    right:AddChildren(t2)
+    if admin then right:AddChildren(alb1,alb2,alb3) end
+    right:AddChildren(biddingZone)
+    f:AddChildren(left,right)
 end
-
-