Documentation ¶
Overview ¶
Package internal contains utility functions and constants for Spy Cards Online.
Index ¶
- Constants
- Variables
- func DoPutRequest(ctx context.Context, url, contentType string, body []byte) ([]byte, error)
- func FetchBytes(ctx context.Context, url string) ([]byte, error)
- func FetchJSON(ctx context.Context, url string, v interface{}) error
- func GoRoutineID() string
- func LikelyTouch() bool
- func LoadData(key string) ([]byte, error)
- func MarshalJSON(v interface{}) ([]byte, error)
- func ModifyRequest(r *http.Request) *http.Request
- func OpenAsset(name string) (io.ReadCloser, error)
- func OpenURL(ctx context.Context, u string) error
- func PerformanceMark(name string)
- func PerformanceMeasure(name, start, end string)
- func PrefersReducedMotion() bool
- func RandomlyFail() error
- func ReadClipboard() (string, error)
- func SaveSettings(s *Settings)
- func SetActive(b bool)
- func SetTitle(title string)
- func StoreData(key string, val []byte) error
- func UnmarshalJSON(b []byte, v interface{}) error
- func VersionNumber() []byte
- func WarnIfCalledFromRenderLoop(message string, args ...interface{})
- func WithConfig(ctx context.Context, config *Config) context.Context
- func WriteClipboard(s string) error
- type AudioSettings
- type ButtonStyle
- type Cache
- type Config
- type ControlsSettings
- type ErrUnexpectedStatus
- type GamepadButton
- type GamepadLayout
- type KeyboardLayout
- type Settings
Constants ¶
const ( NormalClosure = 1000 MMServerError = 3000 MMClientError = 3001 MMConnectionError = 3002 MMTimeout = 3003 MMNotFound = 3004 )
Matchmaking websocket close codes.
Variables ¶
var DefaultConfig = &Config{
MatchmakingServer: "wss://spy-cards.lubar.me/spy-cards/ws",
UserImageBaseURL: "https://spy-cards.lubar.me/spy-cards/user-img/",
CustomCardAPIBaseURL: "https://spy-cards.lubar.me/spy-cards/custom/api/",
ModeChangelogBaseURL: "https://spy-cards.lubar.me/spy-cards/changelog/",
MatchRecordingBaseURL: "https://spy-cards.lubar.me/spy-cards/recording/",
ArcadeAPIBaseURL: "https://spy-cards.lubar.me/spy-cards/arcade/api/",
BaseURL: "https://spy-cards.lubar.me/",
IPFSBaseURL: "https://ipfs.lubar.me/ipfs/",
}
DefaultConfig is the Config used by the official Spy Cards Online site.
var ErrRandomFailure = errors.New("internal: synthesized error for testing")
ErrRandomFailure is returned 1/16 of the time for certain operations in random failure mode.
var OnSettingsChanged []func(*Settings)
OnSettingsChanged is a slice of callbacks for when a setting is saved.
var RenderLoopID string
RenderLoopID is the goroutine ID of the render loop.
var SetWindowTitle func(string)
SetWindowTitle is set to a callback that sets the window title.
var Version = [3]uint64{0, 3, 26}
Version is the current version of Spy Cards Online.
Functions ¶
func DoPutRequest ¶ added in v0.3.17
func GoRoutineID ¶ added in v0.3.1
func GoRoutineID() string
GoRoutineID returns the ID of the current goroutine.
This is a very bad idea. You should never, ever do this.
func LikelyTouch ¶ added in v0.3.23
func LikelyTouch() bool
func MarshalJSON ¶ added in v0.3.17
func ModifyRequest ¶ added in v0.2.67
ModifyRequest modifies an HTTP request before it is sent.
func OpenAsset ¶ added in v0.2.73
func OpenAsset(name string) (io.ReadCloser, error)
OpenAsset opens a local asset or performs an HTTP request.
func PerformanceMark ¶ added in v0.3.19
func PerformanceMark(name string)
func PerformanceMeasure ¶ added in v0.3.19
func PerformanceMeasure(name, start, end string)
func PrefersReducedMotion ¶ added in v0.3.4
func PrefersReducedMotion() bool
func RandomlyFail ¶ added in v0.3.9
func RandomlyFail() error
func ReadClipboard ¶ added in v0.2.81
func SaveSettings ¶
func SaveSettings(s *Settings)
SaveSettings stores the settings in the user's persistent storage and invokes OnSettingsChanged callbacks.
func SetActive ¶
func SetActive(b bool)
SetActive sets the active flag for the UI, which hides some UI elements.
func UnmarshalJSON ¶ added in v0.3.17
func VersionNumber ¶ added in v0.2.75
func VersionNumber() []byte
VersionNumber returns a string representation of Version.
func WarnIfCalledFromRenderLoop ¶ added in v0.3.1
func WarnIfCalledFromRenderLoop(message string, args ...interface{})
func WithConfig ¶
WithConfig attaches a Config to a context.
func WriteClipboard ¶ added in v0.2.81
Types ¶
type AudioSettings ¶ added in v0.2.67
AudioSettings are the audio volume settings.
type ButtonStyle ¶ added in v0.2.67
type ButtonStyle int
ButtonStyle is a graphical style for button prompts.
const ( StyleKeyboard ButtonStyle = 0 StyleGenericGamepad ButtonStyle = 1 )
Constants for ButtonStyle.
func (ButtonStyle) String ¶ added in v0.2.72
func (i ButtonStyle) String() string
type Cache ¶ added in v0.2.75
type Cache struct { MaxEntries int // contains filtered or unexported fields }
Cache is a FIFO cache.
type Config ¶
type Config struct { MatchmakingServer string `json:"matchmaking_server"` UserImageBaseURL string `json:"user_image_base_url"` CustomCardAPIBaseURL string `json:"custom_card_api_base_url"` ModeChangelogBaseURL string `json:"mode_changelog_base_url"` MatchRecordingBaseURL string `json:"match_recording_base_url"` ArcadeAPIBaseURL string `json:"arcade_api_base_url"` BaseURL string `json:"base_url"` IPFSBaseURL string `json:"ipfs_base_url"` }
Config holds data about external services used by Spy Cards Online.
type ControlsSettings ¶ added in v0.2.67
type ControlsSettings struct { Keyboard int `json:"keyboard,omitempty"` Gamepad map[string]int `json:"gamepad,omitempty"` CustomKB []KeyboardLayout `json:"customKB"` CustomGP []GamepadLayout `json:"customGP"` }
ControlsSettings are the input settings.
type ErrUnexpectedStatus ¶ added in v0.3.7
type ErrUnexpectedStatus struct {
Status string
}
func (ErrUnexpectedStatus) Error ¶ added in v0.3.7
func (err ErrUnexpectedStatus) Error() string
type GamepadButton ¶ added in v0.2.67
GamepadButton is a button on a gamepad.
func (GamepadButton) MarshalJSON ¶ added in v0.2.67
func (gpb GamepadButton) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (GamepadButton) String ¶ added in v0.2.67
func (gpb GamepadButton) String() string
String implements fmt.Stringer.
func (*GamepadButton) UnmarshalJSON ¶ added in v0.2.67
func (gpb *GamepadButton) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type GamepadLayout ¶ added in v0.2.67
type GamepadLayout struct { Name string `json:"name"` Button [10]GamepadButton `json:"button"` Style ButtonStyle `json:"style,omitempty"` }
GamepadLayout is a custom gamepad layout.
type KeyboardLayout ¶ added in v0.2.67
KeyboardLayout is a custom keyboard layout.
type Settings ¶
type Settings struct { Audio AudioSettings `json:"audio"` Character string `json:"character,omitempty"` Disable3D bool `json:"disable3D,omitempty"` DisableCRT bool `json:"disableCRT,omitempty"` PrefersReducedMotion bool `json:"prefersReducedMotion,omitempty"` NoStandardSize bool `json:"noStandardSize,omitempty"` AlternateColors bool `json:"alternateColors,omitempty"` ScreenReader bool `json:"screenReader,omitempty"` AutoUploadRecording bool `json:"autoUploadRecording,omitempty"` DisplayTermacadeButtons bool `json:"displayTermacadeButtons,omitempty"` LastTermacadeOption int `json:"lastTermacadeOption"` LastTermacadeName string `json:"lastTermacadeName,omitempty"` Theme string `json:"theme,omitempty"` DPIScale float64 `json:"dpiScale,omitempty"` LimitGPULevel int `json:"limitGPULevel,omitempty"` Controls ControlsSettings `json:"controls"` }
Settings are the user-configurable options for Spy Cards Online.
func LoadSettings ¶
func LoadSettings() *Settings
LoadSettings retrieves saved settings from persistent storage.