printTreeRecursive uses g.children
This commit is contained in:
parent
472af504e8
commit
b52ff1164c
3 changed files with 8 additions and 9 deletions
|
@ -18,8 +18,10 @@ func init() {
|
|||
|
||||
// DrawDFS is a DrawManager that does not add any structure. Components are
|
||||
// drawn in the order in which they are encountered by a depth-first search
|
||||
// through the game tree, without any extra sorting based on Z values or
|
||||
// consideration for DrawOrderer).
|
||||
// through the game tree using Scan, without any extra sorting based on Z values
|
||||
// or consideration for DrawOrderer. Also, children registered in Game but not
|
||||
// registered by subcomponents (such that they are visited with Scan) won't be
|
||||
// drawn.
|
||||
type DrawDFS struct {
|
||||
Child interface{}
|
||||
Hides
|
||||
|
|
|
@ -201,7 +201,7 @@ func (g *Game) Scan(visit VisitFunc) error {
|
|||
}
|
||||
|
||||
// Load loads a component and all subcomponents recursively.
|
||||
// Note that this method does not implement Loader.
|
||||
// Note that this method does not implement Loader itself.
|
||||
func (g *Game) Load(component interface{}, assets fs.FS) error {
|
||||
if l, ok := component.(Loader); ok {
|
||||
if err := l.Load(assets); err != nil {
|
||||
|
@ -217,7 +217,7 @@ func (g *Game) Load(component interface{}, assets fs.FS) error {
|
|||
}
|
||||
|
||||
// Prepare prepares a component and all subcomponents recursively.
|
||||
// Note that this method does not implement Prepper.
|
||||
// Note that this method does not implement Prepper itself.
|
||||
func (g *Game) Prepare(component interface{}) error {
|
||||
// Postorder traversal, in case ancestors depend on descendants being
|
||||
// ready to answer queries.
|
||||
|
|
|
@ -102,11 +102,8 @@ func (g *Game) printTreeRecursive(dst io.Writer, depth int, c interface{}) {
|
|||
} else {
|
||||
fmt.Fprintf(dst, "%s%v\n", indent, c)
|
||||
}
|
||||
if sc, ok := c.(Scanner); ok {
|
||||
sc.Scan(func(x interface{}) error {
|
||||
g.printTreeRecursive(dst, depth+1, x)
|
||||
return nil
|
||||
})
|
||||
for x := range g.children[c] {
|
||||
g.printTreeRecursive(dst, depth+1, x)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue