visual

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 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, bool) 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  card.Number
	// 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 CheapCardSheet added in v0.3.5

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

func NewCheapCardSheet added in v0.3.5

func NewCheapCardSheet() *CheapCardSheet

func (*CheapCardSheet) Ready added in v0.3.5

func (s *CheapCardSheet) Ready(ctx context.Context) bool

func (*CheapCardSheet) Release added in v0.3.5

func (s *CheapCardSheet) Release()

func (*CheapCardSheet) SetCard added in v0.3.5

func (s *CheapCardSheet) SetCard(i int, c *Card)

func (*CheapCardSheet) Sprite added in v0.3.5

func (s *CheapCardSheet) Sprite(i int) *sprites.Sprite

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 InlineLayout added in v0.3.4

type InlineLayout struct {
	*Layout
	Context context.Context
	Dy      float32
	// contains filtered or unexported fields
}

func (*InlineLayout) Height added in v0.3.4

func (l *InlineLayout) Height() float32

func (*InlineLayout) Render added in v0.3.4

func (l *InlineLayout) Render(sb *sprites.Batch)

func (*InlineLayout) SetY added in v0.3.4

func (l *InlineLayout) SetY(y float32)

func (*InlineLayout) Update added in v0.3.4

func (l *InlineLayout) Update(cam *gfx.Camera, ictx *input.Context)

func (*InlineLayout) Width added in v0.3.4

func (l *InlineLayout) Width() float32

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]card.Number)

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
	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
	// 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, frameAdvance bool) error

Jump to

Keyboard shortcuts

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