Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit a2de18a

Browse files
committed
game_market ui/ux improvements
game_market ui/ux improvements added server opcode support 238 from edubart#1027
1 parent 764f4b9 commit a2de18a

File tree

10 files changed

+99
-17
lines changed

10 files changed

+99
-17
lines changed

modules/client_locales/neededtranslations.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ neededTranslations = {
284284
"Position",
285285
"Premium",
286286
"Premium Account (%s) days left",
287+
"Press %s button to update",
287288
"Price",
288289
"Primary",
289290
"Process",
@@ -320,6 +321,7 @@ neededTranslations = {
320321
"Secondary",
321322
"Select",
322323
"Select all",
324+
"Select an item to view the offers",
323325
"Select object",
324326
"Select Outfit",
325327
"Select your language",

modules/game_market/market.lua

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ itemsPanel = nil
4040
selectedOffer = {}
4141
selectedMyOffer = {}
4242

43-
nameLabel = nil
4443
feeLabel = nil
4544
balanceLabel = nil
4645
totalPriceEdit = nil
@@ -49,6 +48,8 @@ amountEdit = nil
4948
searchEdit = nil
5049
radioItemSet = nil
5150
selectedItem = nil
51+
selectedItemLabel = nil
52+
selectedItemTitleLabel = nil
5253
offerTypeList = nil
5354
categoryList = nil
5455
subCategoryList = nil
@@ -443,7 +444,9 @@ local function updateSelectedItem(widget)
443444
Market.resetCreateOffer()
444445
if Market.isItemSelected() then
445446
selectedItem:setItem(selectedItem.item.displayItem)
446-
nameLabel:setText(selectedItem.item.marketData.name)
447+
selectedItemLabel:setText('')
448+
selectedItemTitleLabel:setText(selectedItem.item.marketData.name)
449+
Market:hideOffersTableInstructions()
447450
clearOffers()
448451

449452
Market.enableCreateOffer(true) -- update offer types
@@ -726,8 +729,10 @@ local function initMarketItems()
726729
}
727730

728731
-- add new market item
732+
if marketItems[marketData.category] ~= nil then
729733
table.insert(marketItems[marketData.category], marketItem)
730734
itemSet[marketData.tradeAs] = true
735+
end
731736
end
732737
end
733738
end
@@ -741,7 +746,11 @@ local function initInterface()
741746

742747
-- setup 'Market Offer' section tabs
743748
marketOffersPanel = g_ui.loadUI('ui/marketoffers')
744-
mainTabBar:addTab(tr('Market Offers'), marketOffersPanel)
749+
local mopTab = mainTabBar:addTab(tr('Market Offers'), marketOffersPanel)
750+
mopTab.onClick = function()
751+
mainTabBar:selectTab(mopTab)
752+
Market.refreshOffers()
753+
end
745754

746755
selectionTabBar = marketOffersPanel:getChildById('leftTabBar')
747756
selectionTabBar:setContentWidget(marketOffersPanel:getChildById('leftTabContent'))
@@ -769,7 +778,11 @@ local function initInterface()
769778

770779
-- setup 'My Offer' section tabs
771780
myOffersPanel = g_ui.loadUI('ui/myoffers')
772-
mainTabBar:addTab(tr('My Offers'), myOffersPanel)
781+
local moTab = mainTabBar:addTab(tr('My Offers'), myOffersPanel)
782+
moTab.onClick = function()
783+
mainTabBar:selectTab(moTab)
784+
Market.refreshMyOffers()
785+
end
773786

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

792805
-- setup selected item
793-
nameLabel = marketOffersPanel:getChildById('nameLabel')
794806
selectedItem = marketOffersPanel:getChildById('selectedItem')
807+
selectedItemLabel = selectedItem:getChildById('selectedItemLabel')
808+
selectedItemTitleLabel = marketOffersPanel:getChildById('selectedItemTitleLabel')
795809

796810
-- setup create new offer
797811
totalPriceEdit = marketOffersPanel:getChildById('totalPriceEdit')
@@ -917,10 +931,38 @@ function terminate()
917931
Market = nil
918932
end
919933

934+
function Market.showMyOffersTableInstructions()
935+
local instruction = tr('Press %s button to update', tr('Refresh Offers'))
936+
if sellMyOfferTable then sellMyOfferTable:setText(instruction) end
937+
if buyMyOfferTable then buyMyOfferTable:setText(instruction) end
938+
end
939+
940+
function Market.hideMyOffersTableInstructions()
941+
if sellMyOfferTable then sellMyOfferTable:setText('') end
942+
if buyMyOfferTable then buyMyOfferTable:setText('') end
943+
end
944+
945+
function Market.showOffersTableInstructions()
946+
local instruction = tr('Select an item to view the offers')
947+
if sellOfferTable then sellOfferTable:setText(instruction) end
948+
if buyOfferTable then buyOfferTable:setText(instruction) end
949+
end
950+
951+
function Market.hideOffersTableInstructions()
952+
if sellOfferTable then sellOfferTable:setText('') end
953+
if buyOfferTable then buyOfferTable:setText('') end
954+
end
955+
956+
920957
function Market.reset()
921958
balanceLabel:setColor('#bbbbbb')
922959
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
923960
searchEdit:setText('')
961+
962+
-- When uses closes market at this screen we need to show this instruction again when it gets opened,
963+
-- since we cannot load offers for the user ourselves due to the bot protection.
964+
Market:showMyOffersTableInstructions()
965+
924966
clearFilters()
925967
clearMyOffers()
926968
if not table.empty(information) then
@@ -944,11 +986,13 @@ function Market.clearSelectedItem()
944986

945987
clearOffers()
946988
radioItemSet:selectWidget(nil)
947-
nameLabel:setText('No item selected.')
989+
Market:showOffersTableInstructions()
948990
selectedItem:setItem(nil)
949991
selectedItem.item = nil
950992
selectedItem.ref:setChecked(false)
951993
selectedItem.ref = nil
994+
selectedItemLabel:setText('?')
995+
selectedItemTitleLabel:setText(tr('No item selected.'))
952996

953997
detailsTable:clearData()
954998
buyStatsTable:clearData()
@@ -1084,6 +1128,7 @@ function Market.refreshOffers()
10841128
end
10851129

10861130
function Market.refreshMyOffers()
1131+
Market:hideMyOffersTableInstructions()
10871132
clearMyOffers()
10881133
MarketProtocol.sendMarketBrowseMyOffers()
10891134
end
@@ -1265,3 +1310,7 @@ end
12651310
function Market.onMarketBrowse(offers)
12661311
updateOffers(offers)
12671312
end
1313+
1314+
function Market.onMarketResourceBalance(balance, money)
1315+
return
1316+
end

modules/game_market/marketprotocol.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ local function parseMarketBrowse(protocol, msg)
129129
return true
130130
end
131131

132+
local function parseMarketResourcesBalance(protocol, msg)
133+
msg:getU8()
134+
local balance = msg:getU64() -- bank
135+
msg:getU8()
136+
msg:getU8()
137+
local money = msg:getU64() -- inventory
138+
139+
signalcall(Market.onMarketResourceBalance, balance, money)
140+
return true
141+
end
142+
132143
-- public functions
133144
function initProtocol()
134145
connect(g_game, { onGameStart = MarketProtocol.registerProtocol,
@@ -161,6 +172,7 @@ function MarketProtocol.registerProtocol()
161172
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketLeave, parseMarketLeave)
162173
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketDetail, parseMarketDetail)
163174
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerMarketBrowse, parseMarketBrowse)
175+
ProtocolGame.registerOpcode(GameServerOpcodes.GameServerSendResourceBalance, parseMarketResourcesBalance)
164176
end
165177
MarketProtocol.updateProtocol(g_game.getProtocolGame())
166178
end
@@ -171,6 +183,7 @@ function MarketProtocol.unregisterProtocol()
171183
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketLeave, parseMarketLeave)
172184
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketDetail, parseMarketDetail)
173185
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerMarketBrowse, parseMarketBrowse)
186+
ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerSendResourceBalance, parseMarketResourcesBalance)
174187
end
175188
MarketProtocol.updateProtocol(nil)
176189
end

modules/game_market/ui/general/marketcombobox.otui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ MarketComboBoxPopupMenu < ComboBoxRoundedPopupMenu
1515
MarketComboBox < ComboBoxRounded
1616
font: verdana-11px-rounded
1717
size: 86 20
18-
text-offset: 3 2
18+
text-offset: 9 9

modules/game_market/ui/marketoffers.otui

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,31 @@ Panel
3939
size: 34 34
4040
padding: 1
4141
font: verdana-11px-rounded
42-
border-color: white
42+
border-color: #535353
43+
border-width: 1
4344
anchors.top: rightTabBar.bottom
4445
anchors.left: rightTabContent.left
4546
margin-top: 6
4647
margin-left: 6
4748

49+
Label
50+
id: selectedItemLabel
51+
font: verdana-11px-rounded
52+
text-offset: 0 2
53+
anchors.top: selectedItem.top
54+
anchors.left: selectedItem.left
55+
size: 34 34
56+
text-align: center
57+
!text: '?'
58+
4859
Label
49-
id: nameLabel
60+
id: selectedItemTitleLabel
5061
!text: tr('No item selected.')
5162
font: verdana-11px-rounded
5263
text-offset: 0 2
53-
anchors.top: prev.top
54-
anchors.left: prev.right
55-
anchors.right: parent.right
56-
margin-left: 5
64+
anchors.top: selectedItem.top
65+
anchors.left: selectedItem.right
66+
margin-left: 6
5767

5868
Label
5969
id: createLabel

modules/game_market/ui/marketoffers/browse.otui

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MarketItemBox < UICheckBox
1212
text-offset: 0 22
1313
text-align: right
1414
anchors.top: parent.top
15-
anchors.horizontalCenter: parent.horizontalCenter
15+
anchors.left: parent.left
1616
margin: 1
1717

1818
$checked:
@@ -105,9 +105,7 @@ Panel
105105
anchors.right: parent.right
106106
anchors.bottom: parent.bottom
107107
margin-top: 10
108-
margin-left: 3
109108
margin-bottom: 30
110-
margin-right: 3
111109

112110
VerticalScrollBar
113111
id: itemsPanelListScrollBar

modules/game_market/ui/marketoffers/itemoffers.otui

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Panel
6868
column-style: OfferTableColumn
6969
header-column-style: false
7070
header-row-style: false
71+
color: #cccccc
72+
!text: tr('Select an item to view the offers')
7173

7274
OfferTableHeaderRow
7375
id: header
@@ -141,6 +143,8 @@ Panel
141143
column-style: OfferTableColumn
142144
header-column-style: false
143145
header-row-style: false
146+
color: #cccccc
147+
!text: tr('Select an item to view the offers')
144148

145149
OfferTableHeaderRow
146150
id: header
@@ -173,4 +177,4 @@ Panel
173177
anchors.bottom: buyingTable.bottom
174178
anchors.right: buyingTable.right
175179
step: 28
176-
pixels-scroll: true
180+
pixels-scroll: true

modules/game_market/ui/myoffers/currentoffers.otui

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Panel
6868
column-style: OfferTableColumn
6969
header-column-style: false
7070
header-row-style: false
71+
color: #cccccc
72+
!text: tr('Press %s button to update', tr('Refresh Offers'))
7173

7274
OfferTableHeaderRow
7375
id: header
@@ -141,6 +143,8 @@ Panel
141143
column-style: OfferTableColumn
142144
header-column-style: false
143145
header-row-style: false
146+
color: #cccccc
147+
!text: tr('Press %s button to update', tr('Refresh Offers'))
144148

145149
OfferTableHeaderRow
146150
id: header

modules/gamelib/protocol.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ GameServerOpcodes = {
9191
GameServerCoinBalance = 223, -- 1080
9292
GameServerStoreError = 224, -- 1080
9393
GameServerRequestPurchaseData = 225, -- 1080
94+
GameServerSendResourceBalance = 238, -- market
9495
GameServerQuestLog = 240,
9596
GameServerQuestLine = 241,
9697
GameServerCoinBalanceUpdating = 242, -- 1080

src/client/protocolcodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ namespace Proto {
148148
GameServerCoinBalance = 223, // 1080
149149
GameServerStoreError = 224, // 1080
150150
GameServerRequestPurchaseData = 225, // 1080
151+
GameServerSendResourceBalance = 238, // market
151152
GameServerQuestLog = 240,
152153
GameServerQuestLine = 241,
153154
GameServerCoinBalanceUpdating = 242, // 1080

0 commit comments

Comments
 (0)