Skip to content

Commit 16927d6

Browse files
committed
Keep Max Price and Max Level between Trade Queries
1 parent 2210cf5 commit 16927d6

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
@@ -109,7 +109,9 @@ local TradeQueryGeneratorClass = newClass("TradeQueryGenerator", function(self,
109109
self.queryTab = queryTab
110110
self.itemsTab = queryTab.itemsTab
111111
self.calcContext = { }
112-
112+
self.lastMaxPrice = nil
113+
self.lastMaxPriceTypeIndex = nil
114+
self.lastMaxLevel = nil
113115
end)
114116

115117
local function fetchStats()
@@ -652,7 +654,37 @@ function TradeQueryGeneratorClass:OnFrame()
652654
end
653655
end
654656

657+
local currencyTable = {
658+
{ name = "Chaos Orb Equivalent", id = nil },
659+
{ name = "Chaos Orb", id = "chaos" },
660+
{ name = "Divine Orb", id = "divine" },
661+
{ name = "Orb of Alchemy", id = "alch" },
662+
{ name = "Orb of Alteration", id = "alt" },
663+
{ name = "Chromatic Orb", id = "chrome" },
664+
{ name = "Exalted Orb", id = "exalted" },
665+
{ name = "Blessed Orb", id = "blessed" },
666+
{ name = "Cartographer's Chisel", id = "chisel" },
667+
{ name = "Gemcutter's Prism", id = "gcp" },
668+
{ name = "Jeweller's Orb", id = "jewellers" },
669+
{ name = "Orb of Scouring", id = "scour" },
670+
{ name = "Orb of Regret", id = "regret" },
671+
{ name = "Orb of Fusing", id = "fusing" },
672+
{ name = "Orb of Chance", id = "chance" },
673+
{ name = "Regal Orb", id = "regal" },
674+
{ name = "Vaal Orb", id = "vaal" }
675+
}
676+
655677
function TradeQueryGeneratorClass:StartQuery(slot, options)
678+
if self.lastMaxPrice then
679+
options.maxPrice = self.lastMaxPrice
680+
end
681+
if self.lastMaxPriceTypeIndex then
682+
options.maxPriceType = currencyTable[self.lastMaxPriceTypeIndex].id
683+
end
684+
if self.lastMaxLevel then
685+
options.maxLevel = self.lastMaxLevel
686+
end
687+
656688
-- Figure out what type of item we're searching for
657689
local existingItem = slot and self.itemsTab.items[slot.selItemId]
658690
local testItemType = existingItem and existingItem.baseName or "Unset Amulet"
@@ -1072,35 +1104,19 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
10721104
end
10731105

10741106
-- Add max price limit selection dropbox
1075-
local currencyTable = {
1076-
{ name = "Chaos Orb Equivalent", id = nil },
1077-
{ name = "Chaos Orb", id = "chaos" },
1078-
{ name = "Divine Orb", id = "divine" },
1079-
{ name = "Orb of Alchemy", id = "alch" },
1080-
{ name = "Orb of Alteration", id = "alt" },
1081-
{ name = "Chromatic Orb", id = "chrome" },
1082-
{ name = "Exalted Orb", id = "exalted" },
1083-
{ name = "Blessed Orb", id = "blessed" },
1084-
{ name = "Cartographer's Chisel", id = "chisel" },
1085-
{ name = "Gemcutter's Prism", id = "gcp" },
1086-
{ name = "Jeweller's Orb", id = "jewellers" },
1087-
{ name = "Orb of Scouring", id = "scour" },
1088-
{ name = "Orb of Regret", id = "regret" },
1089-
{ name = "Orb of Fusing", id = "fusing" },
1090-
{ name = "Orb of Chance", id = "chance" },
1091-
{ name = "Regal Orb", id = "regal" },
1092-
{ name = "Vaal Orb", id = "vaal" }
1093-
}
10941107
local currencyDropdownNames = { }
10951108
for _, currency in ipairs(currencyTable) do
10961109
t_insert(currencyDropdownNames, currency.name)
10971110
end
10981111
controls.maxPrice = new("EditControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 70, 18}, nil, nil, "%D")
1112+
controls.maxPrice.buf = self.lastMaxPrice and tostring(self.lastMaxPrice) or ""
10991113
controls.maxPriceType = new("DropDownControl", {"LEFT",controls.maxPrice,"RIGHT"}, {5, 0, 150, 18}, currencyDropdownNames, nil)
1114+
controls.maxPriceType.selIndex = self.lastMaxPriceTypeIndex or 1
11001115
controls.maxPriceLabel = new("LabelControl", {"RIGHT",controls.maxPrice,"LEFT"}, {-5, 0, 0, 16}, "^7Max Price:")
11011116
updateLastAnchor(controls.maxPrice)
11021117

11031118
controls.maxLevel = new("EditControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 100, 18}, nil, nil, "%D")
1119+
controls.maxLevel.buf = self.lastMaxLevel and tostring(self.lastMaxLevel) or ""
11041120
controls.maxLevelLabel = new("LabelControl", {"RIGHT",controls.maxLevel,"LEFT"}, {-5, 0, 0, 16}, "Max Level:")
11051121
updateLastAnchor(controls.maxLevel)
11061122

@@ -1177,10 +1193,13 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
11771193
end
11781194
if controls.maxPrice.buf then
11791195
options.maxPrice = tonumber(controls.maxPrice.buf)
1196+
self.lastMaxPrice = options.maxPrice
11801197
options.maxPriceType = currencyTable[controls.maxPriceType.selIndex].id
1198+
self.lastMaxPriceTypeIndex = controls.maxPriceType.selIndex
11811199
end
11821200
if controls.maxLevel.buf then
11831201
options.maxLevel = tonumber(controls.maxLevel.buf)
1202+
self.lastMaxLevel = options.maxLevel
11841203
end
11851204
if controls.sockets and controls.sockets.buf then
11861205
options.sockets = tonumber(controls.sockets.buf)

0 commit comments

Comments
 (0)