nothing should care about tombstone other than Game
This commit is contained in:
parent
dd889e17a0
commit
3d9c1aae3b
2 changed files with 16 additions and 6 deletions
|
@ -40,9 +40,9 @@ func (d *DebugToast) Draw(screen *ebiten.Image, _ *ebiten.DrawImageOptions) {
|
||||||
ebitenutil.DebugPrintAt(screen, d.Text, d.Pos.X, d.Pos.Y)
|
ebitenutil.DebugPrintAt(screen, d.Text, d.Pos.X, d.Pos.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw last, but sort tombstones later.
|
// Draw last.
|
||||||
func (DebugToast) DrawAfter(x Drawer) bool { return x != tombstone{} }
|
func (DebugToast) DrawAfter(Drawer) bool { return true }
|
||||||
func (DebugToast) DrawBefore(x Drawer) bool { return x == tombstone{} }
|
func (DebugToast) DrawBefore(Drawer) bool { return false }
|
||||||
|
|
||||||
func (d *DebugToast) Toast(text string) {
|
func (d *DebugToast) Toast(text string) {
|
||||||
d.Text = text
|
d.Text = text
|
||||||
|
@ -66,6 +66,6 @@ func (p PerfDisplay) Draw(screen *ebiten.Image, _ *ebiten.DrawImageOptions) {
|
||||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f FPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f FPS: %0.2f", ebiten.CurrentTPS(), ebiten.CurrentFPS()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw last, but sort tombstones later.
|
// Draw last.
|
||||||
func (PerfDisplay) DrawAfter(x Drawer) bool { return x != tombstone{} }
|
func (PerfDisplay) DrawAfter(Drawer) bool { return true }
|
||||||
func (PerfDisplay) DrawBefore(x Drawer) bool { return x == tombstone{} }
|
func (PerfDisplay) DrawBefore(Drawer) bool { return false }
|
||||||
|
|
|
@ -436,6 +436,16 @@ func (tombstone) DrawBefore(Drawer) bool { return false }
|
||||||
type drawList []Drawer
|
type drawList []Drawer
|
||||||
|
|
||||||
func (d drawList) Less(i, j int) bool {
|
func (d drawList) Less(i, j int) bool {
|
||||||
|
// Ideally other components wouldn't need to know about tombstones. So
|
||||||
|
// skip evaluating before/after for them.
|
||||||
|
if d[i] == (tombstone{}) {
|
||||||
|
// tombstones are not less than anything
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if d[j] == (tombstone{}) {
|
||||||
|
// non-tombstones are less than tombstones
|
||||||
|
return true
|
||||||
|
}
|
||||||
return d[i].DrawBefore(d[j]) || d[j].DrawAfter(d[i])
|
return d[i].DrawBefore(d[j]) || d[j].DrawAfter(d[i])
|
||||||
}
|
}
|
||||||
func (d drawList) Len() int { return len(d) }
|
func (d drawList) Len() int { return len(d) }
|
||||||
|
|
Loading…
Reference in a new issue