tbc loop change part 3

This commit is contained in:
Manuel Simon Hirsig
2017-06-02 19:51:28 +02:00
parent d4b089d508
commit 4c5a7f2a75
9 changed files with 39 additions and 40 deletions
+5 -6
View File
@@ -959,8 +959,7 @@ function M.new(parent, rows, columns)
_G[scrollBar:GetName() .. 'ScrollDownButton']:Hide()
rt.headCells = {}
for i = 1, getn(rt.columns) do
local column = rt.columns[i]
for i, column in ipairs(rt.columns) do
local cell = CreateFrame('Button', nil, rt.contentFrame)
cell:SetHeight(HEAD_HEIGHT)
if i == 1 then
@@ -1024,12 +1023,12 @@ function M.new(parent, rows, columns)
row.highlight = highlight
row.cells = {}
for j = 1, getn(rt.columns) do
for j, column in ipairs(rt.columns) do
local cell = CreateFrame('Frame', nil, row)
local text = cell:CreateFontString()
cell.text = text
text:SetFont(gui.font, min(14, rt.ROW_HEIGHT))
text:SetJustifyH(rt.columns[j].align or 'LEFT')
text:SetJustifyH(column.align or 'LEFT')
text:SetJustifyV('CENTER')
text:SetPoint('TOPLEFT', 1, -1)
text:SetPoint('BOTTOMRIGHT', -1, 1)
@@ -1049,8 +1048,8 @@ function M.new(parent, rows, columns)
tex:SetTexture(.3, .3, .3, .2)
end
if rt.columns[j].init then
rt.columns[j].init(rt, cell)
if column.init then
column.init(rt, cell)
end
tinsert(row.cells, cell)
+1 -1
View File
@@ -255,7 +255,7 @@ do
do (self._on_select or nop)(id) end
end
function mt.__index:update()
for _, tab in self._tabs do
for _, tab in pairs(self._tabs) do
if tab.group._selected == tab.id then
tab.text:SetTextColor(color.label.enabled())
tab:Disable()
+1 -1
View File
@@ -21,7 +21,7 @@ function M:render()
local rows = self.rows
for i, row in rows do
for i, row in pairs(rows) do
local item_record = self.item_records[i + offset]
if item_record then
+17 -16
View File
@@ -76,7 +76,7 @@ local methods = {
self:AddColumn()
end
for i, col in self.headCols do
for i, col in pairs(self.headCols) do
if self.colInfo[i] then
col:Show()
col:SetWidth(self.colInfo[i].width * width)
@@ -92,7 +92,7 @@ local methods = {
self:AddRow()
end
for i, row in self.rows do
for i, row in pairs(self.rows) do
if i > self.numRows then
row.data = nil
row:Hide()
@@ -101,7 +101,7 @@ local methods = {
while getn(row.cols) < getn(self.colInfo) do
self:AddCell(i)
end
for j, col in row.cols do
for j, col in pairs(row.cols) do
if self.headCols[j] and self.colInfo[j] then
col:Show()
col:SetWidth(self.colInfo[j].width * width)
@@ -119,22 +119,23 @@ local methods = {
self.offset = offset
for i = 1, self.numRows do
self.rows[i].data = nil
local row = self.rows[i]
row.data = nil
if i > getn(self.rowData) then
self.rows[i]:Hide()
row:Hide()
else
self.rows[i]:Show()
row:Show()
local data = self.rowData[i + offset]
if not data then break end
self.rows[i].data = data
row.data = data
if self.rows[i].mouseover or self.selected and self.selected(data) then
self.rows[i].highlight:Show()
if row.mouseover or self.selected and self.selected(data) then
row.highlight:Show()
else
self.rows[i].highlight:Hide()
row.highlight:Hide()
end
for j, col in self.rows[i].cols do
for j, col in pairs(row.cols) do
if self.colInfo[j] then
local colData = data.cols[j]
if type(colData.value) == 'function' then
@@ -149,8 +150,8 @@ local methods = {
end,
SetData = function(self, rowData)
for _, row in self.rowData or empty do
for _, col in row.cols do release(col) end
for _, row in pairs(self.rowData or empty) do
for _, col in pairs(row.cols) do release(col) end
release(row.cols)
release(row)
end
@@ -184,7 +185,7 @@ local methods = {
tinsert(self.headCols, col)
for i, row in self.rows do
for i, row in pairs(self.rows) do
while getn(row.cols) < getn(self.headCols) do
self:AddCell(i)
end
@@ -216,7 +217,7 @@ local methods = {
local row = CreateFrame('Button', nil, self.contentFrame)
row:SetHeight(ROW_HEIGHT)
row:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
for name, func in handlers do
for name, func in pairs(handlers) do
row:SetScript(name, func)
end
local rowNum = getn(self.rows) + 1
@@ -287,7 +288,7 @@ function M.new(parent)
_G[scroll_bar:GetName() .. 'ScrollUpButton']:Hide()
_G[scroll_bar:GetName() .. 'ScrollDownButton']:Hide()
for name, func in methods do
for name, func in pairs(methods) do
st[name] = func
end
+3 -3
View File
@@ -8,7 +8,7 @@ local pool, pool_size, overflow_pool, auto_release = {}, 0, setmetatable({}, {__
function wipe(t)
setmetatable(t, nil)
for k, v in t do
for k, v in pairs(t) do
t[k] = nil
end
t.reset, t.reset = nil, 1
@@ -17,7 +17,7 @@ end
M.wipe = wipe
CreateFrame'Frame':SetScript('OnUpdate', function()
for t in auto_release do release(t) end
for t in pairs(auto_release) do release(t) end
wipe(auto_release)
end)
@@ -124,7 +124,7 @@ M.A = vararg(function(arg)
end)
M.S = vararg(function(arg)
local t = acquire()
for _, v in arg do
for _, v in pairs(arg) do
t[v] = true
end
return t
+3 -3
View File
@@ -13,10 +13,10 @@ function format_value(v)
end
function print_table(t, depth)
for i = 1, getn(t) do
print_pair(i, t[i], depth)
for i, v in ipairs(t) do
print_pair(i, v, depth)
end
for k, v in t do
for k, v in pairs(t) do
if type(k) ~= 'number' or k < 1 or k > getn(t) then
print_pair(k, v, depth)
end
+1 -1
View File
@@ -24,7 +24,7 @@ end
function include(self, name)
local module = name and loaded[name] or error('No module "%s".', name)
for k, v in module.public_fields do define(self, k, v, true) end
for k, v in pairs(module.public_fields) do define(self, k, v, true) end
end
public_modifier_mt = {__metatable=false, __newindex=define}
+5 -6
View File
@@ -122,8 +122,7 @@ function update_auction_listing(listing, records, reference)
if selected_item then
local historical_value = history.value(selected_item.key)
local stack_size = stack_size_slider:GetValue()
for i = 1, getn(records[selected_item.key] or empty) do
local record = records[selected_item.key][i]
for _, record in pairs(records[selected_item.key] or empty) do
local price_color = undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and color.red
local price = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1)
tinsert(rows, O(
@@ -181,7 +180,7 @@ function update_auction_listings()
end
function M.select_item(item_key)
for _, inventory_record in filter(copy(inventory_records), function(record) return record.aux_quantity > 0 end) do
for _, inventory_record in pairs(filter(copy(inventory_records), function(record) return record.aux_quantity > 0 end)) do
if inventory_record.key == item_key then
update_item(inventory_record)
return
@@ -237,7 +236,7 @@ function post_auctions()
end
update_inventory_records()
local same
for _, record in inventory_records do
for _, record in pairs(inventory_records) do
if record.key == key then
same = record
break
@@ -500,7 +499,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
bid_records[key] = bid_records[key] or T
do
local entry
for _, record in bid_records[key] do
for _, record in pairs(bid_records[key]) do
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
entry = record
end
@@ -515,7 +514,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
if unit_buyout_price == 0 then return end
do
local entry
for _, record in buyout_records[key] do
for _, record in pairs(buyout_records[key]) do
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
entry = record
end
+3 -3
View File
@@ -81,17 +81,17 @@ function update_form()
if blizzard_query.exact then
usable_checkbox:Disable()
for key in temp-S('min_level', 'max_level') do
for key in pairs(temp-S('min_level', 'max_level')) do
_M[key .. '_input']:EnableMouse(false)
_M[key .. '_input']:ClearFocus()
end
for key in temp-S('class', 'subclass', 'slot', 'quality') do
for key in pairs(temp-S('class', 'subclass', 'slot', 'quality')) do
_M[key .. '_dropdown'].button:Disable()
end
CloseDropDownMenus()
else
usable_checkbox:Enable()
for key in temp-S('min_level', 'max_level') do
for key in pairs(temp-S('min_level', 'max_level')) do
_M[key .. '_input']:EnableMouse(true)
end
class_dropdown.button:Enable()