File src/Flowerpicker.lua changed (mode: 100644) (index 576b8df..7169e24) |
... |
... |
Otherwise returns `nil`. |
81 |
81 |
@return nil or short integer |
@return nil or short integer |
82 |
82 |
]] |
]] |
83 |
83 |
local function sanitiseShort(supposedNumber) |
local function sanitiseShort(supposedNumber) |
84 |
|
local sane |
|
85 |
84 |
if nil == supposedNumber then |
if nil == supposedNumber then |
86 |
|
sane = nil |
|
87 |
|
elseif 'number' == type(supposedNumber) then |
|
|
85 |
|
return nil |
|
86 |
|
end |
|
87 |
|
if 'string' == type(supposedNumber) then |
|
88 |
|
supposedNumber = tonumber(supposedNumber) |
|
89 |
|
end |
|
90 |
|
local sane = nil |
|
91 |
|
if 'number' == type(supposedNumber) then |
88 |
92 |
sane = math.min(math.max(-32768, math.ceil(supposedNumber)), 32767) |
sane = math.min(math.max(-32768, math.ceil(supposedNumber)), 32767) |
89 |
|
else |
|
90 |
|
sane = nil |
|
91 |
93 |
end |
end |
92 |
94 |
return sane |
return sane |
93 |
95 |
end |
end |
|
... |
... |
Otherwise returns `nil`. |
114 |
116 |
@return nil or integer |
@return nil or integer |
115 |
117 |
]] |
]] |
116 |
118 |
local function sanitiseInteger(supposedNumber) |
local function sanitiseInteger(supposedNumber) |
117 |
|
local sane |
|
118 |
119 |
if nil == supposedNumber then |
if nil == supposedNumber then |
119 |
|
sane = nil |
|
120 |
|
elseif 'number' == type(supposedNumber) then |
|
|
120 |
|
return nil |
|
121 |
|
end |
|
122 |
|
if 'string' == type(supposedNumber) then |
|
123 |
|
supposedNumber = tonumber(supposedNumber) |
|
124 |
|
end |
|
125 |
|
local sane = nil |
|
126 |
|
if 'number' == type(supposedNumber) then |
121 |
127 |
sane = math.min(math.max(-2147483648, math.ceil(supposedNumber)), 2147483647) |
sane = math.min(math.max(-2147483648, math.ceil(supposedNumber)), 2147483647) |
122 |
|
else |
|
123 |
|
sane = nil |
|
124 |
128 |
end |
end |
125 |
129 |
return sane |
return sane |
126 |
130 |
end |
end |
|
... |
... |
local function validatePositiveAndNonZero(n) |
296 |
300 |
return isValid, errorMsg |
return isValid, errorMsg |
297 |
301 |
end |
end |
298 |
302 |
|
|
|
303 |
|
local function validatePositiveOrZero(n) |
|
304 |
|
local isValid = true |
|
305 |
|
local errorMsg = nil |
|
306 |
|
|
|
307 |
|
isValid = n ~= nil and isValid |
|
308 |
|
if not isValid then |
|
309 |
|
errorMsg = 'Null pointer.' |
|
310 |
|
return isValid, errorMsg |
|
311 |
|
end |
|
312 |
|
|
|
313 |
|
isValid = 'number' == type(n) and isValid |
|
314 |
|
if not isValid then |
|
315 |
|
errorMsg = 'Not a number.' |
|
316 |
|
return isValid, errorMsg |
|
317 |
|
end |
|
318 |
|
|
|
319 |
|
isValid = n >= 0 and isValid |
|
320 |
|
if not isValid then |
|
321 |
|
errorMsg = 'Is below zero.' |
|
322 |
|
return isValid, errorMsg |
|
323 |
|
end |
|
324 |
|
|
|
325 |
|
return isValid, errorMsg |
|
326 |
|
end |
|
327 |
|
|
299 |
328 |
--[[-- |
--[[-- |
300 |
329 |
Checker that ensures that given element is a member of a given table. |
Checker that ensures that given element is a member of a given table. |
301 |
330 |
The table size is limited to at most 1024 elements. |
The table size is limited to at most 1024 elements. |
|
... |
... |
local function validateEnum(element, permissibleValueSet) |
324 |
353 |
return isValid, 'Illegal value in an enumeration.' |
return isValid, 'Illegal value in an enumeration.' |
325 |
354 |
end |
end |
326 |
355 |
|
|
|
356 |
|
local function validateItemInfo( |
|
357 |
|
itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, |
|
358 |
|
itemType, itemSubType, itemStackCount, |
|
359 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper |
|
360 |
|
) |
|
361 |
|
local isValid, errorMsg = validatePositiveAndNonZero(itemId) |
|
362 |
|
if not isValid then |
|
363 |
|
return isValid, 'Invalid item identifier: ' .. errorMsg |
|
364 |
|
end |
|
365 |
|
|
|
366 |
|
isValid, errorMsg = validateAnyName(itemName) |
|
367 |
|
if not isValid then |
|
368 |
|
return isValid, 'Invalid item name: ' .. errorMsg |
|
369 |
|
end |
|
370 |
|
|
|
371 |
|
isValid, errorMsg = validateAnyName(itemLink, 8, 256) |
|
372 |
|
if not isValid then |
|
373 |
|
return isValid, 'Invalid item lin: ' .. errorMsg |
|
374 |
|
end |
|
375 |
|
|
|
376 |
|
isValid, errorMsg = validatePositiveOrZero(itemRarity) |
|
377 |
|
if not isValid then |
|
378 |
|
return isValid, 'Invalid item rarity: ' .. errorMsg |
|
379 |
|
end |
|
380 |
|
|
|
381 |
|
isValid, errorMsg = validatePositiveOrZero(itemLevel) |
|
382 |
|
if not isValid then |
|
383 |
|
return isValid, 'Invalid item level: ' .. errorMsg |
|
384 |
|
end |
|
385 |
|
|
|
386 |
|
isValid, errorMsg = validatePositiveOrZero(itemMinLevel) |
|
387 |
|
if not isValid then |
|
388 |
|
return isValid, 'Ivalid item minimum level requirement: ' .. errorMsg |
|
389 |
|
end |
|
390 |
|
|
|
391 |
|
isValid, errorMsg = validateAnyName(itemType) |
|
392 |
|
if not isValid then |
|
393 |
|
return isValid, 'Invalid item type name: ' .. errorMsg |
|
394 |
|
end |
|
395 |
|
|
|
396 |
|
isValid, errorMsg = validateAnyName(itemSubType) |
|
397 |
|
if not isValid then |
|
398 |
|
return isValid, 'Invalid item subtype name: ' .. errorMsg |
|
399 |
|
end |
|
400 |
|
|
|
401 |
|
isValid, errorMsg = validatePositiveAndNonZero(itemStackCount) |
|
402 |
|
if not isValid then |
|
403 |
|
return isValid, 'Invalid item stack count: ' .. errorMsg |
|
404 |
|
end |
|
405 |
|
|
|
406 |
|
isValid, errorMsg = validateAnyName(itemEquipLoc) |
|
407 |
|
if not isValid then |
|
408 |
|
return isValid, 'Invalid item equip slot name: ' .. errorMsg |
|
409 |
|
end |
|
410 |
|
|
|
411 |
|
isValid, errorMsg = validateAnyName(itemPictureFile, 4, 256) |
|
412 |
|
if not isValid then |
|
413 |
|
return isValid, 'Invalid item picture file path: ' .. errorMsg |
|
414 |
|
end |
|
415 |
|
|
|
416 |
|
isValid, errorMsg = validatePositiveOrZero(itemSellPriceCopper) |
|
417 |
|
if not isValid then |
|
418 |
|
return isValid, 'Invalid item sell price in copper: ' .. errorMsg |
|
419 |
|
end |
|
420 |
|
|
|
421 |
|
return isValid, errorMsg |
|
422 |
|
end |
327 |
423 |
--[[-- |
--[[-- |
328 |
424 |
flowerpicker.base. |
flowerpicker.base. |
329 |
425 |
Business logic of the add-on, agnostic of the WoW API. |
Business logic of the add-on, agnostic of the WoW API. |
|
... |
... |
Create a table that is an event and is to be later registered or discarded. |
395 |
491 |
@param harvestedItemQuantity a short integer that is produced item quantity |
@param harvestedItemQuantity a short integer that is produced item quantity |
396 |
492 |
@return table indexed by number |
@return table indexed by number |
397 |
493 |
]] |
]] |
398 |
|
local function createEventHarvest(realmName, harvesterName, zoneName, subzoneName, harvestTimestamp, |
|
399 |
|
harvestTypeDesignation, sourceName, harvestedItemName, harvestedItemQuantity) |
|
|
494 |
|
local function createEventHarvest( |
|
495 |
|
realmName, harvesterName, zoneName, subzoneName, harvestTimestamp, |
|
496 |
|
harvestTypeDesignation, sourceName, |
|
497 |
|
itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, |
|
498 |
|
itemType, itemSubType, itemStackCount, itemEquipLoc, |
|
499 |
|
itemPictureFile, itemSellPriceCopper, itemQuantity |
|
500 |
|
) |
400 |
501 |
local r = sanitiseAnyName(realmName) |
local r = sanitiseAnyName(realmName) |
401 |
502 |
local c = sanitiseAnyName(harvesterName) |
local c = sanitiseAnyName(harvesterName) |
402 |
503 |
local z = sanitiseAnyName(zoneName) |
local z = sanitiseAnyName(zoneName) |
|
... |
... |
local function createEventHarvest(realmName, harvesterName, zoneName, subzoneNam |
404 |
505 |
local t = sanitiseTimestamp(harvestTimestamp) |
local t = sanitiseTimestamp(harvestTimestamp) |
405 |
506 |
local d = sanitiseAnyName(harvestTypeDesignation) |
local d = sanitiseAnyName(harvestTypeDesignation) |
406 |
507 |
local s = sanitiseAnyName(sourceName) |
local s = sanitiseAnyName(sourceName) |
407 |
|
local i = sanitiseAnyName(harvestedItemName) |
|
408 |
|
local q = sanitiseShort(harvestedItemQuantity) |
|
|
508 |
|
local q = sanitiseShort(itemQuantity) |
409 |
509 |
assert (validateAnyName(r)) |
assert (validateAnyName(r)) |
410 |
510 |
assert (validateAnyName(c)) |
assert (validateAnyName(c)) |
411 |
511 |
assert (validateAnyName(z)) |
assert (validateAnyName(z)) |
|
... |
... |
local function createEventHarvest(realmName, harvesterName, zoneName, subzoneNam |
413 |
513 |
assert (validateTimestamp(t)) |
assert (validateTimestamp(t)) |
414 |
514 |
assert (validateEnum(d, getPermissibleHarvestTypeSet())) |
assert (validateEnum(d, getPermissibleHarvestTypeSet())) |
415 |
515 |
assert (validateAnyName(s)) |
assert (validateAnyName(s)) |
416 |
|
assert (validateAnyName(i)) |
|
417 |
516 |
assert (validatePositiveAndNonZero(q)) |
assert (validatePositiveAndNonZero(q)) |
|
517 |
|
assert (validateItemInfo(itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, |
|
518 |
|
itemStackCount, itemEquipLoc, itemPictureFile, itemSellPriceCopper)) |
418 |
519 |
|
|
419 |
520 |
local event = { |
local event = { |
420 |
|
r, c, z, sz, t, d, s, i, q |
|
|
521 |
|
r, c, z, sz, t, d, s, |
|
522 |
|
itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
|
523 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper, q |
421 |
524 |
} |
} |
422 |
525 |
|
|
423 |
526 |
assert (event ~= nil) |
assert (event ~= nil) |
|
... |
... |
Access item name property of a given event object. |
491 |
594 |
local function getEventItemName(event) |
local function getEventItemName(event) |
492 |
595 |
assert (event ~= nil) |
assert (event ~= nil) |
493 |
596 |
assert ('table' == type(event)) |
assert ('table' == type(event)) |
494 |
|
local itemName = sanitiseAnyName(event[8]) |
|
|
597 |
|
local itemName = sanitiseAnyName(event[9]) |
495 |
598 |
|
|
496 |
599 |
assert (validateAnyName(itemName)) |
assert (validateAnyName(itemName)) |
497 |
600 |
return itemName |
return itemName |
|
... |
... |
Access item quantity property of a given event object. |
523 |
626 |
local function getEventItemQuantity(event) |
local function getEventItemQuantity(event) |
524 |
627 |
assert (event ~= nil) |
assert (event ~= nil) |
525 |
628 |
assert ('table' == type(event)) |
assert ('table' == type(event)) |
526 |
|
local itemQuantity = sanitiseShort(event[9]) |
|
|
629 |
|
local itemQuantity = sanitiseShort(event[20]) |
527 |
630 |
|
|
528 |
631 |
assert (validatePositiveAndNonZero(itemQuantity)) |
assert (validatePositiveAndNonZero(itemQuantity)) |
529 |
632 |
return itemQuantity |
return itemQuantity |
|
... |
... |
local function getEventTimestamptz(event) |
540 |
643 |
return timestamptz |
return timestamptz |
541 |
644 |
end |
end |
542 |
645 |
|
|
|
646 |
|
local function getEventItemLink(event) |
|
647 |
|
assert (event ~= nil) |
|
648 |
|
assert ('table' == type(event)) |
|
649 |
|
local itemLink = event[10] |
|
650 |
|
|
|
651 |
|
assert (validateAnyName(itemLink, 8, 256)) |
|
652 |
|
return itemLink |
|
653 |
|
end |
|
654 |
|
|
|
655 |
|
local function getEventZone(event) |
|
656 |
|
assert (event ~= nil) |
|
657 |
|
assert ('table' == type(event)) |
|
658 |
|
local zoneName = sanitiseAnyName(event[3]) |
|
659 |
|
|
|
660 |
|
assert (validateAnyName(zoneName)) |
|
661 |
|
return zoneName |
|
662 |
|
end |
|
663 |
|
|
|
664 |
|
local function getEventSubZone(event) |
|
665 |
|
assert (event ~= nil) |
|
666 |
|
assert ('table' == type(event)) |
|
667 |
|
local subzoneName = sanitiseAnyName(event[4]) |
|
668 |
|
|
|
669 |
|
assert (validateAnyName(subzoneName)) |
|
670 |
|
return subzoneName |
|
671 |
|
end |
|
672 |
|
|
|
673 |
|
local function getEventSourceName(event) |
|
674 |
|
assert (event ~= nil) |
|
675 |
|
assert ('table' == type(event)) |
|
676 |
|
local sourceName = sanitiseAnyName(event[7]) |
|
677 |
|
|
|
678 |
|
assert (validateAnyName(sourceName)) |
|
679 |
|
return sourceName |
|
680 |
|
end |
|
681 |
|
|
543 |
682 |
--[[-- |
--[[-- |
544 |
683 |
Checks if a given elements matches a given predicate. |
Checks if a given elements matches a given predicate. |
545 |
684 |
@function queryFilter |
@function queryFilter |
|
... |
... |
local function queryFilter(event, predicateTable) |
568 |
707 |
return matches |
return matches |
569 |
708 |
end |
end |
570 |
709 |
|
|
|
710 |
|
local function eventMergeInPlace(source, target) |
|
711 |
|
assert (source ~= nil) |
|
712 |
|
assert ('table' == type(source)) |
|
713 |
|
assert (20 == #source) |
|
714 |
|
assert (target ~= nil) |
|
715 |
|
assert ('table' == type(target)) |
|
716 |
|
assert (20 == #target) |
|
717 |
|
|
|
718 |
|
assert(getEventTypeDesignation(source) == getEventTypeDesignation(target)) |
|
719 |
|
assert(getEventItemName(source) == getEventItemName(target)) |
|
720 |
|
|
|
721 |
|
local st = getEventTimestamptz(source) |
|
722 |
|
local tt = getEventTimestamptz(target) |
|
723 |
|
if st > tt then |
|
724 |
|
target[5] = st |
|
725 |
|
else |
|
726 |
|
target[5] = tt |
|
727 |
|
end |
|
728 |
|
|
|
729 |
|
local sq = getEventItemQuantity(source) |
|
730 |
|
local tq = getEventItemQuantity(target) |
|
731 |
|
target[20] = sq + tq |
|
732 |
|
|
|
733 |
|
return target |
|
734 |
|
end |
|
735 |
|
|
571 |
736 |
--[[-- |
--[[-- |
572 |
737 |
Event registry accessor. |
Event registry accessor. |
573 |
738 |
@function query |
@function query |
|
... |
... |
local function query(dao, predicateTable, pageNumber) |
596 |
761 |
local r |
local r |
597 |
762 |
local eventType |
local eventType |
598 |
763 |
local itemName |
local itemName |
599 |
|
local itemQuantity |
|
600 |
764 |
while (i < j) do |
while (i < j) do |
601 |
765 |
i = i + 1 |
i = i + 1 |
602 |
766 |
e = dao[i] |
e = dao[i] |
603 |
767 |
if queryFilter(e, predicateTable) then |
if queryFilter(e, predicateTable) then |
604 |
768 |
eventType = getEventTypeDesignation(e) |
eventType = getEventTypeDesignation(e) |
605 |
769 |
itemName = getEventItemName(e) |
itemName = getEventItemName(e) |
606 |
|
itemQuantity = getEventItemQuantity(e) |
|
607 |
770 |
local k = 0 |
local k = 0 |
608 |
771 |
r = nil |
r = nil |
609 |
772 |
while (k < #resultTable) do |
while (k < #resultTable) do |
610 |
773 |
k = k + 1 |
k = k + 1 |
611 |
774 |
r = resultTable[k] |
r = resultTable[k] |
612 |
|
if eventType == r[1] and itemName == r[2] then |
|
613 |
|
r[3] = r[3] + itemQuantity |
|
|
775 |
|
if getEventTypeDesignation(r) == eventType and |
|
776 |
|
getEventItemName(r) == itemName then |
|
777 |
|
eventMergeInPlace(e, r) |
614 |
778 |
break |
break |
615 |
779 |
else |
else |
616 |
780 |
r = nil |
r = nil |
617 |
781 |
end |
end |
618 |
782 |
end |
end |
619 |
783 |
if nil == r and #resultTable then |
if nil == r and #resultTable then |
620 |
|
r = {eventType, itemName, itemQuantity} |
|
|
784 |
|
r = {} |
|
785 |
|
assert (20 == #e) |
|
786 |
|
for ri = 1, #e do |
|
787 |
|
r[ri] = e[ri] |
|
788 |
|
end |
621 |
789 |
table.insert(resultTable, r) |
table.insert(resultTable, r) |
622 |
790 |
end |
end |
623 |
791 |
end |
end |
|
... |
... |
WoW event callbacks and GUI render that use the base module to implement the bus |
645 |
813 |
@section wow |
@section wow |
646 |
814 |
]] |
]] |
647 |
815 |
|
|
648 |
|
local function getFlowerpickerNormalFontFile() |
|
649 |
|
return "Interface\\AddOns\\flowerpicker\\resources\\DejaVuSansMono.ttf" |
|
650 |
|
end |
|
651 |
|
|
|
652 |
|
local function getFlowerpickerHighlightedFontFile() |
|
653 |
|
return "Interface\\AddOns\\flowerpicker\\resources\\DejaVuSansMono-Bold.ttf" |
|
654 |
|
end |
|
655 |
|
|
|
656 |
|
local function getColorTextHighlighted() |
|
657 |
|
return 255 / 255, 193 / 255, 7 / 255, 1 |
|
658 |
|
end |
|
659 |
|
|
|
660 |
|
local function getColorButtonNormal() |
|
661 |
|
return 74 / 255, 119 / 255, 24 / 255, 1 |
|
662 |
|
end |
|
663 |
|
|
|
664 |
|
local function getColorButtonPushed() |
|
665 |
|
return 115 / 255, 186 / 255, 37 / 255, 1 |
|
666 |
|
end |
|
667 |
|
|
|
668 |
|
local function getColorButtonHighlight() |
|
669 |
|
return 185 / 255, 231 / 255, 135 / 255, 1 |
|
670 |
|
end |
|
671 |
|
|
|
672 |
816 |
local function getColorNavBackground() |
local function getColorNavBackground() |
673 |
817 |
return 23 / 255, 63 / 255, 79 / 255, 1 |
return 23 / 255, 63 / 255, 79 / 255, 1 |
674 |
818 |
end |
end |
|
... |
... |
local function persistEventHarvest(event) |
816 |
960 |
table.insert(dao, event) |
table.insert(dao, event) |
817 |
961 |
end |
end |
818 |
962 |
|
|
|
963 |
|
local function deserialiseItemIdFromItemLink(itemLink) |
|
964 |
|
assert (validateAnyName(itemLink, 8, 256)) |
|
965 |
|
local itemId = sanitiseInteger(string.match(itemLink, '.*item:(%d+).*')) |
|
966 |
|
assert (validatePositiveAndNonZero(itemId)) |
|
967 |
|
return itemId |
|
968 |
|
end |
|
969 |
|
|
|
970 |
|
local function getCarriedItemInfo(localisedItemName) |
|
971 |
|
--[[ |
|
972 |
|
-- Note that localised name is used as an argument to GetItemInfo function. |
|
973 |
|
-- When GetItemInfo function is called with localised item name as the argument, |
|
974 |
|
-- it is mandatory that the player character currently carries the target item. |
|
975 |
|
-- Otherwise no values will be returned by the function. |
|
976 |
|
]]-- |
|
977 |
|
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
|
978 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper = GetItemInfo(localisedItemName) |
|
979 |
|
if nil == itemEquipLoc or string.len(itemEquipLoc) <= 0 then |
|
980 |
|
itemEquipLoc = 'ItemEquipLocUnknown' |
|
981 |
|
end |
|
982 |
|
if nil == itemType or string.len(itemType) <= 0 then |
|
983 |
|
itemType = 'ItemTypeUnknown' |
|
984 |
|
end |
|
985 |
|
if nil == itemSubType or string.len(itemSubType) <= 0 then |
|
986 |
|
itemSubType = 'ItemSubTypeUnknown' |
|
987 |
|
end |
|
988 |
|
if nil == itemPictureFile or string.len(itemPictureFile) <= 0 then |
|
989 |
|
itemPictureFile = "Interface\\Icons\\INV_Misc_QuestionMark" |
|
990 |
|
end |
|
991 |
|
local itemId = deserialiseItemIdFromItemLink(itemLink) |
|
992 |
|
return itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
|
993 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper |
|
994 |
|
end |
|
995 |
|
|
|
996 |
|
|
819 |
997 |
--[[-- |
--[[-- |
820 |
998 |
A utility function to increase readability of code that registers events. |
A utility function to increase readability of code that registers events. |
821 |
999 |
"realmName", "harvesterName", "zoneName", "subzoneName", "harvestTimestamp" |
"realmName", "harvesterName", "zoneName", "subzoneName", "harvestTimestamp" |
|
... |
... |
by the user. |
830 |
1008 |
@function createEventHarvestWithDefaults |
@function createEventHarvestWithDefaults |
831 |
1009 |
@return table that is an event |
@return table that is an event |
832 |
1010 |
]] |
]] |
833 |
|
local function createEventHarvestWithDefaults(eventTypeDesignation, sourceName, itemName, itemQuantity) |
|
|
1011 |
|
local function createEventHarvestWithDefaults(eventTypeDesignation, sourceName, givenItemName, givenItemQuantity) |
834 |
1012 |
--[[ begin defaults ]]-- |
--[[ begin defaults ]]-- |
835 |
1013 |
local r = sanitiseAnyName(GetRealmName()) |
local r = sanitiseAnyName(GetRealmName()) |
836 |
1014 |
assert (validateAnyName(r)) |
assert (validateAnyName(r)) |
|
... |
... |
local function createEventHarvestWithDefaults(eventTypeDesignation, sourceName, |
861 |
1039 |
local s = sanitiseAnyName(sourceName) |
local s = sanitiseAnyName(sourceName) |
862 |
1040 |
assert (validateAnyName(s)) |
assert (validateAnyName(s)) |
863 |
1041 |
|
|
864 |
|
local i = sanitiseAnyName(itemName) |
|
|
1042 |
|
local i = sanitiseAnyName(givenItemName) |
865 |
1043 |
assert (validateAnyName(i)) |
assert (validateAnyName(i)) |
866 |
1044 |
|
|
867 |
|
local q = sanitiseShort(itemQuantity) |
|
|
1045 |
|
local q = sanitiseShort(givenItemQuantity) |
868 |
1046 |
assert (validatePositiveAndNonZero(q)) |
assert (validatePositiveAndNonZero(q)) |
|
1047 |
|
|
|
1048 |
|
local itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
|
1049 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper = getCarriedItemInfo(i) |
|
1050 |
|
assert (validateItemInfo(itemId, itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, |
|
1051 |
|
itemStackCount, itemEquipLoc, itemPictureFile, itemSellPriceCopper)) |
869 |
1052 |
--[[ end explicit ]]-- |
--[[ end explicit ]]-- |
870 |
1053 |
|
|
871 |
|
local e = createEventHarvest(r, p, z, sz, t, d, s, i, q) |
|
|
1054 |
|
local e = createEventHarvest(r, p, z, sz, t, d, s, |
|
1055 |
|
itemId, i, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
|
1056 |
|
itemEquipLoc, itemPictureFile, itemSellPriceCopper, |
|
1057 |
|
q) |
872 |
1058 |
assert (e ~= nil) |
assert (e ~= nil) |
873 |
1059 |
return e |
return e |
874 |
1060 |
end |
end |
|
... |
... |
local function main(self, event, arg1, arg2, arg3, arg4) |
1074 |
1260 |
assert (arg3 ~= nil) |
assert (arg3 ~= nil) |
1075 |
1261 |
self.swap.lastSpellTargetName = sanitiseAnyName(arg4) |
self.swap.lastSpellTargetName = sanitiseAnyName(arg4) |
1076 |
1262 |
elseif 'LOOT_OPENED' == event then |
elseif 'LOOT_OPENED' == event then |
1077 |
|
updateLootCache(FlowerpickerLootCache) |
|
|
1263 |
|
local lootCache = FlowerpickerLootCache |
|
1264 |
|
updateLootCache(lootCache) |
1078 |
1265 |
if (1 == UnitIsDead('target')) then |
if (1 == UnitIsDead('target')) then |
1079 |
1266 |
self.swap.lastLootedCorpseName = sanitiseAnyName(UnitName('target')) |
self.swap.lastLootedCorpseName = sanitiseAnyName(UnitName('target')) |
1080 |
1267 |
end |
end |
|
... |
... |
local function getFilterDateUntilTimestamptz() |
1155 |
1342 |
return string.format('%04d-%02d-%02d 23:59:59', uy, um, ud) .. get_tzoffset(get_timezone()) |
return string.format('%04d-%02d-%02d 23:59:59', uy, um, ud) .. get_tzoffset(get_timezone()) |
1156 |
1343 |
end |
end |
1157 |
1344 |
|
|
|
1345 |
|
local function describeResultTableEntry(r) |
|
1346 |
|
if nil == r or 'table' ~= type(r) then |
|
1347 |
|
return nil |
|
1348 |
|
end |
|
1349 |
|
|
|
1350 |
|
local desc |
|
1351 |
|
local eventType = getEventTypeDesignation(r) |
|
1352 |
|
if 'FISHING' == eventType then |
|
1353 |
|
desc = 'Fishing' |
|
1354 |
|
elseif 'HERBALISM' == eventType then |
|
1355 |
|
desc = 'Gathering herbs' |
|
1356 |
|
elseif 'LOOTCORPSE' == eventType then |
|
1357 |
|
desc = 'Victory over ' .. getEventSourceName(r) |
|
1358 |
|
else |
|
1359 |
|
desc = eventType .. ': ' |
|
1360 |
|
end |
|
1361 |
|
|
|
1362 |
|
--[[local subzone = getEventSubZone(r) |
|
1363 |
|
local zone = getEventZone(r) |
|
1364 |
|
if 'Unknown Subzone' == subzone then |
|
1365 |
|
desc = desc .. ' in ' .. zone |
|
1366 |
|
else |
|
1367 |
|
desc = desc .. ' in ' .. subzone .. ' of ' .. zone |
|
1368 |
|
end]]-- |
|
1369 |
|
|
|
1370 |
|
desc = desc .. ' yielded ' .. getEventItemLink(r) .. ' x ' .. getEventItemQuantity(r) |
|
1371 |
|
|
|
1372 |
|
assert (nil == desc or ('string' == type(desc) and string.len(desc) > 4)) |
|
1373 |
|
return desc |
|
1374 |
|
end |
|
1375 |
|
|
1158 |
1376 |
--[[-- |
--[[-- |
1159 |
1377 |
Query event registry and display the results in a report for the player. |
Query event registry and display the results in a report for the player. |
1160 |
1378 |
The result of the function is a side effect that updates the state of the |
The result of the function is a side effect that updates the state of the |
|
... |
... |
local function reportRefresh() |
1201 |
1419 |
assert (et ~= nil) |
assert (et ~= nil) |
1202 |
1420 |
assert ('table' == type(et)) |
assert ('table' == type(et)) |
1203 |
1421 |
r = resultTable[i] |
r = resultTable[i] |
1204 |
|
if nil == r or 'table' ~= type(r) then |
|
1205 |
|
et:SetText(nil) |
|
1206 |
|
elseif 'Money' == r[2] then |
|
1207 |
|
et:SetText(r[1] .. ': Gold x ' .. (r[3] / 10000)) |
|
1208 |
|
else |
|
1209 |
|
et:SetText(r[1] .. ': ' .. r[2] .. ' x ' .. r[3]) |
|
1210 |
|
end |
|
1211 |
|
end |
|
|
1422 |
|
et:SetText(describeResultTableEntry(r)) |
|
1423 |
|
end |
1212 |
1424 |
end |
end |
1213 |
1425 |
|
|
1214 |
1426 |
local function reportShow() |
local function reportShow() |
|
... |
... |
local function initGUIMain(reportFrame) |
1649 |
1861 |
e:SetPoint('TOPLEFT', reportFrame, 'TOPLEFT', 0, offseth) |
e:SetPoint('TOPLEFT', reportFrame, 'TOPLEFT', 0, offseth) |
1650 |
1862 |
|
|
1651 |
1863 |
et = e:CreateFontString(e:GetName() .. 'Text', 'OVERLAY') |
et = e:CreateFontString(e:GetName() .. 'Text', 'OVERLAY') |
1652 |
|
--et:SetFont(getFlowerpickerNormalFontFile(), 14) |
|
1653 |
1864 |
et:SetFontObject(FlowerpickerNormalFont) |
et:SetFontObject(FlowerpickerNormalFont) |
1654 |
|
--[[ Mandatory to SetAllPoints. Otherwise, the text will be missing. ]]-- |
|
1655 |
|
et:SetAllPoints() |
|
|
1865 |
|
et:SetPoint('LEFT', e, 'LEFT', 0, 0) |
|
1866 |
|
et:SetSize(ew, eh) |
1656 |
1867 |
e.text = et |
e.text = et |
1657 |
1868 |
|
|
1658 |
1869 |
assert (e ~= nil) |
assert (e ~= nil) |