about summary refs log tree commit diff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main.zig b/src/main.zig
index 9accfc8..08c84ab 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,5 +1,5 @@
 // Main function
-// Copyright (C) 2021-2023  Nguyễn Gia Phong
+// Copyright (C) 2021-2023, 2025  Nguyễn Gia Phong
 //
 // This file is part of Black Shades.
 //
@@ -16,13 +16,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
 
-const DefaultPrng = std.rand.DefaultPrng;
+const DefaultPrng = std.Random.DefaultPrng;
 const allocator = std.heap.c_allocator;
-const free = std.c.free;
 const std = @import("std");
 
-const Loca = @import("loca").Loca;
 const al = @import("zeal");
+const folders = @import("known-folders");
 const gf = @import("gfz");
 const gl = @import("zgl");
 
@@ -84,10 +83,10 @@ fn click(window: gf.Window, button: gf.MouseButton,
 }
 
 pub fn main() !void {
-    const loca = try Loca.init(allocator, .{});
-    defer loca.deinit();
-    const config = try configuration.parse(loca.user_config);
-    defer free(config.levels.ptr);
+    const user_config = (try folders.getPath(allocator, .local_configuration)).?;
+    defer allocator.free(user_config);
+    const config = try configuration.parse(user_config);
+    defer config.deinit();
 
     try gf.init();
     defer gf.deinit() catch unreachable;
@@ -100,10 +99,11 @@ pub fn main() !void {
     defer textures.deinit();
     var decals = Decals.init(allocator, &textures);
     defer decals.deinit();
+    const user_data = (try folders.getPath(allocator, .data)).?;
+    defer allocator.free(user_data);
     game = c.makeGame(&decals, @bitCast(config),
-                      @bitCast(try loadScores(loca.user_data))).?;
-    defer saveScores(loca.user_data, @bitCast(c.getScores(game)))
-        catch unreachable;
+                      @bitCast(try loadScores(user_data))).?;
+    defer saveScores(user_data, @bitCast(c.getScores(game))) catch unreachable;
 
     try window.setSizeCallback(resizeWindow);
     try gf.swapInterval(@intFromBool(config.vsync));