app

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default configuration file.
	ConfigFile = "erago.conf"

	DefaultBaseDir = erago.DefaultBaseDir

	LogFileStdOut  = "stdout"    // specify log outputs to stdout
	LogFileStdErr  = "stderr"    // specify log outputs to stderr
	DefaultLogFile = "erago.log" // default output log file.

	LogLevelInfo  = "info"  // logging only information level.
	LogLevelDebug = "debug" // logging all levels, debug and info.

	DefaultFont     = theme.DefaultFontName // font file. empty means use builtin font.
	DefaultFontSize = 12.0                  // font size in pt

	DefaultWidth  = 800 // initial window width
	DefaultHeight = 600 // initial window height
)

Variables

View Source
var ErrDefaultConfigGenerated error = errors.New("default config generated")

ErrDefaultConfigGenerated implies that the specified config file is not found, and intead of that default config is generated and used.

Functions

func BuildTheme

func BuildTheme(appConf *Config) (*theme.Theme, error)

build new theme according to application configure.

func DPI

func DPI(pixelsPerPt float32) float64

func Main

func Main(title string, appConf *Config)

entry point of main application. appconf nil is OK, use default if it is. its internal errors are handled by itself.

func Testing

func Testing(appConf *Config, scriptFiles []string)

Testing test given script files on appConf context. the errors in testing are logged to appConf.LogFile.

Types

type Config

type Config struct {
	LogFile  string `toml:"logfile"`
	LogLevel string `toml:"loglevel"`

	Font     string  `toml:"font"`     // path for fontfile. empty means that use builtin font.
	FontSize float64 `toml:"fontsize"` // font size in pt.

	Width  int `toml:"width"`  // initial window width.
	Height int `toml:"height"` // initial window height.

	Game erago.Config `toml:"game"`
}

Configure for the Applicaltion. To build this, use NewConfig instead of struct constructor, AppConfig{}.

func LoadConfigOrDefault

func LoadConfigOrDefault(file string) (*Config, error)

if config file exists load it and return. if not exists return default config and write it.

func NewConfig

func NewConfig(baseDir string) *Config

return default App config. if baseDir is empty use default insteadly.

type FpsLimitter

type FpsLimitter struct {
	EventDeque screen.EventDeque

	FPS int // zero FPS means no limit fps.
	// contains filtered or unexported fields
}

fpsLimitter limits and delays paint events to not exceed over specified fps. To construct this:

fps := FpsLimitter{EventDeque: deque, FPS: fps}

zero value is invalid.

func (*FpsLimitter) Filter

func (l *FpsLimitter) Filter(ev interface{}) interface{}

Filter handles paint event to limits fps. if paint event is delayed, return type paintSchedule and consume paint event. other events are returned itself.

type ModelErrorFilter

type ModelErrorFilter struct {
	// contains filtered or unexported fields
}

ModelErrorFilter filters ui.EragoPresenter's ModelError.

func (ModelErrorFilter) Err

func (me ModelErrorFilter) Err() error

return internal error. it is valid when model error is arrived.

func (*ModelErrorFilter) Filter

func (me *ModelErrorFilter) Filter(e interface{}) interface{}

type PaintScheduled

type PaintScheduled struct{}

paintSchedule notifies setting a new schedule which sends paint event after some time.

type UI

type UI struct {
	node.ShellEmbed

	// These Backgrounds fill each widgets by background color.
	// To change color you can modify XXXBackground.ThemeColor.
	CmdLineBackground *widget.Uniform
	// contains filtered or unexported fields
}

UI is mixture of widgets in ui package.

func NewUI

func NewUI(presenter *ui.EragoPresenter) *UI

construct standard UI node tree for the era application.

func (UI) Editor

func (ui UI) Editor() uiadapter.UI

return erago/uiadapter.UI interface.

func (*UI) OnLifecycleEvent

func (ui *UI) OnLifecycleEvent(e lifecycle.Event)

implement node.Node interface.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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