feat: add About menu with version info
/ build-dist (push) Successful in 1m16s Details

dev
LeRoyce Pearson 2024-05-30 12:48:20 -06:00
parent 771603b9d5
commit 6ff5164721
1 changed files with 31 additions and 10 deletions

View File

@ -255,16 +255,6 @@ fn render(window: seizer.Window) !void {
@floor((canvas.window_size[1] - space_taken_by_board[1]) / 2), @floor((canvas.window_size[1] - space_taken_by_board[1]) / 2),
}; };
_ = canvas.printText(
.{
0,
canvas.window_size[1],
},
"{s}",
.{build_options.version},
.{ .@"align" = .left, .baseline = .bottom, .scale = scalef },
);
if (win_count) |w| { if (win_count) |w| {
_ = canvas.printText( _ = canvas.printText(
.{ .{
@ -892,6 +882,7 @@ var main_menu_item_selected: u32 = 0;
const MAIN_MENU_ITEMS = [_][]const u8{ const MAIN_MENU_ITEMS = [_][]const u8{
"Continue", "Continue",
"New Game", "New Game",
"About",
"Quit", "Quit",
}; };
fn menuMain(event: MenuEvent) !void { fn menuMain(event: MenuEvent) !void {
@ -911,6 +902,8 @@ fn menuMain(event: MenuEvent) !void {
} else if (std.mem.eql(u8, menu_item, "New Game")) { } else if (std.mem.eql(u8, menu_item, "New Game")) {
try resetGame(); try resetGame();
current_menu_fn = null; current_menu_fn = null;
} else if (std.mem.eql(u8, menu_item, "About")) {
current_menu_fn = menuAbout;
} else if (std.mem.eql(u8, menu_item, "Quit")) { } else if (std.mem.eql(u8, menu_item, "Quit")) {
window_global.setShouldClose(true); window_global.setShouldClose(true);
} }
@ -939,6 +932,34 @@ fn menuMain(event: MenuEvent) !void {
} }
} }
fn menuAbout(event: MenuEvent) !void {
switch (event) {
.up => {},
.down => {},
.select => {},
.deselect => {
current_menu_fn = menuMain;
},
.draw => |d| {
const version_text_size = canvas.font.fmtTextSize("version = {s}", .{build_options.version}, d.scalef);
const margin = [2]f32{ d.scalef * 10, d.scalef * 10 };
const menu_size = [2]f32{ version_text_size[0] + 2 * margin[0], version_text_size[1] + 2 * margin[1] };
const menu_offset = [2]f32{ @floor((canvas.window_size[0] - menu_size[0]) / 2), @floor((canvas.window_size[1] - menu_size[1]) / 2) };
canvas.rect(
menu_offset,
menu_size,
.{ .color = .{ 0, 0, 0, 0xFF } },
);
const x: f32 = canvas.window_size[0] / 2;
const y: f32 = menu_offset[1] + margin[1];
_ = canvas.printText(.{ x, y }, "version = {s}", .{build_options.version}, .{ .@"align" = .center, .scale = d.scalef });
},
}
}
const DeckSprites = assets.DeckSprites; const DeckSprites = assets.DeckSprites;
const Card = assets.Card; const Card = assets.Card;