Skip to content

Commit 44409c5

Browse files
committed
Add "Beautify Lua" checkbox
1 parent 4f944e9 commit 44409c5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main.zig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const Settings = struct {
1010
input_folder_path: []const u8 = "",
1111
output_folder_path: []const u8 = "",
1212
game_executable_path: []const u8 = "",
13+
beautify_lua: bool = true,
1314
};
1415

1516
pub fn main() !void {
@@ -19,7 +20,7 @@ pub fn main() !void {
1920
};
2021
defer zglfw.terminate();
2122

22-
const window = zglfw.Window.create(1600, 300, "Legacy Mod Converter v1.0 for CCCP v6.0.0", null) catch {
23+
const window = zglfw.Window.create(1600, 300, "Legacy Mod Converter v1.2 for CCCP release 6", null) catch {
2324
std.log.err("Failed to create window.", .{});
2425
return;
2526
};
@@ -101,6 +102,10 @@ pub fn main() !void {
101102
try writeSettings(settings);
102103
}
103104

105+
if (zgui.checkbox("Beautify Lua", .{ .v = &settings.beautify_lua })) {
106+
try writeSettings(settings);
107+
}
108+
104109
if (zgui.button("Convert", .{ .w = 200.0 })) {
105110
std.debug.print("Converting...\n", .{});
106111

@@ -115,7 +120,9 @@ pub fn main() !void {
115120
allocator,
116121
&diagnostics,
117122
)) {
118-
try converter.beautifyLua(settings.output_folder_path, allocator);
123+
if (settings.beautify_lua) {
124+
try converter.beautifyLua(settings.output_folder_path, allocator);
125+
}
119126

120127
// TODO: Run .convert() in a separate thread, letting it update a passed Progress struct so we can update a progress bar here?
121128
// TODO: Check if std/Progress.zig is of use: https://ziglang.org/documentation/master/std/src/std/Progress.zig.html
@@ -179,10 +186,6 @@ pub fn main() !void {
179186
zgui.openPopup("popup", .{});
180187
}
181188
}
182-
if (zgui.beginPopup("popup", .{})) {
183-
zgui.text("{s}\n", .{popup_slice});
184-
zgui.endPopup();
185-
}
186189

187190
zgui.setNextItemWidth(@max(zgui.calcTextSize(settings.game_executable_path, .{})[0] + padding, min_width));
188191
if (zgui.inputTextWithHint("Game executable path", .{ .hint = "Copy-paste a path from File Explorer here", .buf = &game_executable_path_mut })) {
@@ -213,6 +216,11 @@ pub fn main() !void {
213216
// try converter.zipMods(settings.input_folder_path, settings.output_folder_path, allocator);
214217
// std.debug.print("Done zipping!\n", .{});
215218
// }
219+
220+
if (zgui.beginPopup("popup", .{})) {
221+
zgui.text("{s}\n", .{popup_slice});
222+
zgui.endPopup();
223+
}
216224
}
217225
zgui.end();
218226

0 commit comments

Comments
 (0)