mirror of
https://github.com/edubart/otclient.git
synced 2025-04-29 17:19:20 +02:00

* Added new left and right game button panels. * Relocated main game toggle buttons to the right side of the screen to make it easier to toggle miniwindows. * Added table.empty(t) function to table lib. * Renamed module game_healthbar to game_healthinfo. * Combat controls now save per character (e.g. Fight mode, chase mode, safe fight mode) * Last channels open now save per character. * Fixed typo in containers.lua. * Added logout prompting window message when you logout via the logout button. * Added exit promting window message when you attempt to exit the client. * Repositioned some minimap buttons. * Fixed so when creatures health percent is < 1 it will not draw the creature information. Known Issues: * If you move a container widget into the map rect if you move an item onto itself it will allow this to execute still dropping the item on the ground. * The server is calling to open channels after onGameStart is executed causing it to focus the last tab opened. Fix: Don't save channels to the settings that are opened by the server.
84 lines
2.2 KiB
Lua
84 lines
2.2 KiB
Lua
UIGameMap = extends(UIMap)
|
|
|
|
function UIGameMap.create()
|
|
local gameMap = UIGameMap.internalCreate()
|
|
gameMap:setKeepAspectRatio(true)
|
|
gameMap:setVisibleDimension({width = 15, height = 11})
|
|
return gameMap
|
|
end
|
|
|
|
|
|
function UIGameMap: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.currentDragThing = thing
|
|
g_mouse.setTargetCursor()
|
|
return true
|
|
end
|
|
|
|
function UIGameMap:onDragLeave(droppedWidget, mousePos)
|
|
self.currentDragThing = nil
|
|
g_mouse.restoreCursor()
|
|
return true
|
|
end
|
|
|
|
function UIGameMap: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 thing = widget.currentDragThing
|
|
local toPos = tile:getPosition()
|
|
|
|
local thingPos = thing:getPosition()
|
|
if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then return false end
|
|
|
|
if thing:asItem() and thing:getCount() > 1 then
|
|
GameInterface.moveStackableItem(thing, toPos)
|
|
else
|
|
g_game.move(thing, toPos, 1)
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
function UIGameMap:onMousePress()
|
|
self.cancelNextRelease = false
|
|
end
|
|
|
|
function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
|
if self.cancelNextRelease then
|
|
self.cancelNextRelease = false
|
|
return true
|
|
end
|
|
|
|
local tile = self:getTile(mousePosition)
|
|
if tile == nil then return false end
|
|
|
|
local localPlayerPos = g_game.getLocalPlayer():getPosition()
|
|
local autoWalkPos = tile:getPosition()
|
|
if autoWalkPos.z ~= localPlayerPos.z then
|
|
local dz = autoWalkPos.z - localPlayerPos.z
|
|
autoWalkPos.x = autoWalkPos.x + dz
|
|
autoWalkPos.y = autoWalkPos.y + dz
|
|
autoWalkPos.z = localPlayerPos.z
|
|
end
|
|
|
|
local lookThing = tile:getTopLookThing()
|
|
local useThing = tile:getTopUseThing()
|
|
local creatureThing = tile:getTopCreature()
|
|
local multiUseThing = tile:getTopMultiUseThing()
|
|
|
|
local ret = GameInterface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, multiUseThing)
|
|
if ret then
|
|
self.cancelNextRelease = true
|
|
end
|
|
|
|
return ret
|
|
end
|