joelschutz / stagehand

The only scene manager you will ever need for Ebitengine
MIT License
25 stars 5 forks source link

FinalScreenDrawer is not called #10

Open sedyh opened 1 month ago

sedyh commented 1 month ago

It is necessary to call interfaces that game can optionally implement, like FinalScreenDrawer.

func (s *SceneManager[T]) Update() error {
    return s.current.Update()
}

func (s *SceneManager[T]) Draw(screen *ebiten.Image) {
    s.current.Draw(screen)
}

func (s *SceneManager[T]) Layout(w, h int) (int, int) {
    return s.current.Layout(w, h)
}

I've implemented quick fix for this:

func (s *SceneManager[T]) DrawFinalScreen(screen ebiten.FinalScreen, offscreen *ebiten.Image, geoM ebiten.GeoM) {
    if v, ok := s.current.(ebiten.FinalScreenDrawer); ok {
        v.DrawFinalScreen(screen, offscreen, geoM)
        return
    }
    screen.DrawImage(offscreen, nil)
}

However, there are still some bugs with it. Like it turns off just before the transition.

joelschutz commented 3 weeks ago

What is the purpose of this interface?

joelschutz commented 3 weeks ago

I had missed this interface. This easy to add, will do it as soon as possible. Never even knew this interface existed and what is used for.

sedyh commented 3 weeks ago

What is the purpose of this interface?

This is workaround in order to solve the problem of drawing a shader on the same input and output image (otherwise we will get a panic due to some implementation features).

This easy to add, will do it as soon as possible.

Thanks. However, I'm not so sure about this. It should be tricky cause it exposes some scaling internals. As far as I remember, noppikinatta had to push to fix the existing ebitentine api for this. https://github.com/hajimehoshi/ebiten/issues/3139