Files
sml-projects/fcore/common-update.sml

49 lines
1.2 KiB
Standard ML
Raw Normal View History

structure CommonUpdate =
struct
2025-07-12 06:03:59 +01:00
open AppType
open DrawMessage
open FileMessage
open InputMessage
open UpdateMessage
2025-07-12 06:03:59 +01:00
fun getSaveSquaresMsg (model: app_type) =
let
val {canvasWidth, canvasHeight, squares, ...} = model
val str = CollisionTree.toSaveString (squares, canvasWidth, canvasHeight)
2025-07-12 06:03:59 +01:00
val msg = SAVE_SQUARES str
in
(model, [FILE msg])
end
fun getLoadSquaresMsg model =
(model, [FILE LOAD_SQUARES])
fun getExportSquaresMsg (model: app_type) =
let
val {squares, canvasWidth, canvasHeight, ...} = model
val exportString =
CollisionTree.toExportString (squares, canvasWidth, canvasHeight)
val msg = EXPORT_SQUARES exportString
in
(model, [FILE msg])
end
fun getCollisionMsg (model: app_type) =
let
val {squares, canvasWidth, canvasHeight, modalNum, ...} = model
val exportString =
CollisionTree.toCollisionString (squares, canvasWidth, canvasHeight, modalNum)
val msg = EXPORT_COLLISIONS exportString
val model = AppWith.modalNum (model, 0)
in
(model, [FILE msg])
end
(* unimplemented *)
fun useSquaresInNormalMode (model, squares) = (model, [])
fun squaresLoadError model = (model, [])
end