don't reset position of selection when selecting cards

This makes it easier to select the next card.
dev
LeRoyce Pearson 2024-02-28 15:00:50 -07:00
parent 807712af79
commit 52a247bceb
1 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ const Response = union(enum) {
transition: struct { transition: struct {
game_state: GameState, game_state: GameState,
can_undo: bool, can_undo: bool,
reset_selection: bool = false,
}, },
}; };
@ -296,7 +297,6 @@ pub fn main() !void {
if (input_state.action) { if (input_state.action) {
request_command = try gpa.allocator().dupe(u8, hovered.command); request_command = try gpa.allocator().dupe(u8, hovered.command);
root_element = null; root_element = null;
hovered_action = null;
} }
} else if (actions.items.len > 0) { } else if (actions.items.len > 0) {
hovered_action = actions.items[0]; hovered_action = actions.items[0];
@ -358,6 +358,9 @@ pub fn main() !void {
switch (response) { switch (response) {
.page => |page_root_element| root_element = page_root_element, .page => |page_root_element| root_element = page_root_element,
.transition => |transition| { .transition => |transition| {
if (transition.reset_selection) {
hovered_action = null;
}
if (!transition.can_undo) { if (!transition.can_undo) {
for (history.items) |*state| { for (history.items) |*state| {
state.deinit(); state.deinit();
@ -1075,6 +1078,7 @@ fn playerTurnHandler(arena: std.mem.Allocator, request: Request) HandlerError!Re
return Response{ .transition = .{ return Response{ .transition = .{
.game_state = new_game_state, .game_state = new_game_state,
.can_undo = true, .can_undo = true,
.reset_selection = false,
} }; } };
} }
} }