Minor bug fixes

This commit is contained in:
OTCv8 2020-01-31 19:11:08 +01:00
parent 6bc4188d7a
commit dbfad99ca4
3 changed files with 37 additions and 6 deletions

View File

@ -113,9 +113,21 @@ context.setSpellTimeout = function()
context.lastSpell = context.now
end
context.use = g_game.useInventoryItem
context.usewith = g_game.useInventoryItemWith
context.useWith = g_game.useInventoryItemWith
context.use = function(thing, subtype)
if type(thing) == 'number' then
return g_game.useInventoryItem(thing, subtype)
else
return g_game.use(thing)
end
end
context.usewith = function(thing, target, subtype)
if type(thing) == 'number' then
return g_game.useInventoryItemWith(thing, target, subtype)
else
return g_game.useWith(item, target, subtype)
end
end
context.useWith = context.usewith
context.useRune = function(itemid, target, lastSpellTimeout)
if context.lastRuneUse == nil then

View File

@ -928,7 +928,6 @@ function updateSize()
local height = gameMapPanel:getHeight()
local width = gameMapPanel:getWidth()
print("updatesize")
if not classic then
local rheight = gameRootPanel:getHeight()
local rwidth = gameRootPanel:getWidth()

View File

@ -60,6 +60,7 @@ function timeleftTranslation(timeleft, forPreyTimeleft) -- in seconds
end
function init()
connect(g_game, {
onGameStart = check,
onGameEnd = hide,
onResourceBalance = onResourceBalance,
onPreyFreeRolls = onPreyFreeRolls,
@ -73,11 +74,14 @@ function init()
preyWindow = g_ui.displayUI('prey')
preyWindow:hide()
preyButton = modules.client_topmenu.addRightGameToggleButton('preyButton', tr('Preys'), '/images/topbuttons/prey', toggle)
if g_game.isOnline() then
check()
end
end
function terminate()
disconnect(g_game, {
onGameStart = check,
onGameEnd = hide,
onResourceBalance = onResourceBalance,
onPreyFreeRolls = onPreyFreeRolls,
@ -89,7 +93,9 @@ function terminate()
onPreySelection = onPreySelection
})
preyButton:destroy()
if preyButton then
preyButton:destroy()
end
preyWindow:destroy()
if msgWindow then
msgWindow:destroy()
@ -97,6 +103,17 @@ function terminate()
end
end
function check()
if g_game.getFeature(GamePrey) then
if not preyButton then
preyButton = modules.client_topmenu.addRightGameToggleButton('preyButton', tr('Preys'), '/images/topbuttons/prey', toggle)
end
elseif preyButton then
preyButton:destroy()
preyButton = nil
end
end
function hide()
preyWindow:hide()
if msgWindow then
@ -106,6 +123,9 @@ function hide()
end
function show()
if not g_game.getFeature(GamePrey) then
return hide()
end
preyWindow:show()
preyWindow:raise()
preyWindow:focus()