fmm

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 21 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) Read added in v0.8.0

func (r *DatReader) Read(buf []byte) (int, error)

func (*DatReader) ReadBool

func (r *DatReader) ReadBool() bool

func (*DatReader) ReadDouble added in v0.8.0

func (r *DatReader) ReadDouble() float64

func (*DatReader) ReadInt64 added in v0.8.0

func (r *DatReader) ReadInt64() int64

func (*DatReader) ReadModSettings added in v0.8.0

func (r *DatReader) ReadModSettings() ModSettings

func (*DatReader) ReadModWithCRC

func (r *DatReader) ReadModWithCRC() ModIdent

func (*DatReader) ReadPropertyTree added in v0.8.0

func (r *DatReader) ReadPropertyTree() PropertyTree

func (*DatReader) ReadString

func (r *DatReader) ReadString() string

func (*DatReader) ReadStringOptional added in v0.8.0

func (r *DatReader) ReadStringOptional() string

func (*DatReader) ReadUint16

func (r *DatReader) ReadUint16() uint16

func (*DatReader) ReadUint16Optimized

func (r *DatReader) ReadUint16Optimized() uint16

func (*DatReader) ReadUint32

func (r *DatReader) ReadUint32() uint32

func (*DatReader) ReadUint32Optimized added in v0.8.0

func (r *DatReader) ReadUint32Optimized() uint32

func (*DatReader) ReadUint64 added in v0.8.0

func (r *DatReader) ReadUint64() uint64

func (*DatReader) ReadUint8

func (r *DatReader) ReadUint8() uint8

func (*DatReader) ReadVersionOptimized added in v0.8.0

func (r *DatReader) ReadVersionOptimized(withBuild bool) Version

func (*DatReader) ReadVersionUnoptimized added in v0.8.0

func (r *DatReader) ReadVersionUnoptimized() Version

type DatWriter added in v0.8.0

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

func (*DatWriter) Write added in v0.8.0

func (w *DatWriter) Write(buf []byte) (int, error)

func (*DatWriter) WriteBool added in v0.8.0

func (w *DatWriter) WriteBool(value bool)

func (*DatWriter) WriteDouble added in v0.8.0

func (w *DatWriter) WriteDouble(value float64)

func (*DatWriter) WriteInt64 added in v0.8.0

func (w *DatWriter) WriteInt64(value int64)

func (*DatWriter) WriteModSettings added in v0.8.0

func (w *DatWriter) WriteModSettings(input *ModSettings)

func (*DatWriter) WritePropertyTree added in v0.8.0

func (w *DatWriter) WritePropertyTree(pt PropertyTree)

func (*DatWriter) WriteString added in v0.8.0

func (w *DatWriter) WriteString(value string)

func (*DatWriter) WriteStringOptional added in v0.8.0

func (w *DatWriter) WriteStringOptional(value string)

func (*DatWriter) WriteUint16 added in v0.8.0

func (w *DatWriter) WriteUint16(value uint16)

func (*DatWriter) WriteUint16Optimized added in v0.8.0

func (w *DatWriter) WriteUint16Optimized(value uint16)

func (*DatWriter) WriteUint32 added in v0.8.0

func (w *DatWriter) WriteUint32(value uint32)

func (*DatWriter) WriteUint32Optimized added in v0.8.0

func (w *DatWriter) WriteUint32Optimized(value uint32)

func (*DatWriter) WriteUint64 added in v0.8.0

func (w *DatWriter) WriteUint64(value uint64)

func (*DatWriter) WriteUint8 added in v0.8.0

func (w *DatWriter) WriteUint8(value uint8)

func (*DatWriter) WriteVersionUnoptimized added in v0.8.0

func (w *DatWriter) WriteVersionUnoptimized(version 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) CheckDownloadUpdates added in v0.8.0

func (m *Manager) CheckDownloadUpdates(mods []ModIdent)

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) GetLatestMods added in v0.8.0

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

GetLatestMods gets a list of the newest mods managed by this Manager.

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) MergeStartupModSettings added in v0.8.0

func (m *Manager) MergeStartupModSettings(input PropertyTree) error

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 (*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 ModSettings added in v0.8.0

type ModSettings struct {
	MapVersion Version
	Settings   PropertyTree
}

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 PropertyTree added in v0.8.0

type PropertyTree interface {
	// contains filtered or unexported methods
}

type PropertyTreeBool added in v0.8.0

type PropertyTreeBool bool

type PropertyTreeDict added in v0.8.0

type PropertyTreeDict map[string]PropertyTree

type PropertyTreeList added in v0.8.0

type PropertyTreeList []PropertyTree

type PropertyTreeNone added in v0.8.0

type PropertyTreeNone struct{}

type PropertyTreeNumber added in v0.8.0

type PropertyTreeNumber float64

type PropertyTreeSignedInteger added in v0.8.0

type PropertyTreeSignedInteger int64

type PropertyTreeString added in v0.8.0

type PropertyTreeString string

type PropertyTreeUnsignedInteger added in v0.8.0

type PropertyTreeUnsignedInteger uint64

type Release

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

type SaveFileInfo added in v0.8.0

type SaveFileInfo struct {
	Mods        []ModIdent
	ModSettings PropertyTree
}

func ParseSaveFile

func ParseSaveFile(filepath string) (SaveFileInfo, error)

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

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