diff --git a/pkg/main_scene.go b/pkg/main_scene.go index f9cec9b..4a00d22 100644 --- a/pkg/main_scene.go +++ b/pkg/main_scene.go @@ -7,6 +7,7 @@ import ( "git.kirsle.net/apps/doodle/pkg/branding" "git.kirsle.net/apps/doodle/pkg/level" "git.kirsle.net/apps/doodle/pkg/log" + "git.kirsle.net/apps/doodle/pkg/modal" "git.kirsle.net/apps/doodle/pkg/native" "git.kirsle.net/apps/doodle/pkg/scripting" "git.kirsle.net/apps/doodle/pkg/uix" @@ -112,10 +113,15 @@ func (s *MainScene) Setup(d *Doodle) error { Name: "Edit a Level", Func: d.GotoLoadMenu, }, - // { - // Name: "Settings", - // Func: d.GotoSettingsMenu, - // }, + { + Name: "Settings", + Func: func() { + log.Error("TEST Alert()") + modal.Alert("Hello world!").then(func() { + d.Flash("Alert has been clicked thru!") + }) + }, + }, } for _, button := range buttons { button := button diff --git a/pkg/modal/modal.go b/pkg/modal/modal.go new file mode 100644 index 0000000..9d14a04 --- /dev/null +++ b/pkg/modal/modal.go @@ -0,0 +1,44 @@ +// Package modal provides global pop-up confirmation modals (Alert, Confirm). +package modal + +import ( + "git.kirsle.net/go/render" + "git.kirsle.net/go/ui" +) + +// Global state variables. +var ( + // Darkening screen that covers the whole window. + screen = *ui.Frame + modalActive bool +) + +func init() { + screen = ui.NewFrame("screen") + screen.SetBackground(render.RGBA(0, 0, 0, 180)) +} + +type Modal struct { + type string + title string + message string +} + +func (m *Modal) Then(fn func) { + +} + +// Present the modal view. +func Present(e render.Engine) { + +} + +// Alert the user to an important message. The callback function is invoked +// after the user confirms the message. +func Alert(message string, v ...interface{}) Modal { + return Modal{ + type: "alert", + title: "Alert!", + message: fmt.Sprintf(message, v...), + } +}