mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
reaname and cleanup many stuff
This commit is contained in:
@@ -28,8 +28,8 @@ local function tryLogin(charInfo, tries)
|
||||
return
|
||||
end
|
||||
|
||||
if Game.isOnline() then
|
||||
Game.safeLogout()
|
||||
if g_game.isOnline() then
|
||||
g_game.safeLogout()
|
||||
if tries == 1 then
|
||||
loadBox = displayCancelBox('Please wait', 'Loggin out...')
|
||||
end
|
||||
@@ -39,12 +39,12 @@ local function tryLogin(charInfo, tries)
|
||||
|
||||
CharacterList.destroyLoadBox()
|
||||
|
||||
Game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
g_game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
|
||||
loadBox = displayCancelBox('Please wait', 'Connecting to game server...')
|
||||
connect(loadBox, { onCancel = function()
|
||||
loadBox = nil
|
||||
Game.cancelLogin()
|
||||
g_game.cancelLogin()
|
||||
CharacterList.show()
|
||||
end })
|
||||
|
||||
@@ -110,7 +110,7 @@ end
|
||||
|
||||
function CharacterList.destroy()
|
||||
CharacterList.hide()
|
||||
if not Game.isOnline() then
|
||||
if not g_game.isOnline() then
|
||||
EnterGame.show()
|
||||
end
|
||||
end
|
||||
|
@@ -110,7 +110,7 @@ function EnterGame.hide()
|
||||
end
|
||||
|
||||
function EnterGame.openWindow()
|
||||
if Game.isOnline() then
|
||||
if g_game.isOnline() then
|
||||
CharacterList.show()
|
||||
elseif not CharacterList.isVisible() then
|
||||
EnterGame.show()
|
||||
|
@@ -8,8 +8,8 @@ local gameButtonsPanel
|
||||
|
||||
-- private functions
|
||||
local function onLogout()
|
||||
if Game.isOnline() then
|
||||
Game.safeLogout()
|
||||
if g_game.isOnline() then
|
||||
g_game.safeLogout()
|
||||
else
|
||||
exit()
|
||||
end
|
||||
@@ -25,7 +25,7 @@ function TopMenu.init()
|
||||
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
|
||||
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
|
||||
|
||||
connect(Game, { onGameStart = TopMenu.showGameButtons,
|
||||
connect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ function TopMenu.terminate()
|
||||
topMenu:destroy()
|
||||
topMenu = nil
|
||||
|
||||
disconnect(Game, { onGameStart = TopMenu.showGameButtons,
|
||||
disconnect(g_game, { onGameStart = TopMenu.showGameButtons,
|
||||
onGameEnd = TopMenu.hideGameButtons })
|
||||
|
||||
TopMenu = nil
|
||||
|
@@ -40,10 +40,10 @@ function UIItem:onDrop(widget, mousePos)
|
||||
spinbox:setCurrentIndex(count)
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function() Game.move(widget.currentDragThing, pos, spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
okButton.onClick = function() g_game.move(widget.currentDragThing, pos, spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
else
|
||||
Game.move(widget.currentDragThing, pos, 1)
|
||||
g_game.move(widget.currentDragThing, pos, 1)
|
||||
end
|
||||
|
||||
self:setBorderWidth(0)
|
||||
@@ -70,6 +70,6 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||
|
||||
local item = self:getItem()
|
||||
if not item or not self:containsPoint(mousePosition) then return false end
|
||||
return Game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
|
||||
return g_game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
|
||||
end
|
||||
|
||||
|
@@ -8,7 +8,7 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers)
|
||||
CharacterList.show()
|
||||
return true
|
||||
elseif keyCode == KeyQ then
|
||||
Game.safeLogout()
|
||||
g_game.safeLogout()
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -16,97 +16,97 @@ local function onGameKeyPress(self, keyCode, keyboardModifiers)
|
||||
end
|
||||
|
||||
local function onUseWithMouseRelease(self, mousePosition, mouseButton)
|
||||
if Game.selectedThing == nil then return false end
|
||||
if g_game.selectedThing == nil then return false end
|
||||
if mouseButton == MouseLeftButton then
|
||||
local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
if clickedWidget then
|
||||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
Game.useWith(Game.selectedThing, tile:getTopMultiUseThing())
|
||||
g_game.useWith(g_game.selectedThing, tile:getTopMultiUseThing())
|
||||
end
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
Game.useWith(Game.selectedThing, clickedWidget:getItem())
|
||||
g_game.useWith(g_game.selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
end
|
||||
end
|
||||
Game.selectedThing = nil
|
||||
g_game.selectedThing = nil
|
||||
Mouse.restoreCursor()
|
||||
self:ungrabMouse()
|
||||
return true
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Game.startUseWith(thing)
|
||||
Game.selectedThing = thing
|
||||
function g_game.startUseWith(thing)
|
||||
g_game.selectedThing = thing
|
||||
m_mouseGrabberWidget:grabMouse()
|
||||
Mouse.setTargetCursor()
|
||||
end
|
||||
|
||||
function Game.createInterface()
|
||||
function g_game.createInterface()
|
||||
Background.hide()
|
||||
CharacterList.destroyLoadBox()
|
||||
Game.gameUi = displayUI('game.otui')
|
||||
g_game.gameUi = displayUI('game.otui')
|
||||
|
||||
--Keyboard.bindKeyPress('Up', function() Game.walk(North) end)
|
||||
--Keyboard.bindKeyPress('Down', function() Game.walk(South) end)
|
||||
--Keyboard.bindKeyPress('Left', function() Game.walk(West) end)
|
||||
--Keyboard.bindKeyPress('Right', function() Game.walk(East) end)
|
||||
--Keyboard.bindKeyPress('Up', function() g_game.walk(North) end)
|
||||
--Keyboard.bindKeyPress('Down', function() g_game.walk(South) end)
|
||||
--Keyboard.bindKeyPress('Left', function() g_game.walk(West) end)
|
||||
--Keyboard.bindKeyPress('Right', function() g_game.walk(East) end)
|
||||
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Up', function() Game.forceWalk(North) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Down', function() Game.forceWalk(South) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Left', function() Game.forceWalk(West) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Right', function() Game.forceWalk(East) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Up', function() g_game.forceWalk(North) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Down', function() g_game.forceWalk(South) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Left', function() g_game.forceWalk(West) end)
|
||||
Keyboard.bindKeyPress('Ctrl+Shift+Right', function() g_game.forceWalk(East) end)
|
||||
|
||||
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
||||
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
|
||||
Game.gameRightPanel = Game.gameUi:getChildById('gameRightPanel')
|
||||
Game.gameBottomPanel = Game.gameUi:getChildById('gameBottomPanel')
|
||||
m_mouseGrabberWidget = Game.gameUi:getChildById('mouseGrabber')
|
||||
connect(Game.gameUi, { onKeyPress = onGameKeyPress })
|
||||
rootWidget:moveChildToIndex(g_game.gameUi, 1)
|
||||
g_game.gameMapPanel = g_game.gameUi:getChildById('gameMapPanel')
|
||||
g_game.gameRightPanel = g_game.gameUi:getChildById('gameRightPanel')
|
||||
g_game.gameBottomPanel = g_game.gameUi:getChildById('gameBottomPanel')
|
||||
m_mouseGrabberWidget = g_game.gameUi:getChildById('mouseGrabber')
|
||||
connect(g_game.gameUi, { onKeyPress = onGameKeyPress })
|
||||
connect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
|
||||
end
|
||||
|
||||
function Game.destroyInterface()
|
||||
if Game.gameUi then
|
||||
Game.gameUi:destroy()
|
||||
Game.gameUi = nil
|
||||
function g_game.destroyInterface()
|
||||
if g_game.gameUi then
|
||||
g_game.gameUi:destroy()
|
||||
g_game.gameUi = nil
|
||||
end
|
||||
Background.show()
|
||||
CharacterList.show()
|
||||
end
|
||||
|
||||
function Game.show()
|
||||
Game.gameUi:show()
|
||||
Game.gameUi:focus()
|
||||
Game.gameMapPanel:focus()
|
||||
function g_game.show()
|
||||
g_game.gameUi:show()
|
||||
g_game.gameUi:focus()
|
||||
g_game.gameMapPanel:focus()
|
||||
end
|
||||
|
||||
function Game.hide()
|
||||
Game.gameUi:hide()
|
||||
function g_game.hide()
|
||||
g_game.gameUi:hide()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onLoginError(message)
|
||||
function g_game.onLoginError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
|
||||
connect(errorBox, { onOk = CharacterList.show })
|
||||
end
|
||||
|
||||
function Game.onConnectionError(message)
|
||||
function g_game.onConnectionError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
|
||||
connect(errorBox, { onOk = CharacterList.show })
|
||||
end
|
||||
|
||||
local function onApplicationClose()
|
||||
if Game.isOnline() then
|
||||
Game.forceLogout()
|
||||
if g_game.isOnline() then
|
||||
g_game.forceLogout()
|
||||
else
|
||||
exit()
|
||||
end
|
||||
end
|
||||
|
||||
setonclose(onApplicationClose)
|
||||
connect(Game, { onGameStart = Game.createInterface }, true)
|
||||
connect(Game, { onGameEnd = Game.destroyInterface })
|
||||
connect(g_game, { onGameStart = g_game.createInterface }, true)
|
||||
connect(g_game, { onGameEnd = g_game.destroyInterface })
|
||||
|
@@ -36,10 +36,10 @@ function UIMap:onDrop(widget, mousePos)
|
||||
spinbox:setCurrentIndex(count)
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function() Game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
okButton.onClick = function() g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
else
|
||||
Game.move(widget.currentDragThing, tile:getPosition(), 1)
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), 1)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -47,7 +47,7 @@ end
|
||||
|
||||
function UIMap:onMouseRelease(mousePosition, mouseButton)
|
||||
local tile = self:getTile(mousePosition)
|
||||
if tile and Game.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
|
||||
if tile and g_game.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
|
@@ -11,7 +11,7 @@ function Thing:getContainerId()
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
function g_game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
local keyboardModifiers = g_window.getKeyboardModifiers()
|
||||
|
||||
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
@@ -21,60 +21,60 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
|
||||
|
||||
if not Options.classicControl then
|
||||
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.look(lookThing)
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
if useThing:isContainer() then
|
||||
if useThing:isInsideContainer() then
|
||||
Game.open(useThing, useThing:getContainerId())
|
||||
g_game.open(useThing, useThing:getContainerId())
|
||||
return true
|
||||
else
|
||||
Game.open(useThing, Containers.getFreeContainerId())
|
||||
g_game.open(useThing, Containers.getFreeContainerId())
|
||||
return true
|
||||
end
|
||||
elseif useThing:isMultiUse() then
|
||||
Game.startUseWith(useThing)
|
||||
g_game.startUseWith(useThing)
|
||||
return true
|
||||
else
|
||||
Game.use(useThing)
|
||||
g_game.use(useThing)
|
||||
return true
|
||||
end
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.attack(creatureThing)
|
||||
g_game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
else
|
||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
if multiUseThing:asCreature() then
|
||||
Game.attack(multiUseThing:asCreature())
|
||||
g_game.attack(multiUseThing:asCreature())
|
||||
return true
|
||||
elseif multiUseThing:isContainer() then
|
||||
if multiUseThing:isInsideContainer() then
|
||||
Game.open(multiUseThing, multiUseThing:getContainerId())
|
||||
g_game.open(multiUseThing, multiUseThing:getContainerId())
|
||||
return true
|
||||
else
|
||||
Game.open(multiUseThing, Containers.getFreeContainerId())
|
||||
g_game.open(multiUseThing, Containers.getFreeContainerId())
|
||||
return true
|
||||
end
|
||||
elseif multiUseThing:isMultiUse() then
|
||||
Game.startUseWith(multiUseThing)
|
||||
g_game.startUseWith(multiUseThing)
|
||||
return true
|
||||
else
|
||||
Game.use(multiUseThing)
|
||||
g_game.use(multiUseThing)
|
||||
end
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.look(lookThing)
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.attack(creatureThing)
|
||||
g_game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -83,31 +83,31 @@ function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing,
|
||||
end
|
||||
|
||||
|
||||
function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
function g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
local menu = createWidget('PopupMenu')
|
||||
|
||||
if lookThing then
|
||||
menu:addOption('Look', function() Game.look(lookThing) end)
|
||||
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() Game.open(useThing, useThing:getContainerId()) end)
|
||||
menu:addOption('Open in new window', function() Game.open(useThing, Containers.getFreeContainerId()) 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)
|
||||
else
|
||||
menu:addOption('Open', function() Game.open(useThing, Containers.getFreeContainerId()) end)
|
||||
menu:addOption('Open', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
|
||||
end
|
||||
else
|
||||
if useThing:isMultiUse() then
|
||||
menu:addOption('Use with ...', function() Game.startUseWith(useThing) end)
|
||||
menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
|
||||
else
|
||||
menu:addOption('Use', function() Game.use(useThing) end)
|
||||
menu:addOption('Use', function() g_game.use(useThing) end)
|
||||
end
|
||||
end
|
||||
|
||||
if useThing:isRotateable() then
|
||||
menu:addOption('Rotate', function() Game.rotate(useThing) end)
|
||||
menu:addOption('Rotate', function() g_game.rotate(useThing) end)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -123,38 +123,38 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
menu:addSeparator()
|
||||
|
||||
if creatureThing:asLocalPlayer() then
|
||||
menu:addOption('Set Outfit', function() Game.requestOutfit() end)
|
||||
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() Game.partyShareExperience(false) end)
|
||||
menu:addOption('Disable Shared Experience', function() g_game.partyShareExperience(false) end)
|
||||
else
|
||||
menu:addOption('Enable Shared Experience', function() Game.partyShareExperience(true) end)
|
||||
menu:addOption('Enable Shared Experience', function() g_game.partyShareExperience(true) end)
|
||||
end
|
||||
end
|
||||
menu:addOption('Leave Party', function() Game.partyLeave() end)
|
||||
menu:addOption('Leave Party', function() g_game.partyLeave() end)
|
||||
end
|
||||
|
||||
else
|
||||
local localPlayer = Game.getLocalPlayer()
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
if localPlayer then
|
||||
if localPlayer:getAttackingCreature() ~= creatureThing then
|
||||
menu:addOption('Attack', function() Game.attack(creatureThing) end)
|
||||
if g_game.getAttackingCreature() ~= creatureThing then
|
||||
menu:addOption('Attack', function() g_game.attack(creatureThing) end)
|
||||
else
|
||||
menu:addOption('Stop Attack', function() Game.cancelAttack() end)
|
||||
menu:addOption('Stop Attack', function() g_game.cancelAttack() end)
|
||||
end
|
||||
|
||||
if localPlayer:getFollowingCreature() ~= creatureThing then
|
||||
menu:addOption('Follow', function() Game.follow(creatureThing) end)
|
||||
if g_game.getFollowingCreature() ~= creatureThing then
|
||||
menu:addOption('Follow', function() g_game.follow(creatureThing) end)
|
||||
else
|
||||
menu:addOption('Stop Follow', function() Game.cancelFollow() end)
|
||||
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() Game.addVip(creatureThing:getName()) end)
|
||||
menu:addOption('Add to VIP list', function() g_game.addVip(creatureThing:getName()) end)
|
||||
menu:addOption('Ignore ' .. creatureThing:getName(), function() print('ignore') end)
|
||||
|
||||
local localPlayerShield = localPlayer:asCreature():getShield()
|
||||
@@ -162,21 +162,21 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
|
||||
if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
|
||||
if creatureShield == ShieldWhiteYellow then
|
||||
menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() Game.partyJoin(creatureThing:getId()) end)
|
||||
menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() g_game.partyJoin(creatureThing:getId()) end)
|
||||
else
|
||||
menu:addOption('Invite to Party', function() Game.partyInvite(creatureThing:getId()) end)
|
||||
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() Game.partyRevokeInvitation(creatureThing:getId()) end)
|
||||
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() Game.partyRevokeInvitation(creatureThing:getId()) end)
|
||||
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() Game.partyPassLeadership(creatureThing:getId()) end)
|
||||
menu:addOption('Pass Leadership to ' .. creatureThing:getName(), function() g_game.partyPassLeadership(creatureThing:getId()) end)
|
||||
else
|
||||
menu:addOption('Invite to Party', function() Game.partyInvite(creatureThing:getId()) end)
|
||||
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -22,8 +22,8 @@ local function onFightModeChange(self, selectedFightButton)
|
||||
else
|
||||
fightMode = FightDefensive
|
||||
end
|
||||
if Game.getFightMode ~= fightMode then
|
||||
Game.setFightMode(fightMode)
|
||||
if g_game.getFightMode ~= fightMode then
|
||||
g_game.setFightMode(fightMode)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,15 +34,15 @@ local function onChaseModeChange(self, checked)
|
||||
else
|
||||
chaseMode = DontChase
|
||||
end
|
||||
if Game.getChaseMode() ~= chaseMode then
|
||||
Game.setChaseMode(chaseMode)
|
||||
if g_game.getChaseMode() ~= chaseMode then
|
||||
g_game.setChaseMode(chaseMode)
|
||||
end
|
||||
end
|
||||
|
||||
local function onSafeFightChange(self, checked)
|
||||
local safeFight = not checked
|
||||
if Game.isSafeFight() ~= safeFight then
|
||||
Game.setSafeFight(not checked)
|
||||
if g_game.isSafeFight() ~= safeFight then
|
||||
g_game.setSafeFight(not checked)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,16 +66,16 @@ function CombatControls.init()
|
||||
connect(fightModeRadioGroup, { onSelectionChange = onFightModeChange })
|
||||
connect(chaseModeButton, { onCheckChange = onChaseModeChange })
|
||||
connect(safeFightButton, { onCheckChange = onSafeFightChange })
|
||||
connect(Game, { onGameStart = CombatControls.online })
|
||||
connect(Game, { onGameEnd = CombatControls.offline })
|
||||
connect(g_game, { onGameStart = CombatControls.online })
|
||||
connect(g_game, { onGameEnd = CombatControls.offline })
|
||||
|
||||
if Game.isOnline() then
|
||||
if g_game.isOnline() then
|
||||
CombatControls.online()
|
||||
end
|
||||
end
|
||||
|
||||
function CombatControls.terminate()
|
||||
if Game.isOnline() then
|
||||
if g_game.isOnline() then
|
||||
CombatControls.offline()
|
||||
end
|
||||
|
||||
@@ -94,17 +94,17 @@ function CombatControls.terminate()
|
||||
combatControlsWindow:destroy()
|
||||
combatControlsWindow = nil
|
||||
|
||||
disconnect(Game, { onGameStart = CombatControls.online })
|
||||
disconnect(Game, { onGameEnd = CombatControls.offline })
|
||||
disconnect(g_game, { onGameStart = CombatControls.online })
|
||||
disconnect(g_game, { onGameEnd = CombatControls.offline })
|
||||
|
||||
CombatControls = nil
|
||||
end
|
||||
|
||||
function CombatControls.online()
|
||||
Game.gameRightPanel:addChild(combatControlsWindow)
|
||||
g_game.gameRightPanel:addChild(combatControlsWindow)
|
||||
combatControlsWindow:setVisible(combatControlsButton:isOn())
|
||||
|
||||
local fightMode = Game.getFightMode()
|
||||
local fightMode = g_game.getFightMode()
|
||||
if fightMode == FightOffensive then
|
||||
fightModeRadioGroup:selectWidget(fightOffensiveBox)
|
||||
elseif fightMode == FightBalanced then
|
||||
@@ -113,15 +113,15 @@ function CombatControls.online()
|
||||
fightModeRadioGroup:selectWidget(fightDefensiveBox)
|
||||
end
|
||||
|
||||
local chaseMode = Game.getChaseMode()
|
||||
local chaseMode = g_game.getChaseMode()
|
||||
chaseModeButton:setChecked(chaseMode == ChaseOpponent)
|
||||
|
||||
local safeFight = Game.isSafeFight()
|
||||
local safeFight = g_game.isSafeFight()
|
||||
safeFightButton:setChecked(not safeFight)
|
||||
end
|
||||
|
||||
function CombatControls.offline()
|
||||
Game.gameRightPanel:removeChild(combatControlsWindow)
|
||||
g_game.gameRightPanel:removeChild(combatControlsWindow)
|
||||
end
|
||||
|
||||
function CombatControls.toggle()
|
||||
|
@@ -78,7 +78,7 @@ end
|
||||
|
||||
-- public functions
|
||||
function Console.create()
|
||||
consolePanel = displayUI('console.otui', { parent = Game.gameBottomPanel } )
|
||||
consolePanel = displayUI('console.otui', { parent = g_game.gameBottomPanel } )
|
||||
consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
|
||||
consoleBuffer = consolePanel:getChildById('consoleBuffer')
|
||||
consoleTabBar = consolePanel:getChildById('consoleTabBar')
|
||||
@@ -100,7 +100,7 @@ function Console.create()
|
||||
connect(consoleTabBar, { onTabChange = Console.onTabChange })
|
||||
|
||||
-- tibia like hotkeys
|
||||
Keyboard.bindKeyDown('Ctrl+O', Game.requestChannels)
|
||||
Keyboard.bindKeyDown('Ctrl+O', g_game.requestChannels)
|
||||
Keyboard.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
|
||||
end
|
||||
|
||||
@@ -139,9 +139,9 @@ function Console.removeCurrentTab()
|
||||
|
||||
-- notificate the server that we are leaving the channel
|
||||
if tab.channelId then
|
||||
Game.leaveChannel(tab.channelId)
|
||||
g_game.leaveChannel(tab.channelId)
|
||||
elseif tab:getText() == "NPCs" then
|
||||
Game.closeNpcChannel()
|
||||
g_game.closeNpcChannel()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -264,7 +264,7 @@ function Console.sendCurrentMessage()
|
||||
speaktypedesc = 'channelYellow'
|
||||
end
|
||||
|
||||
Game.talkChannel(SpeakTypesSettings[speaktypedesc].speakType, tab.channelId, message)
|
||||
g_game.talkChannel(SpeakTypesSettings[speaktypedesc].speakType, tab.channelId, message)
|
||||
return
|
||||
else
|
||||
local isPrivateCommand = false
|
||||
@@ -280,8 +280,8 @@ function Console.sendCurrentMessage()
|
||||
|
||||
|
||||
local speaktype = SpeakTypesSettings[speaktypedesc]
|
||||
local player = Game.getLocalPlayer()
|
||||
Game.talkPrivate(speaktype.speakType, name, message)
|
||||
local player = g_game.getLocalPlayer()
|
||||
g_game.talkPrivate(speaktype.speakType, name, message)
|
||||
|
||||
message = applyMessagePrefixies(player:getName(), player:getLevel(), message)
|
||||
Console.addPrivateText(message, speaktype, name, isPrivateCommand)
|
||||
@@ -316,7 +316,7 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
||||
Console.addText(message, speaktype, channel)
|
||||
else
|
||||
-- server sent a message on a channel that we are not aware of, must leave it
|
||||
Game.leaveChannel(channelId)
|
||||
g_game.leaveChannel(channelId)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -336,11 +336,11 @@ local function doChannelListSubmit(channelsWindow)
|
||||
local channelListPanel = channelsWindow:getChildById('channelList')
|
||||
local openPrivateChannelWith = channelsWindow:getChildById('openPrivateChannelWith'):getText()
|
||||
if openPrivateChannelWith ~= '' then
|
||||
Game.openPrivateChannel(openPrivateChannelWith)
|
||||
g_game.openPrivateChannel(openPrivateChannelWith)
|
||||
else
|
||||
local selectedChannelLabel = channelListPanel:getFocusedChild()
|
||||
if not selectedChannelLabel then return end
|
||||
Game.joinChannel(selectedChannelLabel.channelId)
|
||||
g_game.joinChannel(selectedChannelLabel.channelId)
|
||||
end
|
||||
channelsWindow:destroy()
|
||||
end
|
||||
@@ -365,7 +365,7 @@ local function onChannelList(channelList)
|
||||
end
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = Console.create,
|
||||
connect(g_game, { onGameStart = Console.create,
|
||||
onGameEnd = Console.destroy,
|
||||
onCreatureSpeak = onCreatureSpeak,
|
||||
onChannelList = onChannelList,
|
||||
|
@@ -57,7 +57,7 @@ Panel
|
||||
anchors.top: parent.top
|
||||
margin-right: 5
|
||||
margin-top: 6
|
||||
@onClick: Game.requestChannels()
|
||||
@onClick: g_game.requestChannels()
|
||||
|
||||
Panel
|
||||
id: consoleBuffer
|
||||
|
@@ -18,13 +18,13 @@ function Containers.getFreeContainerId()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Containers.onContainerOpen(containerId, itemId, name, capacity, hasParent, items)
|
||||
function Containers.onOpenContainer(containerId, itemId, name, capacity, hasParent, items)
|
||||
local container = m_containers[containerId]
|
||||
if container then
|
||||
Game.gameRightPanel:removeChild(container)
|
||||
g_game.gameRightPanel:removeChild(container)
|
||||
end
|
||||
|
||||
container = displayUI('container.otui', { parent = Game.gameRightPanel })
|
||||
container = displayUI('container.otui', { parent = g_game.gameRightPanel })
|
||||
name = name:sub(1,1):upper() .. name:sub(2)
|
||||
container:setText(name)
|
||||
|
||||
@@ -57,7 +57,7 @@ end
|
||||
function Containers.onContainerClose(containerId)
|
||||
local container = m_containers[containerId]
|
||||
if container then
|
||||
Game.gameRightPanel:removeChild(container)
|
||||
g_game.gameRightPanel:removeChild(container)
|
||||
end
|
||||
m_containers[containerId] = nil
|
||||
end
|
||||
@@ -128,9 +128,9 @@ function Containers.onContainerRemoveItem(containerId, slot)
|
||||
container.itemCount = container.itemCount - 1
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = Containers.clean,
|
||||
connect(g_game, { onGameStart = Containers.clean,
|
||||
onGameEnd = Containers.clean,
|
||||
onContainerOpen = Containers.onContainerOpen,
|
||||
onOpenContainer = Containers.onOpenContainer,
|
||||
onContainerClose = Containers.onContainerClose,
|
||||
onContainerAddItem = Containers.onContainerAddItem,
|
||||
onContainerUpdateItem = Containers.onContainerUpdateItem,
|
||||
|
@@ -9,7 +9,7 @@ local manaLabel
|
||||
|
||||
-- public functions
|
||||
function HealthBar.create()
|
||||
healthBarWindow = displayUI('healthbar.otui', { parent = Game.gameRightPanel })
|
||||
healthBarWindow = displayUI('healthbar.otui', { parent = g_game.gameRightPanel })
|
||||
healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
|
||||
healthBarButton:setOn(true)
|
||||
healthBar = healthBarWindow:getChildById('healthBar')
|
||||
@@ -53,7 +53,7 @@ function HealthBar.onManaChange(mana, maxMana)
|
||||
manaBar:setPercent(percent)
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = HealthBar.create,
|
||||
connect(g_game, { onGameStart = HealthBar.create,
|
||||
onGameEnd = HealthBar.destroy,
|
||||
onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
|
@@ -35,11 +35,11 @@ local hotkeyColors = {
|
||||
-- public functions
|
||||
function HotkeysManager.init()
|
||||
hotkeysWindow = displayUI('hotkeys_manager.otui')
|
||||
|
||||
|
||||
hotkeysWindow:setVisible(false)
|
||||
hotkeysButton = TopMenu.addButton('hotkeysButton', 'Hotkeys (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
|
||||
Keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
|
||||
|
||||
|
||||
currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
|
||||
currentItemPreview = hotkeysWindow:getChildById('itemPreview')
|
||||
addHotkey = hotkeysWindow:getChildById('addHotkey')
|
||||
@@ -52,52 +52,52 @@ function HotkeysManager.init()
|
||||
useOnSelf = hotkeysWindow:getChildById('useOnSelf')
|
||||
useOnTarget = hotkeysWindow:getChildById('useOnTarget')
|
||||
useWith = hotkeysWindow:getChildById('useWith')
|
||||
|
||||
|
||||
itemWidget = createWidget('UIItem')
|
||||
itemWidget:setVirtual(true)
|
||||
itemWidget:setVisible(false)
|
||||
itemWidget:setFocusable(false)
|
||||
|
||||
itemWidget:setFocusable(false)
|
||||
|
||||
connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) HotkeysManager.checkSelectedHotkey(focusedChild) end } )
|
||||
|
||||
|
||||
hotkeysManagerLoaded = true
|
||||
|
||||
|
||||
HotkeysManager.load()
|
||||
end
|
||||
|
||||
function HotkeysManager.load()
|
||||
local hotkeySettings = Settings.getNode('HotkeysManager')
|
||||
|
||||
|
||||
if hotkeySettings ~= nil then
|
||||
for i, v in pairs(hotkeySettings) do
|
||||
for i, v in pairs(hotkeySettings) do
|
||||
HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.save()
|
||||
local hotkeySettings = {}
|
||||
local hotkeySettings = {}
|
||||
for i = 1, currentHotkeysList:getChildCount() do
|
||||
local child = currentHotkeysList:getChildByIndex(i)
|
||||
table.insert(hotkeySettings, {keyCombo = child.keyCombo,
|
||||
autoSend = child.autoSend,
|
||||
itemId = child.itemId,
|
||||
table.insert(hotkeySettings, {keyCombo = child.keyCombo,
|
||||
autoSend = child.autoSend,
|
||||
itemId = child.itemId,
|
||||
useType = child.useType,
|
||||
value = child.value})
|
||||
value = child.value})
|
||||
end
|
||||
Settings.setNode('HotkeysManager', hotkeySettings)
|
||||
end
|
||||
|
||||
function HotkeysManager.terminate()
|
||||
function HotkeysManager.terminate()
|
||||
hotkeysManagerLoaded = false
|
||||
|
||||
|
||||
Keyboard.unbindKeyDown('Ctrl+K')
|
||||
HotkeysManager.save()
|
||||
|
||||
|
||||
currentHotkeysList = nil
|
||||
hotkeyLabelSelectedOnList = nil
|
||||
currentItemPreview = nil
|
||||
|
||||
|
||||
hotkeyList = {}
|
||||
addHotkey = nil
|
||||
removeHotkey = nil
|
||||
@@ -109,7 +109,7 @@ function HotkeysManager.terminate()
|
||||
useOnSelf = nil
|
||||
useOnTarget = nil
|
||||
useWith = nil
|
||||
|
||||
|
||||
itemWidget:destroy()
|
||||
itemWidget = nil
|
||||
hotkeysWindow:destroy()
|
||||
@@ -127,14 +127,14 @@ function HotkeysManager.toggle()
|
||||
end
|
||||
|
||||
function HotkeysManager.show()
|
||||
if Game.isOnline() then
|
||||
if g_game.isOnline() then
|
||||
hotkeysWindow:grabKeyboard()
|
||||
hotkeysWindow:show()
|
||||
hotkeysWindow:lock()
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.hide()
|
||||
function HotkeysManager.hide()
|
||||
hotkeysWindow:ungrabKeyboard()
|
||||
hotkeysWindow:unlock()
|
||||
hotkeysWindow:hide()
|
||||
@@ -144,13 +144,13 @@ end
|
||||
function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButton)
|
||||
local item = nil
|
||||
if mouseButton == MouseLeftButton then
|
||||
local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
if clickedWidget then
|
||||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
local thing = tile:getTopMoveThing()
|
||||
if thing then
|
||||
if thing then
|
||||
item = thing:asItem()
|
||||
end
|
||||
end
|
||||
@@ -165,9 +165,9 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
|
||||
hotkeyLabelSelectedOnList.itemId = item:getId()
|
||||
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
||||
HotkeysManager.checkSelectedHotkey(hotkeyLabelSelectedOnList)
|
||||
HotkeysManager:show()
|
||||
HotkeysManager:show()
|
||||
end
|
||||
|
||||
|
||||
Mouse.restoreCursor()
|
||||
self:ungrabMouse()
|
||||
self:destroy()
|
||||
@@ -182,23 +182,23 @@ function HotkeysManager.startChooseItem()
|
||||
|
||||
mouseGrabberWidget:grabMouse()
|
||||
Mouse.setTargetCursor()
|
||||
|
||||
|
||||
HotkeysManager:hide()
|
||||
end
|
||||
|
||||
function HotkeysManager.clearObject()
|
||||
hotkeyLabelSelectedOnList.itemId = nil
|
||||
hotkeyLabelSelectedOnList.itemId = nil
|
||||
currentItemPreview:clearItem()
|
||||
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
||||
HotkeysManager.sendAutomatically(false)
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': ')
|
||||
|
||||
|
||||
HotkeysManager.checkSelectedHotkey(hotkeyLabelSelectedOnList)
|
||||
end
|
||||
|
||||
function HotkeysManager.addHotkey()
|
||||
local widget
|
||||
|
||||
|
||||
messageBox = createWidget('MainWindow', hotkeysWindow)
|
||||
messageBox:grabKeyboard()
|
||||
messageBox:setId('assignWindow')
|
||||
@@ -206,13 +206,13 @@ function HotkeysManager.addHotkey()
|
||||
messageBox:setWidth(420)
|
||||
messageBox:setHeight(140)
|
||||
messageBox:setDragable(false)
|
||||
|
||||
|
||||
widget = createWidget('Label', messageBox)
|
||||
widget:setText('Please, press the key you wish to add onto your hotkeys manager')
|
||||
widget:resizeToText()
|
||||
widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
||||
widget:addAnchor(AnchorTop, 'parent', AnchorTop)
|
||||
|
||||
|
||||
widget = createWidget('Label', messageBox)
|
||||
widget:setId('comboPreview')
|
||||
widget:setText('Current hotkey to add: None')
|
||||
@@ -221,18 +221,18 @@ function HotkeysManager.addHotkey()
|
||||
widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
||||
widget:addAnchor(AnchorTop, 'prev', AnchorBottom)
|
||||
widget:setMarginTop(20)
|
||||
|
||||
|
||||
widget = createWidget('Button', messageBox)
|
||||
widget:setId('cancelButton')
|
||||
widget:setText('Cancel')
|
||||
widget:setWidth(64)
|
||||
widget:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
||||
widget:addAnchor(AnchorRight, 'parent', AnchorRight)
|
||||
widget.onClick = function (self)
|
||||
messageBox = nil
|
||||
self:getParent():destroy()
|
||||
widget.onClick = function (self)
|
||||
messageBox = nil
|
||||
self:getParent():destroy()
|
||||
end
|
||||
|
||||
|
||||
widget = createWidget('Button', messageBox)
|
||||
widget:setId('addButton')
|
||||
widget:setText('Add')
|
||||
@@ -241,11 +241,11 @@ function HotkeysManager.addHotkey()
|
||||
widget:addAnchor(AnchorBottom, 'cancelButton', AnchorBottom)
|
||||
widget:addAnchor(AnchorRight, 'cancelButton', AnchorLeft)
|
||||
widget:setMarginRight(10)
|
||||
widget.onClick = function (self)
|
||||
widget.onClick = function (self)
|
||||
messageBox = nil
|
||||
HotkeysManager.addKeyCombo(self:getParent(), self:getParent():getChildById('comboPreview').keyCombo)
|
||||
end
|
||||
|
||||
|
||||
connect(messageBox, { onKeyDown = HotkeysManager.hotkeyCapture }, true)
|
||||
end
|
||||
|
||||
@@ -257,7 +257,7 @@ function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
|
||||
label:setColor(hotkeyColors.text)
|
||||
label:setText(keyCombo..': ')
|
||||
if keySettings then
|
||||
hotkeyLabelSelectedOnList = label
|
||||
hotkeyLabelSelectedOnList = label
|
||||
label.keyCombo = keyCombo
|
||||
HotkeysManager.sendAutomatically(keySettings.autoSend)
|
||||
label.itemId = keySettings.itemId
|
||||
@@ -271,40 +271,40 @@ function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
|
||||
label.useType = HOTKEY_MANAGER_USEONSELF
|
||||
label.value = ''
|
||||
end
|
||||
|
||||
|
||||
HotkeysManager.checkSelectedHotkey(label)
|
||||
|
||||
|
||||
hotkeyList[keyCombo] = label
|
||||
Keyboard.bindKeyPress(keyCombo, function () HotkeysManager.call(keyCombo) end, nil, 350)
|
||||
end
|
||||
|
||||
|
||||
if messageBox then
|
||||
messageBox:destroy()
|
||||
messageBox = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.call(keyCombo)
|
||||
if Game.isOnline() then
|
||||
if g_game.isOnline() then
|
||||
local hotKey = hotkeyList[keyCombo]
|
||||
if hotKey.itemId == nil and hotKey.value ~= '' then
|
||||
if hotKey.autoSend then
|
||||
Game.talk(hotKey.value)
|
||||
g_game.talk(hotKey.value)
|
||||
else
|
||||
Console.setLineEditText(hotKey.value)
|
||||
end
|
||||
elseif hotKey.itemId ~= nil then
|
||||
if hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
||||
Game.useInventoryItemWith(hotKey.itemId, Game.getLocalPlayer())
|
||||
g_game.useInventoryItemWith(hotKey.itemId, g_game.getLocalPlayer())
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USEONTARGET then
|
||||
local attackingCreature = Game.getLocalPlayer():getAttackingCreature()
|
||||
local attackingCreature = g_game.getAttackingCreature()
|
||||
if attackingCreature then
|
||||
Game.useInventoryItemWith(hotKey.itemId, attackingCreature)
|
||||
g_game.useInventoryItemWith(hotKey.itemId, attackingCreature)
|
||||
end
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||
itemWidget:setItemId(hotKey.itemId)
|
||||
Game.startUseWith(itemWidget:getItem())
|
||||
end
|
||||
g_game.startUseWith(itemWidget:getItem())
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -312,23 +312,23 @@ end
|
||||
function HotkeysManager.checkSelectedHotkey(focused)
|
||||
if hotkeysManagerLoaded then
|
||||
hotkeyLabelSelectedOnList = focused
|
||||
|
||||
if hotkeyLabelSelectedOnList ~= nil then
|
||||
|
||||
if hotkeyLabelSelectedOnList ~= nil then
|
||||
removeHotkey:enable()
|
||||
|
||||
if hotkeyLabelSelectedOnList.itemId == nil then
|
||||
hotkeyText:enable()
|
||||
hotKeyTextLabel:enable()
|
||||
hotkeyText:setText(hotkeyLabelSelectedOnList.value)
|
||||
|
||||
if hotkeyLabelSelectedOnList.value ~= '' then
|
||||
|
||||
if hotkeyLabelSelectedOnList.value ~= '' then
|
||||
sendAutomatically:enable()
|
||||
else
|
||||
sendAutomatically:disable()
|
||||
end
|
||||
|
||||
|
||||
selectObjectButton:enable()
|
||||
clearObjectButton:disable()
|
||||
clearObjectButton:disable()
|
||||
|
||||
currentItemPreview:setItemId(0)
|
||||
else
|
||||
@@ -336,20 +336,20 @@ function HotkeysManager.checkSelectedHotkey(focused)
|
||||
hotkeyText:disable()
|
||||
hotKeyTextLabel:disable()
|
||||
sendAutomatically:disable()
|
||||
|
||||
|
||||
selectObjectButton:disable()
|
||||
clearObjectButton:enable()
|
||||
|
||||
currentItemPreview:setItemId(hotkeyLabelSelectedOnList.itemId)
|
||||
|
||||
currentItemPreview:setItemId(hotkeyLabelSelectedOnList.itemId)
|
||||
end
|
||||
HotkeysManager.changeUseType(hotkeyLabelSelectedOnList.useType)
|
||||
HotkeysManager.changeUseType(hotkeyLabelSelectedOnList.useType)
|
||||
else
|
||||
hotkeyText:clearText()
|
||||
removeHotkey:disable()
|
||||
hotkeyText:disable()
|
||||
sendAutomatically:disable()
|
||||
sendAutomatically:setChecked(false)
|
||||
|
||||
|
||||
currentItemPreview:setItemId(0)
|
||||
selectObjectButton:disable()
|
||||
clearObjectButton:disable()
|
||||
@@ -359,25 +359,25 @@ function HotkeysManager.checkSelectedHotkey(focused)
|
||||
useOnSelf:setChecked(false)
|
||||
useOnTarget:setChecked(false)
|
||||
useWith:setChecked(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.changeUseType(useType, checked)
|
||||
if checked == nil or checked then
|
||||
hotkeyLabelSelectedOnList.useType = useType
|
||||
hotkeyLabelSelectedOnList.useType = useType
|
||||
if hotkeyLabelSelectedOnList.itemId ~= nil and currentItemPreview:getItem():isMultiUse() then
|
||||
useOnSelf:enable()
|
||||
useOnTarget:enable()
|
||||
useWith:enable()
|
||||
|
||||
|
||||
if useType == HOTKEY_MANAGER_USEONSELF then
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on yourself)')
|
||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseSelf)
|
||||
useOnSelf:setChecked(true)
|
||||
useOnTarget:setChecked(false)
|
||||
useWith:setChecked(false)
|
||||
elseif useType == HOTKEY_MANAGER_USEONTARGET then
|
||||
elseif useType == HOTKEY_MANAGER_USEONTARGET then
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on target)')
|
||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseTarget)
|
||||
useOnSelf:setChecked(false)
|
||||
@@ -386,7 +386,7 @@ function HotkeysManager.changeUseType(useType, checked)
|
||||
elseif useType == HOTKEY_MANAGER_USEWITH then
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object with crosshair)')
|
||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseWith)
|
||||
|
||||
|
||||
useOnSelf:setChecked(false)
|
||||
useOnTarget:setChecked(false)
|
||||
useWith:setChecked(true)
|
||||
@@ -395,18 +395,18 @@ function HotkeysManager.changeUseType(useType, checked)
|
||||
useOnSelf:disable()
|
||||
useOnTarget:disable()
|
||||
useWith:disable()
|
||||
|
||||
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object)')
|
||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUse)
|
||||
|
||||
|
||||
useOnSelf:setChecked(false)
|
||||
useOnTarget:setChecked(false)
|
||||
useWith:setChecked(false)
|
||||
else
|
||||
else
|
||||
useOnSelf:disable()
|
||||
useOnTarget:disable()
|
||||
useWith:disable()
|
||||
|
||||
|
||||
useOnSelf:setChecked(false)
|
||||
useOnTarget:setChecked(false)
|
||||
useWith:setChecked(false)
|
||||
@@ -422,11 +422,11 @@ function HotkeysManager.removeHotkey()
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.onHotkeyTextChange(id, value)
|
||||
function HotkeysManager.onHotkeyTextChange(id, value)
|
||||
if hotkeyLabelSelectedOnList ~= nil and hotkeyLabelSelectedOnList.keyCombo ~= nil then
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': ' .. value)
|
||||
hotkeyLabelSelectedOnList.value = value
|
||||
|
||||
|
||||
if value ~= '' then
|
||||
sendAutomatically:enable()
|
||||
else
|
||||
@@ -452,6 +452,6 @@ function HotkeysManager.hotkeyCapture(widget, keyCode, keyboardModifiers)
|
||||
comboPreview.keyCombo = keyCombo
|
||||
comboPreview:resizeToText()
|
||||
hotkeysWindow:getChildById('assignWindow'):getChildById('addButton'):enable()
|
||||
|
||||
|
||||
return true
|
||||
end
|
@@ -6,7 +6,7 @@ local inventoryButton
|
||||
|
||||
-- public functions
|
||||
function Inventory.create()
|
||||
inventoryWindow = displayUI('inventory.otui', { parent = Game.gameRightPanel })
|
||||
inventoryWindow = displayUI('inventory.otui', { parent = g_game.gameRightPanel })
|
||||
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||
inventoryButton:setOn(true)
|
||||
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||
@@ -42,7 +42,7 @@ function Inventory.onSoulChange(soul)
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = Inventory.create,
|
||||
connect(g_game, { onGameStart = Inventory.create,
|
||||
onGameEnd = Inventory.destroy,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
|
@@ -175,7 +175,7 @@ function Outfit.destroy()
|
||||
end
|
||||
|
||||
function Outfit.accept()
|
||||
Game.setOutfit(m_outfit)
|
||||
g_game.changeOutfit(m_outfit)
|
||||
Outfit.destroy()
|
||||
end
|
||||
|
||||
@@ -198,5 +198,5 @@ function Outfit.previousType()
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
connect(Game, { onOpenOutfitWindow = Outfit.create,
|
||||
connect(g_game, { onOpenOutfitWindow = Outfit.create,
|
||||
onGameEnd = Outfit.destroy })
|
||||
|
@@ -42,7 +42,7 @@ end
|
||||
|
||||
-- public functions
|
||||
function Skills.create()
|
||||
skillsWindow = displayUI('skills.otui', { parent = Game.gameRightPanel })
|
||||
skillsWindow = displayUI('skills.otui', { parent = g_game.gameRightPanel })
|
||||
skillsWindow:hide()
|
||||
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
|
||||
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
|
||||
@@ -122,7 +122,7 @@ function Skills.onSkillChange(id, level, percent)
|
||||
setSkillPercent('skillId' .. id, percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = Skills.create,
|
||||
connect(g_game, { onGameStart = Skills.create,
|
||||
onGameEnd = Skills.destroy,
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
|
@@ -21,7 +21,7 @@ local centerLabel
|
||||
|
||||
-- private functions
|
||||
local function displayMessage(msgtype, msg, time)
|
||||
if not Game.isOnline() then return end
|
||||
if not g_game.isOnline() then return end
|
||||
|
||||
if msgtype.consoleTab ~= nil then
|
||||
if msgtype.consoleOption == nil or Options[msgtype.consoleOption] then
|
||||
@@ -30,7 +30,7 @@ local function displayMessage(msgtype, msg, time)
|
||||
end
|
||||
|
||||
if msgtype.labelId then
|
||||
local label = Game.gameMapPanel:recursiveGetChildById(msgtype.labelId)
|
||||
local label = g_game.gameMapPanel:recursiveGetChildById(msgtype.labelId)
|
||||
|
||||
label:setVisible(true)
|
||||
label:setText(msg)
|
||||
@@ -66,7 +66,7 @@ end
|
||||
-- public functions
|
||||
|
||||
function TextMessage.create()
|
||||
centerTextMessagePanel = createWidget('Panel', Game.gameMapPanel)
|
||||
centerTextMessagePanel = createWidget('Panel', g_game.gameMapPanel)
|
||||
centerTextMessagePanel:setId('centerTextMessagePanel')
|
||||
local layout = UIVerticalLayout.create(centerTextMessagePanel)
|
||||
layout:setFitChildren(true)
|
||||
@@ -78,7 +78,7 @@ function TextMessage.create()
|
||||
createTextMessageLabel('centerAdvance', centerTextMessagePanel)
|
||||
createTextMessageLabel('centerInfo', centerTextMessagePanel)
|
||||
|
||||
bottomStatusLabel = createTextMessageLabel('bottomStatus', Game.gameMapPanel)
|
||||
bottomStatusLabel = createTextMessageLabel('bottomStatus', g_game.gameMapPanel)
|
||||
bottomStatusLabel:setHeight(16)
|
||||
bottomStatusLabel:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
||||
bottomStatusLabel:addAnchor(AnchorLeft, 'parent', AnchorLeft)
|
||||
@@ -102,7 +102,7 @@ end
|
||||
|
||||
-- hooked events
|
||||
local function onGameDeath()
|
||||
local advanceLabel = Game.gameMapPanel:recursiveGetChildById('centerAdvance')
|
||||
local advanceLabel = g_game.gameMapPanel:recursiveGetChildById('centerAdvance')
|
||||
if advanceLabel:isVisible() then return end
|
||||
TextMessage.displayEventAdvance('You are dead.')
|
||||
end
|
||||
@@ -111,7 +111,7 @@ local function onGameTextMessage(msgtypedesc, msg)
|
||||
TextMessage.display(msgtypedesc, msg)
|
||||
end
|
||||
|
||||
connect(Game, { onGameStart = TextMessage.create,
|
||||
connect(g_game, { onGameStart = TextMessage.create,
|
||||
onGameEnd = TextMessage.destroy,
|
||||
onDeath = onGameDeath,
|
||||
onTextMessage = onGameTextMessage })
|
||||
|
@@ -7,7 +7,7 @@ local addVipWindow
|
||||
|
||||
-- public functions
|
||||
function VipList.create()
|
||||
vipWindow = displayUI('viplist.otui', { parent = Game.gameRightPanel })
|
||||
vipWindow = displayUI('viplist.otui', { parent = g_game.gameRightPanel })
|
||||
vipWindow:hide()
|
||||
vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
|
||||
end
|
||||
@@ -35,7 +35,7 @@ function VipList.destroyAddWindow()
|
||||
end
|
||||
|
||||
function VipList.addVip()
|
||||
Game.addVip(addVipWindow:getChildById('name'):getText())
|
||||
g_game.addVip(addVipWindow:getChildById('name'):getText())
|
||||
VipList.destroyAddWindow()
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ function VipList.onAddVip(id, name, online)
|
||||
label.vipOnline = online
|
||||
|
||||
label:setPhantom(false)
|
||||
connect(label, { onDoubleClick = function () Game.openPrivateChannel(label:getText()) return true end } )
|
||||
connect(label, { onDoubleClick = function () g_game.openPrivateChannel(label:getText()) return true end } )
|
||||
|
||||
local nameLower = name:lower()
|
||||
local childrenCount = vipList:getChildCount()
|
||||
@@ -114,7 +114,7 @@ function VipList.onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||
|
||||
local menu = createWidget('PopupMenu')
|
||||
menu:addOption('Add new VIP', function() VipList.createAddWindow() end)
|
||||
menu:addOption('Remove ' .. widget:getText(), function() if widget then Game.removeVip(widget:getId():sub(4)) vipList:removeChild(widget) end end)
|
||||
menu:addOption('Remove ' .. widget:getText(), function() if widget then g_game.removeVip(widget:getId():sub(4)) vipList:removeChild(widget) end end)
|
||||
menu:addSeparator()
|
||||
menu:addOption('Copy Name', function() g_window.setClipboardText(widget:getText()) end)
|
||||
menu:display(mousePos)
|
||||
@@ -123,7 +123,7 @@ function VipList.onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||
end
|
||||
|
||||
|
||||
connect(Game, { onGameStart = VipList.create,
|
||||
connect(g_game, { onGameStart = VipList.create,
|
||||
onGameEnd = VipList.destroy,
|
||||
onAddVip = VipList.onAddVip,
|
||||
onVipStateChange = VipList.onVipStateChange })
|
||||
|
@@ -1,12 +1,12 @@
|
||||
-- this file use loaded after everything is loaded and initialized
|
||||
-- you can place any custom user code here
|
||||
|
||||
Keyboard.bindKeyDown('F1', function() Game.talk('exura gran') end)
|
||||
Keyboard.bindKeyDown('F2', function() Game.talk('exori mort') end)
|
||||
Keyboard.bindKeyDown('F3', function() Game.talk('exori frigo') end)
|
||||
Keyboard.bindKeyDown('F4', function() Game.talk('exevo vis hur') end)
|
||||
Keyboard.bindKeyDown('F5', function() Game.talk('utani gran hur') end)
|
||||
Keyboard.bindKeyDown('F6', function() Game.talk('exani tera') end)
|
||||
Keyboard.bindKeyDown('F1', function() g_game.talk('exura gran') end)
|
||||
Keyboard.bindKeyDown('F2', function() g_game.talk('exori mort') end)
|
||||
Keyboard.bindKeyDown('F3', function() g_game.talk('exori frigo') end)
|
||||
Keyboard.bindKeyDown('F4', function() g_game.talk('exevo vis hur') end)
|
||||
Keyboard.bindKeyDown('F5', function() g_game.talk('utani gran hur') end)
|
||||
Keyboard.bindKeyDown('F6', function() g_game.talk('exani tera') end)
|
||||
|
||||
local function reload()
|
||||
dofile('otclientrc.lua')
|
||||
|
Reference in New Issue
Block a user