restore inventory and healthbar

* make inventory/healthbar work again allowing reload
* changes in top menu toggle buttons
* all modules are now reloadable by default
* fix warning when using fade in
* remove some unused files
master
Eduardo Bart 12年前
コミット 239f58296e

@ -5,6 +5,7 @@ Module
website: https://github.com/edubart/otclient
autoload: true
autoload-priority: 100
reloadable: false
load-later:
- client_topmenu

@ -3,7 +3,6 @@ Module
description: Create the about window
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- client_topmenu

@ -25,6 +25,7 @@ function Background.terminate()
disconnect(g_game, { onGameStart = Background.hide })
disconnect(g_game, { onGameEnd = Background.show })
Effects.cancelFade(background:getChildById('clientVersionLabel'))
background:destroy()
background = nil

@ -3,7 +3,6 @@ Module
description: Handles the background of the login screen
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- client_topmenu

@ -3,7 +3,6 @@ Module
description: Manages enter game and character list windows
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- client_topmenu

@ -3,9 +3,6 @@ Module
description: Manage other modules
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
autoload: true
autoload-priority: 140
dependencies:
- client_topmenu

@ -3,7 +3,6 @@ Module
description: Create the options window
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- client_topmenu

@ -3,7 +3,6 @@ Module
description: Terminal for executing lua functions
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
@onLoad: |
dofile 'terminal'

@ -19,12 +19,7 @@ local function addButton(id, description, icon, callback, panel, toggle)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 3))
if toggle then
button.onCheckChange = callback
else
button.onClick = callback
end
button.onClick = callback
return button
end
@ -38,6 +33,10 @@ function TopMenu.init()
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
if g_game.isOnline() then
gameButtonsPanel:show()
end
end
function TopMenu.terminate()

@ -3,7 +3,6 @@ Module
description: Create the top menu
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
@onLoad: |
dofile 'topmenu'

@ -17,7 +17,7 @@ TopButton < UIButton
image-color: #ffffff44
icon-color: #ffffff44
TopToggleButton < UICheckBox
TopToggleButton < UIButton
size: 26 26
image-source: images/top_game_button.png
image-clip: 26 0 26 26
@ -25,7 +25,7 @@ TopToggleButton < UICheckBox
image-border: 3
icon-color: #ffffffff
$checked:
$on:
image-clip: 0 0 26 26
image-color: #ffffffff
icon-color: #ffffffff
@ -62,6 +62,7 @@ TopPanel
anchors.bottom: parent.bottom
anchors.left: prev.right
anchors.right: next.left
visible: false
TopMenuButtonsPanel
id: rightButtonsPanel

@ -5,6 +5,7 @@ Module
website: https://github.com/edubart/otclient
autoload: true
autoload-priority: 10
reloadable: false
@onLoad: |
dofile 'ext/table'

@ -1,26 +1,34 @@
Effects = {}
function Effects.fadeIn(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.min(elapsed/time, 1))
if elapsed < time then
scheduleEvent(function()
Effects.fadeIn(widget, time, elapsed + 30)
end, 30)
end
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.min(elapsed/time, 1))
if elapsed < time then
removeEvent(widget.fadeEvent)
widget.fadeEvent = scheduleEvent(function()
Effects.fadeIn(widget, time, elapsed + 30)
end, 30)
else
widget.fadeEvent = nil
end
end
function Effects.fadeOut(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.max((time - elapsed)/time, 0))
if elapsed < time then
scheduleEvent(function()
Effects.fadeOut(widget, time, elapsed + 30)
end, 30)
else
widget:destroy()
end
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.max((time - elapsed)/time, 0))
if elapsed < time then
removeEvent(widget.fadeEvent)
widget.fadeEvent = scheduleEvent(function()
Effects.fadeOut(widget, time, elapsed + 30)
end, 30)
else
widget.fadeEvent = nil
widget:destroy()
end
end
function Effects.cancelFade(widget)
removeEvent(widget.fadeEvent)
end

@ -5,6 +5,7 @@ Module
website: https://github.com/edubart/otclient
autoload: true
autoload-priority: 20
reloadable: false
@onLoad: |
importFont 'fonts/verdana-11px-antialised'

@ -3,7 +3,6 @@ Module
description: Create the game interface, where the ingame stuff starts
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependencies:
- game_tibiafiles
@ -14,8 +13,8 @@ Module
- game_textmessage
- game_console
- game_outfit
//- game_healthbar
//- game_inventory
- game_healthbar
- game_inventory
//- game_combatcontrols
//- game_skills
//- game_viplist
@ -30,9 +29,13 @@ Module
dofile 'const'
dofile 'widgets/uigamemap'
dofile 'widgets/uiitem'
dofile 'gameinterface'
dofile 'creature'
dofile 'player'
dofile 'gameinterface'
GameInterface.init()
@onUnload: |

@ -105,7 +105,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
if useThing then
if useThing:isContainer() then
if useThing:isInsideContainer() then
if useThing:getParentContainer() then
menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
else
@ -220,7 +220,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
return true
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
if useThing:isContainer() then
if useThing:isInsideContainer() then
if useThing:getParentContainer() then
g_game.open(useThing, useThing:getContainerId())
return true
else
@ -245,7 +245,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
g_game.attack(multiUseThing:asCreature())
return true
elseif multiUseThing:isContainer() then
if multiUseThing:isInsideContainer() then
if multiUseThing:getParentContainer() then
g_game.open(multiUseThing, multiUseThing:getContainerId())
return true
else

@ -33,8 +33,8 @@ UIWidget
margin-bottom: 172
height: 4
margin-top: -2
background: red
@canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 100), self:getParent():getHeight() - 300) end
@onGeometryChange: function(self) self:setMarginBottom(math.min(self:getParent():getHeight() - 300, self:getMarginBottom())) end
GameBottomPanel
id: gameBottomPanel
@ -50,6 +50,7 @@ UIWidget
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
focusable: false
GameSidePanel
id: gameLeftPanel
@ -58,6 +59,7 @@ UIWidget
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
focusable: false
UIWidget
id: mouseGrabber

@ -18,3 +18,6 @@ MiniWindow < UIMiniWindow
$on:
height: 24
image-border-bottom: 1
BorderlessGameWindow < UIWindow
focusable: false

@ -73,6 +73,6 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
local item = self:getItem()
if not item or not self:containsPoint(mousePosition) then return false end
return g_game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
return GameInterface.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
end

@ -155,7 +155,7 @@ function Console.init()
onChannelList = onChannelList,
onOpenChannel = onOpenChannel,
onOpenPrivateChannel = onOpenPrivateChannel,
onGameEnd = Console.clean })
onGameEnd = Console.clear })
consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
@ -188,7 +188,7 @@ function Console.terminate()
onChannelList = onChannelList,
onOpenChannel = onOpenChannel,
onOpenPrivateChannel = onOpenPrivateChannel,
onGameEnd = Console.clean })
onGameEnd = Console.clear })
for channelid, channelname in pairs(channels) do
if channelid ~= 0 then
@ -218,7 +218,7 @@ function Console.debug()
print(#channels)
end
function Console.clean()
function Console.clear()
for channelid, channelname in pairs(channels) do
if channelid ~= 0 then
local tab = consoleTabBar:getTab(channelname)
@ -229,6 +229,7 @@ function Console.clean()
consoleTabBar:getTab('Default').tabPanel:destroyChildren()
consoleTabBar:getTab('Server Log').tabPanel:destroyChildren()
consoleLineEdit:clearText()
if channelsWindow then
channelsWindow:destroy()

@ -3,7 +3,6 @@ Module
description: Manage chat window
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependecies:
- game

@ -8,17 +8,29 @@ local healthLabel
local manaLabel
-- public functions
function HealthBar.create()
function HealthBar.init()
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
healthBarButton:setOn(true)
healthBar = healthBarWindow:getChildById('healthBar')
manaBar = healthBarWindow:getChildById('manaBar')
healthLabel = healthBarWindow:getChildById('healthLabel')
manaLabel = healthBarWindow:getChildById('manaLabel')
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
HealthBar.onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
HealthBar.onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
end
end
function HealthBar.destroy()
function HealthBar.terminate()
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow:destroy()
healthBarWindow = nil
healthBarButton:destroy()
@ -53,7 +65,3 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
manaBar:setPercent(percent)
end
connect(g_game, { onGameStart = HealthBar.create,
onGameEnd = HealthBar.destroy })
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })

@ -4,5 +4,12 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
- game
@onLoad: |
dofile 'healthbar'
HealthBar.init()
@onUnload: |
HealthBar.terminate()

@ -32,7 +32,7 @@ ManaLabel < GameLabel
margin-top: 2
text: 0 / 0
UIWindow
BorderlessGameWindow
id: healthManaPanel
width: 192
height: 34

@ -1,199 +0,0 @@
GameInterface = {}
-- private variables
local WALK_AUTO_REPEAT_DELAY = 90
local gameRootPanel
local gameMapPanel
local gameRightPanel
local gameLeftPanel
local gameBottomPanel
-- private functions
function onGameStart()
-- hook window close event
setonclose(GameInterface.tryLogout)
GameInterface.show()
end
function onGameEnd()
setonclose(exit)
GameInterface.hide()
end
-- public functions
function GameInterface.init()
gameRootPanel = displayUI('gameinterface.otui')
gameRootPanel:lower()
connect(g_game, { onGameStart = onGameStart }, true)
connect(g_game, { onGameEnd = onGameEnd })
Keyboard.bindKeyPress('Up', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Right', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Down', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Left', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
Keyboard.bindKeyPress('Esc', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
end
function GameInterface.terminate()
disconnect(g_game, { onGameStart = onGameStart }, true)
disconnect(g_game, { onGameEnd = onGameEnd })
end
function GameInterface.show()
gameRootPanel:show()
end
function GameInterface.hide()
gameRootPanel:hide()
end
function GameInterface.tryLogout()
if g_game.isOnline() then
g_game.forceLogout()
else
exit()
end
end
function GameInterface.getRootPanel()
return gameRootPanel
end
function GameInterface.getMapPanel()
return gameMapPanel
end
function GameInterface.getRightPanel()
return gameRightPanel
end
function GameInterface.getLeftPanel()
return gameLeftPanel
end
function GameInterface.getBottomPanel()
return gameBottomPanel
end
function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
local menu = createWidget('PopupMenu')
if lookThing then
menu:addOption('Look', function() g_game.look(lookThing) end)
end
if useThing then
if useThing:isContainer() then
if useThing:isInsideContainer() then
menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
else
menu:addOption('Open', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
end
else
if useThing:isMultiUse() then
menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
else
menu:addOption('Use', function() g_game.use(useThing) end)
end
end
if useThing:isRotateable() then
menu:addOption('Rotate', function() g_game.rotate(useThing) end)
end
end
if lookThing and not lookThing:asCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
menu:addSeparator()
menu:addOption('Trade with ...', function() print('trade with') end)
end
-- check for move up
if creatureThing then
menu:addSeparator()
if creatureThing:asLocalPlayer() then
menu:addOption('Set Outfit', function() g_game.requestOutfit() end)
if creatureThing:asPlayer():isPartyMember() --[[and not fighting]] then
if creatureThing:asPlayer():isPartyLeader() then
if creatureThing:asPlayer():isPartySharedExperienceActive() then
menu:addOption('Disable Shared Experience', function() g_game.partyShareExperience(false) end)
else
menu:addOption('Enable Shared Experience', function() g_game.partyShareExperience(true) end)
end
end
menu:addOption('Leave Party', function() g_game.partyLeave() end)
end
else
local localPlayer = g_game.getLocalPlayer()
if localPlayer then
if g_game.getAttackingCreature() ~= creatureThing then
menu:addOption('Attack', function() g_game.attack(creatureThing) end)
else
menu:addOption('Stop Attack', function() g_game.cancelAttack() end)
end
if g_game.getFollowingCreature() ~= creatureThing then
menu:addOption('Follow', function() g_game.follow(creatureThing) end)
else
menu:addOption('Stop Follow', function() g_game.cancelFollow() end)
end
if creatureThing:asPlayer() then
menu:addSeparator()
menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
menu:addOption('Add to VIP list', function() g_game.addVip(creatureThing:getName()) end)
local localPlayerShield = localPlayer:asCreature():getShield()
local creatureShield = creatureThing:getShield()
if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
if creatureShield == ShieldWhiteYellow then
menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() g_game.partyJoin(creatureThing:getId()) end)
else
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldWhiteYellow then
if creatureShield == ShieldWhiteBlue then
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
if creatureShield == ShieldWhiteBlue then
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
menu:addOption('Pass Leadership to ' .. creatureThing:getName(), function() g_game.partyPassLeadership(creatureThing:getId()) end)
else
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
end
end
end
end
end
menu:addSeparator()
menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end)
end
menu:display(menuPosition)
end

@ -1,20 +0,0 @@
Module
name: game_interface
description: |
Create the game main interface (map and bottom/left/right panels),
any game module must use it to add ingame interfaces
author: OTClient team
website: https://github.com/edubart/otclient
@onLoad: |
dofile 'uiminiwindow'
dofile 'uiminiwindowcontainer'
dofile 'uiitem'
dofile 'uimap'
dofile 'gameinterface'
GameInterface.init()
@onUnload: |
GameInterface.terminate()

@ -1,46 +0,0 @@
GameSidePanel < UIMiniWindowContainer
image-source: images/sidepanel.png
image-border: 4
GameBottomPanel < Panel
image-source: images/bottompanel.png
image-border: 4
GameMapPanel < UIMap
padding: 4
image-source: images/mappanel.png
image-border: 4
UIGame
id: gameRootPanel
anchors.fill: parent
anchors.top: topMenu.bottom
GameSidePanel
id: gameRightPanel
width: 190
layout: verticalBox
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
GameBottomPanel
id: gameBottomPanel
height: 170
anchors.left: parent.left
anchors.right: gameRightPanel.left
anchors.bottom: parent.bottom
GameMapPanel
id: gameMapPanel
anchors.left: parent.left
anchors.right: gameRightPanel.left
anchors.top: parent.top
anchors.bottom: gameBottomPanel.top
focusable: false
UIWidget
id: mouseGrabber
focusable: false
visible: false

@ -1,56 +0,0 @@
function UIMap:onDragEnter(mousePos)
local tile = self:getTile(mousePos)
if not tile then return false end
local thing = tile:getTopMoveThing()
if not thing then return false end
self.parsed = false
self.currentDragThing = thing
Mouse.setTargetCursor()
return true
end
function UIMap:onDragLeave(droppedWidget, mousePos)
if not self.parsed then
self.currentDragThing = nil
end
Mouse.restoreCursor()
return true
end
function UIMap:onDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end
local tile = self:getTile(mousePos)
if not tile then return false end
local count = widget.currentDragThing:getCount()
if widget.currentDragThing:isStackable() and count > 1 then
widget.parsed = true
local moveWindow = displayUI('/game/movewindow.otui')
local spinbox = moveWindow:getChildById('spinbox')
spinbox:setMaximum(count)
spinbox:setMinimum(1)
spinbox:setCurrentIndex(count)
local okButton = moveWindow:getChildById('buttonOk')
okButton.onClick = function()
g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex())
okButton:getParent():destroy()
widget.currentDragThing = nil
end
moveWindow.onEnter = okButton.onClick
else
g_game.move(widget.currentDragThing, tile:getPosition(), 1)
end
return true
end
function UIMap:onMouseRelease(mousePosition, mouseButton)
local tile = self:getTile(mousePosition)
if tile and g_game.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
return false
end

@ -5,15 +5,31 @@ local inventoryWindow
local inventoryButton
-- public functions
function Inventory.create()
function Inventory.init()
connect(g_game, { onGameEnd = Inventory.clear,
onInventoryChange = Inventory.onInventoryChange,
onFreeCapacityChange = Inventory.onFreeCapacityChange,
onSoulChange = Inventory.onSoulChange })
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
inventoryWindow = displayUI('inventory.otui', GameInterface.getRightPanel())
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
inventoryButton = TopMenu.addGameToggleButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
inventoryButton:setOn(true)
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
if g_game.isOnline() then
Inventory.reload()
end
end
function Inventory.destroy()
function Inventory.terminate()
connect(g_game, { onGameEnd = Inventory.clear,
onInventoryChange = Inventory.onInventoryChange,
onFreeCapacityChange = Inventory.onFreeCapacityChange,
onSoulChange = Inventory.onSoulChange })
Keyboard.unbindKeyDown('Ctrl+I')
inventoryWindow:destroy()
inventoryWindow = nil
inventoryButton:destroy()
@ -26,6 +42,12 @@ function Inventory.toggle()
inventoryButton:setOn(visible)
end
function Inventory.clear()
end
function Inventory.reload()
end
-- hooked events
function Inventory.onInventoryChange(slot, item)
local itemWidget = inventoryWindow:getChildById('slot' .. slot)
@ -41,10 +63,3 @@ function Inventory.onSoulChange(soul)
local widget = inventoryWindow:getChildById('soul')
widget:setText("Soul:\n" .. soul)
end
connect(g_game, { onGameStart = Inventory.create,
onGameEnd = Inventory.destroy,
onInventoryChange = Inventory.onInventoryChange,
onFreeCapacityChange = Inventory.onFreeCapacityChange,
onSoulChange = Inventory.onSoulChange })

@ -4,5 +4,13 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
- game
@onLoad: |
dofile 'inventory'
Inventory.init()
@onUnload: |
Inventory.terminate()

@ -1,4 +1,5 @@
UIWindow
BorderlessGameWindow
id: inventoryWindow
width: 192
height: 154
margin-top: 10
@ -93,9 +94,7 @@ UIWindow
anchors.left: slot9.left
anchors.right: slot9.right
margin-top: 5
text-align: center
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
@ -106,9 +105,7 @@ UIWindow
anchors.left: slot10.left
anchors.right: slot10.right
margin-top: 5
text-align: center
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1

@ -3,7 +3,6 @@ Module
description: Change local player outfit
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
@onLoad: |
dofile 'outfit'

@ -41,14 +41,14 @@ local function setSkillPercent(id, percent, tooltip)
end
-- public functions
function Skills.create()
function Skills.init()
skillsWindow = displayUI('skills.otui', GameInterface.getRightPanel())
skillsWindow:hide()
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
end
function Skills.destroy()
function Skills.terminate()
Keyboard.unbindKeyDown('Ctrl+S')
skillsButton:destroy()
skillsButton = nil

@ -6,3 +6,7 @@ Module
@onLoad: |
dofile 'skills'
Skills.init()
@onUnload: |
Skills.terminate()

@ -3,7 +3,6 @@ Module
description: Manage game text messages
author: OTClient team
website: https://github.com/edubart/otclient
reloadable: true
dependecies:
- game

@ -1,6 +1,7 @@
Module
name: game_tibiafiles
description: Contains tibia spr and dat
reloadable: false
@onLoad: |
if not g_thingsType.load('/game_tibiafiles/Tibia.dat') then

@ -108,7 +108,7 @@ void Module::discover(const OTMLNodePtr& moduleNode)
m_website = moduleNode->valueAt("website", none);
m_version = moduleNode->valueAt("version", none);
m_autoLoad = moduleNode->valueAt<bool>("autoload", false);
m_reloadable = moduleNode->valueAt<bool>("reloadable", false);
m_reloadable = moduleNode->valueAt<bool>("reloadable", true);
m_autoLoadPriority = moduleNode->valueAt<int>("autoload-priority", 9999);
if(OTMLNodePtr node = moduleNode->get("dependencies")) {

@ -25,7 +25,9 @@
#include "declarations.h"
class Container
#include <framework/luascript/luaobject.h>
class Container : public LuaObject
{
public:
Container();

@ -31,10 +31,6 @@ public:
Player() { }
virtual ~Player() { }
bool isPartyMember() { return (m_shield != 0); }
bool isPartyLeader() { return (m_shield & Otc::ShieldYellow); }
bool isPartySharedExperienceActive() { return false; }
PlayerPtr asPlayer() { return std::static_pointer_cast<Player>(shared_from_this()); }
};

@ -25,6 +25,7 @@
#include <otclient/luascript/luavaluecasts.h>
#include <otclient/core/game.h>
#include <otclient/core/tile.h>
#include <otclient/core/container.h>
#include <otclient/core/item.h>
#include <otclient/core/effect.h>
#include <otclient/core/missile.h>
@ -161,6 +162,8 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<ProtocolGame, Protocol>();
g_lua.registerClass<Container>();
g_lua.registerClass<Thing>();
g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
g_lua.bindClassMemberFunction<Thing>("setPosition", &Thing::setPosition);
@ -192,6 +195,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassMemberFunction<Thing>("isHookSouth", &Thing::isHookSouth);
g_lua.bindClassMemberFunction<Thing>("isTranslucent", &Thing::isTranslucent);
g_lua.bindClassMemberFunction<Thing>("isFullGround", &Thing::isFullGround);
g_lua.bindClassMemberFunction<Thing>("getParentContainer", &Thing::getParentContainer);
g_lua.registerClass<Creature, Thing>();
g_lua.bindClassMemberFunction<Creature>("getId", &Creature::getId);
@ -221,9 +225,6 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<AnimatedText, Thing>();
g_lua.registerClass<Player, Creature>();
g_lua.bindClassMemberFunction<Player>("isPartyMember", &LocalPlayer::isPartyMember);
g_lua.bindClassMemberFunction<Player>("isPartyLeader", &LocalPlayer::isPartyLeader);
g_lua.bindClassMemberFunction<Player>("isPartySharedExperienceActive", &LocalPlayer::isPartySharedExperienceActive);
g_lua.registerClass<Npc, Creature>();
g_lua.registerClass<Monster, Creature>();

読み込み中…
キャンセル
保存