Skip to content

Commit 1f9d03c

Browse files
committed
Hide zgui subwindow title
Add two path text fields Add progress bar
1 parent f717d1d commit 1f9d03c

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/main.zig

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ pub fn main() !void {
1717
};
1818
defer zglfw.terminate();
1919

20-
const window = zglfw.Window.create(1600, 1000, "Legacy Mod Converter 1.0 for Pre-Release 5.2", null) catch {
20+
const window = zglfw.Window.create(1000, 300, "Legacy Mod Converter 1.0 for Pre-Release 5.2", null) catch {
2121
std.log.err("Failed to create window.", .{});
2222
return;
2323
};
2424
defer window.destroy();
25-
window.setSizeLimits(400, 400, -1, -1);
25+
// window.setSizeLimits(600, 400, -1, -1);
2626

2727
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
2828
defer _ = gpa_state.deinit();
@@ -54,10 +54,25 @@ pub fn main() !void {
5454
);
5555

5656
// Set the starting window position and size to custom values
57-
zgui.setNextWindowPos(.{ .x = 20.0, .y = 20.0, .cond = .first_use_ever });
58-
zgui.setNextWindowSize(.{ .w = -1.0, .h = -1.0, .cond = .first_use_ever });
59-
60-
if (zgui.begin("Button list", .{})) {
57+
zgui.setNextWindowPos(.{ .x = 0.0, .y = 0.0, .cond = .always });
58+
// zgui.setNextWindowSize(.{ .w = -1.0, .h = -1.0, .cond = .always });
59+
60+
if (zgui.begin("a", .{ .flags = .{ .no_title_bar = true, .no_resize = true, .no_background = true } })) {
61+
const static = struct {
62+
var input_mod_path_buf: [std.fs.MAX_PATH_BYTES + 1]u8 = undefined;
63+
var output_mod_path_buf: [std.fs.MAX_PATH_BYTES + 1]u8 = undefined;
64+
var progress: f32 = 0.0;
65+
};
66+
// std.debug.print("xd: {d}\n", .{"I:/Programming/Cortex-Command-Community-Project-Source".len});
67+
// zgui.pushItemWidth("I:/Programming/Cortex-Command-Community-Project-Source".len);
68+
// zgui.setNextItemWidth("I:/Programming/Cortex-Command-Community-Project-Source".len);
69+
if (zgui.inputTextWithHint("Input/ directory path", .{ .hint = "Copy-paste a path from File Explorer here", .buf = static.input_mod_path_buf[0..] })) {
70+
std.debug.print("The user edited input_mod_path_buf\n", .{});
71+
}
72+
// zgui.popItemWidth();
73+
if (zgui.inputTextWithHint("Mods/ directory path", .{ .hint = "Copy-paste a path from File Explorer here", .buf = static.output_mod_path_buf[0..] })) {
74+
std.debug.print("The user edited output_mod_path_buf\n", .{});
75+
}
6176
if (zgui.button("Convert", .{ .w = 200.0 })) {
6277
std.debug.print("Converting...\n", .{});
6378

@@ -134,7 +149,16 @@ pub fn main() !void {
134149
const output_mod_path = try cwd.realpath("I:/Programming/Cortex-Command-Community-Project-Data/Mods", &output_mod_path_buffer);
135150

136151
try converter.zip_mods(input_mod_path, output_mod_path, allocator);
152+
153+
std.debug.print("Done zipping!\n", .{});
137154
}
155+
156+
zgui.pushStyleColor4f(.{ .idx = .plot_histogram, .c = .{ 0.1 + 0.5 * (1 - static.progress), 0.2 + 0.7 * static.progress, 0.3, 1.0 } });
157+
zgui.progressBar(.{ .fraction = static.progress, .overlay = "" });
158+
zgui.popStyleColor(.{});
159+
160+
static.progress += 0.03;
161+
if (static.progress > 2.0) static.progress = 0.0;
138162
}
139163
zgui.end();
140164

0 commit comments

Comments
 (0)