Skip to content

Commit 40d5081

Browse files
Wires77mcagnionLocalIdentity
authored
Keep Max Price and Max Level between Trade Queries (#1215)
* [PATCH 1/2] Keep Max Price and Max Level between Trade Queries * [PATCH 2/2] Fix use of spaces instead of tabs --------- Co-authored-by: Mickael Cagnion <cagnionm@gmail.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 1f0ee49 commit 40d5081

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

src/Classes/TradeQueryGenerator.lua

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ local TradeQueryGeneratorClass = newClass("TradeQueryGenerator", function(self,
9898
self.queryTab = queryTab
9999
self.itemsTab = queryTab.itemsTab
100100
self.calcContext = { }
101-
101+
self.lastMaxPrice = nil
102+
self.lastMaxPriceTypeIndex = nil
103+
self.lastMaxLevel = nil
102104
end)
103105

104106
local function fetchStats()
@@ -568,7 +570,31 @@ function TradeQueryGeneratorClass:OnFrame()
568570
end
569571
end
570572

573+
local currencyTable = {
574+
{ name = "Relative", id = nil },
575+
{ name = "Exalted Orb", id = "exalted" },
576+
{ name = "Chaos Orb", id = "chaos" },
577+
{ name = "Divine Orb", id = "divine" },
578+
{ name = "Orb of Augmentation", id = "aug" },
579+
{ name = "Orb of Transmutation", id = "transmute" },
580+
{ name = "Regal Orb", id = "regal" },
581+
{ name = "Vaal Orb", id = "vaal" },
582+
{ name = "Annulment Orb", id = "annul" },
583+
{ name = "Orb of Alchemy", id = "alch" },
584+
{ name = "Mirror of Kalandra", id = "mirror" }
585+
}
586+
571587
function TradeQueryGeneratorClass:StartQuery(slot, options)
588+
if self.lastMaxPrice then
589+
options.maxPrice = self.lastMaxPrice
590+
end
591+
if self.lastMaxPriceTypeIndex then
592+
options.maxPriceType = currencyTable[self.lastMaxPriceTypeIndex].id
593+
end
594+
if self.lastMaxLevel then
595+
options.maxLevel = self.lastMaxLevel
596+
end
597+
572598
-- Figure out what type of item we're searching for
573599
local existingItem = slot and self.itemsTab.items[slot.selItemId]
574600
local testItemType = existingItem and existingItem.baseName or "Diamond"
@@ -830,12 +856,12 @@ function TradeQueryGeneratorClass:FinishQuery()
830856
end
831857
end
832858
if not options.includeMirrored then
833-
queryTable.query.filters.misc_filters = {
834-
disabled = false,
835-
filters = {
836-
mirrored = false,
837-
}
838-
}
859+
queryTable.query.filters.misc_filters = {
860+
disabled = false,
861+
filters = {
862+
mirrored = false,
863+
}
864+
}
839865
end
840866

841867
if options.maxPrice and options.maxPrice > 0 then
@@ -927,29 +953,19 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
927953
end
928954

929955
-- Add max price limit selection dropbox
930-
local currencyTable = {
931-
{ name = "Relative", id = nil },
932-
{ name = "Exalted Orb", id = "exalted" },
933-
{ name = "Chaos Orb", id = "chaos" },
934-
{ name = "Divine Orb", id = "divine" },
935-
{ name = "Orb of Augmentation", id = "aug" },
936-
{ name = "Orb of Transmutation", id = "transmute" },
937-
{ name = "Regal Orb", id = "regal" },
938-
{ name = "Vaal Orb", id = "vaal" },
939-
{ name = "Annulment Orb", id = "annul" },
940-
{ name = "Orb of Alchemy", id = "alch" },
941-
{ name = "Mirror of Kalandra", id = "mirror" }
942-
}
943956
local currencyDropdownNames = { }
944957
for _, currency in ipairs(currencyTable) do
945958
t_insert(currencyDropdownNames, currency.name)
946959
end
947960
controls.maxPrice = new("EditControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 70, 18}, nil, nil, "%D")
961+
controls.maxPrice.buf = self.lastMaxPrice and tostring(self.lastMaxPrice) or ""
948962
controls.maxPriceType = new("DropDownControl", {"LEFT",controls.maxPrice,"RIGHT"}, {5, 0, 150, 18}, currencyDropdownNames, nil)
963+
controls.maxPriceType.selIndex = self.lastMaxPriceTypeIndex or 1
949964
controls.maxPriceLabel = new("LabelControl", {"RIGHT",controls.maxPrice,"LEFT"}, {-5, 0, 0, 16}, "^7Max Price:")
950965
updateLastAnchor(controls.maxPrice)
951966

952967
controls.maxLevel = new("EditControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 100, 18}, nil, nil, "%D")
968+
controls.maxLevel.buf = self.lastMaxLevel and tostring(self.lastMaxLevel) or ""
953969
controls.maxLevelLabel = new("LabelControl", {"RIGHT",controls.maxLevel,"LEFT"}, {-5, 0, 0, 16}, "Max Level:")
954970
updateLastAnchor(controls.maxLevel)
955971

@@ -1001,10 +1017,13 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
10011017
end
10021018
if controls.maxPrice.buf then
10031019
options.maxPrice = tonumber(controls.maxPrice.buf)
1020+
self.lastMaxPrice = options.maxPrice
10041021
options.maxPriceType = currencyTable[controls.maxPriceType.selIndex].id
1022+
self.lastMaxPriceTypeIndex = controls.maxPriceType.selIndex
10051023
end
10061024
if controls.maxLevel.buf then
10071025
options.maxLevel = tonumber(controls.maxLevel.buf)
1026+
self.lastMaxLevel = options.maxLevel
10081027
end
10091028
if controls.sockets and controls.sockets.buf then
10101029
options.sockets = tonumber(controls.sockets.buf)

0 commit comments

Comments
 (0)