Documentation ¶
Overview ¶
Package native provides native system functions for Linux, MacOS and Windows to perform operating system-specific tasks such as open web links or native dialog boxes.
Index ¶
- Variables
- func CopyToClipboard(text string) error
- func DefaultAuthor() string
- func HasTouchscreen(e render.Engine) bool
- func OpenFile(title string, filter string) (string, error)
- func OpenLocalURL(path string)
- func OpenURL(url string)
- func SaveFile(title string, filter string) (string, error)
- func TextToImage(e render.Engine, text render.Text) (image.Image, error)
Constants ¶
This section is empty.
Variables ¶
var ( // This is set to True when a file dialog driver is available. // If false, a fallback uses the developer shell Prompt() // to ask for a file name. FileDialogsReady bool )
FileDialog common variables.
var USER string = os.Getenv("USER")
Functions ¶
func CopyToClipboard ¶
CopyToClipboard puts some text on your clipboard.
func DefaultAuthor ¶
func DefaultAuthor() string
DefaultAuthor will return the local user's name to be the default Author for levels and doodads they create.
If they have registered the game, use the name from their license JWT token.
Otherwise fall back to their native operating system user.
func HasTouchscreen ¶
HasTouchscreen checks if the device has at least one SDL_GetNumTouchDevices.
func OpenFile ¶
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 OpenLocalURL ¶
func OpenLocalURL(path string)
OpenLocalURL opens a web browser to a local HTML path. It converts a relative path like "guidebook/index.html" to its absolute filesystem location.
func OpenURL ¶
func OpenURL(url string)
OpenURL opens a web browser to the given URL.
On Linux this will look for xdg-open or try a few common browser names. On Windows this uses the “start“ command. On MacOS this uses the “open“ command.
func SaveFile ¶
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 TextToImage ¶
TextToImage takes an SDL2_TTF texture and makes it into a Go image.
Notes: - The text is made Black & White with a white background on the image. - Drop shadow, stroke, etc. probably not supported. - Returns a non-antialiased image.
Types ¶
This section is empty.