More market work (getting close to completion)

* Can now create market offers with fully working UI.
* All filtering is now completed (just need to finish word searching).
* Added some user friendly features to offer selections and item displays (show amount in depot).
* Some more UI ascetics.
* Some other minor market fixes.

TODO:
* Finishing applying changes for latest module updates by edubart.
* Finish buying/selling existing offers.
* Word searching items.
* Offer management.
* Full cipsoft tibia testing.
master
BeniS 12 years ago
parent 2b2f5b33ff
commit 7aba117cf2

File diff suppressed because it is too large Load Diff

@ -1,16 +1,9 @@
Module
name: game_market
description: Manage the Players Market system
description: Global item market system
author: BeniS
website: www.otclient.info
@onLoad: |
dofile 'marketoffer'
dofile 'marketprotocol'
dofile 'market'
MarketProtocol.init()
Market.init()
@onUnload: |
MarketProtocol.terminate()
Market.terminate()
sandboxed: true
scripts: [marketoffer.lua, marketprotocol.lua, market.lua]
@onLoad: init()
@onUnload: terminate()

@ -3,8 +3,8 @@ MarketWindow < MainWindow
!text: tr('Market')
size: 700 510
@onEnter: self:hide() self:unlock()
@onEscape: self:hide() self:unlock()
@onEnter: self:hide() self:unlock() Market.clearSelectedItem()
@onEscape: self:hide() self:unlock() Market.clearSelectedItem()
// Main Panel Window
@ -24,3 +24,11 @@ MarketWindow < MainWindow
padding: 3
border-width: 1
border-color: #000000
Label
id: balanceLabel
!text: tr('Balance: 10000')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: parent.top
anchors.right: parent.right

@ -46,15 +46,15 @@ MarketOffer.new = function(offerId, action, item, amount, price, playerName, sta
return offer
end
function MarketOffer:isEqual(offer)
return self.offer[OFFER_TIMESTAMP] == offer[OFFER_TIMESTAMP] and self.offer[OFFER_COUNTER] == offer[OFFER_COUNTER]
function MarketOffer:isEqual(id)
return self.id[OFFER_TIMESTAMP] == id[OFFER_TIMESTAMP] and self.id[OFFER_COUNTER] == id[OFFER_COUNTER]
end
function MarketOffer:isLessThan(offer)
return self.offer[OFFER_TIMESTAMP] <= offer[OFFER_TIMESTAMP] and self.offer[OFFER_COUNTER] < offer[OFFER_COUNTER]
function MarketOffer:isLessThan(id)
return self.id[OFFER_TIMESTAMP] <= id[OFFER_TIMESTAMP] and self.id[OFFER_COUNTER] < id[OFFER_COUNTER]
end
function MarketOffer:isNull(offer)
function MarketOffer:isNull()
return table.empty(self.id)
end

@ -44,8 +44,8 @@ local function parseMarketEnter(msg)
local offers = msg:getU8()
local depotItems = {}
local depotCount = (msg:getU16() - 1)
for i = 0, depotCount do
local depotCount = msg:getU16()
for i = 1, depotCount do
local itemId = msg:getU16() -- item id
local itemCount = msg:getU16() -- item count
@ -103,13 +103,13 @@ local function parseMarketBrowse(msg)
local var = msg:getU16()
local offers = {}
local buyOfferCount = (msg:getU32() - 1)
for i = 0, buyOfferCount do
local buyOfferCount = msg:getU32()
for i = 1, buyOfferCount do
table.insert(offers, readMarketOffer(msg, MarketAction.Buy, var))
end
local sellOfferCount = (msg:getU32() - 1)
for i = 0, sellOfferCount do
local sellOfferCount = msg:getU32()
for i = 1, sellOfferCount do
table.insert(offers, readMarketOffer(msg, MarketAction.Sell, var))
end
@ -118,7 +118,7 @@ local function parseMarketBrowse(msg)
end
-- public functions
function MarketProtocol.init()
function initProtocol()
connect(g_game, { onGameStart = MarketProtocol.registerProtocol,
onGameEnd = MarketProtocol.unregisterProtocol })
@ -128,7 +128,7 @@ function MarketProtocol.init()
end
end
function MarketProtocol.terminate()
function terminateProtocol()
disconnect(g_game, { onGameStart = MarketProtocol.registerProtocol,
onGameEnd = MarketProtocol.unregisterProtocol })

@ -1,8 +1,8 @@
MarketButtonBox < UICheckBox
font: verdana-11px-antialised
font: verdana-11px-rounded
color: #f55e5ebb
size: 106 22
text-offset: 0 0
text-offset: 0 2
text-align: center
image-source: /images/tabbutton_rounded.png
image-clip: 0 0 20 20

@ -1,8 +1,8 @@
MarketComboBoxPopupMenuButton < UIButton
height: 18
font: verdana-11px-antialised
font: verdana-11px-rounded
text-align: left
text-offset: 2 0
text-offset: 2 2
color: #aaaaaa
background-color: alpha
@ -28,10 +28,10 @@ MarketComboBoxPopupMenu < UIPopupMenu
padding: 1
MarketComboBox < UIComboBox
font: verdana-11px-antialised
font: verdana-11px-rounded
color: #aaaaaa
size: 86 20
text-offset: 3 0
text-offset: 3 2
text-align: left
image-source: /images/combobox_rounded.png
image-border: 1

@ -4,6 +4,8 @@ MarketTabBarPanel < Panel
MarketTabBarButton < UIButton
size: 20 25
image-source: /images/tabbutton_square.png
font: verdana-11px-rounded
text-offset: 0 2
image-clip: 0 0 20 20
image-border: 2
icon-color: white

@ -18,7 +18,7 @@ Panel
MarketTabBar
id: rightTabBar
width: 157
width: 166
height:25
anchors.top: parent.top
anchors.right: parent.right
@ -48,7 +48,142 @@ Panel
Label
id: nameLabel
!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
Label
id: createLabel
!text: tr('Create New Offer')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: rightTabBar.top
anchors.left: rightTabContent.left
margin-top: 355
margin-left: 6
Label
id: offerTypeLabel
!text: tr('Offer Type:')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 7
MarketComboBox
id: offerTypeComboBox
!text: tr('Please Select')
anchors.top: prev.bottom
anchors.left: createLabel.left
margin-top: 3
width: 105
$disabled:
color: #aaaaaa44
Label
id: totalPriceLabel
!text: tr('Total Price:')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: offerTypeLabel.top
anchors.left: prev.right
margin-left: 7
SpinBox
id: totalPriceEdit
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 3
width: 75
minimum: 1
maximum: 99999999
$disabled:
color: #aaaaaa44
Label
id: piecePriceLabel
!text: tr('Piece Price:')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: offerTypeLabel.top
anchors.left: prev.right
margin-left: 7
SpinBox
id: piecePriceEdit
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 3
width: 75
minimum: 1
maximum: 99999999
$disabled:
color: #aaaaaa44
Label
id: amountLabel
!text: tr('Amount:')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: offerTypeLabel.top
anchors.left: prev.right
margin-left: 32
PreviousButton
id: prevAmountButton
anchors.verticalCenter: piecePriceEdit.verticalCenter
anchors.left: piecePriceEdit.right
margin-left: 7
@onClick: Market.decrementAmount()
SpinBox
id: amountEdit
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
margin-left: 3
width: 55
minimum: 1
maximum: 999999
NextButton
id: nextAmountButton
anchors.verticalCenter: piecePriceEdit.verticalCenter
anchors.left: prev.right
margin-left: 3
@onClick: Market.incrementAmount()
Button
id: createOfferButton
!text: tr('Create Offer')
anchors.verticalCenter: prev.verticalCenter
anchors.left: prev.right
margin-left: 7
width: 90
//@onClick: g_game.closeNpcTrade()
CheckBox
id: anonymousCheckBox
!text: tr('Anonymous')
anchors.left: prev.left
anchors.bottom: prev.top
margin-bottom: 6
@onSetup: self:setChecked(false)
height: 16
width: 70
Label
id: feeLabel
!text: tr('')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: createOfferButton.bottom
anchors.right: parent.right
margin-right: 8
margin-top: 3

@ -1,14 +1,15 @@
MarketItemBox < UICheckBox
id: itemBox
border-width: 1
border-color: #000000
color: #aaaaaa
text-align: center
text-offset: 0 20
@onCheckChange: Market.onItemBoxChecked(self)
Item
id: item
phantom: true
text-offset: 0 13
text-align: right
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
margin: 1

@ -25,9 +25,9 @@ Panel
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
margin-top: 55
margin-top: 63
margin-left: 6
margin-bottom: 75
margin-bottom: 85
margin-right: 6
padding: 1
focusable: false

@ -49,6 +49,8 @@ Panel
Label
!text: tr('Sell Offers')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: parent.top
anchors.left: parent.left
margin-top: 44
@ -59,7 +61,7 @@ Panel
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: parent.right
height: 120
height: 115
margin-top: 5
margin-bottom: 5
margin-right: 6
@ -101,6 +103,8 @@ Panel
Label
!text: tr('Buy Offers')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: prev.top
anchors.left: parent.left
margin-top: 9
@ -114,7 +118,7 @@ Panel
margin-top: 5
margin-bottom: 5
margin-right: 6
height: 120
height: 115
padding: 1
focusable: false
background-color: #222833

@ -20,6 +20,8 @@ Panel
Label
!text: tr('Buy Offers')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
@ -62,6 +64,8 @@ Panel
Label
!text: tr('Sell Offers')
font: verdana-11px-rounded
text-offset: 0 2
anchors.top: buyStatsTable.bottom
anchors.left: parent.left
margin-top: 9
@ -73,7 +77,7 @@ Panel
anchors.left: buyStatsTable.left
anchors.right: buyStatsTable.right
margin-top: 6
height: 122
height: 112
padding: 1
focusable: false
background-color: #222833

@ -1,3 +1,21 @@
MarketAction = {
Buy = 0,
Sell = 1
}
MarketRequest = {
MyOffers = 0xFFFE,
MyHistory = 0xFFFF
}
MarketOfferState = {
Active = 0,
Cancelled = 1,
Expired = 2,
Accepted = 3,
AcceptedEx = 255
}
MarketCategory = {
All = 0,
Armors = 1,
@ -64,23 +82,18 @@ MarketCategoryStrings = {
[255] = 'Weapons'
}
MarketAction = {
Buy = 0,
Sell = 1
}
MarketRequest = {
MyOffers = 0xFFFE,
MyHistory = 0xFFFF
}
function getMarketCategoryName(id)
if table.hasKey(MarketCategoryStrings, id) then
return MarketCategoryStrings[id]
end
end
MarketOfferState = {
Active = 0,
Cancelled = 1,
Expired = 2,
Accepted = 3,
AcceptedEx = 255
}
function getMarketCategoryId(name)
local id = table.find(MarketCategoryStrings, name)
if id then
return id
end
end
MarketItemDescription = {
Armor = 1,
@ -121,6 +134,19 @@ MarketItemDescriptionStrings = {
[15] = 'Weight'
}
function getMarketDescriptionName(id)
if table.hasKey(MarketItemDescriptionStrings, id) then
return MarketItemDescriptionStrings[id]
end
end
function getMarketDescriptionId(name)
local id = table.find(MarketItemDescriptionStrings, name)
if id then
return id
end
end
MarketSlotFilters = {
[InventorySlotOther] = "Two-Handed",
[InventorySlotLeft] = "One-Handed",
@ -134,4 +160,17 @@ MarketFilters = {
}
MarketFilters.First = MarketFilters.vocation
MarketFilters.Last = MarketFilters.depot
MarketFilters.Last = MarketFilters.depot
function getMarketSlotFilterId(name)
local id = table.find(MarketSlotFilters, name)
if id then
return id
end
end
function getMarketSlotFilterName(id)
if table.hasKey(MarketSlotFilters, id) then
return MarketSlotFilters[id]
end
end
Loading…
Cancel
Save