aboutsummaryrefslogtreecommitdiff
path: root/source/app.d
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2021-08-08 23:59:29 -0400
committerHolden Rohrer <hr@hrhr.dev>2021-08-08 23:59:29 -0400
commita770dd88e6c55ac7fd67c243ad30f04425e3e175 (patch)
tree38902b17472d73bc7dda030b3b864e856ee2268d /source/app.d
parentc353004717da1ef7ba8be6e9a3ce10002c7d6d66 (diff)
featureful saving and loading
Diffstat (limited to 'source/app.d')
-rw-r--r--source/app.d21
1 files changed, 18 insertions, 3 deletions
diff --git a/source/app.d b/source/app.d
index 943b9d0..52074b1 100644
--- a/source/app.d
+++ b/source/app.d
@@ -75,10 +75,13 @@ void main()
try
{
auto file = File(filename, "wb");
-
+ file.writefln!"%s %s"(disp.y, disp.x);
+ file.writefln!"%d"(rocks);
+ overlay.save(file);
}
- catch (ErrnoException e)
+ catch (Exception e)
{
+ // TODO: log the error in a user-visible way
}
disp.print();
break;
@@ -86,10 +89,22 @@ void main()
auto filename = stdscr.readquery("Load:");
try
{
+ import std.algorithm.iteration : splitter, map;
+ import std.conv : to;
+ import std.bigint;
+
auto file = File(filename);
+ auto coord = file.readln.splitter().map!(to!BigInt);
+ disp.y = coord.front;
+ coord.popFront;
+ disp.x = coord.front;
+ file.readf!"%d\n"(rocks);
+ disp.status = format("%d", rocks);
+ overlay.load(file);
}
- catch (ErrnoException e)
+ catch (Exception e)
{
+ printw("exception!");
}
disp.print();
break;