File Flowerpicker.lua changed (mode: 100644) (index c9c8640..f8ae1ef) |
... |
... |
Event registry accessor. |
491 |
491 |
@param dao a table that is the entire event registry to query |
@param dao a table that is the entire event registry to query |
492 |
492 |
@return table that is the result set of the query |
@return table that is the result set of the query |
493 |
493 |
]] |
]] |
494 |
|
local function query(dao) |
|
|
494 |
|
local function query(dao, pageNumber) |
495 |
495 |
assert (dao ~= nil) |
assert (dao ~= nil) |
496 |
496 |
assert ('table' == type(dao)) |
assert ('table' == type(dao)) |
497 |
497 |
|
|
|
498 |
|
local p = sanitiseShort(pageNumber) |
|
499 |
|
assert (validatePositiveAndNonZero(p)) |
|
500 |
|
local maxEntryQuantityPerPage = 16 |
|
501 |
|
|
498 |
502 |
table.sort(dao, function(a, b) |
table.sort(dao, function(a, b) |
499 |
503 |
return getEventItemName(a) < getEventItemName(b) |
return getEventItemName(a) < getEventItemName(b) |
500 |
504 |
end) |
end) |
|
... |
... |
local function query(dao) |
525 |
529 |
r = nil |
r = nil |
526 |
530 |
end |
end |
527 |
531 |
end |
end |
528 |
|
if nil == r and #resultTable < 16 then |
|
|
532 |
|
if nil == r and #resultTable then |
529 |
533 |
r = {eventType, itemName, itemQuantity} |
r = {eventType, itemName, itemQuantity} |
530 |
534 |
table.insert(resultTable, r) |
table.insert(resultTable, r) |
531 |
535 |
end |
end |
532 |
536 |
end |
end |
533 |
537 |
|
|
534 |
|
assert (resultTable ~= nil) |
|
535 |
|
assert ('table' == type(resultTable)) |
|
536 |
|
return resultTable |
|
|
538 |
|
local finalResultTable = {} |
|
539 |
|
local s = math.max((p - 1), 0)*maxEntryQuantityPerPage |
|
540 |
|
local t = math.max(p, 0)*maxEntryQuantityPerPage |
|
541 |
|
local w |
|
542 |
|
while (s < t) do |
|
543 |
|
s = s + 1 |
|
544 |
|
w = resultTable[s] |
|
545 |
|
if w ~= nil and 'table' == type(w) then |
|
546 |
|
table.insert(finalResultTable, w) |
|
547 |
|
end |
|
548 |
|
end |
|
549 |
|
assert (finalResultTable ~= nil) |
|
550 |
|
assert ('table' == type(finalResultTable)) |
|
551 |
|
return finalResultTable |
537 |
552 |
end |
end |
538 |
553 |
|
|
539 |
554 |
--[[-- |
--[[-- |
|
... |
... |
local function reportRefresh() |
1008 |
1023 |
--[[ Lookup global table instead of reference frame table. |
--[[ Lookup global table instead of reference frame table. |
1009 |
1024 |
-- Frame table can be changed by the user easily. |
-- Frame table can be changed by the user easily. |
1010 |
1025 |
-- Declared global cannot be nullified by the user maybe??]]-- |
-- Declared global cannot be nullified by the user maybe??]]-- |
1011 |
|
local reportEntryTableSize = 16 |
|
1012 |
1026 |
local i = 0 |
local i = 0 |
1013 |
1027 |
local e |
local e |
1014 |
1028 |
local et |
local et |
1015 |
1029 |
local dao = FlowerpickerSavedVariables |
local dao = FlowerpickerSavedVariables |
1016 |
|
local resultTable = query(dao) |
|
|
1030 |
|
local pageEditBox = FlowerpickerPageEditBox |
|
1031 |
|
assert (pageEditBox ~= nil) |
|
1032 |
|
assert ('table' == type(pageEditBox)) |
|
1033 |
|
local pageNumber = sanitiseShort(pageEditBox:GetNumber()) |
|
1034 |
|
if not validatePositiveAndNonZero(pageNumber) then |
|
1035 |
|
pageNumber = 1 |
|
1036 |
|
end |
|
1037 |
|
local resultTable = query(dao, pageNumber) |
|
1038 |
|
local reportEntryTableSize = sanitiseShort(#resultTable) |
|
1039 |
|
assert (reportEntryTableSize ~= nil) |
|
1040 |
|
assert (reportEntryTableSize >= 0) |
|
1041 |
|
local maxEntryQuantityPerPage = 16 |
1017 |
1042 |
local r |
local r |
1018 |
|
while (i < reportEntryTableSize) do |
|
|
1043 |
|
while (i < maxEntryQuantityPerPage) do |
1019 |
1044 |
i = i + 1 |
i = i + 1 |
1020 |
1045 |
e = _G[string.format('FlowerpickerEntry%02d', i)] |
e = _G[string.format('FlowerpickerEntry%02d', i)] |
1021 |
1046 |
assert (e ~= nil) |
assert (e ~= nil) |
|
... |
... |
local function reportRefresh() |
1024 |
1049 |
assert (et ~= nil) |
assert (et ~= nil) |
1025 |
1050 |
assert ('table' == type(et)) |
assert ('table' == type(et)) |
1026 |
1051 |
r = resultTable[i] |
r = resultTable[i] |
1027 |
|
if 'Money' == r[2] then |
|
|
1052 |
|
if nil == r or 'table' ~= type(r) then |
|
1053 |
|
et:SetText(nil) |
|
1054 |
|
elseif 'Money' == r[2] then |
1028 |
1055 |
et:SetText(r[1] .. ': Gold x ' .. (r[3] / 10000)) |
et:SetText(r[1] .. ': Gold x ' .. (r[3] / 10000)) |
1029 |
1056 |
else |
else |
1030 |
1057 |
et:SetText(r[1] .. ': ' .. r[2] .. ' x ' .. r[3]) |
et:SetText(r[1] .. ': ' .. r[2] .. ' x ' .. r[3]) |
|
... |
... |
local function reportHide() |
1047 |
1074 |
f:Hide() |
f:Hide() |
1048 |
1075 |
end |
end |
1049 |
1076 |
|
|
|
1077 |
|
local function createInputBox(newInputBoxName, newInputBoxParent, newInputBoxLengthChars) |
|
1078 |
|
local newInputBox = CreateFrame("EditBox", newInputBoxName, newInputBoxParent, "InputBoxTemplate"); |
|
1079 |
|
newInputBox:SetPoint("CENTER", 0, 0); |
|
1080 |
|
newInputBox:SetSize(16*newInputBoxLengthChars, 16); |
|
1081 |
|
newInputBox:SetNumeric(true); |
|
1082 |
|
newInputBox:SetMaxLetters(newInputBoxLengthChars); |
|
1083 |
|
local historyLineQuantity = 4 |
|
1084 |
|
newInputBox:SetHistoryLines(historyLineQuantity); |
|
1085 |
|
newInputBox:SetBackdrop({ |
|
1086 |
|
bgFile="Interface\\ChatFrame\\ChatFrameBackground", |
|
1087 |
|
edgeFile="Interface\\ChatFrame\\ChatFrameBackground", |
|
1088 |
|
tile=true, |
|
1089 |
|
tileSize=5, |
|
1090 |
|
edgeSize= 2, |
|
1091 |
|
}); |
|
1092 |
|
newInputBox:SetBackdropColor(0, 0, 0, 0.5); |
|
1093 |
|
newInputBox:SetBackdropBorderColor(0, 0, 0, 0.5); |
|
1094 |
|
newInputBox:SetAutoFocus(false); |
|
1095 |
|
newInputBox:ClearFocus(); |
|
1096 |
|
newInputBox:SetFocus(false); |
|
1097 |
|
|
|
1098 |
|
return newInputBox; |
|
1099 |
|
end |
|
1100 |
|
|
|
1101 |
|
local function initGUIPagination(reportFrame) |
|
1102 |
|
local pageEditBoxLenght = 2 |
|
1103 |
|
local pageEditBox = createInputBox('FlowerpickerPageEditBox', reportFrame, pageEditBoxLenght) |
|
1104 |
|
pageEditBox:SetPoint('BOTTOMRIGHT', -8, 8) |
|
1105 |
|
pageEditBox:SetNumber(1) |
|
1106 |
|
pageEditBox:SetScript('OnEnterPressed', reportRefresh) |
|
1107 |
|
end |
|
1108 |
|
|
1050 |
1109 |
local function initGUIMinimise() |
local function initGUIMinimise() |
1051 |
1110 |
local showBtnW = 32 |
local showBtnW = 32 |
1052 |
1111 |
local showBtnH = showBtnW |
local showBtnH = showBtnW |
|
... |
... |
local function initGUI(addonFrame) |
1152 |
1211 |
|
|
1153 |
1212 |
reportFrame:Show() |
reportFrame:Show() |
1154 |
1213 |
initGUIMinimise() |
initGUIMinimise() |
|
1214 |
|
initGUIPagination(reportFrame) |
1155 |
1215 |
reportHide() |
reportHide() |
1156 |
1216 |
end |
end |
1157 |
1217 |
|
|