Fixes to minimap

master
Henrique Santiago 11 years ago
parent 654f71e75f
commit 8a2d2cd5ac

@ -271,6 +271,7 @@ locale = {
["Remove"] = "Remover", ["Remove"] = "Remover",
["Report Bug"] = "Reportar defeito", ["Report Bug"] = "Reportar defeito",
["Reserved for more functionality later."] = "Reservado para futura maior funcionalidade.", ["Reserved for more functionality later."] = "Reservado para futura maior funcionalidade.",
["Reset All"] = "Resetar Todos",
["Reset Market"] = "Resetar Mercado", ["Reset Market"] = "Resetar Mercado",
["Revoke %s's Invitation"] = "Não aceitar o convite do %s", ["Revoke %s's Invitation"] = "Não aceitar o convite do %s",
["Rotate"] = "Girar", ["Rotate"] = "Girar",

@ -141,7 +141,7 @@ MinimapFlagWindow < MainWindow
margin-top: 3 margin-top: 3
anchors.left: parent.left anchors.left: parent.left
anchors.top: prev.bottom anchors.top: prev.bottom
width: 158 anchors.right: parent.right
MinimapFlagCheckBox MinimapFlagCheckBox
id: flag0 id: flag0
@ -245,3 +245,20 @@ MinimapFlagWindow < MainWindow
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
// Minimap Full Panel
MinimapFullPanel < UIWidget
image-smooth: true
border-width: 2
border-color: #000000
anchors.fill: parent
anchors.top: topMenu.bottom
Button
!text: tr('Close')
margin-right: 4
margin-top: 4
anchors.right: parent.right
anchors.top: parent.top
@onClick: self:getParent():destroy()

@ -5,4 +5,9 @@ function UIButton.create()
local button = UIButton.internalCreate() local button = UIButton.internalCreate()
button:setFocusable(false) button:setFocusable(false)
return button return button
end end
function UIButton:onMouseRelease(pos, button)
if self:isPressed() then return true end
return false
end

@ -13,10 +13,10 @@ function init()
minimapWidget = minimapWindow:recursiveGetChildById('minimap') minimapWidget = minimapWindow:recursiveGetChildById('minimap')
local gameRootPanel = modules.game_interface.getRootPanel() local gameRootPanel = modules.game_interface.getRootPanel()
g_keyboard.bindKeyPress('Alt+Left', function() minimapWidget:move(-1,0) end, gameRootPanel) g_keyboard.bindKeyPress('Alt+Left', function() minimapWidget:move(1,0) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Right', function() minimapWidget:move(1,0) end, gameRootPanel) g_keyboard.bindKeyPress('Alt+Right', function() minimapWidget:move(-1,0) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Up', function() minimapWidget:move(0,-1) end, gameRootPanel) g_keyboard.bindKeyPress('Alt+Up', function() minimapWidget:move(0,1) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Down', function() minimapWidget:move(0,1) end, gameRootPanel) g_keyboard.bindKeyPress('Alt+Down', function() minimapWidget:move(0,-1) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+M', toggle) g_keyboard.bindKeyDown('Ctrl+M', toggle)
minimapWindow:setup() minimapWindow:setup()
@ -105,3 +105,7 @@ function saveMap()
end end
minimapWidget:save() minimapWidget:save()
end end
function getMinimap()
return minimapWidget
end

@ -7,6 +7,7 @@ function UIMinimap:onSetup()
self.zoomOutWidget = self:getChildById('zoomOut') self.zoomOutWidget = self:getChildById('zoomOut')
self.dx = 0 self.dx = 0
self.dy = 0 self.dy = 0
self.autowalk = true
self.onPositionChange = function() self:followLocalPlayer() end self.onPositionChange = function() self:followLocalPlayer() end
self.onAddAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end self.onAddAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end
self.onRemoveAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end self.onRemoveAutomapFlag = function(pos, icon, description) self:addFlag(pos, icon, description) end
@ -24,6 +25,36 @@ function UIMinimap:onDestroy()
onRemoveAutomapFlag = self.onRemoveAutomapFlag, onRemoveAutomapFlag = self.onRemoveAutomapFlag,
}) })
self:destroyFlagWindow() self:destroyFlagWindow()
self:destroyFullPanel()
end
function UIMinimap:onVisibilityChange()
if not self:isVisible() then
self:destroyFlagWindow()
self:destroyFullPanel()
end
end
function UIMinimap:hideFlags()
self.flagsWidget:hide()
end
function UIMinimap:hideFloor()
self.floorUpWidget:hide()
self.floorDownWidget:hide()
end
function UIMinimap:hideZoom()
self.zoomInWidget:hide()
self.zoomOutWidget:hide()
end
function UIMinimap:disableAutoWalk()
self.autowalk = false
end
function UIMinimap:enableFullPanel(image)
self.fullImage = image
end end
function UIMinimap:load() function UIMinimap:load()
@ -192,8 +223,7 @@ function UIMinimap:onMousePress(pos, button)
end end
function UIMinimap:onMouseRelease(pos, button) function UIMinimap:onMouseRelease(pos, button)
-- TODO: if not self.allowNextRelease then return true end
--if not self.allowNextRelease then return true end
self.allowNextRelease = false self.allowNextRelease = false
local mapPos = self:getPosition(pos) local mapPos = self:getPosition(pos)
@ -201,15 +231,14 @@ function UIMinimap:onMouseRelease(pos, button)
if button == MouseLeftButton then if button == MouseLeftButton then
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if not player:autoWalk(mapPos) then if self.autowalk and not player:autoWalk(mapPos) then
player.onAutoWalkFail = function() modules.game_textmessage.displayFailureMessage(tr('There is no way.')) end player.onAutoWalkFail = function() modules.game_textmessage.displayFailureMessage(tr('There is no way.')) end
end end
return true return true
elseif button == MouseRightButton then elseif button == MouseRightButton then
local menu = g_ui.createWidget('PopupMenu') local menu = g_ui.createWidget('PopupMenu')
menu:addOption(tr('Create mark'), function() menu:addOption(tr('Create mark'), function() self:createFlagWindow(mapPos) end)
self:createFlagWindow(mapPos) if self.fullImage then menu:addOption(tr('Full map'), function() self:createFullPanel() end) end
end)
menu:display(pos) menu:display(pos)
return true return true
end end
@ -229,6 +258,19 @@ function UIMinimap:onDragLeave(widget, pos)
return true return true
end end
function UIMinimap:createFullPanel()
self.fullPanel = g_ui.createWidget('MinimapFullPanel', rootWidget)
self.fullPanel:setImageSource(self.fullImage)
self.fullPanel.onDestroy = function() self.fullPanel = nil end
end
function UIMinimap:destroyFullPanel()
if self.fullPanel then
self.fullPanel:destroy()
self.fullPanel = nil
end
end
function UIMinimap:createFlagWindow(pos) function UIMinimap:createFlagWindow(pos)
if self.flagWindow then return end if self.flagWindow then return end
if not pos then return end if not pos then return end

Loading…
Cancel
Save