Skip to content

Commit 83cb6ef

Browse files
committed
Show popup on successful conversion
1 parent 5415a86 commit 83cb6ef

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/main.zig

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ pub fn main() !void {
6969
@memcpy(game_executable_path_mut[0..settings.game_executable_path.len], settings.game_executable_path);
7070
game_executable_path_mut[settings.game_executable_path.len] = 0;
7171

72-
var err_msg_buf: [420420]u8 = undefined;
73-
var err_msg_slice: []u8 = undefined;
72+
var popup_buf: [420420]u8 = undefined;
73+
var popup_slice: []u8 = undefined;
7474

7575
while (!window.shouldClose()) {
7676
zglfw.pollEvents();
@@ -129,54 +129,58 @@ pub fn main() !void {
129129
// if (progress > 2.0) progress = 0.0;
130130

131131
std.debug.print("Done converting!\n", .{});
132+
133+
popup_slice = try std.fmt.bufPrint(&popup_buf, "The converted mods have been put in {s}", .{settings.output_folder_path});
134+
135+
zgui.openPopup("popup", .{});
132136
} else |err| {
133137
switch (err) {
134138
error.InvalidInputPath => {
135-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Invalid input path", .{});
139+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Invalid input path", .{});
136140
},
137141
error.InvalidOutputPath => {
138-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Invalid output path", .{});
142+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Invalid output path", .{});
139143
},
140144
error.FileNotFound => {
141-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Please enter valid input and output paths", .{});
145+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Please enter valid input and output paths", .{});
142146
},
143147
error.UnexpectedToken => {
144-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Unexpected token '{s}' in file {s} on line {} and column {}", .{
148+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Unexpected token '{s}' in file {s} on line {} and column {}", .{
145149
diagnostics.token orelse "null",
146150
diagnostics.file_path orelse "null",
147151
diagnostics.line orelse -1,
148152
diagnostics.column orelse -1,
149153
});
150154
},
151155
error.UnclosedMultiComment => {
152-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Unclosed multi-line comment in file {s}", .{
156+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Unclosed multi-line comment in file {s}", .{
153157
diagnostics.file_path orelse "null",
154158
});
155159
},
156160
error.TooManyTabs => {
157-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Too many tabs in file {s} on line {} and column {}", .{
161+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Too many tabs in file {s} on line {} and column {}", .{
158162
diagnostics.file_path orelse "null",
159163
diagnostics.line orelse -1,
160164
diagnostics.column orelse -1,
161165
});
162166
},
163167
error.ExpectedADataModule => {
164-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Expected a DataModule", .{});
168+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Expected a DataModule", .{});
165169
},
166170
error.ContainsMoreThanOneDataModule => {
167-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: The mod contains more than one DataModule", .{});
171+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: The mod contains more than one DataModule", .{});
168172
},
169173
else => |_| {
170-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "{?}", .{@errorReturnTrace()});
174+
popup_slice = try std.fmt.bufPrint(&popup_buf, "{?}", .{@errorReturnTrace()});
171175
},
172176
}
173177

174-
std.debug.print("{s}\n", .{err_msg_slice});
175-
zgui.openPopup("error_popup", .{});
178+
std.debug.print("{s}\n", .{popup_slice});
179+
zgui.openPopup("popup", .{});
176180
}
177181
}
178-
if (zgui.beginPopup("error_popup", .{})) {
179-
zgui.text("{s}\n", .{err_msg_slice});
182+
if (zgui.beginPopup("popup", .{})) {
183+
zgui.text("{s}\n", .{popup_slice});
180184
zgui.endPopup();
181185
}
182186

@@ -193,19 +197,19 @@ pub fn main() !void {
193197
var argv = [_][]const u8{settings.game_executable_path};
194198
_ = std.ChildProcess.exec(.{ .argv = &argv, .allocator = gpa }) catch |err| switch (err) {
195199
error.FileNotFound => {
196-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Please enter the game executable path", .{});
197-
zgui.openPopup("error_popup", .{});
200+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Please enter the game executable path", .{});
201+
zgui.openPopup("popup", .{});
198202
},
199203
else => |e| return e,
200204
};
201205
} else |err| switch (err) {
202206
error.BadPathName => {
203-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Please enter the game executable path", .{});
204-
zgui.openPopup("error_popup", .{});
207+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Please enter the game executable path", .{});
208+
zgui.openPopup("popup", .{});
205209
},
206210
error.FileNotFound => {
207-
err_msg_slice = try std.fmt.bufPrint(&err_msg_buf, "Error: Please enter the game executable path", .{});
208-
zgui.openPopup("error_popup", .{});
211+
popup_slice = try std.fmt.bufPrint(&popup_buf, "Error: Please enter the game executable path", .{});
212+
zgui.openPopup("popup", .{});
209213
},
210214
else => |e| return e,
211215
}

0 commit comments

Comments
 (0)