Big API refactor
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct BoardWidget<'a> {
|
||||
impl<'a> BoardWidget<'a> {
|
||||
/// Creates a widget that renders `board`, scrolling to follow the player.
|
||||
pub fn new(board: &'a Board) -> Self {
|
||||
let focus = (board.player.x, board.player.y);
|
||||
let focus = (board.player.x as i32, board.player.y as i32);
|
||||
Self { board, focus }
|
||||
}
|
||||
|
||||
|
||||
@@ -409,8 +409,8 @@ fn center_top(obj_sy: u16, box_h: u16, area: Rect) -> u16 {
|
||||
/// Returns `(sx, sy, on_screen)`. Off-screen coordinates are clamped to the viewport edge;
|
||||
/// `on_screen` is `false` when clamping occurred (tail should be suppressed for that bubble).
|
||||
fn board_screen_pos(area: Rect, board: &Board, bx: usize, by: usize) -> (u16, u16, bool) {
|
||||
let (off_x, pad_x, _) = BoardWidget::axis(board.width, area.width as usize, board.player.x);
|
||||
let (off_y, pad_y, _) = BoardWidget::axis(board.height, area.height as usize, board.player.y);
|
||||
let (off_x, pad_x, _) = BoardWidget::axis(board.width, area.width as usize, board.player.x as i32);
|
||||
let (off_y, pad_y, _) = BoardWidget::axis(board.height, area.height as usize, board.player.y as i32);
|
||||
let raw_sx = area.x as i32 + pad_x as i32 + (bx as i32 - off_x as i32);
|
||||
let raw_sy = area.y as i32 + pad_y as i32 + (by as i32 - off_y as i32);
|
||||
let sx = raw_sx.clamp(area.left() as i32, area.right() as i32 - 1) as u16;
|
||||
|
||||
Reference in New Issue
Block a user