diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2024-06-20 00:44:24 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2024-06-20 00:44:24 -0500 |
| commit | 0dc97d45f1b228f6f3b9feb1773b972eca343766 (patch) | |
| tree | 3d133ce030dbd23632759edb31ab4c1878d20517 /src/imgui.zig | |
| parent | 2374e1f1a11d62ee579d25a39b24312a68e7387e (diff) | |
| download | particle-sim-0dc97d45f1b228f6f3b9feb1773b972eca343766.tar.gz | |
Added load / save feature with simple CSV parsing
Diffstat (limited to 'src/imgui.zig')
| -rw-r--r-- | src/imgui.zig | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/imgui.zig b/src/imgui.zig index b6def48..163ee0f 100644 --- a/src/imgui.zig +++ b/src/imgui.zig @@ -1,7 +1,7 @@ const std = @import("std"); const rl = @import("raylib"); const z = @import("zgui"); -const part = @import("particle.zig"); +const rul = @import("rules.zig"); const cfg = @import("config.zig"); const c = @cImport({ @@ -9,7 +9,7 @@ const c = @cImport({ @cInclude("rlImGui.h"); }); -pub fn update() !void { +pub fn update(alloc: std.mem.Allocator, buf: [:0]u8) !void { c.rlImGuiBegin(); defer c.rlImGuiEnd(); @@ -28,12 +28,6 @@ pub fn update() !void { _ = z.sliderFloat("Minimum Distance", .{ .v = &cfg.minDistance, .min = 1.0, .max = 100.0 }); } if (z.collapsingHeader("Ruleset", .{ .default_open = true })) { - // comptime var string: [:0]const u8 = ""; - // comptime for (0..cfg.colors.len) |cols| { - // string = string ++ part.colorToString(cols) ++ "\t\t\t\t\t"; - // }; - // - // z.text("{s:<}", .{string}); _ = z.beginTable("Rules", .{ .column = cfg.colorAmnt + 1, .flags = .{}, @@ -46,13 +40,13 @@ pub fn update() !void { z.text("Rules", .{}); for (0..cfg.colorAmnt) |i| { _ = z.tableNextColumn(); - z.text("{s}", .{part.colorToString(i)}); + z.text("{s}", .{rul.colorToString(i)}); } for (&cfg.rules, 0..) |*row, i| { _ = z.tableNextRow(.{}); _ = z.tableSetColumnIndex(0); - z.text("{s}", .{part.colorToString(i)}); + z.text("{s}", .{rul.colorToString(i)}); _ = z.tableNextColumn(); for (row, 0..) |*cols, j| { var id: [2:0]u8 = undefined; @@ -65,4 +59,16 @@ pub fn update() !void { } } } + if (z.collapsingHeader("Load / Save", .{ .default_open = true })) { + _ = z.inputText("Save Path", .{ .buf = buf }); + if (z.button("Save", .{})) { + const path = buf; + _ = rul.saveRules(path) catch void; + } + _ = z.inputText("Load Path", .{ .buf = buf }); + if (z.button("Load", .{})) { + const path = buf; + _ = rul.loadRules(alloc, path) catch void; + } + } } |
