Version 1.5 - bug fixes and small improvements

This commit is contained in:
OTCv8
2019-12-23 20:19:46 +01:00
parent cf8b21263d
commit d15cc347dc
17 changed files with 149 additions and 25 deletions

View File

@@ -19,7 +19,7 @@ local function sendAction(action, data)
data = {}
end
if protocolGame then
protocolGame:sendExtendedOpcode(SHOP_EXTENTED_OPCODE, json.encode({action = action, data = data}))
protocolGame:sendExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, {action = action, data = data})
end
end
@@ -27,7 +27,7 @@ end
function init()
connect(g_game, { onGameStart = check, onGameEnd = hide })
ProtocolGame.registerExtendedOpcode(SHOP_EXTENTED_OPCODE, onExtendedOpcode)
ProtocolGame.registerExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, onExtendedJSONOpcode)
if g_game.isOnline() then
check()
@@ -37,7 +37,7 @@ end
function terminate()
disconnect(g_game, { onGameStart = check, onGameEnd = hide })
ProtocolGame.unregisterExtendedOpcode(SHOP_EXTENTED_OPCODE, onExtendedOpcode)
ProtocolGame.unregisterExtendedJSONOpcode(SHOP_EXTENTED_OPCODE, onExtendedJSONOpcode)
if shopButton then
shopButton:destroy()
@@ -87,7 +87,7 @@ function toggle()
check()
end
function onExtendedOpcode(protocol, code, buffer)
function onExtendedJSONOpcode(protocol, code, json_data)
if not shop then
shop = g_ui.displayUI('shop')
shop:hide()
@@ -96,12 +96,6 @@ function onExtendedOpcode(protocol, code, buffer)
connect(shop.categories, { onChildFocusChange = changeCategory })
end
local json_status, json_data = pcall(function() return json.decode(buffer) end)
if not json_status then
g_logger.error("SHOP json error: " .. json_data)
return false
end
local action = json_data['action']
local data = json_data['data']
local status = json_data['status']
@@ -316,6 +310,7 @@ function addOffer(category, data)
offer.description:setText(data["description"])
if category ~= 0 then
offer.onDoubleClick = buyOffer
offer.buyButton.onClick = function() buyOffer(offer) end
end
end