// SPDX-License-Identifier: MIT // Copyright (c) 2021 KikooDX // This file is part of [KBLE](https://sr.ht/~kikoodx/kble), which is // MIT licensed. The MIT license requires this copyright notice to be // included in all copies and substantial portions of the software. const std = @import("std"); const expect = std.testing.expect; const movement = @import("movement.zig"); const scaling = @import("scaling.zig"); const Vec2 = @import("vec2.zig"); const Level = @import("level.zig"); pub const ActionCat = enum { none, // do nothing movement, // move and change selection verb, // do stuff with selection scale, // change draw scaling }; pub const Action = struct { category: ActionCat, toggle: bool = false, // bool that can be passed to actions, i.e. exclusive for movement // Only one of these should be set, and only one should be used. function_move: fn (*Vec2, u32, bool) movement.SelectionUpdate = movement.move_left, function_verb: fn (*Level) void = Level.action_delete, function_scale: fn (scaling.scale_type) scaling.scale_type = scaling.scale_reset, }; pub const ActionsDef = .{ .none = Action{ .category = ActionCat.none, }, // Movement. // Left. .move_left = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_left, }, .move_LEFT = Action{ .category = ActionCat.movement, .function_move = movement.move_left, }, // Right. .move_right = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_right, }, .move_RIGHT = Action{ .category = ActionCat.movement, .function_move = movement.move_right, }, // Up. .move_up = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_up, }, .move_UP = Action{ .category = ActionCat.movement, .function_move = movement.move_up, }, // Down. .move_down = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_down, }, .move_DOWN = Action{ .category = ActionCat.movement, .function_move = movement.move_down, }, // Up-left. .move_up_left = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_up_left, }, .move_UP_LEFT = Action{ .category = ActionCat.movement, .function_move = movement.move_up_left, }, // Up-right. .move_up_right = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_up_right, }, .move_UP_RIGHT = Action{ .category = ActionCat.movement, .function_move = movement.move_up_right, }, // Down-left. .move_down_left = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_down_left, }, .move_DOWN_LEFT = Action{ .category = ActionCat.movement, .function_move = movement.move_up_left, }, // Down-right. .move_down_right = Action{ .toggle = true, .category = ActionCat.movement, .function_move = movement.move_down_right, }, .move_DOWN_RIGHT = Action{ .category = ActionCat.movement, .function_move = movement.move_down_right, }, // Scale. .scale_reset = Action{ .category = ActionCat.scale, .function_scale = scaling.scale_reset, }, .scale_up = Action{ .category = ActionCat.scale, .function_scale = scaling.scale_up, }, .scale_down = Action{ .category = ActionCat.scale, .function_scale = scaling.scale_down, }, };