2024-07-18 20:00:51 +00:00
|
|
|
|
|
|
|
local love = assert( love )
|
|
|
|
local button = require 'ui.button'
|
|
|
|
local savemodal = require 'ui.savemodal'
|
|
|
|
local loadmodal = require 'ui.loadmodal'
|
|
|
|
local Camera = require 'ui.camera'
|
|
|
|
local map = require 'map.map'
|
|
|
|
|
2024-07-19 02:36:47 +00:00
|
|
|
local loadImg = love.graphics.newImage
|
|
|
|
local layers = {
|
|
|
|
{ name = "AF", layer = "africa" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "EU", layer = "europe" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "NA", layer = "northamerica" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "SA", layer = "southamerica" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "AS", layer = "southasia" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "RU", layer = "russia" , menu = require 'ui.menu.territory' },
|
|
|
|
{ name = "PATH", layer = "travelnodes" , menu = require 'ui.menu.travelnodes', icon = loadImg( "icons/layer-travelnodes.png" )},
|
|
|
|
{ name = "AI", layer = "ainodes" , menu = require 'ui.menu.ainodes', icon = loadImg( "icons/layer-ainodes.png" )},
|
|
|
|
{ name = "CITY", layer = "cities" , menu = require 'ui.menu.cities', icon = loadImg( "icons/layer-cities.png" )},
|
|
|
|
{ name = "COAST", layer = "coastlines" , menu = require 'ui.menu.lines', icon = loadImg( "icons/layer-coastlines.png" )},
|
|
|
|
{ name = "LOW", layer = "coastlinesLow", menu = require 'ui.menu.lines', icon = loadImg( "icons/layer-coastlines-low.png" )},
|
|
|
|
{ name = "INT", layer = "international", menu = require 'ui.menu.lines', icon = loadImg( "icons/layer-international.png" )},
|
|
|
|
{ name = "SAIL", layer = "sailable" , menu = require 'ui.menu.territory', icon = loadImg( "icons/layer-sailable.png" )},
|
|
|
|
}
|
|
|
|
|
2024-07-18 20:00:51 +00:00
|
|
|
button.new{
|
|
|
|
name = "LOAD", x = 250, y = 0,
|
|
|
|
w = 28 * 13,
|
|
|
|
callback = loadmodal.start,
|
|
|
|
icon = love.graphics.newImage( "icons/load.png" )}
|
|
|
|
button.new{
|
|
|
|
name = "SAVE", x = 250, y = 28,
|
|
|
|
w = 28 * 13,
|
|
|
|
callback = savemodal.start,
|
|
|
|
icon = love.graphics.newImage( "icons/save.png" )}
|
|
|
|
button.new{
|
|
|
|
name = "UNDO", x = 250, y = 2 * 28,
|
|
|
|
w = 28 * 13,
|
|
|
|
callback = map.undo,
|
|
|
|
icon = love.graphics.newImage( "icons/undo.bmp" ) }
|
|
|
|
|
|
|
|
local showButtons = {}
|
|
|
|
local visibilityIcon = love.graphics.newImage( "icons/eye.bmp" )
|
|
|
|
local function updateVisibilityIcons()
|
|
|
|
for i = 1, #showButtons do
|
|
|
|
showButtons[i].icon = map.layers[ showButtons[i].layer ].visible and visibilityIcon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function toggleVisibleLayer( self )
|
|
|
|
if not (self and self.layer) then return end
|
|
|
|
local ml = map.layers[ self.layer ]
|
|
|
|
ml.visible = not( ml.visible )
|
|
|
|
return updateVisibilityIcons()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local activeLayerButton
|
|
|
|
local function back( self )
|
|
|
|
self.visible = false
|
|
|
|
map.setEditLayer()
|
|
|
|
activeLayerButton = nil
|
|
|
|
return updateVisibilityIcons()
|
|
|
|
end
|
|
|
|
|
|
|
|
local backButton = button.new{
|
|
|
|
name = "UP",
|
|
|
|
visible = false,
|
|
|
|
y = 5 * 28,
|
|
|
|
x = 250,
|
|
|
|
icon = love.graphics.newImage( "icons/up.bmp" ),
|
|
|
|
callback = back,
|
|
|
|
}
|
|
|
|
|
|
|
|
local function editLayer( self )
|
|
|
|
map.setEditLayer( self.layer )
|
|
|
|
activeLayerButton = self
|
|
|
|
backButton.visible = true
|
|
|
|
return updateVisibilityIcons()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function copy( i, target )
|
|
|
|
for k, v in pairs( layers[i] ) do
|
|
|
|
target[k] = target[k] or v
|
|
|
|
end
|
|
|
|
return target
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local layerButtons = {}
|
|
|
|
local x = 250
|
|
|
|
local soloButtons = {}
|
|
|
|
local editButtons = {}
|
|
|
|
for i = 1, #layers do
|
2024-07-19 02:36:47 +00:00
|
|
|
|
2024-07-18 20:00:51 +00:00
|
|
|
editButtons[i] = button.new( copy( i, {
|
|
|
|
y = 3 * 28,
|
|
|
|
x = x + (button.h + 4) * ( i - 1 ),
|
|
|
|
w = 24,
|
|
|
|
callback = editLayer,
|
|
|
|
group = "edit",
|
|
|
|
tooltip = "edit "..layers[i].layer
|
|
|
|
}))
|
|
|
|
layerButtons[ 2 * i - 2 ] = editButtons[i]
|
|
|
|
|
|
|
|
showButtons[i] = button.new( copy( i, {
|
|
|
|
y = 4 * 28,
|
|
|
|
x = x + (button.h + 4) * ( i - 1 ),
|
|
|
|
w = 24,
|
|
|
|
name = "",
|
|
|
|
callback = toggleVisibleLayer,
|
|
|
|
icon = visibilityIcon,
|
|
|
|
group = "show",
|
|
|
|
tooltip = "show "..layers[i].layer
|
|
|
|
}))
|
|
|
|
layerButtons[ 2 * i - 1 ] = showButtons[i]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local t = {}
|
|
|
|
|
|
|
|
function t.draw()
|
|
|
|
--Status bar.
|
|
|
|
love.graphics.setScissor( 0, 0, 250, 200 )
|
|
|
|
local x, y = love.mouse.getPosition()
|
|
|
|
local wx, wy = Camera.GetWorldCoordinate( x, y )
|
|
|
|
local bx, by = Camera.GetBitmapCoordinate( x, y )
|
|
|
|
local h = love.graphics.getHeight() - 60
|
|
|
|
love.graphics.setColor( 0, 0, 0, 1 )
|
|
|
|
love.graphics.rectangle( "fill", 0, 0, 250, love.graphics.getHeight() )
|
|
|
|
love.graphics.setColor( 1, 1, 1, 1 )
|
|
|
|
love.graphics.print(([[
|
|
|
|
SCREEN %-12d %-12d
|
|
|
|
WORLD %-12.2f%-12.2f
|
|
|
|
BITMAP %-12d %-12d
|
|
|
|
%s
|
|
|
|
%s]]):format(
|
|
|
|
x, y,
|
|
|
|
wx, wy,
|
|
|
|
bx, by,
|
|
|
|
button.selected and button.selected.tooltip or "",
|
|
|
|
map.editLayer and map.editLayer.filename or ""), 0, 0)
|
|
|
|
|
|
|
|
if map.selected then love.graphics.print( map.selected:formatDisplayInfo(), 0, 80 ) end
|
|
|
|
if map.selectionLocked then end
|
|
|
|
|
|
|
|
love.graphics.setScissor( 0, 0, love.graphics.getWidth(), 200 )
|
|
|
|
love.graphics.rectangle( "line", 0, 0 , 250, 200 )
|
|
|
|
love.graphics.rectangle( "line", 250, 0, love.graphics.getWidth() - 250, 200 )
|
|
|
|
|
|
|
|
|
|
|
|
love.graphics.setColor( 1, 1, 1, 0.8 )
|
|
|
|
button:draw()
|
|
|
|
|
|
|
|
love.graphics.setColor( 1, 0, 0, 0.4 )
|
|
|
|
if activeLayerButton then activeLayerButton:highlight() end
|
|
|
|
end
|
|
|
|
|
|
|
|
return t
|