done with functionality relating to performing file operations on terminal

This commit is contained in:
2025-08-26 16:15:40 +01:00
parent dcd3c3117e
commit 2de690f325
8 changed files with 84 additions and 70 deletions

View File

@@ -48,34 +48,37 @@ struct
fun getSaveSquaresMsg (model: app_type) =
let
val {layerTree, canvasWidth, canvasHeight, ...} = model
val str =
val {layerTree, canvasWidth, canvasHeight, openFilePath, ...} = model
val saveString =
CollisionTree.toSaveString (layerTree, canvasWidth, canvasHeight)
val msg = SAVE_SQUARES str
val msg = SAVE_SQUARES {output = saveString, filepath = openFilePath}
in
(model, [FILE msg])
end
fun getLoadSquaresMsg model =
(model, [FILE LOAD_SQUARES])
fun getLoadSquaresMsg (model: app_type) =
let val msg = LOAD_SQUARES {filepath = #openFilePath model}
in (model, [FILE msg])
end
fun getExportSquaresMsg (model: app_type) =
let
val {layerTree, canvasWidth, canvasHeight, ...} = model
val {layerTree, canvasWidth, canvasHeight, openFilePath, ...} = model
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = LayerTree.flatten (maxSide, layerTree)
val exportString =
CollisionTree.toExportString (squares, canvasWidth, canvasHeight)
val msg = EXPORT_SQUARES exportString
val msg = EXPORT_SQUARES {output = exportString, filepath = openFilePath}
in
(model, [FILE msg])
end
fun getCollisionMsg (model: app_type) =
let
val {layerTree, canvasWidth, canvasHeight, modalNum, ...} = model
val {layerTree, canvasWidth, canvasHeight, modalNum, openFilePath, ...} =
model
val maxSide = Int.max (canvasWidth, canvasHeight)
val squares = LayerTree.flatten (maxSide, layerTree)
@@ -83,7 +86,10 @@ struct
val exportString =
CollisionTree.toCollisionString
(squares, canvasWidth, canvasHeight, modalNum)
val msg = EXPORT_COLLISIONS exportString
val exportFilePath = FileString.getCollisionFilename openFilePath
val msg =
EXPORT_COLLISIONS {output = exportString, filepath = exportFilePath}
val model = AppWith.modalNum (model, 0)
in