diff --git a/bmp.lua b/bmp.lua index 6928c70..1ec076a 100644 --- a/bmp.lua +++ b/bmp.lua @@ -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 \ No newline at end of file diff --git a/button.lua b/button.lua new file mode 100644 index 0000000..dfe51d8 --- /dev/null +++ b/button.lua @@ -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 \ No newline at end of file diff --git a/locationQuery.lua b/locationQuery.lua index e1281e2..c7b3f16 100644 --- a/locationQuery.lua +++ b/locationQuery.lua @@ -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 diff --git a/main.lua b/main.lua index 2f7128a..f340be3 100644 --- a/main.lua +++ b/main.lua @@ -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 ) diff --git a/map.lua b/map.lua index b9dce1a..036f902 100644 --- a/map.lua +++ b/map.lua @@ -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) diff --git a/nodes.lua b/nodes.lua index 1f1be3c..ed99358 100644 --- a/nodes.lua +++ b/nodes.lua @@ -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 diff --git a/territory.lua b/territory.lua index 96c04ae..844aedf 100644 --- a/territory.lua +++ b/territory.lua @@ -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,