diff options
Diffstat (limited to 'source/app.d')
-rw-r--r-- | source/app.d | 21 |
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; |