checkin old changes

This commit is contained in:
wan-may 2024-04-21 11:10:53 -03:00
parent ea91cc6bc9
commit 688e954c2b
7 changed files with 84 additions and 9 deletions

View File

@ -15,8 +15,8 @@ function t.load( filename )
return img, imgd
end
function t.save( data, format )
function t.save( data, filename )
local w, h = data:getDimensions()
end
return t

32
button.lua Normal file
View File

@ -0,0 +1,32 @@
local t = {}
function t.onHover( button )
end
function t.onClick( button )
end
function t.newButton( name, tooltip, icon, x, y, w, h, callback )
return setmetatable( {
name = name,
tooltip = tooltip,
icon = icon,
x = x,
y = y,
w = w,
h = h,
callback = callback },
t )
end
function t.draw( button )
end
t.__index = t
t.__call = t.newButton
setmetatable( t, t )
return t

View File

@ -6,7 +6,6 @@ local math = math
local hash = function( x, y, debug )
local s = "h"..("%2d%2d"):format(math.floor( 0.5 + (180 + x) / 10 ), math.floor( 0.5 + (100 + y) / 10 ) )
if debug then print( "HASH: ", s, x, y) end
return s
end
@ -25,8 +24,6 @@ function t.getClosestPoint( points, x, y )
end
end
print( #closePoints, distance )
return point
end

View File

@ -1,5 +1,6 @@
local love = assert( love, "This tool requires LOVE: love2d.org" )
local map = require 'map'
local button = require 'button'
local SAVEDIRECTORY = "out/"
local Camera = require 'camera'
local wasKeyPressed
@ -30,12 +31,46 @@ function love.update( dt )
end
local toolButtons = {
"Brush",
"Move Nodes",
"Add Nodes",
"Edit Node",
"Draw Polygon",
"Erase Polygon"
}
local layerButtons = {
"Africa",
"Europe",
"North America",
"South America",
"Asia",
"Russia",
"Travel Nodes",
"AI Markers",
"Cities",
"Coastlines",
"Coastlines Low",
"Sailable"
}
function love.draw()
love.graphics.push( "all" )
map.draw()
love.graphics.pop()
--Layer buttons.
do
love.graphics.setColor( 1, 1, 1, 1 )
local h = love.graphics.getHeight() - 60
for x = 0, 300, 30 do
love.graphics.rectangle( "line", x, h, 30, 30 )
end
end
--Status bar.
local x, y = love.mouse.getPosition()
local wx, wy = Camera.GetWorldCoordinate( x, y )

17
map.lua
View File

@ -44,13 +44,14 @@ function map.draw()
do --territory
lg.setColor( 1,1,1,1)
lg.setLineJoin( "none" )
lg.setLineWidth( 1 / Camera.zoom )
lg.replaceTransform( Camera.tfTerritory )
lg.setBlendMode( "add" )
for k, v in pairs(map.territory) do
if v.visible then
v:draw()
lg.setLineWidth( 1 / Camera.zoom )
v:drawBorder( "land" )
lg.setLineWidth( 3 / Camera.zoom )
v:drawBorder( "sea" )
end
end
@ -67,8 +68,7 @@ function map.draw()
lg.setColor( 1, 1, 1, 0.5)
map.sailable:drawBorder( "sailable" )
lg.setColor( 1, 0, 0, 0.5)
lg.setLineWidth( 3 / Camera.zoom )
map.sailable:drawBorder( "placeable" )
end
@ -123,7 +123,16 @@ function map.draw()
end
function map.save()
map.cities.save()
map.coastlines.save()
map.coastlinesLow.save()
map.international.save()
map.sailable.save()
map.travelnodes.save()
map.ainodes.save()
for k, v in pairs(map.territory) do
map.territory[k].save()
end
end
function map.hover(x, y)

View File

@ -72,6 +72,7 @@ function t.load( filename, sailable )
return setmetatable( nodes, {__index = t } )
end
--Determine if graph has more than one connected component.
function t.isConnected( nodes )
end

View File

@ -14,6 +14,7 @@ local colours = {
function t.load( filename, name )
local img, imgd = assert( bmp.load( filename ) )
img:setWrap( "repeat" )
local territory = {
visible = true,
name = name,