module refactoring
This commit is contained in:
+17
-17
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.auction_listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local sort_util = require 'aux.util.sort'
|
||||
local money = require 'aux.util.money'
|
||||
@@ -10,7 +11,6 @@ local history = require 'aux.core.history'
|
||||
local gui = require 'aux.gui'
|
||||
local search_tab = require 'aux.tabs.search'
|
||||
local tooltip = require 'aux.core.tooltip'
|
||||
local cache = require 'aux.core.cache'
|
||||
|
||||
local price_per_unit = false
|
||||
|
||||
@@ -140,7 +140,7 @@ M.search_columns = {
|
||||
width = .13,
|
||||
align = 'CENTER',
|
||||
fill = function(cell, record)
|
||||
cell.text:SetText(cache.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
cell.text:SetText(info.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
if not record_a.owner and not record_b.owner then
|
||||
@@ -429,7 +429,7 @@ M.bids_columns = {
|
||||
width = .13,
|
||||
align = 'CENTER',
|
||||
fill = function(cell, record)
|
||||
cell.text:SetText(cache.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
cell.text:SetText(info.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
if not record_a.owner and not record_b.owner then
|
||||
@@ -625,9 +625,9 @@ local methods = {
|
||||
DressUpItemLink(this.record.link)
|
||||
elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(this.record.link)
|
||||
elseif not modified and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
tab = 1
|
||||
search_tab.filter = strlower(info.item(this.record.item_id).name) .. '/exact'
|
||||
elseif not modified() and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
set_tab(1)
|
||||
search_tab.set_filter(strlower(info.item(this.record.item_id).name) .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
else
|
||||
local selection = this.rt:GetSelection()
|
||||
@@ -655,13 +655,13 @@ local methods = {
|
||||
for _, v in ipairs(self.rowInfo) do
|
||||
if type(v) == 'table' then
|
||||
for _, child in pairs(v.children) do
|
||||
release(child)
|
||||
T.release(child)
|
||||
end
|
||||
release(v.children)
|
||||
release(v)
|
||||
T.release(v.children)
|
||||
T.release(v)
|
||||
end
|
||||
end
|
||||
wipe(self.rowInfo)
|
||||
T.wipe(self.rowInfo)
|
||||
self.rowInfo.numDisplayRows = 0
|
||||
self.isSorted = nil
|
||||
self:SetSelectedRecord(nil, true)
|
||||
@@ -680,13 +680,13 @@ local methods = {
|
||||
self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].count = self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].count + 1
|
||||
elseif not single_item and prevRecord and record.item_key == prevRecord.item_key then
|
||||
-- it's the same base item as the previous row so insert a new auction
|
||||
tinsert(self.rowInfo[getn(self.rowInfo)].children, O('count', 1, 'record', record))
|
||||
tinsert(self.rowInfo[getn(self.rowInfo)].children, T.map('count', 1, 'record', record))
|
||||
if self.expanded[self.rowInfo[getn(self.rowInfo)].expandKey] then
|
||||
self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1
|
||||
end
|
||||
else
|
||||
-- it's a different base item from the previous row
|
||||
tinsert(self.rowInfo, O('item_key', record.item_key, 'expandKey', record.item_key, 'children', A(O('count', 1, 'record', record))))
|
||||
tinsert(self.rowInfo, T.map('item_key', record.item_key, 'expandKey', record.item_key, 'children', T.list(T.map('count', 1, 'record', record))))
|
||||
self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1
|
||||
end
|
||||
end
|
||||
@@ -695,7 +695,7 @@ local methods = {
|
||||
local totalAuctions, totalPlayerAuctions = 0, 0
|
||||
for _, childInfo in pairs(v.children) do
|
||||
totalAuctions = totalAuctions + childInfo.count
|
||||
if cache.is_player(childInfo.record.owner) then
|
||||
if info.is_player(childInfo.record.owner) then
|
||||
totalPlayerAuctions = totalPlayerAuctions + childInfo.count
|
||||
end
|
||||
end
|
||||
@@ -823,7 +823,7 @@ local methods = {
|
||||
end,
|
||||
|
||||
Reset = function(self)
|
||||
wipe(self.expanded)
|
||||
T.wipe(self.expanded)
|
||||
self:UpdateRowInfo()
|
||||
self:UpdateRows()
|
||||
self:SetSelectedRecord()
|
||||
@@ -876,7 +876,7 @@ local methods = {
|
||||
end
|
||||
end,
|
||||
|
||||
SetSort = vararg-function(arg)
|
||||
SetSort = T.vararg-function(arg)
|
||||
local self = tremove(arg, 1)
|
||||
for _, v in ipairs(arg) do
|
||||
for i, sort in pairs(self.sorts) do
|
||||
@@ -938,7 +938,7 @@ function M.new(parent, rows, columns)
|
||||
contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
rt.contentFrame = contentFrame
|
||||
|
||||
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name, rt, 'FauxScrollFrameTemplate')
|
||||
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name(), rt, 'FauxScrollFrameTemplate')
|
||||
scrollFrame:SetScript('OnVerticalScroll', function()
|
||||
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
|
||||
end)
|
||||
|
||||
+17
-16
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.font = [[Fonts\ARIALN.TTF]]
|
||||
|
||||
M.font_size = immutable-{
|
||||
@@ -11,7 +12,7 @@ M.font_size = immutable-{
|
||||
large = 18,
|
||||
}
|
||||
|
||||
--function LOAD()
|
||||
--function handle.LOAD()
|
||||
-- do
|
||||
-- local blizzard_backdrop, aux_background, aux_border
|
||||
--
|
||||
@@ -25,8 +26,8 @@ M.font_size = immutable-{
|
||||
-- aux_background:SetAllPoints(DropDownList1Backdrop)
|
||||
-- blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
|
||||
-- hook('ToggleDropDownMenu', function(...)
|
||||
-- temp(arg)
|
||||
-- local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
|
||||
-- T.temp(arg)
|
||||
-- local ret = T.temp-T.list(orig.ToggleDropDownMenu(unpack(arg)))
|
||||
-- local dropdown = _G[arg[4] or ''] or this:GetParent()
|
||||
-- if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
|
||||
-- set_aux_dropdown_style(dropdown)
|
||||
@@ -37,7 +38,7 @@ M.font_size = immutable-{
|
||||
-- end)
|
||||
--
|
||||
-- function set_aux_dropdown_style(dropdown)
|
||||
-- DropDownList1Backdrop:SetBackdrop(empty)
|
||||
-- DropDownList1Backdrop:SetBackdrop(T.empty)
|
||||
-- aux_border:Show()
|
||||
-- aux_background:Show()
|
||||
-- DropDownList1:SetWidth(dropdown:GetWidth() * .9)
|
||||
@@ -88,19 +89,19 @@ M.font_size = immutable-{
|
||||
|
||||
do
|
||||
local id = 1
|
||||
function M.get.unique_name()
|
||||
function M.unique_name()
|
||||
id = id + 1
|
||||
return 'AuxFrame' .. id
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local menu = CreateFrame('Frame', unique_name, UIParent, 'UIDropDownMenuTemplate')
|
||||
M.menu = vararg-function(arg)
|
||||
local menu = CreateFrame('Frame', unique_name(), UIParent, 'UIDropDownMenuTemplate')
|
||||
M.menu = T.vararg-function(arg)
|
||||
HideDropDownMenu(1)
|
||||
UIDropDownMenu_Initialize(menu, function()
|
||||
for i = 1, getn(arg), 2 do
|
||||
UIDropDownMenu_AddButton(O('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
|
||||
UIDropDownMenu_AddButton(T.map('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
|
||||
end
|
||||
end, 'MENU')
|
||||
ToggleDropDownMenu(1, nil, menu, 'cursor')
|
||||
@@ -190,11 +191,11 @@ function M.button(parent, text_height)
|
||||
end
|
||||
|
||||
do
|
||||
local mt = {__index=T}
|
||||
local mt = {__index=T.acquire()}
|
||||
function mt.__index:create_tab(text)
|
||||
local id = getn(self._tabs) + 1
|
||||
|
||||
local tab = CreateFrame('Button', unique_name, self._frame)
|
||||
local tab = CreateFrame('Button', unique_name(), self._frame)
|
||||
tab.id = id
|
||||
tab.group = self
|
||||
tab:SetHeight(24)
|
||||
@@ -275,7 +276,7 @@ do
|
||||
local self = {
|
||||
_frame = parent,
|
||||
_orientation = orientation,
|
||||
_tabs = T,
|
||||
_tabs = T.acquire(),
|
||||
}
|
||||
return setmetatable(self, mt)
|
||||
end
|
||||
@@ -320,7 +321,7 @@ function M.editbox(parent)
|
||||
end)
|
||||
editbox:SetScript('OnChar', function() (this.char or nop)() end)
|
||||
do
|
||||
local last_click = O('t', 0)
|
||||
local last_click = T.map('t', 0)
|
||||
editbox:SetScript('OnMouseDown', function()
|
||||
if arg1 == 'RightButton' then
|
||||
this:SetText('')
|
||||
@@ -333,7 +334,7 @@ function M.editbox(parent)
|
||||
if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
|
||||
thread(function() editbox:HighlightText() end)
|
||||
end
|
||||
wipe(last_click)
|
||||
T.wipe(last_click)
|
||||
last_click.t = GetTime()
|
||||
last_click.x = x
|
||||
last_click.y = y
|
||||
@@ -419,7 +420,7 @@ end
|
||||
function M.item(parent)
|
||||
local item = CreateFrame('Frame', nil, parent)
|
||||
set_size(item, 260, 40)
|
||||
local btn = CreateFrame('CheckButton', unique_name, item, 'ActionButtonTemplate')
|
||||
local btn = CreateFrame('CheckButton', unique_name(), item, 'ActionButtonTemplate')
|
||||
item.button = btn
|
||||
btn:SetPoint('LEFT', 2, .5)
|
||||
btn:SetHighlightTexture(nil)
|
||||
@@ -469,7 +470,7 @@ function M.vertical_line(parent, x_offset, top_offset, bottom_offset, inverted_c
|
||||
end
|
||||
|
||||
function M.dropdown(parent)
|
||||
local dropdown = CreateFrame('Frame', unique_name, parent, 'UIDropDownMenuTemplate')
|
||||
local dropdown = CreateFrame('Frame', unique_name(), parent, 'UIDropDownMenuTemplate')
|
||||
set_content_style(dropdown, 0, 0, 4, 4)
|
||||
|
||||
_G[dropdown:GetName() .. 'Left']:Hide()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.item_listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
@@ -10,7 +11,7 @@ local ROW_HEIGHT = 39
|
||||
|
||||
function M:render()
|
||||
|
||||
if getn(self.item_records or empty) > getn(self.rows) then
|
||||
if getn(self.item_records or T.empty) > getn(self.rows) then
|
||||
self.content_frame:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||
else
|
||||
self.content_frame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
@@ -51,7 +52,7 @@ function M.new(parent, on_click, selected)
|
||||
local content_frame = CreateFrame('Frame', nil, parent)
|
||||
content_frame:SetAllPoints()
|
||||
|
||||
local scroll_frame = CreateFrame('ScrollFrame', gui.unique_name, parent, 'FauxScrollFrameTemplate')
|
||||
local scroll_frame = CreateFrame('ScrollFrame', gui.unique_name(), parent, 'FauxScrollFrameTemplate')
|
||||
scroll_frame:SetScript('OnVerticalScroll', function()
|
||||
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end)
|
||||
end)
|
||||
@@ -71,7 +72,7 @@ function M.new(parent, on_click, selected)
|
||||
_G[scroll_bar:GetName() .. 'ScrollUpButton']:Hide()
|
||||
_G[scroll_bar:GetName() .. 'ScrollDownButton']:Hide()
|
||||
|
||||
local rows = T
|
||||
local rows = T.acquire()
|
||||
local row_index = 1
|
||||
local max_height = content_frame:GetHeight()
|
||||
local total_height = 0
|
||||
|
||||
+12
-11
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
local ROW_HEIGHT = 15
|
||||
@@ -64,7 +65,7 @@ local methods = {
|
||||
self.headHeight = 0
|
||||
end
|
||||
|
||||
if getn(self.rowData or empty) > self.numRows then
|
||||
if getn(self.rowData or T.empty) > self.numRows then
|
||||
self.contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||
else
|
||||
self.contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
@@ -150,10 +151,10 @@ local methods = {
|
||||
end,
|
||||
|
||||
SetData = function(self, rowData)
|
||||
for _, row in pairs(self.rowData or empty) do
|
||||
for _, col in pairs(row.cols) do release(col) end
|
||||
release(row.cols)
|
||||
release(row)
|
||||
for _, row in pairs(self.rowData or T.empty) do
|
||||
for _, col in pairs(row.cols) do T.release(col) end
|
||||
T.release(row.cols)
|
||||
T.release(row)
|
||||
end
|
||||
self.rowData = rowData
|
||||
self.updateSort = true
|
||||
@@ -235,7 +236,7 @@ local methods = {
|
||||
row.highlight = highlight
|
||||
row.st = self
|
||||
|
||||
row.cols = T
|
||||
row.cols = T.acquire()
|
||||
self.rows[rowNum] = row
|
||||
for _ = 1, getn(self.colInfo) do
|
||||
self:AddCell(rowNum)
|
||||
@@ -258,7 +259,7 @@ local methods = {
|
||||
}
|
||||
|
||||
function M.new(parent)
|
||||
local st = CreateFrame('Frame', gui.unique_name, parent)
|
||||
local st = CreateFrame('Frame', gui.unique_name(), parent)
|
||||
st:SetAllPoints()
|
||||
|
||||
st.numRows = max(floor((parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / ROW_HEIGHT), 0)
|
||||
@@ -292,9 +293,9 @@ function M.new(parent)
|
||||
st[name] = func
|
||||
end
|
||||
|
||||
st.headCols = T
|
||||
st.rows = T
|
||||
st.handlers = T
|
||||
st.headCols = T.acquire()
|
||||
st.rows = T.acquire()
|
||||
st.handlers = T.acquire()
|
||||
st.colInfo = DEFAULT_COL_INFO
|
||||
|
||||
return st
|
||||
|
||||
Reference in New Issue
Block a user