mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-20 14:43:27 +02:00
Updated to OTCv8 3.0 rev 43
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
local SHOP_EXTENTED_OPCODE = 201
|
||||
|
||||
shop = nil
|
||||
transferWindow = nil
|
||||
local otcv8shop = false
|
||||
local shopButton = nil
|
||||
local msgWindow = nil
|
||||
local browsingHistory = false
|
||||
local transferValue = 0
|
||||
|
||||
-- for classic store
|
||||
local storeUrl = ""
|
||||
@@ -51,6 +53,8 @@ function init()
|
||||
if g_game.isOnline() then
|
||||
check()
|
||||
end
|
||||
createShop()
|
||||
createTransferWindow()
|
||||
end
|
||||
|
||||
function terminate()
|
||||
@@ -107,6 +111,29 @@ function show()
|
||||
shop:focus()
|
||||
end
|
||||
|
||||
function softHide()
|
||||
if not transferWindow then return end
|
||||
|
||||
transferWindow:hide()
|
||||
shop:show()
|
||||
end
|
||||
|
||||
function showTransfer()
|
||||
if not shop or not transferWindow then return end
|
||||
|
||||
hide()
|
||||
transferWindow:show()
|
||||
transferWindow:raise()
|
||||
transferWindow:focus()
|
||||
end
|
||||
|
||||
function hideTransfer()
|
||||
if not shop or not transferWindow then return end
|
||||
|
||||
transferWindow:hide()
|
||||
show()
|
||||
end
|
||||
|
||||
function toggle()
|
||||
if not shop then
|
||||
return
|
||||
@@ -126,6 +153,11 @@ function createShop()
|
||||
connect(shop.categories, { onChildFocusChange = changeCategory })
|
||||
end
|
||||
|
||||
function createTransferWindow()
|
||||
if transferWindow then return end
|
||||
transferWindow = g_ui.displayUI('transfer')
|
||||
transferWindow:hide()
|
||||
end
|
||||
|
||||
function onStoreInit(url, coins)
|
||||
if otcv8shop then return end
|
||||
@@ -141,6 +173,7 @@ function onStoreInit(url, coins)
|
||||
end
|
||||
coinsPacketSize = coins
|
||||
createShop()
|
||||
createTransferWindow()
|
||||
end
|
||||
|
||||
function onStoreCategories(categories)
|
||||
@@ -228,23 +261,46 @@ end
|
||||
|
||||
function onStorePurchase(message)
|
||||
if not shop or otcv8shop then return end
|
||||
processMessage({title="Successful shop purchase", msg=message})
|
||||
if not transferWindow:isVisible() then
|
||||
processMessage({title="Successful shop purchase", msg=message})
|
||||
else
|
||||
processMessage({title="Successfuly gifted coins", msg=message})
|
||||
softHide()
|
||||
end
|
||||
end
|
||||
|
||||
function onStoreError(errorType, message)
|
||||
if not shop or otcv8shop then return end
|
||||
processMessage({title="Shop error", msg=message})
|
||||
if not transferWindow:isVisible() then
|
||||
processMessage({title="Shop Error", msg=message})
|
||||
else
|
||||
processMessage({title="Gift coins error", msg=message})
|
||||
end
|
||||
end
|
||||
|
||||
function onCoinBalance(coins, transferableCoins)
|
||||
if not shop or otcv8shop then return end
|
||||
shop.infoPanel.points:setText(tr("Points:") .. " " .. coins)
|
||||
transferWindow.coinsBalance:setText(tr('Transferable Tibia Coins: ') .. coins)
|
||||
transferWindow.coinsAmount:setMaximum(coins)
|
||||
shop.infoPanel.buy:hide()
|
||||
shop.infoPanel:setHeight(20)
|
||||
end
|
||||
|
||||
function transferCoins()
|
||||
if not transferWindow then return end
|
||||
local amount = 0
|
||||
amount = transferWindow.coinsAmount:getValue()
|
||||
local recipient = transferWindow.recipient:getText()
|
||||
|
||||
g_game.transferCoins(recipient, amount)
|
||||
transferWindow.recipient:setText('')
|
||||
transferWindow.coinsAmount:setValue(0)
|
||||
end
|
||||
|
||||
function onExtendedJSONOpcode(protocol, code, json_data)
|
||||
createShop()
|
||||
createTransferWindow()
|
||||
|
||||
local action = json_data['action']
|
||||
local data = json_data['data']
|
||||
|
@@ -227,10 +227,19 @@ MainWindow
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: modules.game_shop.showHistory()
|
||||
|
||||
Button
|
||||
id: transferOpen
|
||||
!text: tr('Transfer Coins')
|
||||
width: 128
|
||||
anchors.left: prev. right
|
||||
margin-left: 10
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
@onClick: modules.game_shop.showTransfer()
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
!text: tr('Close')
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: modules.game_shop.hide()
|
||||
@onClick: modules.game_shop.hide()
|
80
modules/game_shop/transfer.otui
Normal file
80
modules/game_shop/transfer.otui
Normal file
@@ -0,0 +1,80 @@
|
||||
MainWindow
|
||||
id: transferWindow
|
||||
!text: tr('Gift Tibia Coins')
|
||||
size: 280 240
|
||||
@onEscape: modules.game_shop.hideTransfer()
|
||||
|
||||
Label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text-wrap: true
|
||||
height: 56
|
||||
!text: tr('Please select the amount of Tibia Coins you would like to gift and enter the name of the character that should receive the Tibia Coins.')
|
||||
|
||||
Label
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 20
|
||||
!text: tr('Reciepient:')
|
||||
|
||||
TextEdit
|
||||
id: recipient
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
anchors.right: parent.right
|
||||
width: 150
|
||||
text-align: left
|
||||
|
||||
Label
|
||||
id: coinsBalance
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 10
|
||||
text-align: center
|
||||
!text: tr('Transferable Tibia Coins:')
|
||||
|
||||
Label
|
||||
id: coinsAmountLabel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 20
|
||||
!text: tr('Amount to gift: ')
|
||||
|
||||
SpinBox
|
||||
id: coinsAmount
|
||||
anchors.right: parent.right
|
||||
width: 100
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
text: 0
|
||||
minimum: 0
|
||||
maximum: 0
|
||||
focusable: true
|
||||
editable: true
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: cancelButton.top
|
||||
margin-bottom: 8
|
||||
|
||||
Button
|
||||
id: cancelButton
|
||||
!text: tr('Cancel')
|
||||
font: cipsoftFont
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
size: 45 21
|
||||
margin-top: 15
|
||||
margin-right: 5
|
||||
@onClick: modules.game_shop.hideTransfer()
|
||||
|
||||
Button
|
||||
id: giftButton
|
||||
!text: tr('Gift')
|
||||
font: cipsoftFont
|
||||
size: 45 21
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
anchors.right: prev.left
|
||||
margin-right: 5
|
||||
@onClick: modules.game_shop.transferCoins()
|
Reference in New Issue
Block a user