doodle/pkg/native/file_dialog_native.go
Noah Petherbridge 1a9706c09f Level Thumbnails on Story Mode Select
* Rework the Story Mode UI to display level thumbnails.
  * Responsive UI: defaults to wide screen mode and shows 3 levels horizontally
    but on narrow/mobile display, shows 2 levels per page in portrait.
  * Add "Tiny" screenshot size (224x126) to fit the Story Mode UI.
  * Make the pager buttons bigger and more touchable.
* Maximize the game window on startup unless the -w option with a specific
  window resolution is provided.
2023-12-09 14:59:31 -08:00

51 lines
1.1 KiB
Go

//go:build !js
// +build !js
package native
import (
"errors"
"github.com/gen2brain/dlgs"
)
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")
}
// 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")
}