This commit is contained in:
2025-11-05 03:00:23 -07:00
parent 4696a99095
commit 12e0518948
3 changed files with 62 additions and 9 deletions

View File

@@ -21,6 +21,11 @@ used by this program. An array called `offset` will adjust the positioning of
labels. An array called `color` will set the color via 0 to 1 RGBA values labels. An array called `color` will set the color via 0 to 1 RGBA values
(node only). (node only).
Added `areas` which are exactly like nodes except that they always draw a white
label and can have a custom radius specified. Drawn between edges and nodes.
Use transparency. 25% works well.
- TODO Options: box instead of circle, line instead of fill, ovals
## Example JSON ## Example JSON
```json ```json

View File

@@ -28,13 +28,17 @@
"village crossroad": [130, 101, 296, false, {"notes": "insignificant"}], "village crossroad": [130, 101, 296, false, {"notes": "insignificant"}],
"Second Farm original route corner": [-180, 69, -30, false], "Second Farm original route corner": [-180, 69, -30, false],
"Second Farm original route corner 2": [-202, 79, -169, false], "Second Farm original route corner 2": [-202, 79, -169, false],
"cherry blossum divergence point": [-332, 104, -423], "cherry blossum divergence point": [-332, 104, -423, false],
"original farm worldborder deadend": [-346, 109, -456], "original farm worldborder deadend": [-346, 109, -456, false],
"Cherry Point": [-480, 104, -404, true, {"color": [1, 0.67, 0.67, 1]}], "Cherry Point": [-480, 104, -404, true, {"color": [1, 0.67, 0.67, 1]}],
"unnamed beach point": [-376, 63, -313], "unnamed beach point": [-376, 63, -313, false],
"unnamed summit curve point": [-387, 119, -229], "unnamed summit curve point": [-387, 119, -229, false],
"unnamed summit": [-408, 130, -251], "unnamed summit": [-408, 130, -251],
"Sugarcane Point": [-161, 62, -365, true, {"color": [0.75, 1, 0.25, 1]}] "Sugarcane Point": [-161, 62, -365, true, {"color": [0.75, 1, 0.25, 1]}],
"original border 1": [-500, 0, -500, false],
"original border 2": [-500, 0, 500, false],
"original border 3": [500, 0, 500, false],
"original border 4": [500, 0, -500, false]
}, },
"edges": [ "edges": [
["tree farm north", "Second Farm", null, {"offset": [0, -12]}], ["tree farm north", "Second Farm", null, {"offset": [0, -12]}],
@@ -63,6 +67,14 @@
["Cherry Point", "cherry blossum divergence point"], ["Cherry Point", "cherry blossum divergence point"],
["unnamed summit curve point", "unnamed beach point"], ["unnamed summit curve point", "unnamed beach point"],
["unnamed summit curve point", "unnamed summit", null, {"offset": [-14, 10]}], ["unnamed summit curve point", "unnamed summit", null, {"offset": [-14, 10]}],
["Sugarcane Point", "Second Farm"] ["Sugarcane Point", "Second Farm"],
] ["original border 2", "original border 1", "original border (west)"],
["original border 1", "original border 4", "original border (north)"],
["original border 4", "original border 3", "original border (east)"],
["original border 3", "original border 2", "original border (south)"]
],
"areas": {
"unnamed ocean": [600, 64, -150, true, {"radius": 300, "color": [0, 0, 1, 0.25]}],
"Farm Region": [-230, 80, -100, true, {"radius": 230, "color": [0, 0.5, 0, 0.15], "offset": [-60, 0]}]
}
} }

View File

@@ -12,7 +12,7 @@ local scale_fix_translation_adjustment = 300 -- this is wrong, and the wrong way
local nodes, edges, minimums, maximums, scale, translation local nodes, edges, areas, minimums, maximums, scale, translation
local function load_map(map_file_name) local function load_map(map_file_name)
local file, text local file, text
if type(map_file_name) == "string" then if type(map_file_name) == "string" then
@@ -20,6 +20,7 @@ local function load_map(map_file_name)
if not file then if not file then
nodes = {} nodes = {}
edges = {} edges = {}
areas = {}
minimums = {0, 0} minimums = {0, 0}
maximums = {100, 100} maximums = {100, 100}
scale = 1 scale = 1
@@ -34,8 +35,9 @@ local function load_map(map_file_name)
end end
local map = json.decode(text) local map = json.decode(text)
nodes = map.nodes nodes = map.nodes or {}
edges = map.edges or {} edges = map.edges or {}
areas = map.areas or {}
-- find map size -- find map size
minimums = {math.huge, math.huge} -- x, z minimums = {math.huge, math.huge} -- x, z
@@ -99,6 +101,40 @@ function love.draw()
end end
end end
for name, area in pairs(areas) do
local color = area[5] and area[5].color or {1, 1, 1, 0.25}
love.graphics.setColor(color)
if not (area[4] == false) then
local radius = area[5] and area[5].radius or node_radius
love.graphics.circle("fill", area[1], area[3], radius)
end
if area[4] then
if type(area[4]) == "string" then
name = area[4]
end
local text_x, text_z = area[1] + node_radius / scale, area[3] + node_radius / scale
local difference = area[1] + font:getWidth(name) - maximums[1]
if difference > 0 then
text_x = area[1] - (node_radius + difference) / scale
end
local difference = area[3] + font:getHeight() - maximums[2]
if difference > 0 then
text_z = area[3] - (node_radius + difference) / scale
end
if area[5] and area[5].offset then
text_x = text_x + area[5].offset[1] / scale
text_z = text_z + area[5].offset[2] / scale
end
love.graphics.setColor(1, 1, 1, 1)
love.graphics.print(name, text_x, text_z, 0, 1 / scale, 1 / scale)
end
end
-- draw nodes and label them -- draw nodes and label them
for name, node in pairs(nodes) do for name, node in pairs(nodes) do
local color = node[5] and node[5].color or {1, 1, 1, 1} local color = node[5] and node[5].color or {1, 1, 1, 1}