restoring use with functionality and hotkeys manager module
This commit is contained in:
parent
fdba1379a7
commit
09e831ddc0
|
@ -19,7 +19,7 @@ Module
|
||||||
- game_combatcontrols
|
- game_combatcontrols
|
||||||
- game_battle
|
- game_battle
|
||||||
- game_viplist
|
- game_viplist
|
||||||
//- game_hotkeys
|
- game_hotkeys
|
||||||
|
|
||||||
@onLoad: |
|
@onLoad: |
|
||||||
importStyle 'styles/items.otui'
|
importStyle 'styles/items.otui'
|
||||||
|
|
|
@ -7,6 +7,7 @@ local gameRightPanel
|
||||||
local gameLeftPanel
|
local gameLeftPanel
|
||||||
local gameBottomPanel
|
local gameBottomPanel
|
||||||
local logoutButton
|
local logoutButton
|
||||||
|
local m_mouseGrabberWidget
|
||||||
|
|
||||||
function GameInterface.init()
|
function GameInterface.init()
|
||||||
connect(g_game, { onGameStart = GameInterface.show }, true)
|
connect(g_game, { onGameStart = GameInterface.show }, true)
|
||||||
|
@ -16,6 +17,9 @@ function GameInterface.init()
|
||||||
gameRootPanel:hide()
|
gameRootPanel:hide()
|
||||||
gameRootPanel:lower()
|
gameRootPanel:lower()
|
||||||
|
|
||||||
|
m_mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
|
||||||
|
connect(m_mouseGrabberWidget, { onMouseRelease = GameInterface.onUseWithMouseRelease })
|
||||||
|
|
||||||
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
|
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
|
||||||
gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
|
gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
|
||||||
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
|
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
|
||||||
|
@ -56,6 +60,7 @@ end
|
||||||
function GameInterface.terminate()
|
function GameInterface.terminate()
|
||||||
disconnect(g_game, { onGameStart = GameInterface.show })
|
disconnect(g_game, { onGameStart = GameInterface.show })
|
||||||
disconnect(g_game, { onGameEnd = GameInterface.hide })
|
disconnect(g_game, { onGameEnd = GameInterface.hide })
|
||||||
|
disconnect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
|
||||||
|
|
||||||
logoutButton:destroy()
|
logoutButton:destroy()
|
||||||
logoutButton = nil
|
logoutButton = nil
|
||||||
|
@ -66,6 +71,8 @@ function GameInterface.terminate()
|
||||||
gameLeftPanel = nil
|
gameLeftPanel = nil
|
||||||
gameBottomPanel = nil
|
gameBottomPanel = nil
|
||||||
GameInterface = nil
|
GameInterface = nil
|
||||||
|
m_mouseGrabberWidget:destroy()
|
||||||
|
m_mouseGrabberWidget = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameInterface.show()
|
function GameInterface.show()
|
||||||
|
@ -98,6 +105,33 @@ function GameInterface.tryLogout()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GameInterface.onUseWithMouseRelease(self, mousePosition, mouseButton)
|
||||||
|
if GameInterface.selectedThing == nil then return false end
|
||||||
|
if mouseButton == MouseLeftButton then
|
||||||
|
local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
|
||||||
|
if clickedWidget then
|
||||||
|
if clickedWidget:getClassName() == 'UIMap' then
|
||||||
|
local tile = clickedWidget:getTile(mousePosition)
|
||||||
|
if tile then
|
||||||
|
g_game.useWith(GameInterface.selectedThing, tile:getTopMultiUseThing())
|
||||||
|
end
|
||||||
|
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||||
|
g_game.useWith(GameInterface.selectedThing, clickedWidget:getItem())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
GameInterface.selectedThing = nil
|
||||||
|
Mouse.restoreCursor()
|
||||||
|
self:ungrabMouse()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameInterface.startUseWith(thing)
|
||||||
|
GameInterface.selectedThing = thing
|
||||||
|
m_mouseGrabberWidget:grabMouse()
|
||||||
|
Mouse.setTargetCursor()
|
||||||
|
end
|
||||||
|
|
||||||
function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||||
local menu = createWidget('PopupMenu')
|
local menu = createWidget('PopupMenu')
|
||||||
|
|
||||||
|
@ -115,7 +149,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if useThing:isMultiUse() then
|
if useThing:isMultiUse() then
|
||||||
menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
|
menu:addOption('Use with ...', function() GameInterface.startUseWith(useThing) end)
|
||||||
else
|
else
|
||||||
menu:addOption('Use', function() g_game.use(useThing) end)
|
menu:addOption('Use', function() g_game.use(useThing) end)
|
||||||
end
|
end
|
||||||
|
@ -230,7 +264,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elseif useThing:isMultiUse() then
|
elseif useThing:isMultiUse() then
|
||||||
g_game.startUseWith(useThing)
|
GameInterface.startUseWith(useThing)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
g_game.use(useThing)
|
g_game.use(useThing)
|
||||||
|
@ -255,7 +289,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elseif multiUseThing:isMultiUse() then
|
elseif multiUseThing:isMultiUse() then
|
||||||
g_game.startUseWith(multiUseThing)
|
GameInterface.startUseWith(useThing)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
g_game.use(multiUseThing)
|
g_game.use(multiUseThing)
|
||||||
|
|
|
@ -34,6 +34,7 @@ local hotkeyColors = {
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function HotkeysManager.init()
|
function HotkeysManager.init()
|
||||||
|
print("PASSO HK INIT")
|
||||||
hotkeysWindow = displayUI('hotkeys_manager.otui')
|
hotkeysWindow = displayUI('hotkeys_manager.otui')
|
||||||
|
|
||||||
hotkeysWindow:setVisible(false)
|
hotkeysWindow:setVisible(false)
|
||||||
|
@ -145,7 +146,7 @@ end
|
||||||
function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButton)
|
function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButton)
|
||||||
local item = nil
|
local item = nil
|
||||||
if mouseButton == MouseLeftButton then
|
if mouseButton == MouseLeftButton then
|
||||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition, false)
|
local clickedWidget = GameInterface.getRootPanel():recursiveGetChildByPos(mousePosition, false)
|
||||||
if clickedWidget then
|
if clickedWidget then
|
||||||
if clickedWidget:getClassName() == 'UIMap' then
|
if clickedWidget:getClassName() == 'UIMap' then
|
||||||
local tile = clickedWidget:getTile(mousePosition)
|
local tile = clickedWidget:getTile(mousePosition)
|
||||||
|
@ -304,7 +305,7 @@ function HotkeysManager.call(keyCombo)
|
||||||
end
|
end
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||||
itemWidget:setItemId(hotKey.itemId)
|
itemWidget:setItemId(hotKey.itemId)
|
||||||
g_game.startUseWith(itemWidget:getItem())
|
GameInterface.startUseWith(itemWidget:getItem())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,4 @@
|
||||||
-- you can place any custom user code here
|
-- you can place any custom user code here
|
||||||
-- you
|
-- you
|
||||||
|
|
||||||
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)
|
|
||||||
Keyboard.bindKeyDown('Ctrl+R', Client.reloadScripts)
|
Keyboard.bindKeyDown('Ctrl+R', Client.reloadScripts)
|
||||||
|
|
Loading…
Reference in New Issue