Set up the game review page along with #229
|
@ -354,7 +354,7 @@ impl<T> Tree<T> {
|
||||||
width
|
width
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bfs_iter<'a>(&'a self) -> BFSIter<T> {
|
pub fn bfs_iter(&self) -> BFSIter<T> {
|
||||||
let mut queue = VecDeque::new();
|
let mut queue = VecDeque::new();
|
||||||
queue.push_back(&self.nodes[0]);
|
queue.push_back(&self.nodes[0]);
|
||||||
BFSIter { tree: self, queue }
|
BFSIter { tree: self, queue }
|
||||||
|
@ -363,7 +363,7 @@ impl<T> Tree<T> {
|
||||||
|
|
||||||
impl<'a> From<&'a GameNode> for Tree<Uuid> {
|
impl<'a> From<&'a GameNode> for Tree<Uuid> {
|
||||||
fn from(root: &'a GameNode) -> Self {
|
fn from(root: &'a GameNode) -> Self {
|
||||||
fn add_subtree<'a>(tree: &mut Tree<Uuid>, parent_idx: usize, node: &'a GameNode) {
|
fn add_subtree(tree: &mut Tree<Uuid>, parent_idx: usize, node: &GameNode) {
|
||||||
let idx = tree.add_node(parent_idx, node.id());
|
let idx = tree.add_node(parent_idx, node.id());
|
||||||
|
|
||||||
let children = match node {
|
let children = match node {
|
||||||
|
@ -401,7 +401,7 @@ impl<'a, T> Iterator for BFSIter<'a, T> {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let retval = self.queue.pop_front();
|
let retval = self.queue.pop_front();
|
||||||
if let Some(ref retval) = retval {
|
if let Some(retval) = retval {
|
||||||
retval
|
retval
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -18,7 +18,7 @@ use cairo::Context;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{prelude::*, subclass::prelude::*};
|
use gtk::{prelude::*, subclass::prelude::*};
|
||||||
use otg_core::Tree;
|
use otg_core::Tree;
|
||||||
use sgf::{GameNode, GameRecord};
|
use sgf::GameRecord;
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl GameRecord {
|
||||||
pub fn mainline(&self) -> Vec<&GameNode> {
|
pub fn mainline(&self) -> Vec<&GameNode> {
|
||||||
let mut moves: Vec<&GameNode> = vec![];
|
let mut moves: Vec<&GameNode> = vec![];
|
||||||
|
|
||||||
let mut next = self.children.get(0);
|
let mut next = self.children.first();
|
||||||
while let Some(node) = next {
|
while let Some(node) = next {
|
||||||
// Given that I know that I have a node, and I know that I'm going to push a reference
|
// Given that I know that I have a node, and I know that I'm going to push a reference
|
||||||
// to it onto my final list, I want to get the first of its children. And I want to
|
// to it onto my final list, I want to get the first of its children. And I want to
|
||||||
|
@ -136,8 +136,8 @@ impl GameRecord {
|
||||||
moves.push(node);
|
moves.push(node);
|
||||||
|
|
||||||
next = match node {
|
next = match node {
|
||||||
GameNode::MoveNode(node) => node.children.get(0),
|
GameNode::MoveNode(node) => node.children.first(),
|
||||||
GameNode::SetupNode(node) => node.children.get(0),
|
GameNode::SetupNode(node) => node.children.first(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue