From 52a247bceb47ca833ce2ed270ef778a55f33f4f3 Mon Sep 17 00:00:00 2001 From: geemili Date: Wed, 28 Feb 2024 15:00:50 -0700 Subject: [PATCH] don't reset position of selection when selecting cards This makes it easier to select the next card. --- src/main.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 47286b2..fabaecd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -12,6 +12,7 @@ const Response = union(enum) { transition: struct { game_state: GameState, can_undo: bool, + reset_selection: bool = false, }, }; @@ -296,7 +297,6 @@ pub fn main() !void { if (input_state.action) { request_command = try gpa.allocator().dupe(u8, hovered.command); root_element = null; - hovered_action = null; } } else if (actions.items.len > 0) { hovered_action = actions.items[0]; @@ -358,6 +358,9 @@ pub fn main() !void { switch (response) { .page => |page_root_element| root_element = page_root_element, .transition => |transition| { + if (transition.reset_selection) { + hovered_action = null; + } if (!transition.can_undo) { for (history.items) |*state| { state.deinit(); @@ -1075,6 +1078,7 @@ fn playerTurnHandler(arena: std.mem.Allocator, request: Request) HandlerError!Re return Response{ .transition = .{ .game_state = new_game_state, .can_undo = true, + .reset_selection = false, } }; } }