resources

package
v0.3.1-0...-ca91996 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 2 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionIndex

type CollectionIndex int

CollectionIndex indexes all resource collections of a module.

type Provider

type Provider interface {
	// GetResources returns the list of available resources of the given
	// resource collection index.
	//
	// The resources are filtered by the currently active system, group and scene.
	// Each Resource object is read-only and may be freely shared between threads.
	GetResources(index CollectionIndex) []Resource
	// GetTextures returns the list of available textures.
	GetTextures() []Resource
	// NumFontFamilies returns the number of available font families.
	NumFontFamilies() int
	// FontFamilyName returns the name of the font family at the given index.
	FontFamilyName(index int) string
}

Provider is the interface for querying resources.

type Resource

type Resource struct {
	// Name of the resource as it should be presented to the user.
	Name string
	// Location of the resource. For files from the file system, the URL will have
	// file:// schema and is relative to the server, i.e. must not be resolved in
	// the web UI.
	//
	// Is a pointer because of package url's interface, must not be nil.
	Location *url.URL
}

Resource describes a selectable resource file.

func (*Resource) MarshalJSON

func (r *Resource) MarshalJSON() ([]byte, error)

MarshalJSON marshals the resource's location as a simple string, to be parsed as URL again.

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(b []byte) error

UnmarshalJSON loads the location into a string and then parses it as URL.

type Selector

type Selector struct {
	// may be empty, in which case resource files are searched directly
	// in the module directories.
	Subdirectory string
	// Name of the file including suffix. If not empty, only the first file
	// matching the name is returned.
	Name string
	// filters files by suffix. If empty or nil, no filter will be applied
	// (note however that files starting with a dot will always be filtered out).
	// ignored if Name is not empty.
	Suffixes []string
}

Selector defines where a module finds resource files. A selector can either be used to find one specific file (in which case Name must be non-empty) or a list of files (in which case Name must be empty and Suffixes may be set).

The file(s) are searched in the Subdirectory inside the module's directory in the current scene, group, system and base directory (in that order).

Jump to

Keyboard shortcuts

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