2020-11-16 02:02:35 +00:00
|
|
|
package modal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
|
|
|
"git.kirsle.net/apps/doodle/pkg/log"
|
|
|
|
"git.kirsle.net/go/ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Alert pops up an alert box modal.
|
|
|
|
func Alert(message string, args ...interface{}) *Modal {
|
|
|
|
if !ready {
|
|
|
|
panic("modal.Alert(): not ready")
|
|
|
|
} else if current != nil {
|
|
|
|
return current
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset the supervisor.
|
|
|
|
supervisor = ui.NewSupervisor()
|
|
|
|
|
|
|
|
m := &Modal{
|
|
|
|
title: "Alert",
|
|
|
|
message: fmt.Sprintf(message, args...),
|
|
|
|
}
|
|
|
|
m.window = makeAlert(m)
|
|
|
|
|
|
|
|
center(m.window)
|
|
|
|
current = m
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// alertWindow creates the ui.Window for the Alert modal.
|
|
|
|
func makeAlert(m *Modal) *ui.Window {
|
|
|
|
win := ui.NewWindow("Alert")
|
|
|
|
_, title := win.TitleBar()
|
|
|
|
title.TextVariable = &m.title
|
|
|
|
|
|
|
|
msgFrame := ui.NewFrame("Alert Message")
|
|
|
|
win.Pack(msgFrame, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
})
|
|
|
|
|
|
|
|
msg := ui.NewLabel(ui.Label{
|
|
|
|
TextVariable: &m.message,
|
|
|
|
Font: balance.UIFont,
|
|
|
|
})
|
|
|
|
msgFrame.Pack(msg, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
})
|
|
|
|
|
|
|
|
button := ui.NewButton("Ok Button", ui.NewLabel(ui.Label{
|
|
|
|
Text: "Ok",
|
|
|
|
Font: balance.MenuFont,
|
|
|
|
}))
|
WIP Publish Dialog + UI Improvements
* File->Publish Level in the Level Editor opens the Publish window,
where you can embed custom doodads into your level and export a
portable .level file you can share with others.
* Currently does not actually export a level file yet.
* The dialog lists all unique doodad names in use in your level, and
designates which are built-ins and which are custom (paginated).
* A checkbox would let the user embed built-in doodads into their level,
as well, locking it in to those versions and not using updated
versions from future game releases.
UI Improvements:
* Added styling for a "Primary" UI button, rendered in deep blue.
* Pop-up modals (Alert, Confirm) color their Ok button as Primary.
* The Enter key pressed during an Alert or Confirm modal will invoke its
default button and close the modal, corresponding to its Primary
button.
* The developer console is now opened with the tilde/grave key ` instead
of the Enter key, so that the Enter key is free to click through
modals.
* In the "Open/Edit Drawing" window, a "Browse..." button is added to
the level and doodad sections, spawning a native File Open dialog to
pick a .level or .doodad outside the config root.
2021-06-11 05:31:30 +00:00
|
|
|
button.SetStyle(&balance.ButtonPrimary)
|
2020-11-16 02:02:35 +00:00
|
|
|
button.Handle(ui.Click, func(ev ui.EventData) error {
|
|
|
|
log.Info("clicked!")
|
|
|
|
m.Dismiss(true)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
win.Pack(button, ui.Pack{
|
|
|
|
Side: ui.N,
|
|
|
|
PadY: 4,
|
|
|
|
})
|
|
|
|
|
|
|
|
button.Compute(engine)
|
|
|
|
supervisor.Add(button)
|
|
|
|
|
|
|
|
win.Compute(engine)
|
|
|
|
win.Supervise(supervisor)
|
|
|
|
|
|
|
|
return win
|
|
|
|
}
|