2020-05-11 09:44:50 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
type Dialogs struct {
|
|
|
|
Proxy
|
|
|
|
|
|
|
|
intro Control
|
|
|
|
settings Control
|
2020-05-12 07:11:27 +00:00
|
|
|
research Control
|
2020-05-11 09:44:50 +00:00
|
|
|
|
|
|
|
dialogClosed *Events
|
|
|
|
dialogOpened *Events
|
|
|
|
}
|
|
|
|
|
2020-05-12 07:11:27 +00:00
|
|
|
func NewDialogs(game *Game) *Dialogs {
|
2020-05-11 09:44:50 +00:00
|
|
|
return &Dialogs{
|
2020-05-12 07:11:27 +00:00
|
|
|
intro: &Intro{},
|
|
|
|
settings: &LargeDialog{},
|
|
|
|
research: NewResearch(game),
|
|
|
|
|
2020-05-11 09:44:50 +00:00
|
|
|
dialogClosed: NewEvents(),
|
|
|
|
dialogOpened: NewEvents(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-12 07:11:27 +00:00
|
|
|
func (d *Dialogs) showDialog(ctx *Context, control Control) {
|
|
|
|
d.SetContent(ctx, control)
|
|
|
|
control.(Dialog).ShowDialog(ctx, d.Close)
|
|
|
|
d.dialogOpened.Notify(nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Dialogs) Arrange(ctx *Context, bounds Rectangle) {
|
|
|
|
d.Proxy.Arrange(ctx, bounds)
|
|
|
|
}
|
|
|
|
|
2020-05-11 09:44:50 +00:00
|
|
|
func (d *Dialogs) DialogClosed() EventHandler { return d.dialogClosed }
|
|
|
|
func (d *Dialogs) DialogOpened() EventHandler { return d.dialogOpened }
|
|
|
|
|
|
|
|
func (d *Dialogs) Init(ctx *Context) error {
|
|
|
|
err := d.intro.Init(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = d.settings.Init(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-05-12 07:11:27 +00:00
|
|
|
err = d.research.Init(ctx)
|
2020-05-11 09:44:50 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Dialogs) Close() {
|
2020-05-12 07:11:27 +00:00
|
|
|
d.SetContent(nil, nil)
|
2020-05-11 09:44:50 +00:00
|
|
|
d.dialogClosed.Notify(nil)
|
|
|
|
}
|
|
|
|
|
2020-05-12 07:11:27 +00:00
|
|
|
func (d *Dialogs) ShowIntro(ctx *Context) {
|
|
|
|
d.showDialog(ctx, d.intro)
|
2020-05-11 09:44:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-12 07:11:27 +00:00
|
|
|
func (d *Dialogs) ShowResearch(ctx *Context) {
|
|
|
|
d.showDialog(ctx, d.research)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Dialogs) ShowSettings(ctx *Context) {
|
|
|
|
d.showDialog(ctx, d.settings)
|
2020-05-11 09:44:50 +00:00
|
|
|
}
|