base

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CFG_VERSION = 2

	MAX_SOURCE_PORTS = 6
)

Variables

View Source
var (

	// KnownIwads contains names of the most common iwads
	KnownIwads = map[string]bool{
		"doom.wad":      true,
		"doom2.wad":     true,
		"tnt.wad":       true,
		"plutonia.wad":  true,
		"heretic.wad":   true,
		"hexen.wad":     true,
		"strive1.wad":   true,
		"sve.wad":       true,
		"chex.wad":      true,
		"strife0.wad":   true,
		"freedoom1.wad": true,
		"freedoom2.wad": true,
		"freedm.wad":    true,
		"chex3.wad":     true,
		"action2.wad":   true,
		"harm1.wad":     true,
		"hacx.wad":      true,
		"boa.ipk3":      true,
	}
)

Functions

func DOWNLOAD_PATH added in v0.20.0

func DOWNLOAD_PATH() string

func EnableBasePath

func EnableBasePath() error

EnableBasePath adds the mod base path to the config ini files and/or sets it as DOOMWADDIR that enables the engine, to find mod files added with the -file parameter based on relative paths

func GePathIwads

func GePathIwads(path string) ([]string, error)

func GetConfigFolder

func GetConfigFolder() string

GetConfigFolder returns the folder where configuration is stored

func GetDemoFolder

func GetDemoFolder() string

GetDemoFolder returns the folder where demos are stored

func GetFileContentStringFromPK3

func GetFileContentStringFromPK3(pk3path, filename string) (contentString string, err error)

GetFileContentStringFromPK3 is a wrapper for GetFileFromPK3 It returns the files contents as string

func GetFileFromPK3

func GetFileFromPK3(pk3Path string, filename string) (io.ReadCloser, error)

GetFileFromPK3 returns one specific file from given wad or pk3 file Don't forget to close the ReadCloser when done reading Can return nil if it didn't work out

func GetFileLinesFromPK3

func GetFileLinesFromPK3(pk3path, filename string) (lines []string, err error)

GetFileLinesFromPK3 is a wrapper for GetFileFromPK3 It uses a bufio.Scanner to scan the file line by line and return them as slice

func GetGameConfigFolder

func GetGameConfigFolder() string

GetGameConfigFolder returns the folder where savegames are stored

func GetSavegameFolder

func GetSavegameFolder() string

GetSavegameFolder returns the folder where savegames are stored

func GetSharedGameConfigFolder

func GetSharedGameConfigFolder() string

GetSharedGameConfigFolder returns the folder where savegames are stored

func GetSharedGameConfigs

func GetSharedGameConfigs(port string) []string

GetSharedGameConfigs returns a list with configs for given port name in the according shared subfolder

func ImportArchive

func ImportArchive(zipPath, modName string) (err error)

ImportArchive imports given archive into a subfolder of the base path

func ModOk added in v0.19.0

func ModOk(mod string) bool

ModOk checks, if the given mod (relative file path) exists within the configured DOOMWADDIR TODO: Maybe even check with MD5

func PathHasIwads

func PathHasIwads(path string) (bool, error)

General Helper

func Persist

func Persist() error

Persist writes all games into the according JSON file

func PortSharedConfigPath

func PortSharedConfigPath(port string) string

PortSharedConfigPath returns the path where common/shared configs for the given port should be stored

func SourcePorts

func SourcePorts() []string

func WadDirIsSane

func WadDirIsSane() bool

WadDirIsSane checks if the configured DOOMWADDIR is something useful The root directory "/" for example is a bad idea, especially considering zip import functionality

Types

type Cfg

type Cfg struct {
	WadDir                 string   `json:"wad_dir"`
	WriteWadDirToEngineCfg bool     `json:"write_wad_dir_to_engine_cfg"`
	DontSetDoomwaddir      bool     `json:"dont_set_doomwaddir"`
	ModExtensions          string   `json:"mod_extensions"`
	Ports                  []string `json:"source_ports"`
	IWADs                  []string `json:"iwa_ds"`
	Configured             bool     `json:"configured"`
	DeleteWithoutWarning   bool     `json:"delete_without_warning"`
	HideHeader             bool     `json:"hide_header"`
	GameListAbsoluteWidth  int      `json:"game_list_absolute_width"`
	GameListRelativeWidth  int      `json:"game_list_relative_width"`
	CfgVersion             int      `json:"cfg_version"`
}

Cfg holds basic configuration settings Should only be instantiated via GetInstance

func Config

func Config() *Cfg

Config returns the singleton instance of config

Jump to

Keyboard shortcuts

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