visual

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package visual implements the graphical interface for Spy Cards Online.

Index

Constants

This section is empty.

Variables

View Source
var (
	AsNPC     string
	VersusNPC string
)

Functions

func Loop added in v0.2.78

func Loop(ctx context.Context, looper interface {
	Resize(context.Context) error
	Update(context.Context) error
	Render(context.Context) error
}) error

Loop handles the graphical loop, running Update every 1/60th of a second, and Render every graphical frame. If the loop gets too backlogged, it will drop frames rather than building up pending frames infinitely.

Resize is called once at the start, then once every time the screen resolution changes.

Types

type Card

type Card struct {
	*match.Card
	Active *match.ActiveCard
	ModTP  int64
	// contains filtered or unexported fields
}

func (*Card) Flip

func (c *Card) Flip()

Flip flips the card from face-up to face-down or vice versa.

func (*Card) IsFlip

func (c *Card) IsFlip() bool

IsFlip returns true if the card is face-down.

func (*Card) Render

func (c *Card) Render(ctx context.Context, cam *gfx.Camera, highlightEffect *card.EffectDef)

Render draws a card to the screen.

func (*Card) SetFlip

func (c *Card) SetFlip(down bool)

SetFlip flips the card to a specified side.

type CardEditor added in v0.2.77

type CardEditor struct {
	OnExit func()

	Set card.Set
	// contains filtered or unexported fields
}

func (*CardEditor) EncodeCards added in v0.2.77

func (e *CardEditor) EncodeCards() string

func (*CardEditor) Render added in v0.2.78

func (e *CardEditor) Render(ctx context.Context) error

func (*CardEditor) Resize added in v0.2.81

func (e *CardEditor) Resize(ctx context.Context) error

func (*CardEditor) SetCards added in v0.2.77

func (e *CardEditor) SetCards(ctx context.Context, cards string) error

func (*CardEditor) ShowCard added in v0.3.1

func (e *CardEditor) ShowCard(ctx context.Context, c *card.Def)

func (*CardEditor) ShowMain added in v0.3.1

func (e *CardEditor) ShowMain(ctx context.Context)

func (*CardEditor) ShowMode added in v0.3.1

func (e *CardEditor) ShowMode(ctx context.Context)

func (*CardEditor) Update added in v0.2.78

func (e *CardEditor) Update(ctx context.Context) error

type DeckBuilder

type DeckBuilder struct {
	IsEditor  *Visual
	Confirmed bool
	// contains filtered or unexported fields
}

DeckBuilder constructs or edits a deck.

func NewDeckBuilder

func NewDeckBuilder(ctx context.Context, set *card.Set) *DeckBuilder

NewDeckBuilder creates a deck builder.

func (*DeckBuilder) Render

func (d *DeckBuilder) Render(ctx context.Context)

Render draws the deck builder to the screen.

func (*DeckBuilder) Update

func (d *DeckBuilder) Update(ctx context.Context)

Update processes one frame of input.

type DeckPicker

type DeckPicker struct {
	AllowCreate bool
	IsEditor    *Visual
	Selected    card.Deck
	// contains filtered or unexported fields
}

func NewDeckPicker

func NewDeckPicker(ctx context.Context, set *card.Set) *DeckPicker

func (*DeckPicker) Populate

func (d *DeckPicker) Populate()

func (*DeckPicker) Render

func (d *DeckPicker) Render(ctx context.Context)

func (*DeckPicker) Update

func (d *DeckPicker) Update(ctx context.Context)

type Layout

type Layout struct {
	Cards []*Card

	MinPerRow int
	MaxPerRow int
	OnSelect  func(*Card)
	gui.FocusHandler
	MinScale       float32
	BaseScale      float32
	MaxScale       float32
	HoverScale     float32
	MarginTop      float32
	MarginLeft     float32
	MarginBottom   float32
	MarginRight    float32
	PaddingX       float32
	PaddingY       float32
	ScrollPadding  float32
	GrowDx, GrowDy float32

	CenterLastRow bool
	AllowScroll   bool
	Reverse       bool
	PinCorner     uint8
	Slide         bool
	SquishY       bool
	// contains filtered or unexported fields
}

Layout handles arranging a grid of cards on the screen.

func NewLayout

func NewLayout(ctx context.Context) *Layout

NewLayout creates a new card layout.

func (*Layout) Focus

func (l *Layout) Focus()

Focus attaches the input focus to this Layout.

func (*Layout) Render

func (l *Layout) Render(ctx context.Context, pass int)

Render draws the card layout to the screen.

func (*Layout) Update

func (l *Layout) Update(modTP map[card.ID]int64)

Update processes one frame of input.

type State added in v0.3.1

type State uint64
const (
	StateHome State = iota
	StateConnecting
	StateWait
	StateMatchmakingWait
	StateCharacterSelect
	StateDeckSelect
	StateReadyToStart
	StateNextRound
	StateNextRoundWait
	StateTurnSelect
	StateTurnProcess
	StateTurnEnd
	StateMatchCompleteWait
	StateMatchComplete
	StatePlaybackInit
	StatePlaybackIdle
	StatePlaybackNext
	StatePlaybackTurnWait
	StateInCardEditor
	StateSelectMode
	StateSettings
	StateSpoilerGuard
	StateDeckEditor
)

func (State) String added in v0.3.1

func (i State) String() string

type Visual

type Visual struct {
	State State

	Match *match.Match

	Editor *CardEditor
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, init *match.Init) (*Visual, error)

func (*Visual) InitCardEditor added in v0.3.1

func (v *Visual) InitCardEditor(ctx context.Context, codes string) error

func (*Visual) JoinMatch added in v0.3.1

func (v *Visual) JoinMatch(ctx context.Context, code string) error

func (*Visual) Render

func (v *Visual) Render(ctx context.Context) error

func (*Visual) Resize added in v0.2.81

func (v *Visual) Resize(ctx context.Context) error

func (*Visual) SetDeck added in v0.3.1

func (v *Visual) SetDeck(ctx context.Context, code string) error

func (*Visual) SetRecording

func (v *Visual) SetRecording(ctx context.Context, code string) error

func (*Visual) Update

func (v *Visual) Update(ctx context.Context) error

Jump to

Keyboard shortcuts

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