feat: update to seizer with wayland support

ci-dev
LeRoyce Pearson 2024-05-03 19:58:39 -06:00
parent b82fdbca00
commit 6595013a88
2 changed files with 10 additions and 6 deletions

View File

@ -16,8 +16,8 @@
// internet connectivity. // internet connectivity.
.dependencies = .{ .dependencies = .{
.seizer = .{ .seizer = .{
.url = "https://github.com/leroycep/seizer/archive/5dcad668e4b9f873060cbaccaf8a4a1c2f4f0bc8.tar.gz", .url = "https://github.com/leroycep/seizer/archive/20f89f13d082c6c0644ae60e618671c7109563d4.tar.gz",
.hash = "122041f3ceeb4198fcef9edd8c4c377852ab540c94428397dd35236883f4e40b0b9a", .hash = "1220ab3b947e2654722eb0ecf113b13aab99b6524c6d60ec62ffe4fbca70ca1b36a1",
}, },
}, },
.paths = .{ .paths = .{

View File

@ -2,9 +2,10 @@ pub const main = seizer.main;
var gpa: std.mem.Allocator = undefined; var gpa: std.mem.Allocator = undefined;
var prng: std.rand.DefaultPrng = undefined; var prng: std.rand.DefaultPrng = undefined;
var window_global: *seizer.Window = undefined; var window_global: seizer.Window = undefined;
var canvas: seizer.Canvas = undefined; var canvas: seizer.Canvas = undefined;
var card_tilemap: ?DeckSprites = null; var card_tilemap: ?DeckSprites = null;
var invert_y: bool = false;
var draw_pile: std.ArrayListUnmanaged(Card) = .{}; var draw_pile: std.ArrayListUnmanaged(Card) = .{};
var draw_pile_exhausted = false; var draw_pile_exhausted = false;
@ -48,6 +49,8 @@ pub fn init(context: *seizer.Context) !void {
canvas = try seizer.Canvas.init(context.gpa, .{}); canvas = try seizer.Canvas.init(context.gpa, .{});
errdefer canvas.deinit(); errdefer canvas.deinit();
invert_y = std.mem.eql(u8, context.backend.name, "linux");
card_tilemap = try assets.loadSolitaireCards(context.gpa); card_tilemap = try assets.loadSolitaireCards(context.gpa);
try resetGame(); try resetGame();
@ -150,7 +153,7 @@ fn resetHistory() void {
history.shrinkRetainingCapacity(0); history.shrinkRetainingCapacity(0);
} }
fn destroy(window: *seizer.Window) void { fn destroy(window: seizer.Window) void {
_ = window; _ = window;
for (history.items) |*snapshot| { for (history.items) |*snapshot| {
snapshot.deinit(); snapshot.deinit();
@ -173,7 +176,7 @@ fn destroy(window: *seizer.Window) void {
canvas.deinit(); canvas.deinit();
} }
fn render(window: *seizer.Window) !void { fn render(window: seizer.Window) !void {
if (haveWon() and !win_triggered) { if (haveWon() and !win_triggered) {
win_count += 1; win_count += 1;
@ -191,6 +194,7 @@ fn render(window: *seizer.Window) !void {
canvas.begin(.{ canvas.begin(.{
.window_size = window.getSize(), .window_size = window.getSize(),
.framebuffer_size = window.getFramebufferSize(), .framebuffer_size = window.getFramebufferSize(),
.invert_y = invert_y,
}); });
const scale: u32 = if (canvas.window_size[1] <= 400) 1 else 2; const scale: u32 = if (canvas.window_size[1] <= 400) 1 else 2;
@ -680,7 +684,7 @@ pub fn moveDown(pressed: bool) !void {
if (!pressed) return; if (!pressed) return;
if (show_menu) { if (show_menu) {
menu_item_selected += 1; menu_item_selected += 1;
menu_item_selected %= MENU_ITEMS.len; menu_item_selected %= @intCast(MENU_ITEMS.len);
} else if (hovered_deck == null) { } else if (hovered_deck == null) {
hovered_deck = &draw_pile; hovered_deck = &draw_pile;
hovered_card = 0; hovered_card = 0;