Fixes to minimap

This commit is contained in:
Henrique Santiago 2013-01-31 01:09:56 -02:00
parent 654f71e75f
commit 8a2d2cd5ac
5 changed files with 81 additions and 12 deletions

View File

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

View File

@ -141,7 +141,7 @@ MinimapFlagWindow < MainWindow
margin-top: 3
anchors.left: parent.left
anchors.top: prev.bottom
width: 158
anchors.right: parent.right
MinimapFlagCheckBox
id: flag0
@ -245,3 +245,20 @@ MinimapFlagWindow < MainWindow
width: 64
anchors.right: parent.right
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()

View File

@ -6,3 +6,8 @@ function UIButton.create()
button:setFocusable(false)
return button
end
function UIButton:onMouseRelease(pos, button)
if self:isPressed() then return true end
return false
end

View File

@ -13,10 +13,10 @@ function init()
minimapWidget = minimapWindow:recursiveGetChildById('minimap')
local gameRootPanel = modules.game_interface.getRootPanel()
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+Up', function() minimapWidget:move(0,-1) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Down', function() minimapWidget:move(0,1) 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+Up', 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)
minimapWindow:setup()
@ -105,3 +105,7 @@ function saveMap()
end
minimapWidget:save()
end
function getMinimap()
return minimapWidget
end

View File

@ -7,6 +7,7 @@ function UIMinimap:onSetup()
self.zoomOutWidget = self:getChildById('zoomOut')
self.dx = 0
self.dy = 0
self.autowalk = true
self.onPositionChange = function() self:followLocalPlayer() 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
@ -24,6 +25,36 @@ function UIMinimap:onDestroy()
onRemoveAutomapFlag = self.onRemoveAutomapFlag,
})
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
function UIMinimap:load()
@ -192,8 +223,7 @@ function UIMinimap:onMousePress(pos, button)
end
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
local mapPos = self:getPosition(pos)
@ -201,15 +231,14 @@ function UIMinimap:onMouseRelease(pos, button)
if button == MouseLeftButton then
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
end
return true
elseif button == MouseRightButton then
local menu = g_ui.createWidget('PopupMenu')
menu:addOption(tr('Create mark'), function()
self:createFlagWindow(mapPos)
end)
menu:addOption(tr('Create mark'), function() self:createFlagWindow(mapPos) end)
if self.fullImage then menu:addOption(tr('Full map'), function() self:createFullPanel() end) end
menu:display(pos)
return true
end
@ -229,6 +258,19 @@ function UIMinimap:onDragLeave(widget, pos)
return true
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)
if self.flagWindow then return end
if not pos then return end