Documentation
¶
Overview ¶
Package ui implements the interface file runtime used by the original client's glue screens: table-of-contents loading, XML widget definition parsing, Lua 5.1 script execution, widget objects, and the glue API.
Loader semantics follow the original 3.3.5 client paths documented in the project research notes (GlueXML.toc entry loop, Include/Script dispatch, virtual templates, $parent name substitution, "@%s" chunk names).
Index ¶
- func DecodeBLP(data []byte) (image.Image, error)
- func ScreenRect(r Rect, screenHeight float64) image.Rectangle
- type AudioHost
- type CharacterEntry
- type Font
- type GlueState
- type Host
- type Loader
- type LoginHost
- type RealmInfo
- type Rect
- type Runtime
- func (rt *Runtime) Close()
- func (rt *Runtime) Execute(source, chunkName string) bool
- func (rt *Runtime) FireEvent(event string, payload ...lua.LValue) int
- func (rt *Runtime) GetCVar(name string) (string, bool)
- func (rt *Runtime) ScriptErrors() []ScriptError
- func (rt *Runtime) SetCVar(name, value string)
- func (rt *Runtime) SetCVarDefault(name, value string)
- func (rt *Runtime) TraceInvocations() []string
- type ScriptError
- type UIEngine
- func (eng *UIEngine) Close()
- func (eng *UIEngine) HandleChar(char rune) bool
- func (eng *UIEngine) HandleCursor(x, y float64) bool
- func (eng *UIEngine) HandleKey(key window.Key) bool
- func (eng *UIEngine) HandleKeyUp(key window.Key) bool
- func (eng *UIEngine) HandleKeyWithMods(key window.Key, mods window.ModifierKey) bool
- func (eng *UIEngine) HandleMouse(x, y float64, button window.MouseButton, down bool) bool
- func (eng *UIEngine) Render(screenWidth, screenHeight int) *image.RGBA
- func (eng *UIEngine) SetGlueState(state GlueState)
- func (eng *UIEngine) SetInitialCredentials(account, password string, rememberMe bool)
- func (eng *UIEngine) SetStatusKey(key string)
- func (eng *UIEngine) Update(elapsed float64)
- type WorldHost
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CharacterEntry ¶
type CharacterEntry struct {
Name string
Race string
RaceID int
Class string
ClassID int
Gender int
Level int
Zone string
ZoneID uint32
MapID uint32
Flags uint32
CustomizeFlags uint32
Ghost bool
PaidCustomization bool
PaidRaceChange bool
PaidFactionChange bool
BackgroundModel string
}
CharacterEntry describes one character in the character list.
type Font ¶
type Font struct {
Name string
FontFile string
Height float64
Color rgba
Outline string
Shadow bool
JustifyH string
JustifyV string
}
Font is a named font object created from a <Font> element.
type GlueState ¶
type GlueState struct {
Connected bool
ServerName string
PendingRealmList bool
SelectedRealm int
Realms []RealmInfo
SelectedCharacter int
Characters []CharacterEntry
}
GlueState tracks connection-flow state the glue API surfaces to scripts.
type Host ¶
type Host interface {
ScreenSize() (width, height float64)
PlaySound(id string)
PlayMusic(name string)
PlayAmbience(name string)
StopMusic()
StopAmbience()
StopAllSFX()
LaunchURL(url string)
Quit(runLauncher bool)
ConsoleExec(command string)
Screenshot()
}
Host is implemented by the client shell to back glue API functions that touch audio, the platform, or connection state.
type Loader ¶
type Loader struct {
Root string
// contains filtered or unexported fields
}
Loader reads interface files from a directory tree laid out like the client's Interface data (Interface\GlueXML\...). File lookups are case-insensitive with forward or back slashes, matching the client's MPQ-backed path handling.
func NewLoaderWithAssets ¶
func (*Loader) LoadInterfaceFile ¶
LoadInterfaceFile dispatches one interface file by extension: .lua files execute as script chunks, anything else parses as interface XML. Include elements recurse through this function with paths resolved against the including file's directory.
func (*Loader) LoadTOC ¶
LoadTOC executes a table of contents: every non-comment line names a file relative to the TOC's own directory, entries load in order, and the optional progress callback reports (done, total) after each entry. Entry counting matches the client: non-empty lines that do not start with '#'.
type RealmInfo ¶
type RealmInfo struct {
Name string
Address string
Population string
RealmType string
Locale string
}
RealmInfo describes one realm entry returned by the realm list.
type Rect ¶
type Rect struct {
X0, Y0, X1, Y1 float64 // top-left, bottom-right in client UI space (Y up)
}
Rect is a resolved screen-space rectangle. Y grows downward to match the interface coordinate system (BOTTOMLEFT is the origin of the client's UI space; callers convert when drawing).
func ResolveRect ¶
ResolveRect computes the layout rect of a widget against its parent rect.
type Runtime ¶
type Runtime struct {
L *lua.LState
// Glue carries the connection-flow state surfaced by the realm and
// character list API functions.
Glue GlueState
// Host hooks supply client state that lives outside the interface
// runtime: screen size, audio, login actions, realm and character
// data. Nil hooks behave as an idle, unconnected client.
Host Host
// contains filtered or unexported fields
}
Runtime owns the Lua state, widget registry, virtual template registry, cvar store, and glue event dispatch for one interface session.
func NewRuntime ¶
NewRuntime creates the Lua state and registers the glue API and widget method tables. Callers must Close it when done.
func (*Runtime) Execute ¶
Execute runs Lua source with the given chunk name, recording errors the way the original client logs them. Inline XML bodies pass their enclosing file as the chunk source for error attribution.
func (*Runtime) FireEvent ¶
FireEvent dispatches a glue event to every subscribed widget, passing the event name and payload after the widget argument, matching the OnEvent calling convention the interface scripts expect.
func (*Runtime) GetCVar ¶
GetCVar reads a cvar through the same case-insensitive lookup the client uses for console variables.
func (*Runtime) ScriptErrors ¶
func (rt *Runtime) ScriptErrors() []ScriptError
ScriptErrors returns the script failures recorded so far.
func (*Runtime) SetCVarDefault ¶
SetCVarDefault registers the default value returned by GetCVarDefault.
func (*Runtime) TraceInvocations ¶
TraceInvocations records handler dispatches for diagnostics.
type ScriptError ¶
ScriptError records one Lua load or runtime failure with the chunk name it occurred in, mirroring what the original client writes to its glue log.
func (ScriptError) Error ¶
func (e ScriptError) Error() string
type UIEngine ¶
type UIEngine struct {
Rt *Runtime
FontObj *opentype.Font
FontObjSm *opentype.Font
AssetLoader *Loader
Cache map[string]image.Image
BgImagePath string // Path to a static background image (JPEG/PNG)
// contains filtered or unexported fields
}