1
0
Fork 0
TexasHoldem/TableBrowser.lua

77 lines
2.1 KiB
Lua
Raw Normal View History

2023-04-28 20:27:04 +00:00
local MAX_TABLES = 8
do
local entry = CreateFrame("Button", "$parentEntry1", Poker_TableBrowserTableList, "Poker_TableBrowserEntry")
entry:SetID(1)
entry:SetPoint("TOPLEFT", 4, -28)
for i = 2, MAX_TABLES do
local entry = CreateFrame("Button", "$parentEntry"..i, Poker_TableBrowserTableList, "Poker_TableBrowserEntry")
entry:SetID(i)
entry:SetPoint("TOP", "$parentEntry"..(i-1), "BOTTOM")
end
end
Poker_TableBrowser = {}
Poker_TableBrowser.Tables = {}
function Poker_TableBrowser.Update()
for i = 1, MAX_TABLES do
local entry = Poker_TableBrowser.Tables[i]
local frame = getglobal("Poker_TableBrowserTableListEntry"..i)
if entry then
frame:Show()
getglobal(frame:GetName().."Name"):SetText(entry[1])
getglobal(frame:GetName().."Host"):SetText(entry[2])
getglobal(frame:GetName().."Players"):SetText(entry[3].."/"..entry[4])
getglobal(frame:GetName().."Blinds"):SetText(entry[5].."-"..entry[6])
if entry.isSelected then
getglobal(frame:GetName().."BG"):Show()
else
getglobal(frame:GetName().."BG"):Hide()
end
else
frame:Hide()
end
end
end
2023-04-29 17:11:45 +00:00
do
local currSort = 1
local currOrder = "asc"
function Poker_TableBrowser.SortTables(id)
if currSort == id then
if currOrder == "desc" then
currOrder = "asc"
else
currOrder = "desc"
end
elseif id then
currSort = id
currOrder = "asc"
end
table.sort(Poker_TableBrowser.Tables, function (v1, v2)
if currOrder == "desc" then
return v1[currSort] > v2[currSort]
else
return v1[currSort] < v2[currSort]
end
end)
Poker_TableBrowser.Update()
end
end
2023-04-28 20:27:04 +00:00
for i = 1, MAX_TABLES do
table.insert(Poker_TableBrowser.Tables, {
"Test Table "..i,
"Host "..(MAX_TABLES - i),
i % 3 + 1, -- just dummy values
10,
i * 10,
i * 20
})
end
2023-04-29 17:11:45 +00:00
Poker_TableBrowser.Update()