in generated export string, use structure name which is based on the name of the input file

This commit is contained in:
2025-08-26 16:21:52 +01:00
parent 2de690f325
commit 4a8ff38a66
5 changed files with 10 additions and 8 deletions

BIN
dsc

Binary file not shown.

View File

@@ -69,7 +69,7 @@ struct
val squares = LayerTree.flatten (maxSide, layerTree) val squares = LayerTree.flatten (maxSide, layerTree)
val exportString = val exportString =
CollisionTree.toExportString (squares, canvasWidth, canvasHeight) CollisionTree.toExportString (squares, canvasWidth, canvasHeight, openFilePath)
val msg = EXPORT_SQUARES {output = exportString, filepath = openFilePath} val msg = EXPORT_SQUARES {output = exportString, filepath = openFilePath}
in in
(model, [FILE msg]) (model, [FILE msg])

View File

@@ -585,7 +585,7 @@ struct
item :: acc item :: acc
end end
fun toExportString (squares, canvasWidth, canvasHeight) = fun toExportString (squares, canvasWidth, canvasHeight, filepath) =
let let
val size = Int.max (canvasWidth, canvasHeight) val size = Int.max (canvasWidth, canvasHeight)
val qtree = buildTree (0, 0, size, squares) val qtree = buildTree (0, 0, size, squares)
@@ -594,10 +594,12 @@ struct
val f = toExportStringFolder (canvasWidth, canvasHeight) val f = toExportStringFolder (canvasWidth, canvasHeight)
val coords = BinTree.foldr (f, bintree, []) val coords = BinTree.foldr (f, bintree, [])
val coords = String.concatWith ",\n" coords val coords = String.concatWith ",\n" coords
val structureName = FileString.filenameToStructureName filepath
val structureStart = String.concat ["structure ", structureName, " = struct\n"]
in in
String.concat String.concat
[ "structure AAA = \nstruct\n" [ structureStart
, " fun xToNdc (xOffset, xpos, scale, halfWidth) =\n" , " fun xToNdc (xOffset, xpos, scale, halfWidth) =\n"
, " ((xpos * scale + xOffset) - halfWidth) / halfWidth\n\n" , " ((xpos * scale + xOffset) - halfWidth) / halfWidth\n\n"

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@ struct
SOME line => loadIO (io, str ^ line) SOME line => loadIO (io, str ^ line)
| NONE => str | NONE => str
fun convertFile (fullPath, filename) = fun convertFile fullPath =
let let
val io = TextIO.openIn fullPath val io = TextIO.openIn fullPath
val text = loadIO (io, "") val text = loadIO (io, "")
@@ -17,7 +17,7 @@ struct
val maxSide = Int.max (canvasWidth, canvasHeight) val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = LayerTree.flatten (maxSide, tree) val squares = LayerTree.flatten (maxSide, tree)
val exportString = val exportString =
CollisionTree.toExportString (squares, canvasWidth, canvasHeight) CollisionTree.toExportString (squares, canvasWidth, canvasHeight, fullPath)
val pathWithoutExtension = String.substring val pathWithoutExtension = String.substring
(fullPath, 0, String.size fullPath - 4) (fullPath, 0, String.size fullPath - 4)
@@ -57,7 +57,7 @@ struct
() ()
else if endsWithDsc path then else if endsWithDsc path then
(* is a file ending with .dsc extension *) (* is a file ending with .dsc extension *)
convertFile (folderPath, path) convertFile folderPath
else else
(* is a file but doesn't end with .dsc, so ignore *) (* is a file but doesn't end with .dsc, so ignore *)
() ()