Documentation
¶
Overview ¶
Package wine runs the game's Windows binaries on macOS and Linux: it finds or downloads a Wine runtime, keeps a private prefix for the launcher, and maps paths between the host and Windows.
Index ¶
- Constants
- Variables
- func Env(parent []string, prefix, debug string, overrides ...string) []string
- func InstallHint() string
- func InstallRosetta(ctx context.Context) error
- func NeedsRosetta(ctx context.Context) bool
- func Paths() launch.Paths
- func UnixPath(win string) (string, error)
- func Unpack(r io.Reader, dest string) error
- func WinPath(unix string) string
- type Host
- type Manager
- type MissingLibraryError
- type Pin
- type Prefix
- func (p *Prefix) Check32(ctx context.Context) error
- func (p *Prefix) Command(ctx context.Context, args ...string) *exec.Cmd
- func (p *Prefix) Ensure(ctx context.Context) (changed bool, err error)
- func (p *Prefix) Env(overrides ...string) []string
- func (p *Prefix) Forget()
- func (p *Prefix) Persist(ctx context.Context) error
- func (p *Prefix) WindowsVersion(ctx context.Context) (string, error)
- type Progress
- type Registry
- func (r *Registry) Commit() error
- func (r *Registry) GatewayList() ([]string, error)
- func (r *Registry) SetGame(exe, version string) error
- func (r *Registry) SetGatewayList(values []string) error
- func (r *Registry) SetString(name, value string) error
- func (r *Registry) String(name string) (string, error)
- type Runtime
- type Setup
- type Step
Constants ¶
const DefaultDebug = "-all"
DefaultDebug turns off Wine's debug channels, which are noisy and slow.
Variables ¶
var DefaultPin = func() Pin { if runtime.GOARCH == "amd64" { return LinuxPin } return Pin{} }()
DefaultPin is the runtime the launcher downloads on this platform. The pinned build is amd64; elsewhere only the system's Wine can be used.
var ErrNeedsRosetta = errors.New("Wine needs Rosetta 2, which isn't installed")
ErrNeedsRosetta means Rosetta 2 must be installed first; see InstallRosetta.
var ErrNo32Bit = errors.New("this Wine can't run 32-bit programs")
ErrNo32Bit means a Wine can't run 32-bit programs, as the game is.
var ErrNoRuntime = errors.New("no Wine runtime for this system")
ErrNoRuntime means no Wine is available on this platform.
var ErrNotReady = errors.New("Wine needs setting up before the game can start")
ErrNotReady means Wine hasn't been set up yet, or needs setting up again, such as after an update: the setup screen does that.
var Hosts = append([]string{"github.com"}, fetch.GitHubAssetHosts...)
Hosts are where pinned runtimes download from.
var LinuxPin = Pin{
Version: "11.0",
URL: "https://github.com/Kron4ek/Wine-Builds/releases/download/11.0/wine-11.0-amd64-wow64.tar.xz",
Size: 73144724,
SHA256: "39574efa1132c3ca0d5c77dd2eddbe4a49cca0d6cc2c290ff4924493a1c40314",
}
LinuxPin is Kron4ek/Wine-Builds' amd64-wow64 build, which runs 32-bit programs without 32-bit host libraries. It still needs the usual system libraries and glibc 2.27 or later.
var MacPin = Pin{
Version: "11.0_1",
URL: "https://github.com/Gcenx/macOS_Wine_builds/releases/download/11.0_1/wine-stable-11.0_1-osx64.tar.xz",
Size: 185303032,
SHA256: "b50dc50ec7f41d58b115a6b685d4d1315ba3c797bd3aa0f49213f2703cb82388",
}
MacPin is WineHQ's macOS build of Wine Stable, from Gcenx/macOS_Wine_builds: x86_64, running 32- and 64-bit Windows programs, on Apple Silicon through Rosetta 2.
var MinSystemVersion = [2]int{9, 0}
MinSystemVersion is the oldest system Wine the launcher uses.
Functions ¶
func Env ¶
Env is the environment every Wine call runs with: the parent's, minus any Wine variables of the player's own, plus the prefix and the launcher's settings. debug "" means DefaultDebug; overrides are added to the base DLL overrides, such as "ddraw=n,b".
func InstallHint ¶
func InstallHint() string
InstallHint is the command that installs Wine on this distribution, for a player whose system can't run the downloaded Wine.
func InstallRosetta ¶
InstallRosetta has nothing to do off macOS.
Types ¶
type Host ¶
type Host struct {
Setup Setup
// TempDir holds files passed to Wine programs, such as .reg files.
TempDir string
// contains filtered or unexported fields
}
Host runs the game under Wine: it holds the prefix once Wine is set up, and gives the launcher a registry, a starter and path mapping for it.
func (*Host) Ready ¶
Ready reports whether the game can start now, checking for a prefix an earlier run set up. It doesn't download or create anything. The check runs Wine, so it's done without the lock, which launches need.
func (*Host) Start ¶
Start starts a box under Wine, from the box's folder, and lets it run.
With d2gl on in DirectDraw mode, Wine's own ddraw must give way to the one d2gl ships; in Glide mode (-3dfx), the game loads d2gl's glide3x.dll itself. With d2gl off, the game runs windowed: full screen under Wine changes the display mode, which goes badly on macOS.
type Manager ¶
Manager keeps the launcher's Wine runtimes under Dir, one folder per version, and downloads into CacheDir.
type MissingLibraryError ¶
type MissingLibraryError struct{ Library string }
MissingLibraryError means a downloaded Wine can't find a system library.
func (*MissingLibraryError) Error ¶
func (e *MissingLibraryError) Error() string
type Prefix ¶
type Prefix struct {
Dir string
Runtime *Runtime
// Debug is WINEDEBUG; "" means DefaultDebug.
Debug string
// Log receives the output of every Wine call. Nil discards it.
Log io.Writer
}
Prefix is the launcher's private Wine prefix: its own Windows registry and drive C:, separate from any the player uses.
func (*Prefix) Check32 ¶
Check32 runs the 32-bit cmd.exe: the game is 32-bit, and some Wine builds, such as a distribution's 64-bit-only package, can't run it. A check cut short, by a timeout or the player cancelling, says nothing either way and isn't ErrNo32Bit.
func (*Prefix) Ensure ¶
Ensure makes the prefix ready: created on first use, updated when the runtime has changed since, and with drive Z: mapped to /. It reports whether it created or updated it.
func (*Prefix) Env ¶
Env is the environment for Wine calls in this prefix, with extra DLL overrides.
func (*Prefix) Forget ¶
func (p *Prefix) Forget()
Forget makes the next Ensure check the prefix over, such as after a runtime failed in it.
type Progress ¶
type Progress struct {
Step Step `json:"step"`
Done int64 `json:"done"`
Total int64 `json:"total"`
}
Progress is Wine setup's progress. Done and Total count download bytes in StepWine; both are 0 otherwise.
type Registry ¶
type Registry struct {
// Prefix is the prefix to work in, once there is one.
Prefix func() (*Prefix, error)
// TempDir holds the .reg files passed to regedit.
TempDir string
// contains filtered or unexported fields
}
Registry is the game's registry values in the launcher's Wine prefix, as launch.Registry. Values are read once per launch, by exporting the two keys, and writes are held until Commit imports them all in one go: each regedit is a Windows process start. It never edits the prefix's .reg files directly: the wineserver holds the registry and rewrites them.
regedit /E puts up an error and waits when a key doesn't exist, so the keys are created first; it writes UTF-16, which keeps any path intact, where reg query prints in the console's code page.
func (*Registry) Commit ¶
Commit imports the held writes, then forgets what was read, so the next launch reads afresh: the game may change the values while it runs. Writes that fail to import are kept for the next Commit.
func (*Registry) GatewayList ¶
GatewayList reads the gateway list; none yet is an empty list.
func (*Registry) SetGame ¶
SetGame has Wine report Windows XP to a game older than 1.14, at the next Commit. Under Wine on Apple Silicon, 1.13c's Fog.dll overflows its stack at start-up when told Windows 10, Wine's default; told XP, it starts. A 1.14 game gets Wine's default back.
func (*Registry) SetGatewayList ¶
SetGatewayList writes the gateway list at the next Commit.
type Runtime ¶
type Runtime struct {
// Version is the pin's version, or "system" plus wine --version.
Version string
Wine string
Wineserver string
// System is Wine the player installed, not one the launcher manages.
System bool
}
Runtime is a Wine installation.
func SystemWine ¶
SystemWine is the player's own Wine, if it's on the PATH and recent enough. Whether it runs 32-bit programs is only known once a prefix is made; see Prefix.Check32.
type Setup ¶
type Setup struct {
Manager Manager
PrefixDir string
Debug string
Log io.Writer
// UseSystem tries the player's own Wine first (Linux).
UseSystem bool
}
Setup gets a runtime and a ready prefix.
func (Setup) Quick ¶
Quick is the prefix an earlier Run left ready for the current runtime, or ErrNotReady. It doesn't download or create anything.
func (Setup) SystemPrefixDir ¶
SystemPrefixDir is the prefix used with the system's Wine. It's kept apart from the one the launcher's own Wine uses, so an older system Wine never opens a prefix a newer Wine made (Wine can't take one back a version), and switching between them doesn't update one prefix back and forth.