Fixed Market laoding and 'search all' issue.
This commit is contained in:
parent
6d456994f4
commit
3b9acab7a1
|
@ -67,7 +67,7 @@ MiniWindow
|
|||
icon: /images/topbuttons/healthinfo
|
||||
id: healthInfoWindow
|
||||
!text: tr('Health Info')
|
||||
height: 126
|
||||
height: 124
|
||||
@onClose: modules.game_healthinfo.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ currentItems = {}
|
|||
lastCreatedOffer = 0
|
||||
fee = 0
|
||||
|
||||
loaded = false
|
||||
|
||||
local offerTableHeader = {
|
||||
{['text'] = 'Player Name', ['width'] = 100},
|
||||
{['text'] = 'Amount', ['width'] = 60},
|
||||
|
@ -126,10 +128,7 @@ local function isItemValid(item, category, searchFilter)
|
|||
return false
|
||||
end
|
||||
if searchFilter then
|
||||
local checkString = marketData.name:lower()
|
||||
if not checkString:find(searchFilter) then
|
||||
return false
|
||||
end
|
||||
return marketData.name:lower():find(searchFilter)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -580,22 +579,30 @@ local function onAmountChange()
|
|||
end
|
||||
|
||||
local function initMarketItems(category)
|
||||
-- initialize market category
|
||||
marketItems[category] = {}
|
||||
for c = MarketCategory.First, MarketCategory.Last do
|
||||
marketItems[c] = {}
|
||||
end
|
||||
|
||||
-- populate all market items
|
||||
local types = g_things.findThingTypeByAttr(ThingAttrMarket, 0)
|
||||
for i = 1, #types do
|
||||
local t = types[i]
|
||||
|
||||
local newItem = Item.create(t:getId())
|
||||
if newItem then
|
||||
local marketData = t:getMarketData()
|
||||
if not table.empty(marketData) and marketData.category == category then
|
||||
if not table.empty(marketData) then
|
||||
if marketData.category == category or category == MarketCategory.All then
|
||||
|
||||
-- create new item block
|
||||
local item = {
|
||||
ptr = newItem,
|
||||
marketData = marketData
|
||||
}
|
||||
marketItems[marketData.category][#marketItems[category]+1] = item
|
||||
|
||||
-- add new market item
|
||||
table.insert(marketItems[marketData.category], item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -733,9 +740,6 @@ function init()
|
|||
marketWindow:hide()
|
||||
|
||||
initInterface() -- build interface
|
||||
for category = MarketCategory.First, MarketCategory.Last do
|
||||
initMarketItems(category)
|
||||
end
|
||||
end
|
||||
|
||||
function terminate()
|
||||
|
@ -904,20 +908,15 @@ end
|
|||
|
||||
|
||||
function Market.loadMarketItems(category)
|
||||
if table.empty(marketItems[category]) then
|
||||
initMarketItems(category)
|
||||
end
|
||||
clearItems()
|
||||
|
||||
-- check search filter
|
||||
local searchFilter = searchEdit:getText():lower()
|
||||
if not searchFilter or searchFilter:len() < 3 then
|
||||
searchFilter = nil
|
||||
end
|
||||
local filterSearchAll = filterButtons[MarketFilters.SearchAll]:isChecked()
|
||||
if filterSearchAll and searchFilter then
|
||||
local searchFilter = searchEdit:getText()
|
||||
if searchFilter and searchFilter:len() > 2 then
|
||||
if filterButtons[MarketFilters.SearchAll]:isChecked() then
|
||||
category = MarketCategory.All
|
||||
end
|
||||
end
|
||||
|
||||
if category == MarketCategory.All then
|
||||
-- loop all categories
|
||||
|
@ -1070,6 +1069,11 @@ end
|
|||
-- protocol callback functions
|
||||
|
||||
function Market.onMarketEnter(depotItems, offers, balance, vocation)
|
||||
if not loaded then
|
||||
initMarketItems(MarketCategory.All)
|
||||
loaded = true
|
||||
end
|
||||
|
||||
Market.clearSelectedItem()
|
||||
updateBalance(balance)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ end
|
|||
|
||||
function g_game.getSupportedProtocols()
|
||||
return {
|
||||
810, 853, 854, 860, 861, 862, 870,
|
||||
810, 811, 840, 842, 850, 853, 854, 860, 861, 862, 870,
|
||||
910, 940, 944, 953, 954, 960, 961,
|
||||
963, 970, 971, 973
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue