Documentation
¶
Overview ¶
Package pet plays desktop pets on NSGo: a pack's clips, chosen by its rules in Big Blue Fish's format, in a window of the pet's own or in a view of the host's. It ships no pets: the host loads its packs with Load or LoadDir, and owns the windows, menus and lifecycle around them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WindowOptions ¶
func WindowOptions(pack *Pack) desktop.WindowOptions
WindowOptions are those of a window for pack's pet, for desktop.OpenWindow to open with Options.Window: its size, transparent, without a shadow or a taskbar entry, on every workspace and taking the pointer only where it draws.
Types ¶
type ClipView ¶
type ClipView struct {
Pack *Pack
// Clip is the clip's ID, as Play takes, such as Pack.Clips.Idle.
Clip string
Class string
Style core.Style
TestID string
}
ClipView plays one of a pack's clips over and over, muted and contained in its box, as a host's list of pets previews each: in a core.Video, or on Windows in the engine's own decoder, as the pet plays its clips there. A clip the pack lacks shows nothing.
type Context ¶
Context is what weights depend on besides the rules: the local time and what the user is doing.
type Options ¶
type Options struct {
// Window says the pet's scope is a window of its own, sized to the pet, as WindowOptions opens one: Start floats it above the other windows on every workspace and lets the pointer through outside the pet's body, walking clips and drags move it, and PlaceAtCorner puts it on the bottom right of the screen. Without it the pet is a view of its size in the host's layout, which plays every clip where it is.
Window bool
// Menu is what a right click on the pet shows; nil shows nothing.
Menu func() []core.MenuItem
// Context is what the clips' weights depend on besides the time, such as whether the user is coding or working; its Now is the clock's when zero. Nil reads whether an editor or a terminal is the app in front.
Context func() Context
// Rand chooses the clips; nil seeds one from the clock.
Rand *rand.Rand
}
Options are how a host shows a pet.
type Pack ¶
type Pack struct {
// ID is the pet's directory.
ID string `json:"-"`
Name string `json:"name"`
// Group is the submenu the pet is listed in, empty for the top of the list.
Group string `json:"group"`
Width core.Points `json:"width"`
Height core.Points `json:"height"`
// Body is where the pet's body is in its clips, in percent of the frame: only there does the pet take the pointer.
Body struct {
Left, Top, Width, Height float32
} `json:"body"`
EventSeconds int `json:"eventSeconds"`
// Clips are the clips the pet plays by name.
Clips struct {
Greeting string `json:"greeting"`
Exit string `json:"exit"`
Drag string `json:"drag"`
Idle string `json:"idle"`
Daily string `json:"daily"`
DailyHour int `json:"dailyHour"`
} `json:"clips"`
Source string `json:"source"`
License string `json:"license"`
// Base is where the pet's mov and webm directories play from: an "asset:" path in the app's resources or a file path.
Base string `json:"-"`
Policy *Policy `json:"-"`
}
Pack is one pet: its manifest (pet.json) and its clip rules (animations.json, in Big Blue Fish's format).
func Load ¶
Load reads every pet in fsys, each a directory at its top holding pet.json and animations.json, in the order of their IDs; base is where fsys's directories play from, such as "asset:pets" for resources/pets. A pet that fails to load is left out, and the error names each one; the error is nil when every pet loads, and says so when none does.
type Pet ¶
type Pet struct {
// contains filtered or unexported fields
}
Pet is one pet playing in a scope.
func (*Pet) Act ¶
func (p *Pet) Act()
Act plays an event now, and the next one an event interval later.
func (*Pet) Leave ¶
func (p *Pet) Leave(done func())
Leave plays the pet's exit clip and runs done as it ends, or eight seconds later should it never end; done runs once, and a second Leave does nothing. The host closes the pet's window or view in done.
func (*Pet) PlaceAtCorner ¶
func (p *Pet) PlaceAtCorner()
PlaceAtCorner sizes the pet's window for the pet and puts it on the bottom right of the screen, above the Dock or the taskbar; without Options.Window it does nothing.
func (*Pet) Play ¶
Play plays the clip id names, which a host maps its own states to, such as a session running, waiting or done; the pet goes on by its rules once the clip ends. It reports false, playing nothing, for a clip the pack lacks or a pet leaving.
type Policy ¶
type Policy struct {
Rules []Rule
// contains filtered or unexported fields
}
Policy chooses a pet's clips by pool and weight, a port of Big Blue Fish's CompanionAnimationPolicy.
type Rule ¶
type Rule struct {
ID string `json:"Id"`
File string `json:"File"`
Pool string `json:"Pool"`
Weight float64 `json:"Weight"`
NightOnly bool `json:"NightOnly"`
SeasonOnly string `json:"SeasonOnly"`
SummerWeight *float64 `json:"SummerWeight"`
WinterWeight *float64 `json:"WinterWeight"`
MorningWeight *float64 `json:"MorningWeight"`
Meal string `json:"Meal"`
MealBoost float64 `json:"MealBoost"`
Festival string `json:"Festival"`
RadiusDays float64 `json:"RadiusDays"`
FestivalMode string `json:"FestivalMode"`
FestivalWeight float64 `json:"FestivalWeight"`
WorkKind string `json:"WorkKind"`
WorkWeight float64 `json:"WorkWeight"`
MoveKind string `json:"MoveKind"`
HourParity int `json:"HourParity"`
}
Rule is one clip and when it plays, as Big Blue Fish's animations.json describes it.