otclient-redemption/modules/game_npctrade/controllers/npc_options.lua
kokekanon 4a87cebb11
feat: protocol 15.24 packets and features (#1604)
New Features:
- Task Board (Bounty, Weekly, Shop) with Preferred & Soulseal modals, Kill Tracker, Offline Training dialog, Vocation tutorial, infobanner notifications, redesigned NPC chat/trade, and multi-slot action bar.

Gameplay Enhancements:
- Expanded Cyclopedia stats, talisman upgrades, weekly rewards/progress, soulseal fights, taskboard shop/offers and offline training actions.

UI / Graphics:
- Per-source spell-effect opacity sliders, status icon bar, HUD/scroll improvements, many new templates/styles, screenshot UI updates, and small label/icon fixes.

Bug Fixes:
- Miscellaneous UI behavior, layout and robustness improvements.
2026-05-20 11:26:11 -03:00

65 lines
2 KiB
Lua

function controllerNpcTrader:onOptionsClick()
local menu = g_ui.createWidget('PopupMenu')
menu:setGameMenu(true)
menu:addOption("Sort by Name", function()
self:setSortBy('name')
end)
menu:addOption("Sort by Price", function()
self:setSortBy('price')
end)
menu:addOption("Sort by Weight", function()
self:setSortBy('weight')
end)
menu:addSeparator()
if self.tradeMode == controllerNpcTrader.BUY then
menu:addCheckBox("Ignore Capacity", self.ignoreCapacity, function(widget, checked)
self:toggleIgnoreCapacity()
end)
if self.currencyId == controllerNpcTrader.DEFAULT_CURRENCY_ID then
menu:addCheckBox("Buy with Backpack", self.buyWithBackpack, function(widget, checked)
self:toggleBuyWithBackpack()
end)
end
else
menu:addCheckBox("Sell Equipped", not self.ignoreEquipped, function(widget, checked)
self:toggleIgnoreEquipped()
end)
end
menu:display()
end
function controllerNpcTrader:sortTradeItems(items)
if not items then
return
end
table.sort(items, function(a, b)
if self.sortBy == 'price' then
return a.price < b.price
elseif self.sortBy == 'weight' then
return a.weight < b.weight
else
return a.name:lower() < b.name:lower()
end
end)
end
function controllerNpcTrader:setSortBy(sort)
self.sortBy = sort
self:filterTradeList(self.searchText or "")
end
function controllerNpcTrader:toggleIgnoreCapacity()
self.ignoreCapacity = not self.ignoreCapacity
self:updateAmount(self.amount)
end
function controllerNpcTrader:toggleBuyWithBackpack()
self.buyWithBackpack = not self.buyWithBackpack
self:updateAmount(self.amount)
end
function controllerNpcTrader:toggleIgnoreEquipped()
self.ignoreEquipped = not self.ignoreEquipped
self:refreshPlayerGoods()
self:updateAmount(self.amount)
end