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 years ago
parent b301aa1a2b
commit 239f58296e

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -73,6 +73,6 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
local item = self:getItem() local item = self:getItem()
if not item or not self:containsPoint(mousePosition) then return false end 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 end

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

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

@ -8,17 +8,29 @@ local healthLabel
local manaLabel local manaLabel
-- public functions -- public functions
function HealthBar.create() function HealthBar.init()
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel()) 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) healthBarButton:setOn(true)
healthBar = healthBarWindow:getChildById('healthBar') healthBar = healthBarWindow:getChildById('healthBar')
manaBar = healthBarWindow:getChildById('manaBar') manaBar = healthBarWindow:getChildById('manaBar')
healthLabel = healthBarWindow:getChildById('healthLabel') healthLabel = healthBarWindow:getChildById('healthLabel')
manaLabel = healthBarWindow:getChildById('manaLabel') 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 end
function HealthBar.destroy() function HealthBar.terminate()
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow:destroy() healthBarWindow:destroy()
healthBarWindow = nil healthBarWindow = nil
healthBarButton:destroy() healthBarButton:destroy()
@ -53,7 +65,3 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
manaBar:setPercent(percent) manaBar:setPercent(percent)
end 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 author: OTClient team
website: https://github.com/edubart/otclient website: https://github.com/edubart/otclient
dependecies:
- game
@onLoad: | @onLoad: |
dofile 'healthbar' dofile 'healthbar'
HealthBar.init()
@onUnload: |
HealthBar.terminate()

@ -32,7 +32,7 @@ ManaLabel < GameLabel
margin-top: 2 margin-top: 2
text: 0 / 0 text: 0 / 0
UIWindow BorderlessGameWindow
id: healthManaPanel id: healthManaPanel
width: 192 width: 192
height: 34 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 local inventoryButton
-- public functions -- 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()) 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) inventoryButton:setOn(true)
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
if g_game.isOnline() then
Inventory.reload()
end
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') Keyboard.unbindKeyDown('Ctrl+I')
inventoryWindow:destroy() inventoryWindow:destroy()
inventoryWindow = nil inventoryWindow = nil
inventoryButton:destroy() inventoryButton:destroy()
@ -26,6 +42,12 @@ function Inventory.toggle()
inventoryButton:setOn(visible) inventoryButton:setOn(visible)
end end
function Inventory.clear()
end
function Inventory.reload()
end
-- hooked events -- hooked events
function Inventory.onInventoryChange(slot, item) function Inventory.onInventoryChange(slot, item)
local itemWidget = inventoryWindow:getChildById('slot' .. slot) local itemWidget = inventoryWindow:getChildById('slot' .. slot)
@ -41,10 +63,3 @@ function Inventory.onSoulChange(soul)
local widget = inventoryWindow:getChildById('soul') local widget = inventoryWindow:getChildById('soul')
widget:setText("Soul:\n" .. soul) widget:setText("Soul:\n" .. soul)
end 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 author: OTClient team
website: https://github.com/edubart/otclient website: https://github.com/edubart/otclient
dependecies:
- game
@onLoad: | @onLoad: |
dofile 'inventory' dofile 'inventory'
Inventory.init()
@onUnload: |
Inventory.terminate()

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

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

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

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

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

@ -1,6 +1,7 @@
Module Module
name: game_tibiafiles name: game_tibiafiles
description: Contains tibia spr and dat description: Contains tibia spr and dat
reloadable: false
@onLoad: | @onLoad: |
if not g_thingsType.load('/game_tibiafiles/Tibia.dat') then 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_website = moduleNode->valueAt("website", none);
m_version = moduleNode->valueAt("version", none); m_version = moduleNode->valueAt("version", none);
m_autoLoad = moduleNode->valueAt<bool>("autoload", false); 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); m_autoLoadPriority = moduleNode->valueAt<int>("autoload-priority", 9999);
if(OTMLNodePtr node = moduleNode->get("dependencies")) { if(OTMLNodePtr node = moduleNode->get("dependencies")) {

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

@ -31,10 +31,6 @@ public:
Player() { } Player() { }
virtual ~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()); } PlayerPtr asPlayer() { return std::static_pointer_cast<Player>(shared_from_this()); }
}; };

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

Loading…
Cancel
Save