refactoring
This commit is contained in:
+4
-3
@@ -57,6 +57,7 @@ do
|
|||||||
-- log(getn(table_pool), '-', getn(weak_pool))
|
-- log(getn(table_pool), '-', getn(weak_pool))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function public.t.get()
|
function public.t.get()
|
||||||
return tremove(pool) or tremove(overflow_pool, next(overflow_pool)) or {}
|
return tremove(pool) or tremove(overflow_pool, next(overflow_pool)) or {}
|
||||||
end
|
end
|
||||||
@@ -171,7 +172,7 @@ end
|
|||||||
|
|
||||||
function public.log(...) temp=arg
|
function public.log(...) temp=arg
|
||||||
local msg = '[aux]'
|
local msg = '[aux]'
|
||||||
for i=1,arg.n do msg = msg..' '..tostring(arg[i]) end
|
for i = 1, arg.n do msg = msg..' '..tostring(arg[i]) end
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -363,7 +364,7 @@ do
|
|||||||
local id = GetCraftSelectionIndex()
|
local id = GetCraftSelectionIndex()
|
||||||
local reagent_count = GetCraftNumReagents(id)
|
local reagent_count = GetCraftNumReagents(id)
|
||||||
local total_cost = 0
|
local total_cost = 0
|
||||||
for i=1,reagent_count do
|
for i = 1, reagent_count do
|
||||||
local link = GetCraftReagentItemLink(id, i)
|
local link = GetCraftReagentItemLink(id, i)
|
||||||
if not link then
|
if not link then
|
||||||
total_cost = nil
|
total_cost = nil
|
||||||
@@ -390,7 +391,7 @@ do
|
|||||||
local id = GetTradeSkillSelectionIndex()
|
local id = GetTradeSkillSelectionIndex()
|
||||||
local reagent_count = GetTradeSkillNumReagents(id)
|
local reagent_count = GetTradeSkillNumReagents(id)
|
||||||
local total_cost = 0
|
local total_cost = 0
|
||||||
for i=1,reagent_count do
|
for i = 1, reagent_count do
|
||||||
local link = GetTradeSkillReagentItemLink(id, i)
|
local link = GetTradeSkillReagentItemLink(id, i)
|
||||||
if not link then
|
if not link then
|
||||||
total_cost = nil
|
total_cost = nil
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function merchant_loaded()
|
function merchant_loaded()
|
||||||
for i=1,GetMerchantNumItems() do
|
for i = 1, GetMerchantNumItems() do
|
||||||
if not GetMerchantItemLink(i) then
|
if not GetMerchantItemLink(i) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -107,7 +107,7 @@ end
|
|||||||
function merchant_buy_scan()
|
function merchant_buy_scan()
|
||||||
|
|
||||||
local incomplete_data
|
local incomplete_data
|
||||||
for i=1,GetMerchantNumItems() do
|
for i = 1, GetMerchantNumItems() do
|
||||||
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
||||||
local link = GetMerchantItemLink(i)
|
local link = GetMerchantItemLink(i)
|
||||||
if link then
|
if link then
|
||||||
|
|||||||
+1
-1
@@ -224,7 +224,7 @@ function wait_for_list_results(send_signal, signal_received)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function owner_data_complete(type)
|
function owner_data_complete(type)
|
||||||
for i=1,PAGE_SIZE do
|
for i = 1, PAGE_SIZE do
|
||||||
local auction_info = info.auction(i, type)
|
local auction_info = info.auction(i, type)
|
||||||
if auction_info and not auction_info.owner then
|
if auction_info and not auction_info.owner then
|
||||||
return false
|
return false
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,7 @@ function _G.SlashCmdList.AUX(command)
|
|||||||
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
||||||
local realm = GetCVar 'realmName'
|
local realm = GetCVar 'realmName'
|
||||||
_G.aux_characters[realm] = _G.aux_characters[realm] or {}
|
_G.aux_characters[realm] = _G.aux_characters[realm] or {}
|
||||||
for i=3,getn(arguments) do
|
for i = 3, getn(arguments) do
|
||||||
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
||||||
if not _G.aux_characters[realm][name] then
|
if not _G.aux_characters[realm][name] then
|
||||||
_G.aux_characters[realm][name] = true
|
_G.aux_characters[realm][name] = true
|
||||||
@@ -65,7 +65,7 @@ function _G.SlashCmdList.AUX(command)
|
|||||||
if not _G.aux_characters[realm] then
|
if not _G.aux_characters[realm] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i=3,getn(arguments) do
|
for i = 3, getn(arguments) do
|
||||||
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
||||||
if _G.aux_characters[realm][name] then
|
if _G.aux_characters[realm][name] then
|
||||||
_G.aux_characters[realm][name] = nil
|
_G.aux_characters[realm][name] = nil
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ function record_percentage(record)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function percentage_color(pct)
|
function percentage_color(pct)
|
||||||
for i=1,getn(AUCTION_PCT_COLORS) do
|
for i = 1, getn(AUCTION_PCT_COLORS) do
|
||||||
if pct < AUCTION_PCT_COLORS[i].value then
|
if pct < AUCTION_PCT_COLORS[i].value then
|
||||||
return AUCTION_PCT_COLORS[i].color
|
return AUCTION_PCT_COLORS[i].color
|
||||||
end
|
end
|
||||||
@@ -693,7 +693,7 @@ local methods = {
|
|||||||
|
|
||||||
-- Populate the row info from the database by combining identical auctions and auctions
|
-- Populate the row info from the database by combining identical auctions and auctions
|
||||||
-- of the same base item. Also, get the number of rows which will be shown.
|
-- of the same base item. Also, get the number of rows which will be shown.
|
||||||
for i=1, getn(records) do
|
for i = 1, getn(records) do
|
||||||
local record = records[i]
|
local record = records[i]
|
||||||
local prevRecord = records[i-1]
|
local prevRecord = records[i-1]
|
||||||
if prevRecord and record.search_signature == prevRecord.search_signature then
|
if prevRecord and record.search_signature == prevRecord.search_signature then
|
||||||
@@ -903,7 +903,7 @@ local methods = {
|
|||||||
|
|
||||||
RemoveSelectedRecord = function(self, count)
|
RemoveSelectedRecord = function(self, count)
|
||||||
count = count or 1
|
count = count or 1
|
||||||
for i=1, count do
|
for i = 1, count do
|
||||||
local index = key(self.selected, self.records)
|
local index = key(self.selected, self.records)
|
||||||
if index then
|
if index then
|
||||||
tremove(self.records, index)
|
tremove(self.records, index)
|
||||||
@@ -914,7 +914,7 @@ local methods = {
|
|||||||
|
|
||||||
InsertAuctionRecord = function(self, record, count)
|
InsertAuctionRecord = function(self, record, count)
|
||||||
count = count or 1
|
count = count or 1
|
||||||
for i=1, count do
|
for i = 1, count do
|
||||||
tinsert(self.records, record)
|
tinsert(self.records, record)
|
||||||
end
|
end
|
||||||
self:SetDatabase()
|
self:SetDatabase()
|
||||||
@@ -1089,7 +1089,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
|||||||
|
|
||||||
-- create the rows
|
-- create the rows
|
||||||
rt.rows = {}
|
rt.rows = {}
|
||||||
for i=1, numRows do
|
for i = 1, numRows do
|
||||||
local row = CreateFrame('Frame', nil, rt.contentFrame)
|
local row = CreateFrame('Frame', nil, rt.contentFrame)
|
||||||
row:SetHeight(rt.ROW_HEIGHT)
|
row:SetHeight(rt.ROW_HEIGHT)
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
|
|||||||
+3
-3
@@ -32,7 +32,7 @@ function LOAD()
|
|||||||
DropDownList1:SetHeight(DropDownList1:GetHeight() - 10)
|
DropDownList1:SetHeight(DropDownList1:GetHeight() - 10)
|
||||||
DropDownList1:ClearAllPoints()
|
DropDownList1:ClearAllPoints()
|
||||||
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
|
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
|
||||||
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
for i = 1, UIDROPDOWNMENU_MAXBUTTONS do
|
||||||
local button = _G['DropDownList1Button'..i]
|
local button = _G['DropDownList1Button'..i]
|
||||||
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
||||||
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
||||||
@@ -57,7 +57,7 @@ function LOAD()
|
|||||||
DropDownList1Backdrop:SetBackdrop(blizzard_backdrop)
|
DropDownList1Backdrop:SetBackdrop(blizzard_backdrop)
|
||||||
aux_border:Hide()
|
aux_border:Hide()
|
||||||
aux_background:Hide()
|
aux_background:Hide()
|
||||||
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
for i = 1, UIDROPDOWNMENU_MAXBUTTONS do
|
||||||
local button = _G['DropDownList1Button'..i]
|
local button = _G['DropDownList1Button'..i]
|
||||||
local text = button:GetFontString()
|
local text = button:GetFontString()
|
||||||
text:SetFont([[Fonts\FRIZQT__.ttf]], 10)
|
text:SetFont([[Fonts\FRIZQT__.ttf]], 10)
|
||||||
@@ -100,7 +100,7 @@ do
|
|||||||
orig = menu:GetScript 'OnShow'
|
orig = menu:GetScript 'OnShow'
|
||||||
menu:SetScript('OnShow', function()
|
menu:SetScript('OnShow', function()
|
||||||
UIMenu_Initialize()
|
UIMenu_Initialize()
|
||||||
for i=1,getn(structure) do
|
for i = 1, getn(structure) do
|
||||||
UIMenu_AddButton(
|
UIMenu_AddButton(
|
||||||
structure[i][1],
|
structure[i][1],
|
||||||
structure[i],
|
structure[i],
|
||||||
|
|||||||
+2
-2
@@ -104,7 +104,7 @@ local methods = {
|
|||||||
st.updateSort = nil
|
st.updateSort = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, st.sizes.numRows do
|
for i = 1, st.sizes.numRows do
|
||||||
st.rows[i].data = nil
|
st.rows[i].data = nil
|
||||||
if i > getn(st.rowData) then
|
if i > getn(st.rowData) then
|
||||||
st.rows[i]:Hide()
|
st.rows[i]:Hide()
|
||||||
@@ -375,7 +375,7 @@ local methods = {
|
|||||||
|
|
||||||
row.cols = {}
|
row.cols = {}
|
||||||
st.rows[rowNum] = row
|
st.rows[rowNum] = row
|
||||||
for i=1, getn(st.colInfo) do
|
for i = 1, getn(st.colInfo) do
|
||||||
st:AddRowCol(rowNum)
|
st:AddRowCol(rowNum)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
+44
-44
@@ -12,7 +12,7 @@ local function collision_error(key) error('"%s" already exists.', key) end
|
|||||||
local function nop() end
|
local function nop() end
|
||||||
local function const(v) return function() return v end end
|
local function const(v) return function() return v end end
|
||||||
|
|
||||||
local _state = {}
|
local state = {}
|
||||||
|
|
||||||
local declarator_mt = {__metatable=false}
|
local declarator_mt = {__metatable=false}
|
||||||
do
|
do
|
||||||
@@ -23,86 +23,86 @@ do
|
|||||||
if next(v) or f ~= nil and getter ~= nil then error() end
|
if next(v) or f ~= nil and getter ~= nil then error() end
|
||||||
return f, getter, setter
|
return f, getter, setter
|
||||||
end
|
end
|
||||||
local function declare(state, access, name, handlers)
|
local function declare(self, access, name, handlers)
|
||||||
state.access[name] = state.access[name] and collision_error(name) or access or PRIVATE
|
self.access[name] = self.access[name] and collision_error(name) or access or PRIVATE
|
||||||
for event, handler in handlers do
|
for event, handler in handlers do
|
||||||
if type(handler) ~= 'function' and (event == INDEX or declaration_error()) then
|
if type(handler) ~= 'function' and (event == INDEX or declaration_error()) then
|
||||||
handler = const(handler == nil and tostring(name) or handler)
|
handler = const(handler == nil and tostring(name) or handler)
|
||||||
end
|
end
|
||||||
state[event][name] = handler
|
self[event][name] = handler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function declarator_mt:__index(key) local state=_state[self]
|
function declarator_mt:__index(key) self=state[self]
|
||||||
if ACCESS[key] and not state.declaration_access then
|
if ACCESS[key] and not self.declaration_access then
|
||||||
state.declaration_access = ACCESS[key]
|
self.declaration_access = ACCESS[key]
|
||||||
elseif not state.declaration_name or declaration_error() then
|
elseif not self.declaration_name or declaration_error() then
|
||||||
state.declaration_name = type(key) == 'string' and key or declaration_error()
|
self.declaration_name = type(key) == 'string' and key or declaration_error()
|
||||||
end
|
end
|
||||||
return self
|
return self.declarator
|
||||||
end
|
end
|
||||||
function declarator_mt:__newindex(key, value) local state=_state[self]
|
function declarator_mt:__newindex(key, value) self=state[self]
|
||||||
local name, event = state.declaration_name, nil
|
local name, event = self.declaration_name, nil
|
||||||
if name then
|
if name then
|
||||||
event = EVENT[key] or declaration_error()
|
event = EVENT[key] or declaration_error()
|
||||||
else
|
else
|
||||||
name, event = key, type(value) == 'function' and CALL or INDEX
|
name, event = key, type(value) == 'function' and CALL or INDEX
|
||||||
end
|
end
|
||||||
declare(state, state.declaration_access, name, {[event]=value})
|
declare(self, self.declaration_access, name, {[event]=value})
|
||||||
state.declaration_access, state.declaration_name = nil, nil
|
self.declaration_access, self.declaration_name = nil, nil
|
||||||
end
|
end
|
||||||
function declarator_mt:__call(value) local state=_state[self]
|
function declarator_mt:__call(value) self=state[self]
|
||||||
if state.declaration_name then
|
if self.declaration_name then
|
||||||
local success, f, getter, setter = pcall(extract, value)
|
local success, f, getter, setter = pcall(extract, value)
|
||||||
if not success then declaration_error() end
|
if not success then declaration_error() end
|
||||||
declare(state, state.declaration_access, state.declaration_name, {[CALL]=f, [INDEX]=getter, [NEWINDEX]=setter})
|
declare(self, self.declaration_access, self.declaration_name, {[CALL]=f, [INDEX]=getter, [NEWINDEX]=setter})
|
||||||
end
|
end
|
||||||
state.declaration_access, state.declaration_name = nil, nil
|
self.declaration_access, self.declaration_name = nil, nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local env_mt = {__metatable=false}
|
local env_mt = {__metatable=false}
|
||||||
function env_mt:__index(key) local state=_state[self]
|
function env_mt:__index(key) self=state[self]
|
||||||
local getter = state[INDEX][key]
|
local getter = self[INDEX][key]
|
||||||
if getter then return getter() end
|
if getter then return getter() end
|
||||||
return state[CALL][key] or _G[key] or state.declarator[key]
|
return self[CALL][key] or _G[key] or self.declarator[key]
|
||||||
end
|
end
|
||||||
function env_mt:__newindex(key, value) local state=_state[self]
|
function env_mt:__newindex(key, value) self=state[self]
|
||||||
if state.access[key] then
|
if self.access[key] then
|
||||||
local setter = state[NEWINDEX][key] or collision_error(key)
|
local setter = self[NEWINDEX][key] or collision_error(key)
|
||||||
setter(value)
|
setter(value)
|
||||||
else
|
else
|
||||||
state.declarator[key] = value
|
self.declarator[key] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local interface_mt = {__metatable=false}
|
local interface_mt = {__metatable=false}
|
||||||
function interface_mt:__index(key) local state=_state[self]
|
function interface_mt:__index(key) self=state[self]
|
||||||
if state.access[key] == PUBLIC then
|
if self.access[key] == PUBLIC then
|
||||||
local getter = state[INDEX][key]
|
local getter = self[INDEX][key]
|
||||||
if getter then return getter() else return state[CALL][key] end
|
if getter then return getter() else return self[CALL][key] end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function interface_mt:__newindex(key, value) local state=_state[self]
|
function interface_mt:__newindex(key, value) self=state[self]
|
||||||
if state.access[key] == PUBLIC then (state[NEWINDEX][key] or nop)(value) end
|
if self.access[key] == PUBLIC then (self[NEWINDEX][key] or nop)(value) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function module(...)
|
function module(...)
|
||||||
local state, declarator, env, interface, access, functions, getters, setters
|
local declarator, env, interface = setmetatable({}, declarator_mt), setmetatable({}, env_mt), setmetatable({}, interface_mt)
|
||||||
declarator, env, interface = setmetatable({}, declarator_mt), setmetatable({}, env_mt), setmetatable({}, interface_mt)
|
local self = {
|
||||||
access = {_=PRIVATE, error=PRIVATE, nop=PRIVATE, _G=PRIVATE, M=PRIVATE, I=PRIVATE, public=PRIVATE, private=PRIVATE}
|
access = {_=PRIVATE, error=PRIVATE, nop=PRIVATE, _G=PRIVATE, M=PRIVATE, I=PRIVATE, public=PRIVATE, private=PRIVATE},
|
||||||
functions = {error=error, nop=nop}
|
[CALL] = {error=error, nop=nop},
|
||||||
getters = {_G=const(_G), M=const(env), I=const(interface), public=function() return declarator.public end, private=function() return declarator.private end}
|
[INDEX] = {_G=const(_G), M=const(env), I=const(interface), public=function() return declarator.public end, private=function() return declarator.private end},
|
||||||
setters = {_=nop}
|
[NEWINDEX] = {_=nop},
|
||||||
for i=1,arg.n do
|
declarator = declarator,
|
||||||
local module = _state[arg[i] or import_error()] or import_error()
|
}
|
||||||
local module_functions, module_getters, module_setters = module[CALL], module[INDEX], module[NEWINDEX]
|
for i = 1, arg.n do
|
||||||
|
local module = state[arg[i] or import_error()]
|
||||||
for k, v in module.access do
|
for k, v in module.access do
|
||||||
if v == PUBLIC and (not access[k] or import_error()) then
|
if v == PUBLIC and not self.access[k] then
|
||||||
access[k], functions[k], getters[k], setters[k] = PRIVATE, module_functions[k], module_getters[k], module_setters[k]
|
self.access[k], self[CALL][k], self[INDEX][k], self[NEWINDEX][k] = PRIVATE, module[CALL][k], module[INDEX][k], module[NEWINDEX][k]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
state = {access=access, [CALL]=functions, [INDEX]=getters, [NEWINDEX]=setters, declarator=declarator}
|
state[declarator], state[env], state[interface] = self, self, self
|
||||||
_state[declarator], _state[env], _state[interface] = state, state, state
|
|
||||||
setfenv(2, env)
|
setfenv(2, env)
|
||||||
end
|
end
|
||||||
+2
-2
@@ -221,7 +221,7 @@ function post_auctions()
|
|||||||
unit_buyout_price,
|
unit_buyout_price,
|
||||||
stack_count,
|
stack_count,
|
||||||
function(posted)
|
function(posted)
|
||||||
for i=1,posted do
|
for i = 1, posted do
|
||||||
record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName('player'))
|
record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName('player'))
|
||||||
end
|
end
|
||||||
update_inventory_records()
|
update_inventory_records()
|
||||||
@@ -405,7 +405,7 @@ function update_inventory_records()
|
|||||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||||
if not auctionable_map[item_info.item_key] then
|
if not auctionable_map[item_info.item_key] then
|
||||||
local availability = t
|
local availability = t
|
||||||
for i=0,10 do
|
for i = 0, 10 do
|
||||||
availability[i] = 0
|
availability[i] = 0
|
||||||
end
|
end
|
||||||
availability[charge_class] = item_info.count
|
availability[charge_class] = item_info.count
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ function initialize_quality_dropdown()
|
|||||||
update_form()
|
update_form()
|
||||||
end
|
end
|
||||||
UIDropDownMenu_AddButton(-object('text', ALL, 'value', -1, 'func', on_click))
|
UIDropDownMenu_AddButton(-object('text', ALL, 'value', -1, 'func', on_click))
|
||||||
for i=0,4 do
|
for i = 0, 4 do
|
||||||
UIDropDownMenu_AddButton(-object('text', _G['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click))
|
UIDropDownMenu_AddButton(-object('text', _G['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ function start_search(queries, continuation)
|
|||||||
|
|
||||||
if continuation then
|
if continuation then
|
||||||
start_query, start_page = unpack(continuation)
|
start_query, start_page = unpack(continuation)
|
||||||
for i=1,start_query-1 do
|
for i = 1, start_query - 1 do
|
||||||
tremove(queries, 1)
|
tremove(queries, 1)
|
||||||
end
|
end
|
||||||
queries[1].blizzard_query.first_page = (queries[1].blizzard_query.first_page or 0) + start_page - 1
|
queries[1].blizzard_query.first_page = (queries[1].blizzard_query.first_page or 0) + start_page - 1
|
||||||
|
|||||||
+4
-4
@@ -20,14 +20,14 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local formal_parameters = t
|
local formal_parameters = t
|
||||||
for i=1,9 do
|
for i = 1, 9 do
|
||||||
local key = '_'..i
|
local key = '_'..i
|
||||||
public[key] = t
|
public[key] = t
|
||||||
formal_parameters[M[key]] = i
|
formal_parameters[M[key]] = i
|
||||||
end
|
end
|
||||||
local function helper(f, arg1, arg2)
|
local function helper(f, arg1, arg2)
|
||||||
local params = t
|
local params = t
|
||||||
for i=1,arg1.n do
|
for i = 1, arg1.n do
|
||||||
if formal_parameters[arg1[i]] then
|
if formal_parameters[arg1[i]] then
|
||||||
tinsert(params, arg2[formal_parameters[arg1[i]]])
|
tinsert(params, arg2[formal_parameters[arg1[i]]])
|
||||||
else
|
else
|
||||||
@@ -58,7 +58,7 @@ function public.call(f, ...) temp=arg
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.index(t, ...) temp=arg
|
function public.index(t, ...) temp=arg
|
||||||
for i=1,arg.n do
|
for i = 1, arg.n do
|
||||||
t = t and t[arg[i]]
|
t = t and t[arg[i]]
|
||||||
end
|
end
|
||||||
return t
|
return t
|
||||||
@@ -94,7 +94,7 @@ end
|
|||||||
|
|
||||||
function public.expand(array, ...) temp=arg
|
function public.expand(array, ...) temp=arg
|
||||||
local t = t
|
local t = t
|
||||||
for i=1,arg.n do t[arg[i]] = array[i] end
|
for i = 1, arg.n do t[arg[i]] = array[i] end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -402,7 +402,7 @@ function suggestions(components)
|
|||||||
|
|
||||||
-- rarities
|
-- rarities
|
||||||
if not components.blizzard.quality then
|
if not components.blizzard.quality then
|
||||||
for i=0,4 do tinsert(suggestions, _G['ITEM_QUALITY'..i..'_DESC']) end
|
for i = 0, 4 do tinsert(suggestions, _G['ITEM_QUALITY'..i..'_DESC']) end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- item names
|
-- item names
|
||||||
@@ -534,7 +534,7 @@ function validator(components)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local stack = {}
|
local stack = {}
|
||||||
for i=getn(components.post),1,-1 do
|
for i = getn(components.post), 1, -1 do
|
||||||
local type, name, param = unpack(components.post[i])
|
local type, name, param = unpack(components.post[i])
|
||||||
if type == 'operator' then
|
if type == 'operator' then
|
||||||
local args = {}
|
local args = {}
|
||||||
|
|||||||
+3
-3
@@ -236,7 +236,7 @@ function public.load_tooltip(frame, tooltip)
|
|||||||
frame:AddLine(line.left_text, line.left_color[1], line.left_color[2], line.left_color[3], true)
|
frame:AddLine(line.left_text, line.left_color[1], line.left_color[2], line.left_color[3], true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i=1,getn(tooltip) do -- TODO why is this needed?
|
for i = 1, getn(tooltip) do -- TODO why is this needed?
|
||||||
_G[frame:GetName()..'TextLeft'..i]:SetJustifyH('LEFT')
|
_G[frame:GetName()..'TextLeft'..i]:SetJustifyH('LEFT')
|
||||||
_G[frame:GetName()..'TextRight'..i]:SetJustifyH('LEFT')
|
_G[frame:GetName()..'TextRight'..i]:SetJustifyH('LEFT')
|
||||||
end
|
end
|
||||||
@@ -273,7 +273,7 @@ function public.tooltip(setter)
|
|||||||
AuxTooltip:Show()
|
AuxTooltip:Show()
|
||||||
|
|
||||||
local tooltip = t
|
local tooltip = t
|
||||||
for i=1,AuxTooltip:NumLines() do
|
for i = 1, AuxTooltip:NumLines() do
|
||||||
tinsert(tooltip, {
|
tinsert(tooltip, {
|
||||||
left_text = _G['AuxTooltipTextLeft'..i]:GetText(),
|
left_text = _G['AuxTooltipTextLeft'..i]:GetText(),
|
||||||
left_color = {_G['AuxTooltipTextLeft'..i]:GetTextColor()},
|
left_color = {_G['AuxTooltipTextLeft'..i]:GetTextColor()},
|
||||||
@@ -395,7 +395,7 @@ function public.item_slot_index(class_index, subclass_index, slot_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.item_quality_index(item_quality)
|
function public.item_quality_index(item_quality)
|
||||||
for i=0,4 do
|
for i = 0, 4 do
|
||||||
local quality = _G['ITEM_QUALITY'..i..'_DESC']
|
local quality = _G['ITEM_QUALITY'..i..'_DESC']
|
||||||
if strupper(item_quality) == strupper(quality) then
|
if strupper(item_quality) == strupper(quality) then
|
||||||
return i, quality
|
return i, quality
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ function public.read_record(schema, str)
|
|||||||
local separator = schema[2]
|
local separator = schema[2]
|
||||||
local record = t
|
local record = t
|
||||||
local parts = split(str, separator)
|
local parts = split(str, separator)
|
||||||
for i=3,getn(schema) do
|
for i = 3, getn(schema) do
|
||||||
local key, type = next(schema[i])
|
local key, type = next(schema[i])
|
||||||
record[key] = read(type, parts[i - 2])
|
record[key] = read(type, parts[i - 2])
|
||||||
end
|
end
|
||||||
@@ -79,7 +79,7 @@ end
|
|||||||
function public.write_record(schema, record)
|
function public.write_record(schema, record)
|
||||||
local separator = schema[2]
|
local separator = schema[2]
|
||||||
local parts = tt
|
local parts = tt
|
||||||
for i=3,getn(schema) do
|
for i = 3, getn(schema) do
|
||||||
local key, type = next(schema[i])
|
local key, type = next(schema[i])
|
||||||
tinsert(parts, write(type, record[key]))
|
tinsert(parts, write(type, record[key]))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user