done coding functionality to create a string suitable for exporting
This commit is contained in:
@@ -10,7 +10,7 @@ struct
|
||||
fun getSaveSquaresMsg (model: app_type) =
|
||||
let
|
||||
val {canvasWidth, canvasHeight, squares, ...} = model
|
||||
val str = CollisionTree.toString (squares, canvasWidth, canvasHeight)
|
||||
val str = CollisionTree.toSaveString (squares, canvasWidth, canvasHeight)
|
||||
val msg = SAVE_SQUARES str
|
||||
in
|
||||
(model, [FILE msg])
|
||||
@@ -19,9 +19,17 @@ struct
|
||||
fun getLoadSquaresMsg model =
|
||||
(model, [FILE LOAD_SQUARES])
|
||||
|
||||
(* unimplemented *)
|
||||
fun getExportSquaresMsg model = (model, [])
|
||||
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
|
||||
|
||||
(* unimplemented *)
|
||||
fun useSquaresInNormalMode (model, squares) = (model, [])
|
||||
|
||||
fun squaresLoadError model = (model, [])
|
||||
|
||||
@@ -457,7 +457,7 @@ struct
|
||||
toBintree tree
|
||||
end
|
||||
|
||||
fun toStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) =
|
||||
fun toSaveStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) =
|
||||
let
|
||||
val item = String.concat
|
||||
[ "{"
|
||||
@@ -482,14 +482,14 @@ struct
|
||||
item :: acc
|
||||
end
|
||||
|
||||
fun toString (squares, canvasWidth, canvasHeight) =
|
||||
fun toSaveString (squares, canvasWidth, canvasHeight) =
|
||||
let
|
||||
val size = Int.max (canvasWidth, canvasHeight)
|
||||
val qtree = buildTree (0, 0, size, squares)
|
||||
val bintree = merge (qtree, squares)
|
||||
|
||||
val initial = ["}"]
|
||||
val acc = BinTree.foldr (toStringFolder, bintree, initial)
|
||||
val acc = BinTree.foldr (toSaveStringFolder, bintree, initial)
|
||||
val acc =
|
||||
String.concat
|
||||
[Int.toString canvasWidth, " ", Int.toString canvasHeight, " { "]
|
||||
@@ -582,7 +582,7 @@ struct
|
||||
, " #[\n"
|
||||
]
|
||||
|
||||
val footer = String.concat [" end\n", "end\n"]
|
||||
val footer = String.concat [" ]\n", " end\n", "end\n"]
|
||||
in
|
||||
String.concat [header, coords, footer]
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ struct
|
||||
datatype t =
|
||||
SAVE_SQUARES of string
|
||||
| LOAD_SQUARES
|
||||
| EXPORT_SQUARES of int vector vector
|
||||
| EXPORT_SQUARES of string
|
||||
| LOAD_FILES of string
|
||||
| SELECT_PATH of string
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user