2023-12-09 22:59:31 +00:00
|
|
|
//go:build !js
|
2021-06-07 01:59:04 +00:00
|
|
|
// +build !js
|
|
|
|
|
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
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
|
|
|
|
|
|
|
"github.com/gen2brain/dlgs"
|
2021-06-07 01:59:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
FileDialogsReady = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenFile invokes a native File Chooser dialog with the title
|
|
|
|
// and a set of file filters. The filters are a sequence of label
|
|
|
|
// and comma-separated file extensions.
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// OpenFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")
|
|
|
|
func OpenFile(title string, filter string) (string, error) {
|
|
|
|
filename, ok, err := dlgs.File(title, filter, false)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
return filename, nil
|
|
|
|
}
|
|
|
|
return "", errors.New("canceled")
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// SaveFile invokes a native File Chooser dialog with the title
|
|
|
|
// and a set of file filters. The filters are a sequence of label
|
|
|
|
// and comma-separated file extensions.
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
// SaveFile("Pick a file", "Images", "png,gif,jpg", "Audio", "mp3")
|
|
|
|
func SaveFile(title string, filter string) (string, error) {
|
|
|
|
filename, ok, err := dlgs.File(title, filter, false)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
return filename, nil
|
|
|
|
}
|
|
|
|
return "", errors.New("canceled")
|
|
|
|
}
|