steam

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const InnerOffsetAppInfo = 10

InnerOffsetAppInfo sets byte count before appid match in appinfo

View Source
const InnerOffsetShortcuts = 1

InnerOffsetShortcuts sets byte count before appid match in shortcuts

Variables

DeckCompatibilityRegistry translates DeckCompatibilityCategory values to human-readable strings

Functions

func IsShortcut added in v1.6.0

func IsShortcut(id string) bool

IsShortcut returns whether app id is a shortcut

func Lookup added in v1.6.0

func Lookup(n *vdf.Node, x []string) (*vdf.Node, error)

Lookup looks up a "key path" in a parsed VDF tree

func ParseBinaryVdf added in v1.6.0

func ParseBinaryVdf(in []byte) (*vdf.Node, error)

ParseBinaryVdf unmarshals `in` as binary VDF

func ParseTextConfig added in v1.6.0

func ParseTextConfig(p string) (*vdf.Node, error)

ParseTextConfig reads a file and parses it as text VDF

Types

type AmbiguousNameError added in v1.6.0

type AmbiguousNameError struct{}

AmbiguousNameError is returned if game search by app ID or name leads to several results

func (*AmbiguousNameError) Error added in v1.6.0

func (err *AmbiguousNameError) Error() string

Error returns description string

type BinaryVdf added in v1.6.0

type BinaryVdf struct {
	Bytes []byte
	Path  string
}

BinaryVdf wraps info for binary VDF

func (*BinaryVdf) GetNextEntryStart added in v1.6.0

func (bVdf *BinaryVdf) GetNextEntryStart(offset, innerOffset int, needle []byte) int

GetNextEntryStart returns the next offset to a binary VDF entry beginning where needle was found (starting at given offset)

func (*BinaryVdf) GetNextEntryStartByID added in v1.6.0

func (bVdf *BinaryVdf) GetNextEntryStartByID(offset, innerOffset int, id string) (int, error)

GetNextEntryStartByID returns the next offset to a appinfo binary VDF entry by app id (starting at a given offset)

type BinaryVdfTable added in v1.6.2

type BinaryVdfTable map[uint32]uint

BinaryVdfTable is only used in debug mode to collect the count of duplicate parsing of binary VDF "snippets"

type CompatTool added in v1.6.0

type CompatTool struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Games     Games  `json:"games"`
	IsDefault bool   `json:"isDefault"`
	IsCustom  bool   `json:"isCustom"`
}

CompatTool holds info about a compatibility tool (like human-readable name and a list of the games that are using it)

func (CompatTool) IsInstalled added in v1.6.0

func (t CompatTool) IsInstalled(s *Steam) bool

IsInstalled returns if a tool is installed

type CompatToolMappingVdf added in v1.6.0

type CompatToolMappingVdf struct {
	Vdf
}

CompatToolMappingVdf represents parsed VDF config for CompatToolMapping

func (*CompatToolMappingVdf) Add added in v1.6.0

func (v *CompatToolMappingVdf) Add(appID, versionID string)

Add adds a new compatibility tool version mapping for a given app id

func (*CompatToolMappingVdf) GetCompatToolName added in v1.6.0

func (v *CompatToolMappingVdf) GetCompatToolName(version string) string

GetCompatToolName returns human-readable name for compatibility tool

func (*CompatToolMappingVdf) IsValid added in v1.6.0

func (v *CompatToolMappingVdf) IsValid(version string) bool

IsValid checks whether a version exists in the compatibility tools directory

func (*CompatToolMappingVdf) ReadCompatTools added in v1.6.0

func (v *CompatToolMappingVdf) ReadCompatTools() (CompatTools, error)

ReadCompatTools reads compatibility tool mappings from VDF config and returns a CompatTools map with existing entries

func (*CompatToolMappingVdf) Update added in v1.6.0

func (v *CompatToolMappingVdf) Update(id, version string) error

Update changes or adds a compatibility tool version mapping for a given app ID

type CompatTools added in v1.6.0

type CompatTools map[string]*CompatTool

CompatTools maps compatibility tool version IDs to CompatTool objects containing info like name and games.

func (CompatTools) Add added in v1.6.0

func (c CompatTools) Add(id, name string)

Add adds an entry to the CompatTools config (by tool id and (display) name)

func (CompatTools) AddGame added in v1.6.0

func (c CompatTools) AddGame(toolID string, game *Game) bool

AddGame adds a Game entry to an existing CompatTool entry

func (CompatTools) GetDefault added in v1.6.0

func (c CompatTools) GetDefault() *CompatTool

GetDefault returns the first entry from c that is a default compatibility tool

func (CompatTools) Includes added in v1.6.0

func (c CompatTools) Includes(appID string) bool

Includes returns whether a game is included in c

func (CompatTools) IsValid added in v1.6.0

func (c CompatTools) IsValid(v string) bool

IsValid checks whether a version ID (v) exists in the CompatTools config

func (CompatTools) Merge added in v1.6.0

func (c CompatTools) Merge(other *CompatTools) CompatTools

Merge adds all entries from other to c (without duplicates)

func (CompatTools) Sort added in v1.6.0

func (c CompatTools) Sort() []string

Sort returns slice of alphabetically sorted CompatTools IDs

type DeckCompatibility added in v1.6.0

type DeckCompatibility struct {
	Category DeckCompatibilityCategory `json:"category"`
	Tests    []string                  `json:"tests"`
}

DeckCompatibility holds deck compatibility info for a game

func GetDeckCompatibility added in v1.6.0

func GetDeckCompatibility(n *vdf.Node) *DeckCompatibility

GetDeckCompatibility reads deck compatibility data from VDF node n

func (DeckCompatibility) String added in v1.6.0

func (c DeckCompatibility) String() string

String returns string that represents deck compatibility status

type DeckCompatibilityCategory added in v1.6.0

type DeckCompatibilityCategory int

DeckCompatibilityCategory represents deck compatibility category

const (
	// DeckCompatibilityUnknown represents unknown deck compatibility
	DeckCompatibilityUnknown DeckCompatibilityCategory = iota
	// DeckCompatibilityUnsupported represents unsupported deck compatibility
	DeckCompatibilityUnsupported
	// DeckCompatibilityPlayable represents playable deck compatibility
	DeckCompatibilityPlayable
	// DeckCompatibilityVerified represents verified deck compatibility
	DeckCompatibilityVerified
)

func (DeckCompatibilityCategory) String added in v1.6.0

func (c DeckCompatibilityCategory) String() string

type Game added in v1.4.0

type Game struct {
	ID                string            `json:"appID"`
	Name              string            `json:"-"`
	IsInstalled       bool              `json:"isInstalled"`
	IsShortcut        bool              `json:"isShortcut"`
	DeckCompatibility DeckCompatibility `json:"deckCompatibility"`
}

Game represents Steam game or shortcut

type Games

type Games map[string]*Game

Games maps game name to Game (app ID, install status)

func (Games) CountInstalled added in v1.6.0

func (games Games) CountInstalled() int

CountInstalled returns count of installed games

func (Games) Includes added in v1.6.0

func (games Games) Includes(id string) bool

Includes returns whether app id is included in g

func (Games) Sort

func (games Games) Sort() []string

Sort returns slice of alphabetically sorted Game names

func (Games) SortByDeckCompatibilityCategory added in v1.6.3

func (games Games) SortByDeckCompatibilityCategory() []Game

type KeyNotFoundError added in v1.4.0

type KeyNotFoundError struct {
	Name string
}

KeyNotFoundError is returned if key in VDF is not found

func (*KeyNotFoundError) Error added in v1.4.0

func (e *KeyNotFoundError) Error() string

type LibraryConfigVdf added in v1.6.0

type LibraryConfigVdf struct {
	Vdf
}

LibraryConfigVdf represents parsed VDF config for library config from libraryfolders.vdf

func (LibraryConfigVdf) GetLibraryPathByID added in v1.6.0

func (vdf LibraryConfigVdf) GetLibraryPathByID(id string) string

GetLibraryPathByID returns library path for app id

func (LibraryConfigVdf) GetLibraryPaths added in v1.6.1

func (vdf LibraryConfigVdf) GetLibraryPaths() []string

GetLibraryPaths returns array of Steam library paths

func (LibraryConfigVdf) IsInstalled added in v1.6.0

func (vdf LibraryConfigVdf) IsInstalled(id string) bool

IsInstalled returns whether app id is installed

type LocalConfigVdf added in v1.6.0

type LocalConfigVdf struct {
	Vdf
}

LocalConfigVdf represents parsed VDF config for app config from localconfig.vdf

func (*LocalConfigVdf) GetGames added in v1.6.3

func (v *LocalConfigVdf) GetGames(enableViewedSteamPlay bool) ([]*Game, error)

GetGames returns a slice of games for which the user confirmed the Steam Play disclaimer

type LoginUsersVdf added in v1.6.0

type LoginUsersVdf struct {
	Vdf
}

LoginUsersVdf represents parsed VDF config for app config from loginusers.vdf

func (*LoginUsersVdf) GetID64 added in v1.6.0

func (lu *LoginUsersVdf) GetID64(username string) string

GetID64 return steamID64 for given username

type Steam

type Steam struct {
	AppidCache       *cache.Cache
	VersionNameCache *cache.Cache

	AppInfo           *BinaryVdf
	CompatToolMapping *CompatToolMappingVdf
	LibraryConfig     *LibraryConfigVdf
	LocalConfig       *LocalConfigVdf
	LoginUsers        *LoginUsersVdf
	Shortcuts         *BinaryVdf

	CompatTools CompatTools

	UID                   string
	Root                  string
	EnableViewedSteamPlay bool
}

Steam struct wraps caches and exposes functions for Steam data retrieval

func New

func New(user string, cfg *config.Config, ignoreCache bool) (*Steam, error)

New instantiates Steam struct

func (*Steam) GetAppIDAndName added in v1.6.0

func (s *Steam) GetAppIDAndName(idOrName string) (string, string, error)

GetAppIDAndName returns first found app ID and proper name for app ID or name search (from AppidCache cache)

func (*Steam) GetAppIDAndNames added in v1.6.0

func (s *Steam) GetAppIDAndNames(idOrName string) [][]string

GetAppIDAndNames returns app IDs and proper names for app ID or name search (from AppidCache cache)

func (*Steam) GetCompatToolName added in v1.4.0

func (s *Steam) GetCompatToolName(id string) (string, error)

GetCompatToolName returns human-readable name of compatibility tool, for example: "proton_63" -> "Proton 6.3-8"

func (*Steam) GetCompatdataPath added in v1.2.4

func (s *Steam) GetCompatdataPath(idOrName string) (string, string, error)

GetCompatdataPath returns compatdata path and game name for given game ID or name

func (*Steam) GetCompatibilityToolsDir added in v1.6.0

func (s *Steam) GetCompatibilityToolsDir() string

GetCompatibilityToolsDir returns compatibilitytools.d location

func (*Steam) GetGame added in v1.6.0

func (s *Steam) GetGame(id string, nameOnly ...bool) (*Game, error)

GetGame returns Game struct by app id If nameOnly is true, Game struct will only contain name

func (*Steam) GetGameData added in v1.4.0

func (s *Steam) GetGameData(id string) (*Game, bool, error)

GetGameData returns initialized Game struct by app ID TODO Rename/rewrite GetGameCached? How to handle non-cached data?

func (*Steam) GetGameVersion added in v1.4.0

func (s *Steam) GetGameVersion(id string) *CompatTool

GetGameVersion returns Version struct for a given game ID

func (*Steam) GetInstalldir added in v1.6.0

func (s *Steam) GetInstalldir(id string) (string, error)

GetInstalldir returns installation directory of game by app ID

func (*Steam) GetName added in v1.6.0

func (s *Steam) GetName(id string) (string, error)

GetName returns name of game by app id

func (*Steam) GetNameFromAPI added in v1.6.0

func (s *Steam) GetNameFromAPI(id string) (string, error)

GetNameFromAPI returns name of game by app id using the Steam API

func (*Steam) GetShortcutName added in v1.6.0

func (s *Steam) GetShortcutName(id string) (string, error)

GetShortcutName returns name of shortcut by app id

func (*Steam) IsRunning added in v1.6.2

func (s *Steam) IsRunning() (bool, error)

IsRunning returns whether a process is running that contains "steam" in its binary path. Always returns false if ran in Flatpak sandbox.

func (*Steam) NewCompatTools added in v1.6.0

func (s *Steam) NewCompatTools(data ...map[string][]string) (*CompatTools, error)

NewCompatTools returns new CompatTools struct (optionally initialized with data, which is a map from compatibility tool version IDs to slices of game IDs)

func (*Steam) ReadCompatTools added in v1.6.0

func (s *Steam) ReadCompatTools() error

ReadCompatTools reads compatibility tool mappings from config, and sets s.CompatTools accordingly.

func (*Steam) SaveCache

func (s *Steam) SaveCache() error

SaveCache writes caches to disk

func (*Steam) SearchCompatdataPath added in v1.6.1

func (s *Steam) SearchCompatdataPath(id string) string

SearchCompatdataPath searches for compatdata path for given game id in all library paths

type Vdf added in v1.6.0

type Vdf struct {
	Root  *vdf.Node
	Node  *vdf.Node
	Path  string
	Steam *Steam
}

Vdf represents a parsed VDF file

func (*Vdf) Save added in v1.6.0

func (v *Vdf) Save() error

Save saves a parsed VDF file back to disk

Jump to

Keyboard shortcuts

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