native

package
v0.0.0-...-79996cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
var USER string = os.Getenv("USER")

Functions

func CopyToClipboard

func CopyToClipboard(text string) error

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

func HasTouchscreen(e render.Engine) bool

HasTouchscreen checks if the device has at least one SDL_GetNumTouchDevices.

func OpenFile

func OpenFile(title string, filter string) (string, error)

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

func SaveFile(title string, filter string) (string, error)

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

func TextToImage(e render.Engine, text render.Text) (image.Image, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL