fmm

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidGameDirectory = errors.New("invalid game directory")
	ErrModAlreadyDisabled   = errors.New("mod is already disabled")
	ErrModAlreadyEnabled    = errors.New("mod is already enabled")
	ErrModNotFoundLocal     = errors.New("mod was not found in the local mods directory")
	ErrNoCompatibleRelease  = errors.New("no compatible release was found")
)

Functions

This section is empty.

Types

type DatReader

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

func (*DatReader) Advance

func (d *DatReader) Advance(offset int64)

func (*DatReader) ReadBool

func (d *DatReader) ReadBool() bool

func (*DatReader) ReadModWithCRC

func (d *DatReader) ReadModWithCRC() ModIdent

func (*DatReader) ReadOptimizedVersion

func (d *DatReader) ReadOptimizedVersion(withBuild bool) Version

func (*DatReader) ReadString

func (d *DatReader) ReadString() string

func (*DatReader) ReadUint16

func (d *DatReader) ReadUint16() uint16

func (*DatReader) ReadUint16Optimized

func (d *DatReader) ReadUint16Optimized() uint16

func (*DatReader) ReadUint32

func (d *DatReader) ReadUint32() uint32

func (*DatReader) ReadUint8

func (d *DatReader) ReadUint8() uint8

func (*DatReader) ReadUnoptimizedVersion

func (d *DatReader) ReadUnoptimizedVersion() Version

type Dependency

type Dependency struct {
	Name    string
	Version *Version
	Kind    DependencyKind
	Req     VersionCmpRes
}

func NewDependency

func NewDependency(input string) (*Dependency, error)

func (*Dependency) Test

func (d *Dependency) Test(ver *Version) bool

func (*Dependency) ToString

func (d *Dependency) ToString() string

func (*Dependency) UnmarshalJSON

func (d *Dependency) UnmarshalJSON(data []byte) error

type DependencyKind

type DependencyKind uint8
const (
	DependencyRequired DependencyKind = iota
	DependencyOptional
	DependencyHiddenOptional
	DependencyIncompatible
	DependencyNoLoadOrder
)

type Manager

type Manager struct {
	DoSave bool
	Portal ModPortal
	// contains filtered or unexported fields
}

Manager manages mdos for a given game directory. A game directory is considered valid if it has either a config-path.cfg file or a config/config.ini file.

func NewManager

func NewManager(gamePath string, modsPath string) (*Manager, error)

Creates a new Manager for the given game directory. A game directory is considered valid if it has either a config-path.cfg file or a config/config.ini file. The player's username and token will be automatically retrieved from `player-data.json` if it exists.

func (*Manager) Add

func (m *Manager) Add(mod ModIdent) (*Version, error)

Add downloads and enables the given mod. Returns the version that was added.

func (*Manager) Disable

func (m *Manager) Disable(modName string) error

Requests the mod to be disabled.

func (*Manager) DisableAll

func (m *Manager) DisableAll()

Requests all non-internal mods to be disabled.

func (*Manager) Enable

func (m *Manager) Enable(ident ModIdent) (*Version, error)

Enable the given mod, if it exists. If version is nil, it will default to the newest local release. Returns the version that was enabled, if any.

func (*Manager) ExpandDependencies

func (m *Manager) ExpandDependencies(mods []ModIdent, fetchFromPortal bool) []ModIdent

func (*Manager) GetApiKey

func (m *Manager) GetApiKey() string

Returns the current upload API key.

func (*Manager) GetMod

func (m *Manager) GetMod(name string) (*Mod, error)

Retrieves the corresponding Mod object.

func (*Manager) GetMods

func (m *Manager) GetMods() []ModIdent

GetMods returns a list of the mods managed by this Manager.

func (*Manager) GetPlayerData

func (m *Manager) GetPlayerData() PlayerData

Returns the current player data.

func (*Manager) HasApiKey

func (m *Manager) HasApiKey() bool

Returns true if the Manager has an upload API key.

func (*Manager) HasPlayerData

func (m *Manager) HasPlayerData() bool

Returns true if the Manager has valid player data.

func (*Manager) Save

func (m *Manager) Save() error

Applies the requested modifications and saves to mod-list.json.

func (*Manager) SetApiKey

func (m *Manager) SetApiKey(key string)

Sets the API key used for mod uploading.

func (*Manager) SetPlayerData

func (m *Manager) SetPlayerData(playerData PlayerData)

Sets the player data used for downloading mods. The player data will be automatically retrieved from the game directory if it is available.

type Mod

type Mod struct {
	Name    string
	Enabled *Version
	// contains filtered or unexported fields
}

func (*Mod) GetLatestRelease

func (m *Mod) GetLatestRelease() *Release

func (*Mod) GetMatchingRelease

func (m *Mod) GetMatchingRelease(dep *Dependency) *Release

func (*Mod) GetRelease

func (m *Mod) GetRelease(version *Version) *Release

type ModIdent

type ModIdent struct {
	Name    string
	Version *Version
}

A small representation of a mod, with an optional version.

func NewModIdent

func NewModIdent(input string) ModIdent

Returns a ModIdent parsed from an input string with the format of 'name', 'name_version', or 'name_version.zip'.

func ParseLogFile

func ParseLogFile(filepath string) []ModIdent

Returns a slice of mod names extracted from a list of mod checksums in the given log file.

func ParseSaveFile

func ParseSaveFile(filepath string) ([]ModIdent, error)

Returns a slice of mod names and versions extracted from the given save file.

func (*ModIdent) ToString

func (i *ModIdent) ToString() string

Returns a string in the format of 'name' or 'name_version'.

type ModInitUploadRes

type ModInitUploadRes struct {
	UploadUrl *string `json:"upload_url"`
	Message   *string // When an error occurs
}

type ModListJson

type ModListJson struct {
	Mods []ModListJsonMod `json:"mods"`
}

func ParseModListJson

func ParseModListJson(path string) (*ModListJson, error)

type ModListJsonMod

type ModListJsonMod struct {
	Name    string   `json:"name"`
	Enabled bool     `json:"enabled"`
	Version *Version `json:"version,omitempty"`
	// contains filtered or unexported fields
}

type ModPortal

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

func (*ModPortal) DownloadLatestRelease

func (p *ModPortal) DownloadLatestRelease(name string) (string, error)

DownloadLatestRelease downloads the latest release compatible with the current base version.

func (*ModPortal) DownloadMatchingRelease

func (p *ModPortal) DownloadMatchingRelease(dep *Dependency) (string, error)

DownloadMatchingRelease downloads the latest mod release matching the given dependency. Returns the filepath of the newly downloaded mod.

func (*ModPortal) DownloadRelease

func (p *ModPortal) DownloadRelease(name string, version *Version) (string, error)

func (*ModPortal) GetMatchingRelease

func (p *ModPortal) GetMatchingRelease(dep *Dependency) (*PortalModRelease, error)

GetMatchingRelease fetches information for the newest release matching the given dependency.

func (*ModPortal) GetModInfo

func (p *ModPortal) GetModInfo(name string) (*PortalModInfo, error)

GetModInfo fetches information for the given mod from the mod portal.

func (*ModPortal) UploadMod

func (p *ModPortal) UploadMod(filepath string) error

UploadMod uploads the given file to the mod portal.

type PlayerData

type PlayerData struct {
	Token    string
	Username string
}

type PortalModInfo

type PortalModInfo struct {
	Name     string
	Releases []PortalModRelease
	Title    string
}

type PortalModRelease

type PortalModRelease struct {
	DownloadUrl string   `json:"download_url"`
	FileName    string   `json:"file_name"`
	InfoJson    infoJson `json:"info_json"`
	Version     Version  `json:"version"`
}

type Release

type Release struct {
	Name         string
	Dependencies []*Dependency
	Path         string
	Version      Version
}

type Version

type Version [4]uint16

func NewVersion

func NewVersion(input string) (*Version, error)

func (*Version) Cmp

func (v *Version) Cmp(other *Version) VersionCmpRes

func (*Version) MarshalJSON

func (v *Version) MarshalJSON() ([]byte, error)

func (*Version) ToString

func (v *Version) ToString(includeBuild bool) string

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(data []byte) error

type VersionCmpRes

type VersionCmpRes uint8
const (
	VersionAny VersionCmpRes = iota
	VersionEq
	VersionGt
	VersionGtEq
	VersionLt
	VersionLtEq
)

Jump to

Keyboard shortcuts

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