app

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app holds the services the frontend calls. They stay thin: the work happens in the other internal packages, which know nothing about the UI.

Index

Constants

View Source
const LinkScheme = "diablo2org"

LinkScheme is the URL scheme the installer registers, so a web page can link to diablo2org://add?profile=<https URL of a server profile>.

Variables

View Source
var Version = "dev"

Version is set at build time with -ldflags "-X github.com/diablo2org/launcher/internal/app.Version=v1.2.3".

Functions

func DevEnv

func DevEnv(name string) string

DevEnv returns a development setting from the environment, or "" in a release build. Each one points the launcher at other servers or another certificate, or opens its page to other programs: what a developer testing the launcher wants, and nothing a player should have. One set on a release is logged and ignored.

func HandleLink(s *ServerService, raw string, running bool)

HandleLink takes a link the launcher was started with, or sent while running, and queues it until the frontend asks for it. running says the window is up, to be told and brought to the front. An empty link is ignored, and a link the same as the last one queued isn't queued twice. It isn't a ServerService method so the frontend can't call it.

func LinkArg

func LinkArg(args []string) string

LinkArg returns the first command line argument that is one of the launcher's links, or "". Windows passes a clicked link as an argument.

func ParseAddLink(raw string) (string, error)

ParseAddLink returns the profile URL an add link names. Only the URL is checked here; nothing is fetched until the player agrees.

func Released

func Released() bool

Released reports whether this is a tagged release, not a development build.

Types

type BaseInstallRequest

type BaseInstallRequest struct {
	Version      string `json:"version"`
	Dir          string `json:"dir"`
	ClassicKey   string `json:"classicKey"`
	ExpansionKey string `json:"expansionKey"`
	Owner        string `json:"owner"`
}

BaseInstallRequest is the "Install Diablo II for me" form.

type BaseInstallResult

type BaseInstallResult struct {
	OK bool `json:"ok"`
	// Installed is set once the game is installed, even if something after
	// that failed: the folder is then an existing install, not one to
	// install into again.
	Installed bool   `json:"installed"`
	Cancelled bool   `json:"cancelled"`
	Error     string `json:"error"`
	// Warnings are notes on the keys, such as one that doesn't decode.
	Warnings []string `json:"warnings"`
	// CacheBytes is the download cache the install left, which the player
	// can delete.
	CacheBytes int64 `json:"cacheBytes"`
}

BaseInstallResult is how an install ended.

type Branding

type Branding struct {
	Icon       string `json:"icon"`
	Background string `json:"background"`
}

Branding is a server's images as data URLs, ready for the page.

type CheckResult

type CheckResult struct {
	OK       bool     `json:"ok"`
	Name     string   `json:"name"`
	Problems []string `json:"problems"`
}

CheckResult is what the frontend shows after checking a profile.

type Host

type Host struct {
	// Emit sends an event to the frontend.
	Emit func(name string, data any)
	// PickFolder asks the player for a folder; "" means cancelled.
	PickFolder func(title string) (string, error)
	// Updates fetches release information; nil turns update checks off.
	Updates *fetch.Client
	// OpenFolder shows a folder in the file manager.
	OpenFolder func(path string) error
	// UpdatesDir is the launcher's own folder for downloaded installers.
	UpdatesDir string
	// RunInstaller applies a downloaded update (updates.Apply): starts the
	// installer on Windows, swaps in the new app on macOS and Linux.
	RunInstaller func(path string) error
	// Quit closes the launcher.
	Quit func()
	// SaveFile asks where to save a file; "" means cancelled.
	SaveFile func(title, name string) (string, error)
	// ShowFile shows a file, selected, in the file manager.
	ShowFile func(path string) error
	// Focus brings the launcher's window to the front.
	Focus func()
	// OpenURL opens a page in the player's browser, such as a server's login.
	OpenURL func(url string) error
}

Host is what the service needs from the app window.

type LauncherUpdateProgress

type LauncherUpdateProgress struct {
	Done  int64 `json:"done"`
	Total int64 `json:"total"`
}

LauncherUpdateProgress is sent as the "launcher:update" event while the new launcher downloads.

type LinkRequest

type LinkRequest struct {
	// URL is the profile the link asks to add.
	URL string `json:"url"`
	// Host is where that profile comes from, for the player to see.
	Host string `json:"host"`
	// Error says why the link can't be used; URL is then empty.
	Error string `json:"error"`
}

LinkRequest is a link waiting for the player to agree to it.

type Overview

type Overview struct {
	Base       string            `json:"base"`
	Report     install.Report    `json:"report"`
	Warning    string            `json:"warning"`
	BaseError  string            `json:"baseError"`
	Servers    []core.ServerInfo `json:"servers"`
	Favourites []string          `json:"favourites"`
	Error      string            `json:"error"`
	// FirstRun asks the page to show the welcome screen.
	FirstRun bool `json:"firstRun"`
	// Wine is whether the game runs under Wine here, and if it's ready.
	Wine core.WineStatus `json:"wine"`
}

Overview is the launcher's starting state.

type ProfileService

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

ProfileService lets the frontend check server profiles.

func NewProfileService

func NewProfileService(example []byte) *ProfileService

NewProfileService returns a service that offers example as a starting point.

func (*ProfileService) Check

func (s *ProfileService) Check(profile string) CheckResult

Check parses a profile and reports every problem found.

func (*ProfileService) Example

func (s *ProfileService) Example() string

Example returns the example SlashDiablo profile.

type SendResult

type SendResult struct {
	// ID is the server's reference for the report, to quote when asking
	// about it.
	ID string `json:"id"`
	// Message is anything else the server said.
	Message string `json:"message"`
	// Error says why the report wasn't sent.
	Error string `json:"error"`
	// SavedTo is where the report was saved instead, so the player can send
	// it by hand.
	SavedTo string `json:"savedTo"`
}

SendResult is how sending a report went.

type ServerReport

type ServerReport struct {
	// Host is where it is sent, for the player to see.
	Host string `json:"host"`
	// MaxBytes is the most the server accepts; the files are trimmed to fit.
	MaxBytes int           `json:"maxBytes"`
	Items    []report.Item `json:"items"`
}

ServerReport is a bug report that goes to a server rather than being saved.

type ServerService

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

ServerService is how the frontend drives the launcher.

func NewServerService

func NewServerService(m *core.Manager, host Host) *ServerService

NewServerService wraps a manager for the frontend.

func (s *ServerService) AddFromLink(ctx context.Context, profileURL string) (string, error)

AddFromLink adds the server a link named, once the player has agreed, pins it if there is room, and returns its id. A server that is already listed is just opened.

func (*ServerService) AddServer

func (s *ServerService) AddServer(ctx context.Context, profileURL string) (string, error)

AddServer adds a server that isn't listed, by the URL of its profile.

func (*ServerService) BaseSetup

func (s *ServerService) BaseSetup() core.BaseSetup

BaseSetup describes installing the base game.

func (*ServerService) Branding

func (s *ServerService) Branding(ctx context.Context, id string) Branding

Branding fetches a server's images. Missing or bad images are left empty; the tab falls back to its plain style.

func (*ServerService) CheckForUpdate

func (s *ServerService) CheckForUpdate(ctx context.Context) *updates.Release

CheckForUpdate reports a newer launcher release, if there is one. Errors are swallowed: being offline shouldn't show as a problem.

func (*ServerService) Choices

func (s *ServerService) Choices(ctx context.Context, id string) (core.Choices, error)

func (*ServerService) ChooseBase

func (s *ServerService) ChooseBase(ctx context.Context) (Overview, error)

ChooseBase lets the player pick their Diablo II folder.

func (*ServerService) ChooseInstallFolder

func (s *ServerService) ChooseInstallFolder() (string, error)

ChooseInstallFolder asks where to install Diablo II. A folder that isn't empty gets a Diablo II folder made inside it. "" means cancelled.

func (*ServerService) ClearBaseCache

func (s *ServerService) ClearBaseCache() error

ClearBaseCache deletes the base game's download cache.

func (*ServerService) DEP

func (s *ServerService) DEP(ctx context.Context, id string) (core.DEP, error)

DEP reports the DEP fix for a server's game (Windows only).

func (*ServerService) FinishWelcome

func (s *ServerService) FinishWelcome(pins []string) error

FinishWelcome pins the servers picked on the welcome screen and stops it showing again.

func (*ServerService) InstallBase

InstallBase installs the base game, sending base:progress events, and makes it the Diablo II folder. Cancelling the call stops it.

func (*ServerService) InstallRosetta

func (s *ServerService) InstallRosetta(ctx context.Context) error

InstallRosetta installs Rosetta 2 through macOS's administrator prompt.

func (*ServerService) InstallUpdate

func (s *ServerService) InstallUpdate(ctx context.Context) error

InstallUpdate downloads the newest launcher's update file, checks it against the release's SHA-256, applies it, and closes the launcher. On Windows the player then finishes the installer; on macOS and Linux the new launcher replaces this one and starts by itself.

func (*ServerService) Ladder

func (s *ServerService) Ladder(ctx context.Context, id string) (*core.Ladder, error)

Ladder returns a server's ladder boards.

func (*ServerService) LaunchDelay

func (s *ServerService) LaunchDelay() int

LaunchDelay is the wait between boxes, in milliseconds.

func (*ServerService) LogIn

func (s *ServerService) LogIn(ctx context.Context, id string) (core.Login, error)

LogIn opens the server's login page in the browser and waits for the player to finish there.

func (*ServerService) LogOut

func (s *ServerService) LogOut(id string) error

LogOut forgets the server's login.

func (*ServerService) Login

func (s *ServerService) Login(ctx context.Context, id string) (core.Login, error)

Choices returns the player's picks for a server. Login is the server's login: whether it needs one, and who is logged in.

func (*ServerService) News

func (s *ServerService) News(ctx context.Context, id string) ([]core.NewsItem, error)

News returns a server's latest posts.

func (*ServerService) OpenServerFolder

func (s *ServerService) OpenServerFolder(id string) error

OpenServerFolder shows a server's folder, for dropping in custom files.

func (*ServerService) Overview

func (s *ServerService) Overview(ctx context.Context) Overview

Overview loads the base install check and every server. On the first run it also brings across the old SlashDiablo launcher's settings, then finds the Diablo II folder from the registry if it still isn't known.

func (s *ServerService) PendingLink() *LinkRequest

PendingLink returns the oldest link waiting for the player, once, or nil.

func (*ServerService) Play

func (s *ServerService) Play(ctx context.Context, id string) error

Play starts the server.

func (*ServerService) RemoveServer

func (s *ServerService) RemoveServer(id string) error

RemoveServer forgets a server added by URL.

func (*ServerService) SetChannel

func (s *ServerService) SetChannel(ctx context.Context, id, channel string) error

SetChannel switches release channel.

func (*ServerService) SetComponent

func (s *ServerService) SetComponent(ctx context.Context, id, component, version string) error

SetComponent turns a component on at a version, or off with "".

func (*ServerService) SetD2GLResolutions

func (s *ServerService) SetD2GLResolutions(id, main, loader string) error

SetD2GLResolutions sets the main and loader box window sizes.

func (*ServerService) SetFavourite

func (s *ServerService) SetFavourite(id string, on bool) error

SetFavourite pins or unpins a server.

func (*ServerService) SetFavouriteOrder

func (s *ServerService) SetFavouriteOrder(ids []string) error

SetFavouriteOrder saves the pinned servers' order after the player drags them in the rail.

func (*ServerService) SetInstances

func (s *ServerService) SetInstances(ctx context.Context, id string, n int, splitD2GL bool) error

SetInstances sets the number of boxes and d2gl profile splitting.

func (*ServerService) SetLaunchDelay

func (s *ServerService) SetLaunchDelay(ms int) error

SetLaunchDelay changes the wait between boxes.

func (*ServerService) SetSetting

func (s *ServerService) SetSetting(ctx context.Context, id, setting string, value any) error

SetSetting changes one setting.

func (*ServerService) Settings

func (s *ServerService) Settings(ctx context.Context, id string) ([]core.SettingValue, error)

Settings returns a server's declared settings with their values.

func (*ServerService) SetupWine

func (s *ServerService) SetupWine(ctx context.Context) WineSetupResult

SetupWine downloads Wine and makes the prefix as needed, sending wine:progress events. Cancelling the call stops it.

func (*ServerService) Status

func (s *ServerService) Status(ctx context.Context, id string) core.Status

Status reports whether a server needs installing or updating.

func (*ServerService) TurnOffDEP

func (s *ServerService) TurnOffDEP(ctx context.Context, id string) error

TurnOffDEP turns DEP off for a server's Game.exe.

func (*ServerService) Update

func (s *ServerService) Update(ctx context.Context, id string, allowCopy bool) UpdateResult

Update installs or updates a server.

func (*ServerService) Verify

func (s *ServerService) Verify(ctx context.Context, id string) core.Status

Verify hashes every file in a server's folder again and reports what an update would repair.

func (*ServerService) Version

func (s *ServerService) Version() string

Version is the launcher's version, shown in the corner.

func (*ServerService) WineStatus

func (s *ServerService) WineStatus(ctx context.Context) core.WineStatus

WineStatus is whether the game needs Wine here, and whether it's ready.

type SupportService

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

SupportService is the frontend's way to logs and bug reports.

func NewSupportService

func NewSupportService(st *store.Store, m *core.Manager, host Host) *SupportService

NewSupportService gives the frontend the logs in st's data folder.

func (*SupportService) LogFrontendError

func (s *SupportService) LogFrontendError(message string)

LogFrontendError records an error the page didn't handle.

func (*SupportService) OpenLogs

func (s *SupportService) OpenLogs() error

OpenLogs shows the logs folder.

func (*SupportService) ReportContents

func (s *SupportService) ReportContents() []report.Item

ReportContents lists what a bug report would hold, for the player to see before making one.

func (*SupportService) SaveReport

func (s *SupportService) SaveReport() (string, error)

SaveReport asks where to save a bug report, writes it there and shows it. It returns the file, or "" if the player cancelled.

func (*SupportService) SendReport

func (s *SupportService) SendReport(ctx context.Context, id, message, contact string) SendResult

SendReport sends a bug report to server id, with what the player wrote. If it can't be sent, it is saved in the launcher's reports folder instead.

func (*SupportService) ServerReport

func (s *SupportService) ServerReport(ctx context.Context, id string) (*ServerReport, error)

ServerReport lists what a report sent to server id would hold. It returns nil when the server takes no reports, so the player saves one instead.

func (*SupportService) ShowSavedReport

func (s *SupportService) ShowSavedReport(path string) error

ShowSavedReport shows a report that SendReport saved instead of sending.

type UpdateProgress

type UpdateProgress struct {
	Server   string        `json:"server"`
	Progress sync.Progress `json:"progress"`
}

UpdateProgress is sent as the "update:progress" event while updating.

type UpdateResult

type UpdateResult struct {
	OK bool `json:"ok"`
	// NeedsCopy asks the player whether to copy the game archives, using
	// CopyBytes of disk space.
	NeedsCopy bool   `json:"needsCopy"`
	CopyBytes int64  `json:"copyBytes"`
	Error     string `json:"error"`
}

UpdateResult tells the frontend how an update went.

type WineSetupResult

type WineSetupResult struct {
	OK           bool   `json:"ok"`
	Cancelled    bool   `json:"cancelled"`
	NeedsRosetta bool   `json:"needsRosetta"`
	Error        string `json:"error"`
}

WineSetupResult is how setting Wine up ended.

Jump to

Keyboard shortcuts

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