backend

package
v0.0.0-...-e9243a7 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModsSubPath = "Mods"
)

Variables

View Source
var (
	Sugar *zap.SugaredLogger
	AppFs = afero.NewOsFs()
)

Functions

func EnumerateMods

func EnumerateMods(w http.ResponseWriter, r *http.Request)

func GameDir

func GameDir() string

GameDir returns the game dir from the config

func HasSMAPI

func HasSMAPI() (bool, error)

func InitializeConfig

func InitializeConfig() string

InitializeConfig sets up the config and such

func OpenSmapiInstall

func OpenSmapiInstall() error

func StartAPI

func StartAPI(addr string) error

StartAPI sets up the api routes and starts API server in background

func UploadFile

func UploadFile(w http.ResponseWriter, r *http.Request)

1. Upload file to {config}/zips/ (UploadFile)

func UrlOpener

func UrlOpener(url string) func() error

Types

type ContentPackRef

type ContentPackRef struct {
	UniqueID       string `json:"UniqueID"`
	MinimumVersion string `json:"MinimumVersion"`
}

For a content pack, ContentPackFor specifies which mod can read it.

type DependencyRef

type DependencyRef struct {
	UniqueID string `json:"UniqueID"`
	// optional. If specified, older versions won't meet the requirement.
	MinimumVersion string `json:"MinimumVersion"`
	// You can mark a dependency as optional. It will be loaded first if it's installed, otherwise it'll be ignored.
	IsRequired bool `json:"IsRequired"`
}

The Dependencies field specifies other mods required to use this mod.

type Mod

type Mod struct {
	Directory string      `json:"directory"`
	Enabled   bool        `json:"enabled"`
	Managed   bool        `json:"managed"`
	Metadata  ModMetadata `json:"metadata"`
}

Mod is a a SMAPI mod

func LoadMods

func LoadMods(gameDir string) []Mod

LoadMods searches the provided game directory for mods and parses them into Mod structures

func (*Mod) RefreshEnabled

func (m *Mod) RefreshEnabled()

type ModManager

type ModManager struct {
	Mods    []Mod  `json:"mods"`
	GameDir string `json:"game_dir"`
}

func (*ModManager) LoadModsFromFS

func (m *ModManager) LoadModsFromFS()

func (*ModManager) RefreshEnabled

func (m *ModManager) RefreshEnabled()

type ModMetadata

type ModMetadata struct {
	// The mod name. SMAPI uses this in player messages, logs, and errors.
	Name string `json:"Name"`
	// The name of the person who created the mod. Ideally this should include the username used to publish mods.
	Author string `json:"Author"`
	// The mod's semantic version.
	Version string `json:"Version"`
	// A short explanation of what your mod does (one or two sentences), shown in the SMAPI log
	Description string `json:"Description"`
	// A unique identifier for your mod. The recommended format is <your name>.<mod name>, with no spaces or
	//  special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists
	//  (if the mod breaks in a future version of the game). When another mod needs to reference this mod,
	//  it uses the unique ID.
	UniqueID string `json:"UniqueID"`
	// All mods must specify either EntryDll (for a SMAPI mod) or ContentPackFor (for a content pack).
	//  These are mutually exclusive — you can't specify both.
	//  For a SMAPI mod, EntryDll is the mod's compiled DLL filename in its mod folder.
	EntryDll string `json:"EntryDll"` // not present in content packs
	// For a content pack, ContentPackFor specifies which mod can read it. The MinimumVersion is optional.
	ContentPackFor ContentPackRef `json:"ContentPackFor"` // not present in mods
	// The MinimumApiVersion fields sets the minimum SMAPI version needed to use this mod.
	//  If a player tries to use the mod with an older SMAPI version, they'll see a friendly message
	//  saying they need to update SMAPI. This also serves as a proxy for the minimum game version,
	//  since SMAPI itself enforces a minimum game version.
	MinimumApiVersion string `json:"MinimumApiVersion"`
	// The Dependencies field specifies other mods required to use this mod.
	//  If a player tries to use the mod and the dependencies aren't installed,
	//  the mod won't be loaded and they'll see a friendly message saying they need to
	//  install those
	Dependencies []DependencyRef `json:"Dependencies"`
	UpdateKeys   []string        `json:"UpdateKeys"`
}

Every SMAPI mod or content pack must have a manifest.json file in its folder. SMAPI uses this to identify and load the mod, perform update checks, etc.

Jump to

Keyboard shortcuts

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