wip 2 pointifying

This commit is contained in:
2026-08-11 01:02:38 -05:00
parent 3b5bf21ac5
commit 38c58a2c5f
25 changed files with 163 additions and 309 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ impl EditorState {
/// cursor, applying the placement rules (see [`Board::place_archetype`]).
pub(crate) fn place_current(&mut self) {
let (x, y) = (self.cursor.0 as usize, self.cursor.1 as usize);
let res = self.board_mut().place(x, y, Some(TileSpec::Builtin { kind: self.current_archetype.to_string(), glyph: Some(self.current_glyph) }));
let res = self.board_mut().place((x, y), Some(TileSpec::Builtin { kind: self.current_archetype.to_string(), glyph: Some(self.current_glyph) }));
if let Err(e) = res {
self.log.push(LogLine::error(e))
}
+3 -3
View File
@@ -35,8 +35,8 @@ 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 (x, y) = board.player_pos();
let focus = (x as i32, y as i32);
let p = board.player_pos();
let focus = (p.x as i32, p.y as i32);
Self { board, focus, fov: None }
}
@@ -155,7 +155,7 @@ impl Widget for BoardWidget<'_> {
let visible = self.fov.is_none_or(|l| l.is_visible(bx, by));
if let Some(cell) = buf.cell_mut((sx, sy)) {
if visible {
let glyph = board.glyph_at(bx, by);
let glyph = board.glyph_at((bx, by));
// Modulate by lighting when the board is dark; pass through otherwise.
let (fg, bg) = match self.fov {
Some(l) => (l.tint(bx, by, glyph.fg), l.tint(bx, by, glyph.bg)),
+5 -5
View File
@@ -117,8 +117,8 @@ impl Widget for SpeechBubblesWidget<'_> {
let (px, py, player_vis) = board_screen_pos(
area,
self.board,
player.0,
player.1,
player.ux(),
player.uy(),
);
let player = player_vis.then_some((px, py));
@@ -128,7 +128,7 @@ impl Widget for SpeechBubblesWidget<'_> {
.iter()
.filter_map(|b| {
let obj = self.board.get_hookable(b.object_id)?;
let (x, y) = obj.location();
let (x, y) = obj.location().into();
let (sx, sy, on_screen) = board_screen_pos(area, self.board, x, y);
// On a dark board, a speaker the player can't see is treated like an
// off-screen speaker: the box still draws, but its tail is suppressed.
@@ -426,8 +426,8 @@ fn center_top(obj_sy: u16, box_h: u16, area: Rect) -> u16 {
/// `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 player = board.player_pos();
let (off_x, pad_x, _) = BoardWidget::axis(board.width, area.width as usize, player.0 as i32);
let (off_y, pad_y, _) = BoardWidget::axis(board.height, area.height as usize, player.1 as i32);
let (off_x, pad_x, _) = BoardWidget::axis(board.width, area.width as usize, player.x as i32);
let (off_y, pad_y, _) = BoardWidget::axis(board.height, area.height as usize, 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;