Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include(src/client/CMakeLists.txt)

# functions map for reading backtraces
if(NOT APPLE)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=${PROJECT_NAME}.map")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -no-pie -Wl,-Map=${PROJECT_NAME}.map")
endif()

option(USE_PCH "Use precompiled header (speed up compile)" OFF)
Expand Down
3 changes: 3 additions & 0 deletions data/images/store/64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!unknown.png
Binary file added data/images/store/64/unknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions modules/client_locales/neededtranslations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ neededTranslations = {
"Position",
"Premium",
"Premium Account (%s) days left",
"Press %s button to update",
"Price",
"Primary",
"Process",
Expand Down Expand Up @@ -320,6 +321,7 @@ neededTranslations = {
"Secondary",
"Select",
"Select all",
"Select an item to view the offers",
"Select object",
"Select Outfit",
"Select your language",
Expand Down
1 change: 1 addition & 0 deletions modules/game_interface/interface.otmod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Module
- game_playermount
- game_ruleviolation
- game_market
- game_store
- game_spelllist
- game_cooldown
- game_modaldialog
Expand Down
106 changes: 77 additions & 29 deletions modules/game_market/market.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ offersTabBar = nil
selectionTabBar = nil

marketOffersPanel = nil
browsePanel = nil
BROWSE_PANEL = nil
overviewPanel = nil
itemOffersPanel = nil
itemDetailsPanel = nil
ITEM_DETAILS_PANEL = nil
itemStatsPanel = nil
myOffersPanel = nil
currentOffersPanel = nil
Expand All @@ -40,7 +40,6 @@ itemsPanel = nil
selectedOffer = {}
selectedMyOffer = {}

nameLabel = nil
feeLabel = nil
balanceLabel = nil
totalPriceEdit = nil
Expand All @@ -49,8 +48,10 @@ amountEdit = nil
searchEdit = nil
radioItemSet = nil
selectedItem = nil
selectedItemLabel = nil
selectedItemTitleLabel = nil
offerTypeList = nil
categoryList = nil
CATEGORY_LIST = nil
subCategoryList = nil
slotFilterList = nil
createOfferButton = nil
Expand Down Expand Up @@ -443,7 +444,9 @@ local function updateSelectedItem(widget)
Market.resetCreateOffer()
if Market.isItemSelected() then
selectedItem:setItem(selectedItem.item.displayItem)
nameLabel:setText(selectedItem.item.marketData.name)
selectedItemLabel:setText('')
selectedItemTitleLabel:setText(selectedItem.item.marketData.name)
Market:hideOffersTableInstructions()
clearOffers()

Market.enableCreateOffer(true) -- update offer types
Expand Down Expand Up @@ -726,8 +729,10 @@ local function initMarketItems()
}

-- add new market item
if marketItems[marketData.category] ~= nil then
table.insert(marketItems[marketData.category], marketItem)
itemSet[marketData.tradeAs] = true
end
end
end
end
Expand All @@ -741,13 +746,17 @@ local function initInterface()

-- setup 'Market Offer' section tabs
marketOffersPanel = g_ui.loadUI('ui/marketoffers')
mainTabBar:addTab(tr('Market Offers'), marketOffersPanel)
local mopTab = mainTabBar:addTab(tr('Market Offers'), marketOffersPanel)
mopTab.onClick = function()
mainTabBar:selectTab(mopTab)
Market.refreshOffers()
end

selectionTabBar = marketOffersPanel:getChildById('leftTabBar')
selectionTabBar:setContentWidget(marketOffersPanel:getChildById('leftTabContent'))

browsePanel = g_ui.loadUI('ui/marketoffers/browse')
selectionTabBar:addTab(tr('Browse'), browsePanel)
BROWSE_PANEL = g_ui.loadUI('ui/marketoffers/browse')
selectionTabBar:addTab(tr('Browse'), BROWSE_PANEL)

-- Currently not used
-- "Reserved for more functionality later"
Expand All @@ -760,16 +769,20 @@ local function initInterface()
itemStatsPanel = g_ui.loadUI('ui/marketoffers/itemstats')
displaysTabBar:addTab(tr('Statistics'), itemStatsPanel)

itemDetailsPanel = g_ui.loadUI('ui/marketoffers/itemdetails')
displaysTabBar:addTab(tr('Details'), itemDetailsPanel)
ITEM_DETAILS_PANEL = g_ui.loadUI('ui/marketoffers/itemdetails')
displaysTabBar:addTab(tr('Details'), ITEM_DETAILS_PANEL)

itemOffersPanel = g_ui.loadUI('ui/marketoffers/itemoffers')
displaysTabBar:addTab(tr('Offers'), itemOffersPanel)
displaysTabBar:selectTab(displaysTabBar:getTab(tr('Offers')))

-- setup 'My Offer' section tabs
myOffersPanel = g_ui.loadUI('ui/myoffers')
mainTabBar:addTab(tr('My Offers'), myOffersPanel)
local moTab = mainTabBar:addTab(tr('My Offers'), myOffersPanel)
moTab.onClick = function()
mainTabBar:selectTab(moTab)
Market.refreshMyOffers()
end

offersTabBar = myOffersPanel:getChildById('offersTabBar')
offersTabBar:setContentWidget(myOffersPanel:getChildById('offersTabContent'))
Expand All @@ -790,8 +803,9 @@ local function initInterface()
sellButton.onClick = function() openAmountWindow(Market.acceptMarketOffer, MarketAction.Sell, 'Sell') end

-- setup selected item
nameLabel = marketOffersPanel:getChildById('nameLabel')
selectedItem = marketOffersPanel:getChildById('selectedItem')
selectedItemLabel = selectedItem:getChildById('selectedItemLabel')
selectedItemTitleLabel = marketOffersPanel:getChildById('selectedItemTitleLabel')

-- setup create new offer
totalPriceEdit = marketOffersPanel:getChildById('totalPriceEdit')
Expand All @@ -811,10 +825,10 @@ local function initInterface()
Market.enableCreateOffer(false)

-- setup filters
filterButtons[MarketFilters.Vocation] = browsePanel:getChildById('filterVocation')
filterButtons[MarketFilters.Level] = browsePanel:getChildById('filterLevel')
filterButtons[MarketFilters.Depot] = browsePanel:getChildById('filterDepot')
filterButtons[MarketFilters.SearchAll] = browsePanel:getChildById('filterSearchAll')
filterButtons[MarketFilters.Vocation] = BROWSE_PANEL:getChildById('filterVocation')
filterButtons[MarketFilters.Level] = BROWSE_PANEL:getChildById('filterLevel')
filterButtons[MarketFilters.Depot] = BROWSE_PANEL:getChildById('filterDepot')
filterButtons[MarketFilters.SearchAll] = BROWSE_PANEL:getChildById('filterSearchAll')

-- set filter default values
clearFilters()
Expand All @@ -824,10 +838,10 @@ local function initInterface()
filter.onCheckChange = Market.updateCurrentItems
end

searchEdit = browsePanel:getChildById('searchEdit')
categoryList = browsePanel:getChildById('categoryComboBox')
subCategoryList = browsePanel:getChildById('subCategoryComboBox')
slotFilterList = browsePanel:getChildById('slotComboBox')
searchEdit = BROWSE_PANEL:getChildById('searchEdit')
CATEGORY_LIST = BROWSE_PANEL:getChildById('categoryComboBox')
subCategoryList = BROWSE_PANEL:getChildById('subCategoryComboBox')
slotFilterList = BROWSE_PANEL:getChildById('slotComboBox')

slotFilterList:addOption(MarketSlotFilters[255])
slotFilterList:setEnabled(false)
Expand All @@ -836,22 +850,22 @@ local function initInterface()
if i >= MarketCategory.Ammunition and i <= MarketCategory.WandsRods then
subCategoryList:addOption(getMarketCategoryName(i))
else
categoryList:addOption(getMarketCategoryName(i))
CATEGORY_LIST:addOption(getMarketCategoryName(i))
end
end
categoryList:addOption(getMarketCategoryName(255)) -- meta weapons
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
CATEGORY_LIST:addOption(getMarketCategoryName(255)) -- meta weapons
CATEGORY_LIST:setCurrentOption(getMarketCategoryName(MarketCategory.First))
subCategoryList:setEnabled(false)

-- hook item filters
categoryList.onOptionChange = onChangeCategory
CATEGORY_LIST.onOptionChange = onChangeCategory
subCategoryList.onOptionChange = onChangeSubCategory
slotFilterList.onOptionChange = onChangeSlotFilter

-- setup tables
buyOfferTable = itemOffersPanel:recursiveGetChildById('buyingTable')
sellOfferTable = itemOffersPanel:recursiveGetChildById('sellingTable')
detailsTable = itemDetailsPanel:recursiveGetChildById('detailsTable')
detailsTable = ITEM_DETAILS_PANEL:recursiveGetChildById('detailsTable')
buyStatsTable = itemStatsPanel:recursiveGetChildById('buyStatsTable')
sellStatsTable = itemStatsPanel:recursiveGetChildById('sellStatsTable')
buyOfferTable.onSelectionChange = onSelectBuyOffer
Expand Down Expand Up @@ -917,10 +931,37 @@ function terminate()
Market = nil
end

function Market.showMyOffersTableInstructions()
local instruction = tr('Press %s button to update', tr('Refresh Offers'))
if sellMyOfferTable then sellMyOfferTable:setText(instruction) end
if buyMyOfferTable then buyMyOfferTable:setText(instruction) end
end

function Market.hideMyOffersTableInstructions()
if sellMyOfferTable then sellMyOfferTable:setText('') end
if buyMyOfferTable then buyMyOfferTable:setText('') end
end

function Market.showOffersTableInstructions()
local instruction = tr('Select an item to view the offers')
if sellOfferTable then sellOfferTable:setText(instruction) end
if buyOfferTable then buyOfferTable:setText(instruction) end
end

function Market.hideOffersTableInstructions()
if sellOfferTable then sellOfferTable:setText('') end
if buyOfferTable then buyOfferTable:setText('') end
end

function Market.reset()
balanceLabel:setColor('#bbbbbb')
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
CATEGORY_LIST:setCurrentOption(getMarketCategoryName(MarketCategory.First))
searchEdit:setText('')

-- When uses closes market at this screen we need to show this instruction again when it gets opened,
-- since we cannot load offers for the user ourselves due to the bot protection.
Market:showMyOffersTableInstructions()

clearFilters()
clearMyOffers()
if not table.empty(information) then
Expand All @@ -944,11 +985,13 @@ function Market.clearSelectedItem()

clearOffers()
radioItemSet:selectWidget(nil)
nameLabel:setText('No item selected.')
Market:showOffersTableInstructions()
selectedItem:setItem(nil)
selectedItem.item = nil
selectedItem.ref:setChecked(false)
selectedItem.ref = nil
selectedItemLabel:setText('?')
selectedItemTitleLabel:setText(tr('No item selected.'))

detailsTable:clearData()
buyStatsTable:clearData()
Expand Down Expand Up @@ -1008,7 +1051,7 @@ function Market.decrementAmount()
end

function Market.updateCurrentItems()
local id = getMarketCategoryId(categoryList:getCurrentOption().text)
local id = getMarketCategoryId(CATEGORY_LIST:getCurrentOption().text)
if id == MarketCategory.MetaWeapons then
id = getMarketCategoryId(subCategoryList:getCurrentOption().text)
end
Expand All @@ -1030,7 +1073,7 @@ end

function Market.refreshItemsWidget(selectItem)
local selectItem = selectItem or 0
itemsPanel = browsePanel:recursiveGetChildById('itemsPanel')
itemsPanel = BROWSE_PANEL:recursiveGetChildById('itemsPanel')

local layout = itemsPanel:getLayout()
layout:disableUpdates()
Expand Down Expand Up @@ -1084,6 +1127,7 @@ function Market.refreshOffers()
end

function Market.refreshMyOffers()
Market:hideMyOffersTableInstructions()
clearMyOffers()
MarketProtocol.sendMarketBrowseMyOffers()
end
Expand Down Expand Up @@ -1265,3 +1309,7 @@ end
function Market.onMarketBrowse(offers)
updateOffers(offers)
end

function Market.onMarketResourceBalance(balance, money)
return
end
15 changes: 14 additions & 1 deletion modules/game_market/marketprotocol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ local function parseMarketBrowse(protocol, msg)
return true
end

local function parseMarketResourcesBalance(protocol, msg)
msg:getU8()
local balance = msg:getU64() -- bank
msg:getU8()
msg:getU8()
local money = msg:getU64() -- inventory

signalcall(Market.onMarketResourceBalance, balance, money)
return true
end

-- public functions
function initProtocol()
connect(g_game, { onGameStart = MarketProtocol.registerProtocol,
Expand Down Expand Up @@ -161,6 +172,7 @@ function MarketProtocol.registerProtocol()
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketLeave, parseMarketLeave)
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketDetail, parseMarketDetail)
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketBrowse, parseMarketBrowse)
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerSendResourceBalance, parseMarketResourcesBalance)
end
MarketProtocol.updateProtocol(g_game.getProtocolGame())
end
Expand All @@ -171,6 +183,7 @@ function MarketProtocol.unregisterProtocol()
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketLeave, parseMarketLeave)
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketDetail, parseMarketDetail)
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketBrowse, parseMarketBrowse)
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerSendResourceBalance, parseMarketResourcesBalance)
end
MarketProtocol.updateProtocol(nil)
end
Expand Down Expand Up @@ -244,4 +257,4 @@ function MarketProtocol.sendMarketAcceptOffer(timestamp, counter, amount)
else
g_logger.error('MarketProtocol.sendMarketAcceptOffer does not support the current protocol.')
end
end
end
2 changes: 1 addition & 1 deletion modules/game_market/ui/general/marketcombobox.otui
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ MarketComboBoxPopupMenu < ComboBoxRoundedPopupMenu
MarketComboBox < ComboBoxRounded
font: verdana-11px-rounded
size: 86 20
text-offset: 3 2
text-offset: 9 9
22 changes: 16 additions & 6 deletions modules/game_market/ui/marketoffers.otui
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,31 @@ Panel
size: 34 34
padding: 1
font: verdana-11px-rounded
border-color: white
border-color: #535353
border-width: 1
anchors.top: rightTabBar.bottom
anchors.left: rightTabContent.left
margin-top: 6
margin-left: 6

Label
id: selectedItemLabel
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: selectedItem.top
anchors.left: selectedItem.left
size: 34 34
text-align: center
!text: '?'

Label
id: nameLabel
id: selectedItemTitleLabel
!text: tr('No item selected.')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: prev.top
anchors.left: prev.right
anchors.right: parent.right
margin-left: 5
anchors.top: selectedItem.top
anchors.left: selectedItem.right
margin-left: 6

Label
id: createLabel
Expand Down
4 changes: 1 addition & 3 deletions modules/game_market/ui/marketoffers/browse.otui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MarketItemBox < UICheckBox
text-offset: 0 22
text-align: right
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.left: parent.left
margin: 1

$checked:
Expand Down Expand Up @@ -105,9 +105,7 @@ Panel
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-top: 10
margin-left: 3
margin-bottom: 30
margin-right: 3

VerticalScrollBar
id: itemsPanelListScrollBar
Expand Down
Loading