diff --git a/build.zig b/build.zig index 14b2185..939249a 100644 --- a/build.zig +++ b/build.zig @@ -30,6 +30,7 @@ pub fn build(b: *std.Build) !void { stb_truetype.addIncludePath(.{ .path = root_path ++ "libs/stb" }); const zigimg_module = b.dependency("zigimg", .{}).module("zigimg"); + const zini_module = b.dependency("zini", .{}).module("zini"); const app = try mach_core.App.init(b, .{ .name = "ztyping", .src = "game/app.zig", @@ -40,6 +41,10 @@ pub fn build(b: *std.Build) !void { .name = "zigimg", .module = zigimg_module, }, + .{ + .name = "zini", + .module = zini_module, + }, .{ .name = "bass", .module = zig_bass, diff --git a/build.zig.zon b/build.zig.zon index 2b6f147..34fe9c5 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -7,13 +7,17 @@ .hash = "1220ba5472217ef81455b19d540967049bbfaf768b30d04534865707e907ee1c4aec", }, .zigimg = .{ - .url = "https://github.com/zigimg/zigimg/archive/8873f29fc449e1b63400e9f4ad86d3c76204f962.tar.gz", + .url = "git+https://github.com/zigimg/zigimg#8873f29fc449e1b63400e9f4ad86d3c76204f962", .hash = "122019f6439545235af116d0d8eb81fde1ff05fdb070da57c723772c557f84c5bf39", }, .clap = .{ - .url = "https://github.com/Hejsil/zig-clap/archive/0f2db7700b05356ebb1ccddbbf1797048925f072.tar.gz", + .url = "git+https://github.com/Hejsil/zig-clap#0f2db7700b05356ebb1ccddbbf1797048925f072", .hash = "12203896de6eedec14712f4f1eaac8b646939cfed213c56accf231a0abb05f9dbb77", }, + .zini = .{ + .url = "git+https://github.com/Beyley/zini#aaeba1ad81742d52d3af086cb3c89c515ce5e728", + .hash = "1220b322b8ec9b10bc79e9da8def6cc3a49c9ffccf87d2e7577fc6e522bd0893173b", + }, }, .paths = .{ "game/", diff --git a/game/app.zig b/game/app.zig index 58a1706..6e047c0 100644 --- a/game/app.zig +++ b/game/app.zig @@ -42,8 +42,8 @@ random: std.rand.DefaultPrng = std.rand.DefaultPrng.init(35698752), ///The name of the user, this is owned by the main menu instance at the bottom of the screen stack name: []const u8, -///Our main texture atlas gfx: Gfx, +///Our main texture atlas texture: Gfx.Texture, renderer: Renderer, fontstash: Fontstash, @@ -193,16 +193,6 @@ pub fn update(app: *App) !bool { .app = app, }); - // if (builtin.mode == .Debug) { - // var open = false; - // _ = c.igBegin("fps", &open, 0); - // c.igText("%fms %dfps", state.delta_time * 1000, @as(usize, @intFromFloat(1 / state.delta_time))); - // c.igEnd(); - // } - - // c.igRender(); - // c.ImGui_ImplWGPU_RenderDrawData(c.igGetDrawData(), render_pass_encoder.c); - render_pass_encoder.end(); render_pass_encoder.release(); diff --git a/game/config.zig b/game/config.zig index ce69643..c3e8191 100644 --- a/game/config.zig +++ b/game/config.zig @@ -1,6 +1,6 @@ const std = @import("std"); -const Ini = @import("ini.zig").Ini(std.fs.File.Reader, 256, 0); +const Ini = @import("zini").IniReader(std.fs.File.Reader, 256, 0); const Self = @This(); diff --git a/game/ini.zig b/game/ini.zig deleted file mode 100644 index 0a93007..0000000 --- a/game/ini.zig +++ /dev/null @@ -1,87 +0,0 @@ -const std = @import("std"); - -pub fn Ini(comptime ReaderType: type, comptime max_line_size: comptime_int, comptime max_section_size: comptime_int) type { - return struct { - read_section: bool, - read_buf: [max_line_size]u8, - current_section: [max_section_size]u8, - current_section_len: usize, - reader: ReaderType, - - const Self = @This(); - - pub fn init(reader: ReaderType) Self { - const self = Self{ - .read_buf = undefined, - .current_section = undefined, - .current_section_len = 0, - .reader = reader, - .read_section = false, - }; - - return self; - } - - const Item = struct { - key: []const u8, - value: []const u8, - section: ?[]const u8, - }; - - pub fn next(self: *Self) !?Item { - while (try self.reader.readUntilDelimiterOrEof(&self.read_buf, '\n')) |read_line| { - //Trim the line - var line = std.mem.trim(u8, read_line, " \t\r"); - - //If the line is blank, skip it - if (line.len == 0) { - continue; - } - - //If the first char is a comment, skip it - if (line[0] == '#' or line[0] == ';') { - continue; - } - - //If the line starts with a [, then its the start of a new section - if (line[0] == '[') { - //Find the index of the last ] in the line - const closing_idx = std.mem.lastIndexOf(u8, line, "]"); - - if (closing_idx) |idx| { - //Copy the section into the current section - @memcpy(self.current_section[0 .. idx - 1], line[1..idx]); - - self.current_section_len = idx - 1; - - //Mark that we have read a section - self.read_section = true; - - continue; - } else { - return error.MissingClosingBracket; - } - } - - const sep_idx = std.mem.indexOf(u8, line, "=") orelse return error.MissingKeyValueSeparator; - - var key = line[0..sep_idx]; - var value = line[sep_idx + 1 ..]; - - //NOTE: the full line has already been pre-trimmed, so we dont have to worry about the outsides - //Strip whitespace from end of key - key = std.mem.trimRight(u8, key, " \t"); - //Strip whitespace from start of value - value = std.mem.trimLeft(u8, value, " \t"); - - return .{ - .key = key, - .value = value, - .section = if (self.read_section) &self.current_section else null, - }; - } - - return null; - } - }; -} diff --git a/game/screens/song_select.zig b/game/screens/song_select.zig index 8bef141..2fcfb63 100644 --- a/game/screens/song_select.zig +++ b/game/screens/song_select.zig @@ -420,20 +420,6 @@ pub const h_music_info_sub = 6 + h_comment + 4 + h_play_data + 6; pub fn renderScreen(self: *Screen, render_state: RenderState) anyerror!void { var data = self.getData(SongSelectData); - // var open = true; - - // // if (builtin.mode == .Debug) { - // // _ = c.igBegin("Test", &open, c.ImGuiWindowFlags_AlwaysVerticalScrollbar); - - // // for (data.draw_info.add_height) |height| { - // // c.igText("height: %f", height); - // // } - // // c.igText("wait: %f", data.draw_info.add_height_wait); - // // c.igText("ranking pos: %d", data.draw_info.ranking_pos); - - // // c.igEnd(); - // // } - try render_state.renderer.begin(); try render_state.fontstash.renderer.begin(); diff --git a/libs/zig-bass b/libs/zig-bass index 2d2615f..ec4b11e 160000 --- a/libs/zig-bass +++ b/libs/zig-bass @@ -1 +1 @@ -Subproject commit 2d2615fc83a65fca216ab1100eece37fcd259035 +Subproject commit ec4b11efab181ac9ea783fe8f2f6baff6305a367