mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
audio: AppendHookOnBeforeUpdate should treat multiple calbacks
This commit is contained in:
parent
31758bf3ab
commit
2b7705e7ad
@ -44,7 +44,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type dummyHook struct {
|
type dummyHook struct {
|
||||||
update func() error
|
updates []func() error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *dummyHook) OnSuspendAudio(f func()) {
|
func (h *dummyHook) OnSuspendAudio(f func()) {
|
||||||
@ -54,7 +54,7 @@ func (h *dummyHook) OnResumeAudio(f func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *dummyHook) AppendHookOnBeforeUpdate(f func() error) {
|
func (h *dummyHook) AppendHookOnBeforeUpdate(f func() error) {
|
||||||
h.update = f
|
h.updates = append(h.updates, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -62,5 +62,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateForTesting() error {
|
func UpdateForTesting() error {
|
||||||
return hookForTesting.(*dummyHook).update()
|
for _, f := range hookForTesting.(*dummyHook).updates {
|
||||||
|
if err := f(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user