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