Render the board with the completed game state.
This commit is contained in:
parent
d15613c40e
commit
045daea774
|
@ -44,7 +44,7 @@ use gtk::{
|
||||||
subclass::prelude::*,
|
subclass::prelude::*,
|
||||||
};
|
};
|
||||||
use image::io::Reader as ImageReader;
|
use image::io::Reader as ImageReader;
|
||||||
use otg_core::Color;
|
use otg_core::{Color, Coordinate};
|
||||||
use std::{cell::RefCell, io::Cursor, rc::Rc};
|
use std::{cell::RefCell, io::Cursor, rc::Rc};
|
||||||
|
|
||||||
const WIDTH: i32 = 800;
|
const WIDTH: i32 = 800;
|
||||||
|
@ -178,11 +178,24 @@ impl Goban {
|
||||||
);
|
);
|
||||||
let _ = ctx.stroke();
|
let _ = ctx.stroke();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// This doesn't work except on 19x19 boads. This code needs to be adjusted to at least
|
||||||
|
// handle 13x13 and 9x9. Non-standard boards are On Their Own (TM).
|
||||||
vec![3, 9, 15].into_iter().for_each(|col| {
|
vec![3, 9, 15].into_iter().for_each(|col| {
|
||||||
vec![3, 9, 15].into_iter().for_each(|row| {
|
vec![3, 9, 15].into_iter().for_each(|row| {
|
||||||
pen.star_point(ctx, col, row);
|
pen.star_point(ctx, col, row);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
(0..board.size.height).for_each(|row| {
|
||||||
|
(0..board.size.width).for_each(|column| {
|
||||||
|
match board.stone(&Coordinate{ row, column }) {
|
||||||
|
None => {},
|
||||||
|
Some(Color::White) => pen.stone(ctx, row, column, Color::White, None),
|
||||||
|
Some(Color::Black) => pen.stone(ctx, row, column, Color::Black, None),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,12 @@ impl GameReview {
|
||||||
pub fn new(api: CoreApi, record: GameRecord) -> Self {
|
pub fn new(api: CoreApi, record: GameRecord) -> Self {
|
||||||
let s: Self = Object::builder().build();
|
let s: Self = Object::builder().build();
|
||||||
|
|
||||||
let board_repr = otg_core::Goban::default();
|
// It's actually really bad to be just throwing away errors. Panics make everyone unhappy.
|
||||||
|
// This is not a fatal error, so I'll replace this `unwrap` call with something that
|
||||||
|
// renders the board and notifies the user of a problem that cannot be resolved.
|
||||||
|
let board_repr = otg_core::Goban::default().apply_moves(record.mainline()).unwrap();
|
||||||
|
let board = Goban::new(board_repr);
|
||||||
|
|
||||||
let board = Goban::new(otg_core::Goban::default());
|
|
||||||
/*
|
/*
|
||||||
s.attach(&board, 0, 0, 2, 2);
|
s.attach(&board, 0, 0, 2, 2);
|
||||||
s.attach(>k::Label::new(Some("white player")), 0, 2, 1, 1);
|
s.attach(>k::Label::new(Some("white player")), 0, 2, 1, 1);
|
||||||
|
|
Loading…
Reference in New Issue