Black Mesa Component Prefix QML Files
This page contains information about component prefix QML
Black Mesa files and their code from Resonance Decade Update.
component-alert.qml
component-alert.qml implements the shared modal dialog component used throughout the Black Mesa Qt UI. It is registered in qmldir as Alert 1.0 and is instantiated directly by eight files: routeview-quit.qml, routeview-savebeforequit.qml, routeview-savegame.qml, routeview-loadgame.qml, routeview-video.qml, routeview-audio.qml, routeview-bindings.qml, and main.qml.
Registration
| Key | Value |
|---|---|
| Type name | Alert
|
| Version | 1.0
|
| Source file | component-alert.qml
|
| Base element | MouseArea
|
Root Element
The root element is a MouseArea, not an Item or Rectangle. This is intentional: the MouseArea fills its parent (anchors.fill: parent) and intercepts all pointer events, preventing click-through to the content behind the modal while it is visible. hoverEnabled: true is set so that onEntered and onExited handlers can also consume hover events. Both handlers are empty stubs whose sole purpose is event interception. onClicked calls mouse.accepted = true for the same reason.
The root starts with visible: false and state: "hidden". The enabled and hoverEnabled properties are toggled by the state machine rather than being hardcoded.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
skrim
|
bool
|
true
|
Controls visibility of the dark background overlay rectangle behind the modal panel. |
titleText
|
alias → headerText.text
|
(empty) | Text displayed in the modal header bar. |
messageText
|
alias → bodyText.text
|
(empty) | Text displayed in the modal body. Rendered as Text.RichText.
|
buttons
|
VisualItemModel
|
(unset) | The button row model. Consumed by an internal horizontal ListView.
|
modalWidth
|
int
|
Math.ceil(700 * Theme.heightScale)
|
Width of the modal panel in pixels. |
modalHeight
|
int
|
Math.ceil(215 * Theme.heightScale)
|
Height of the modal panel in pixels. |
spacing
|
int
|
Math.ceil(25 * Theme.heightScale)
|
Defined but unused in the layout. |
headerHeight
|
int
|
Math.ceil(65 * Theme.heightScale)
|
Height of the header bar and the button row ListView.
|
padding
|
int
|
Math.ceil(25 * Theme.widthScale)
|
Left padding applied to header text, body text, and button row right margin. |
headerFontSize
|
int
|
Math.ceil(18 * Theme.heightScale)
|
Font size used for both the header text and the body text. |
buttonSpacing
|
int
|
Math.ceil(5 * Theme.widthScale)
|
Spacing between buttons in the horizontal ListView.
|
Public API
Two functions control the modal's visibility:
show()— setsstate = "visible", triggering the show transition.hide()— setsstate = "hidden", triggering the hide transition.
There are no signals. Consumers communicate results entirely through button onClicked handlers defined inline in the VisualItemModel.
State Machine
| State | skrimRect.opacity
|
modal.opacity
|
alert.enabled
|
alert.visible
|
alert.hoverEnabled
|
|---|---|---|---|---|---|
hidden
|
0
|
0
|
false
|
false
|
false
|
visible
|
Theme.opacity.modalSkrim (0.9)
|
Theme.opacity.modal (0.95)
|
true
|
true
|
true
|
Visual Structure
Skrim
skrimRect is a full-parent Rectangle with color: Theme.colors.skrim (#2d2d2d) and visible: skrim. When skrim is false, the rectangle is hidden entirely regardless of opacity. Two consumers — routeview-quit.qml and routeview-savebeforequit.qml — set skrim: false because they are full-screen route views with their own background, not overlays on top of other content.
Modal Panel
modal is an Item centered in the root via anchors.centerIn: parent. Its initial anchors.verticalCenterOffset is 30000, placing it far off-screen. The show/hide transitions animate this offset to move the panel on and off screen.
The panel contains three child elements stacked vertically:
1. Header bar (header): an Item of height alert.headerHeight containing a Rectangle filled with Theme.colors.highlight (#e47125) at opacity: Theme.opacity.modalHeader (0.85), and a Text element (headerText) with Font.AllUppercase capitalization, Theme.fonts.bold, and color: Theme.colors.headerText (white).
2. Body text (bodyText): a Text element anchored below the header with anchors.topMargin: alert.padding. Uses Theme.fonts.light, color: Theme.colors.text (white), and textFormat: Text.RichText. No explicit width is set.
3. Button row: a horizontal ListView anchored below bodyText with layoutDirection: Qt.RightToLeft, height: headerHeight, interactive: false, and cacheBuffer: 0. Its model is the buttons VisualItemModel property. Buttons are right-aligned and laid out right-to-left, so the first item in the model appears rightmost.
A background Rectangle fills the entire modal panel with color: Theme.colors.modalBackground (#222222) and opacity: Theme.opacity.modal (0.95).
Transitions
A ParallelAnimation runs three animations simultaneously:
skrimRect.opacityanimates to its target value over 600 ms (no easing specified, defaults to linear).modal.anchors.verticalCenterOffsetanimates from 300 to 0 over 600 ms withEasing.InOutQuint.- A
SequentialAnimation:ScriptAction: callsBlackMesaUtils.clearUIElementsData().PauseAnimation: 300 ms.NumberAnimation:modal.opacityfrom 0.0 to 1.0 over 300 ms.PauseAnimation: 150 ms.ScriptAction: callsBlackMesaUtils.traverseUIElements(alert)thenBlackMesaUtils.afterTraverseCallback()to register the modal's interactive elements with the controller/keyboard navigation system.
Hide (catch-all)
The second Transition has no from or to attributes, making it the catch-all for all other state changes (in practice, visible → hidden). It runs a SequentialAnimation:
ScriptAction: callsBlackMesaUtils.clearUIElementsData().ParallelAnimation:skrimRect.opacityto 0 over 600 ms.modal.anchors.verticalCenterOffsetfrom 0 to 300 over 600 ms withEasing.InOutQuint.modal.opacityfrom 1.0 to 0.0 over 300 ms.
NumberAnimation:modal.anchors.verticalCenterOffsetfrom 300 to 30000 over 1 ms — an instant snap to the off-screen parking position.ScriptAction: callsBlackMesaUtils.traverseUIElements(appRoot),BlackMesaUtils.afterTraverseCallback(), andappRoot.forceActiveFocus()to restore navigation focus to the main UI.
Consumers
| File | Instance id | skrim
|
Trigger | Buttons |
|---|---|---|---|---|
routeview-quit.qml
|
alert
|
false
|
Component.onCompleted
|
Quit (CTAButton), Cancel (DefaultButton)
|
routeview-savebeforequit.qml
|
alert
|
false
|
Component.onCompleted
|
Cancel (CTAButton), Don't Save (CTAButton), Save (DefaultButton)
|
routeview-savegame.qml
|
confirmOverwriteAlert
|
true (default)
|
CarouselLoadGameItem.onSelected when save slot is occupied
|
Overwrite Save (WarningButton), Cancel (DefaultButton)
|
routeview-savegame.qml
|
confirmDeleteAlert
|
true (default)
|
CarouselLoadGameItem.onSelectedSecondary
|
Delete Save (WarningButton), Cancel (DefaultButton)
|
routeview-loadgame.qml
|
confirmDeleteAlert
|
true (default)
|
CarouselLoadGameItem.onSelectedSecondary
|
Delete Save (WarningButton), Cancel (DefaultButton)
|
routeview-video.qml
|
confirmAlert
|
true (default)
|
onRouteWillChange when pending changes exist
|
Apply (CTAButton), Discard (WarningButton), Cancel (DefaultButton)
|
routeview-audio.qml
|
confirmAlert
|
true (default)
|
onRouteWillChange when pending changes exist
|
Apply (CTAButton), Discard (WarningButton), Cancel (DefaultButton)
|
routeview-bindings.qml
|
(conflict alert) | true (default)
|
Key conflict detected during binding capture | Confirm (CTAButton), Cancel (DefaultButton)
|
routeview-bindings.qml
|
(reset defaults alert) | true (default)
|
Reset All Defaults button clicked | Confirm (CTAButton), Cancel (DefaultButton)
|
main.qml
|
alertLoadFailed
|
true (default)
|
onLevelLoadingFinished with failure reason
|
OK (DefaultButton)
|
The titleText and messageText for each instance are sourced from L10n.strings.headers.* and L10n.strings.modalMessages.* respectively, except for routeview-quit.qml (which uses a random entry from L10n.strings.quit) and main.qml (which uses BlackMesaEngine.getLocalizedString() directly with #BlackMesaUI_Error and a runtime error string).
Localization Keys
| Consumer | titleText key
|
messageText key
|
|---|---|---|
routeview-quit.qml
|
L10n.strings.headers.quit
|
Random entry from L10n.strings.quit (#QTUI_Quit_Quote01–#QTUI_Quit_Quote06)
|
routeview-savebeforequit.qml
|
L10n.strings.headers.saveBeforeQuit
|
L10n.strings.modalMessages.saveBeforeQuit
|
routeview-savegame.qml (overwrite)
|
L10n.strings.headers.overwriteSaveConfirmation
|
L10n.strings.modalMessages.overwriteSaveConfirmation
|
routeview-savegame.qml (delete)
|
L10n.strings.headers.deleteSaveConfirmation
|
L10n.strings.modalMessages.deleteSaveConfirmation
|
routeview-loadgame.qml (delete)
|
L10n.strings.headers.deleteSaveConfirmation
|
L10n.strings.modalMessages.deleteSaveConfirmation
|
routeview-video.qml / routeview-audio.qml
|
L10n.strings.headers.unsavedWarning
|
L10n.strings.modalMessages.unsavedWarning
|
main.qml
|
BlackMesaEngine.getLocalizedString("#BlackMesaUI_Error")
|
Runtime error string (levelLoadingFinished_FailureReason)
|
Notable Issues
1. modalWidth uses Theme.heightScale. The width is computed as Math.ceil(700 * Theme.heightScale) instead of Theme.widthScale. On non-square displays where the two scale factors differ, the modal will be narrower or wider than intended relative to the horizontal layout.
2. spacing property is dead code. The property spacing: Math.ceil(25 * Theme.heightScale) is declared but referenced nowhere in the component's layout. No child element uses it.
3. bodyText has no explicit width. The body Text element has no width binding. If messageText is a long single-line string, it will overflow the modal panel horizontally with no clipping, since modal does not set clip: true.
4. Double opacity on the background rectangle. The background Rectangle inside modal has opacity: Theme.opacity.modal (0.95) hardcoded. The parent modal Item also has its opacity animated from 0 to 1 during the show transition. The effective background opacity when fully visible is 0.95 × 0.95 ≈ 0.9025, not 0.95 as intended. The header and body text are children of modal and are also subject to the parent opacity, so they are unaffected by the background's own opacity setting.
5. modal.anchors.verticalCenterOffset: 30000 is an off-screen parking hack. The modal is hidden by moving it 30,000 pixels below center rather than by setting visible: false. This is necessary because QML transitions cannot run on elements with visible: false. The 1 ms NumberAnimation at the end of the hide transition snaps the offset back to 30000 after the slide-out animation completes, ensuring the modal is parked off-screen before the next show.
6. Catch-all hide transition. The second Transition has no from or to specified, making it apply to all state changes not matched by the first transition. Since there are only two states (hidden and visible), this is equivalent to specifying from: "visible"; to: "hidden", but it is less explicit and would silently apply to any future states added to the component.
7. appRoot referenced by id in the hide transition. The ScriptAction at the end of the hide transition calls BlackMesaUtils.traverseUIElements(appRoot) and appRoot.forceActiveFocus(). appRoot is the root Item id defined in main.qml. This creates an implicit dependency on the id being in scope at the point where Alert is instantiated. All current consumers are direct or indirect children of appRoot, so this works, but it makes Alert non-portable outside of the main.qml hierarchy.
8. routeview-quit.qml and routeview-savebeforequit.qml auto-show on Component.onCompleted. These two consumers call alert.show() immediately when the component is created, meaning the modal appears as soon as the route is pushed onto the StackView. The show transition (600 ms) runs concurrently with the router's push transition, which may produce visual overlap between the two animations.
9. Button order is right-to-left. The ListView uses layoutDirection: Qt.RightToLeft, so the first item in the VisualItemModel appears at the rightmost position. Consumers must account for this when ordering buttons: the primary action (e.g. Quit, Apply) is placed first in the model to appear on the right, and Cancel is placed last to appear on the left.
component-binding.qml
component-binding.qml defines the BindingList type, the shared base component for all five key-binding category panels in the bindings options screen. It is registered in qmldir as BindingList 1.0 component-binding.qml and is subclassed by component-binding-movement.qml, component-binding-combat.qml, component-binding-misc.qml, component-binding-weapons.qml, and component-binding-multiplayer.qml.
Overview
The file is 111 lines. The root element is an Item with no id. It manages a ListView of key-binding rows, each rendered via component-optionslist-row.qml, and keeps the displayed key labels in sync with the live state of config.cfg by listening to signals from the InputBindingsManager singleton.
Registration
| Property | Value |
|---|---|
| QML type name | BindingList
|
| Version | 1.0
|
| Source file | component-binding.qml
|
| qmldir line | BindingList 1.0 component-binding.qml
|
Properties
| Property | Type | Default | Description |
|---|---|---|---|
commands
|
variant
|
(unset) | Array of binding config objects, each produced by InputBindingsManager.getBindingComponentConfig(). Set by the subclass.
|
bindings
|
variant
|
(unset) | Map of command string → array of bound key strings, populated asynchronously by refreshBindings().
|
selected
|
bool
|
(unset) | Passed through to every row delegate as the selected property.
|
rowHeight
|
int
|
Math.ceil(85 * Theme.heightScale)
|
Height of each binding row in pixels. |
scrollbarDimension
|
int
|
Math.ceil(15 * Theme.widthScale)
|
Width and implicit height of the inline scrollbar thumb. |
opacity
|
real
|
0
|
Hardcoded to zero; the router transition animates it to 1 when the panel becomes active.
|
Signals
| Signal | Parameters | Description |
|---|---|---|
requestInputBinding
|
var cfg, var callback
|
Declared but never emitted within this file. Appears to be dead code; the actual binding-capture flow is initiated directly through InputBindingsManager.selectBinding() from component-optionslist-input-bindingcell.qml.
|
requestInputSelection
|
var model, var ordinal
|
Declared but never emitted within this file. The equivalent functionality is handled by component-optionslist-input-binding.qml calling InputBindingsManager.selectBinding() directly.
|
Functions
refreshBindings()
Defers a call to InputBindingsManager.getBindings() by 1 ms using the internal timer.setTimeout() helper. Extracts the command strings from the commands array, passes them to getBindings(), and stores the result in bindings. The 1 ms deferral prevents synchronous blocking during binding-change events.
var keys = commands.map(function (cfg) { return cfg.command; });
InputBindingsManager.getBindings(keys, function (response) { bindings = response; });
Internal Timer
A Timer element with id: timer implements a setTimeout(callback, delay) helper. It stops any running timer, sets the interval, connects the callback and a self-disconnecting release function to triggered, then starts. This pattern ensures only one deferred call is pending at a time; a second call to setTimeout before the first fires will cancel the first.
Connections to InputBindingsManager
A Connections block targets the InputBindingsManager singleton and calls refreshBindings() on three signals:
| Signal | Trigger |
|---|---|
onBindingSet
|
A key was successfully bound to a command. |
onBindingClear
|
A binding was cleared. |
onDefaultsRestored
|
All bindings were reset to defaults. |
Component.onCompleted also calls refreshBindings() to populate the initial state.
onBindingsChanged Handler
When bindings is updated, the handler iterates over every item in bindingsList.model, resets key1 and key2 to empty strings, then repopulates them from the new bindings map:
current.key1 = bindings[current.command][0];
current.key2 = bindings[current.command][1];
This directly mutates ListModel role properties in-place. The ListModel must have been populated with key1 and key2 roles at append() time for this to work; if a role is absent, the assignment silently fails.
ListView (bindingsList)
| Property | Value |
|---|---|
anchors.fill
|
parent
|
interactive
|
true
|
boundsBehavior
|
Flickable.StopAtBounds
|
cacheBuffer
|
50000
|
The model is a ListModel populated in Component.onCompleted by iterating over commands and calling append(cfg) for each config object. Each cfg object has the roles label, type, command, key1, and key2.
Delegate
Each row is a Loader with width: bindingsList.width and height: rowHeight. In Component.onCompleted, the loader calls:
loader.setSource('component-optionslist-row.qml', { model: model, selected: selected })
The model passed is the ListModel role object for that row. The selected value is the BindingList-level selected property, shared identically across all rows.
Inline ScrollBar
The ListView attaches an inline ScrollBar via ScrollBar.vertical rather than using the registered VerticalScrollBar type. Visibility is conditional:
visible: bindingsList.height + bindingsList.bottomMargin + bindingsList.topMargin + 2 < bindingsList.contentHeight
The thumb is a Rectangle with implicitWidth: scrollbarDimension and color: Theme.colors.highlight.
Usage in routeview-bindings.qml
routeview-bindings.qml defines five category entries in a ListModel, each with a qmlFile property pointing to one of the five subclass files. When the user selects a category, outlet.setCategory(model) is called, which loads the corresponding qmlFile into a Loader via setSource(). The loaded BindingList subclass sets the commands array; BindingList then handles all binding retrieval and display automatically.
The five categories and their files are:
| Rank | Category key | Label property | QML file |
|---|---|---|---|
| 0 | movement
|
labels.binding_movement
|
component-binding-movement.qml
|
| 1 | combat
|
labels.binding_combat
|
component-binding-combat.qml
|
| 2 | misc
|
labels.binding_misc
|
component-binding-misc.qml
|
| 3 | weapons
|
labels.binding_weapons
|
component-binding-weapons.qml
|
| 4 | multiplayer
|
labels.binding_multiplayer
|
component-binding-multiplayer.qml
|
Imports
| Module | Version | Purpose |
|---|---|---|
QtQuick
|
2.9
|
Core QML types (Item, ListView, Timer, Connections, ListModel, Loader, Rectangle, ScrollBar)
|
QtQuick.Controls
|
2.2
|
ScrollBar attached property
|
CrowbarCollective
|
1.0
|
Access to InputBindingsManager, Theme
|
Quirks and Observations
1. Both declared signals are dead code. requestInputBinding and requestInputSelection are never emitted anywhere in the file or in any subclass. The actual binding-capture flow bypasses these signals entirely, going directly through InputBindingsManager.selectBinding() and InputBindingsManager.startBindingRequest() from component-optionslist-input-bindingcell.qml.
2. Inline ScrollBar duplicates VerticalScrollBar. The registered VerticalScrollBar 1.0 type is not used here. The inline scrollbar uses scrollbarDimension based on Theme.widthScale, while VerticalScrollBar uses Theme.widthScale as well but is a separate, independently maintained implementation. Any future changes to the scrollbar style must be applied in both places.
3. cacheBuffer: 50000 pre-renders all rows. With rowHeight of approximately 85 scaled pixels, a list of 15 rows (the maximum in component-binding-weapons.qml) has a total height of roughly 1275 scaled pixels. A cache buffer of 50000 pixels ensures every row is always instantiated, effectively disabling ListView's virtualization for this component.
4. selected is a single value shared by all rows. The selected property on the BindingList root is passed identically to every row delegate. It is not per-row; it reflects the global selection state managed by InputBindingsManager.selectedCfg. Individual row selection is handled inside component-optionslist-input-bindingcell.qml by comparing InputBindingsManager.selectedCfg to the row's own config.
5. onBindingsChanged resets all rows on every binding change. Even if only one binding changed (e.g. a single key was rebound), the handler clears and repopulates key1 and key2 for every row in the model. For the largest category (weapons, 15 rows) this is 15 model mutations per binding event.
6. No id on the root Item. Consistent with all other component-binding-*.qml files, but means child elements cannot reference the root by id.
7. timer.setTimeout cancels any pending deferred call. If refreshBindings() is called twice in rapid succession (e.g. onBindingSet fires while a previous refresh is still pending), the second call cancels the first. This is intentional but means the first callback is silently dropped without executing.
component-binding-combat.qml
component-binding-combat.qml defines the Combat binding category for the key bindings options page. It is a direct subtype of BindingList and declares the commands array that populates one column of BindingCell rows inside routeview-bindings.qml.
Registration
component-binding-combat.qml is not registered in qmldir. It is loaded dynamically by routeview-bindings.qml via a plain string path stored in the categories object:
qmlFile: "component-binding-combat.qml"
The BindingList base type (component-binding.qml) is registered as BindingList 1.0 and is the only named type involved.
Category descriptor (routeview-bindings.qml)
The combat entry in the categories object inside routeview-bindings.qml is:
| Property | Value |
|---|---|
label |
labels.binding_combat
|
rank |
1
|
type |
"binding"
|
action |
"nav"
|
category |
"combat"
|
qmlFile |
"component-binding-combat.qml"
|
Rank 1 places Combat second in the category list, after Movement (rank 0) and before Misc (rank 2), Weapons (rank 3), and Multiplayer (rank 4).
Structure
The root element is a BindingList with no id. It sets a single property:
| Property | Type | Value |
|---|---|---|
commands |
array |
Array of 15 config objects returned by InputBindingsManager.getBindingComponentConfig(command)
|
No other properties, signals, or child elements are declared.
Commands
Each entry is produced by InputBindingsManager.getBindingComponentConfig(command), which returns an object with label, type, command, key1, and key2. Labels are resolved from L10n.strings.options.bindings at singleton initialization time.
| # | Command string | commandMap key |
L10n property |
Localization key |
|---|---|---|---|---|
| 1 | +use |
labels.use |
bindings.use |
#QTUI_Option_Binding_Use
|
| 2 | +attack |
labels.primary |
bindings.primary |
#QTUI_Option_Binding_PrimaryAttack
|
| 3 | +attack2 |
labels.secondary |
bindings.secondary |
#QTUI_Option_Binding_SecondaryAttack
|
| 4 | +reload |
labels.reload |
bindings.reload |
#QTUI_Option_Binding_Reload
|
| 5 | impulse 100 |
labels.flashlight |
bindings.flashlight |
#QTUI_Option_Binding_Flashlight
|
| 6 | +zoom |
labels.zoom |
bindings.zoom |
#QTUI_Option_Binding_SuitZoom
|
| 7 | invnext |
labels.nextWeapon |
bindings.nextWeapon |
#QTUI_Option_Binding_NextWeapon
|
| 8 | invprev |
labels.previousWeapon |
bindings.previousWeapon |
#QTUI_Option_Binding_PreviousWeapon
|
| 9 | lastinv |
labels.lastWeapon |
bindings.lastWeapon |
#QTUI_Option_Binding_LastWeapon
|
| 10 | slot1 |
labels.weaponCategory1 |
bindings.weaponCategory1 |
#QTUI_Option_Binding_WeaponCategory1
|
| 11 | slot2 |
labels.weaponCategory2 |
bindings.weaponCategory2 |
#QTUI_Option_Binding_WeaponCategory2
|
| 12 | slot3 |
labels.weaponCategory3 |
bindings.weaponCategory3 |
#QTUI_Option_Binding_WeaponCategory3
|
| 13 | slot4 |
labels.weaponCategory4 |
bindings.weaponCategory4 |
#QTUI_Option_Binding_WeaponCategory4
|
| 14 | slot5 |
labels.weaponCategory5 |
bindings.weaponCategory5 |
#QTUI_Option_Binding_WeaponCategory5
|
| 15 | slot6 |
labels.weaponCategory6 |
bindings.weaponCategory6 |
#QTUI_Option_Binding_WeaponCategory6
|
component-binding-misc.qml
component-binding-misc.qml defines the Miscellaneous key-binding category for the routeview-bindings.qml key bindings page. It extends BindingList (component-binding.qml) and provides a static commands array of ten engine commands covering save/load shortcuts, the developer console, closed-caption toggle, swimming, and keyboard look/turn controls.
Registration
| Property | Value |
|---|---|
| QML type name | (none — not registered in qmldir)
|
| Base type | BindingList (component-binding.qml)
|
Registered in qmldir |
No |
| Instantiated by | routeview-bindings.qml via dynamic Loader (setSource)
|
| Category key | misc
|
| Category rank | 2 (second in the left-panel list, after movement)
|
The file is loaded dynamically. routeview-bindings.qml defines the category object:
misc: {
label: labels.binding_misc,
type: "binding",
rank: 2,
action: "nav",
category: "misc",
qmlFile: "component-binding-misc.qml"
}
Command List
The commands array is built at instantiation time by calling InputBindingsManager.getBindingComponentConfig(command) for each engine command string. Each call returns a plain JavaScript object with label, type, command, key1, and key2 fields.
| # | Engine command | commandMap key (input-bindings-manager.qml) |
L10n property | Localization key |
|---|---|---|---|---|
| 1 | save quick |
labels.quickSave |
L10n.strings.options.bindings.quickSave |
#QTUI_Option_Binding_QuickSave
|
| 2 | load quick |
labels.quickLoad |
L10n.strings.options.bindings.quickLoad |
#QTUI_Option_Binding_QuickLoad
|
| 3 | toggleconsole |
labels.devConsole |
L10n.strings.options.bindings.devConsole |
#QTUI_Option_Binding_Console
|
| 4 | incrementvar closecaption 0 1 1 |
labels.ccSoundEffects |
L10n.strings.options.bindings.ccSoundEffects |
#QTUI_Option_Binding_CCSoundEffects
|
| 5 | +moveup |
labels.swimUp |
L10n.strings.options.bindings.swimUp |
#QTUI_Option_Binding_SwimUp
|
| 6 | +movedown |
labels.swimDown |
L10n.strings.options.bindings.swimDown |
#QTUI_Option_Binding_SwimDown
|
| 7 | +lookup |
labels.lookUp |
L10n.strings.options.bindings.lookUp |
#QTUI_Option_Binding_LookUp
|
| 8 | +lookdown |
labels.lookDown |
L10n.strings.options.bindings.lookDown |
#QTUI_Option_Binding_LookDown
|
| 9 | +left |
labels.turnLeft |
L10n.strings.options.bindings.turnLeft |
#QTUI_Option_Binding_TurnLeft
|
| 10 | +right |
labels.turnRight |
L10n.strings.options.bindings.turnRight |
#QTUI_Option_Binding_TurnRight
|
Inherited Behaviour (BindingList)
All behaviour is inherited from BindingList (component-binding.qml):
- On instantiation,
Component.onCompletedcallsrefreshBindings(), which uses a 1 msTimerto asynchronously callInputBindingsManager.getBindings(keys, callback). The callback populates thebindingsproperty. onBindingsChangediterates the returned binding data and updates theListViewmodel (bindingsList.model).- A
Connectionsblock onInputBindingsManagerre-callsrefreshBindings()ononBindingSet,onBindingClear, andonDefaultsRestored. - The root
Itemhasopacity: 0; the parentrouteview-bindings.qmlanimates it to1when the category is selected.
component-binding-movement.qml
component-binding-movement.qml defines the Movement category of the key bindings page. It is a concrete BindingList subtype that declares the seven movement-related commands exposed to the player for rebinding.
Registration and Loading
The file is not registered in qmldir. It is loaded dynamically by routeview-bindings.qml via a Loader when the user selects the Movement category from the left-hand category list. The category descriptor object that references it is:
| Property | Value |
|---|---|
label |
L10n.strings.options.labels.binding_movement
|
type |
"binding"
|
rank |
0
|
action |
"nav"
|
category |
"movement"
|
qmlFile |
"component-binding-movement.qml"
|
Rank 0 makes Movement the first entry in the category list. It is also the default category: routeview-bindings.qml calls outlet.setCategory(categories.movement, true) in its Component.onCompleted handler, so the Movement panel is always shown when the bindings page is first opened.
Root Element
The root element is BindingList (registered as BindingList 1.0 → component-binding.qml in qmldir). It has no id. The only property set is commands, which is a JavaScript array of seven configuration objects produced by InputBindingsManager.getBindingComponentConfig().
Command Table
Each entry in commands is produced by InputBindingsManager.getBindingComponentConfig(command), which returns a plain object with the shape { label, type: 'binding', command, key1: '', key2: '' }. The label is resolved from InputBindingsManager.commandMap, which is populated from L10n.strings.options.bindings at singleton initialisation time.
| # | Engine Command | commandMap Key |
Localization Key |
|---|---|---|---|
| 1 | +forward |
move_forward |
#QTUI_Option_Binding_MoveForward
|
| 2 | +back |
move_backward |
#QTUI_Option_Binding_MoveBackward
|
| 3 | +moveleft |
strafe_left |
#QTUI_Option_Binding_StrafeLeft
|
| 4 | +moveright |
strafe_right |
#QTUI_Option_Binding_StrafeRight
|
| 5 | +jump |
jump |
#QTUI_Option_Binding_Jump
|
| 6 | +duck |
duck |
#QTUI_Option_Binding_Duck
|
| 7 | +speed |
sprint |
#QTUI_Option_Binding_Sprint
|
Each command supports two simultaneous key bindings (key1 and key2), rendered by component-binding.qml as two adjacent BindingCell elements per row.
Relationship to BindingList
BindingList (component-binding.qml) provides:
refreshBindings()— callsInputBindingsManager.getBindings(keys, callback)to populate the current key assignments for all commands in the list.- A
ListViewthat renders one row per command usingcomponent-optionslist-input-binding.qmlas the delegate, which in turn instantiates twoBindingCellelements. - A
Connectionsblock onInputBindingsManagerthat callsrefreshBindings()ononBindingSet,onBindingClear, andonDefaultsRestored. - An initial
refreshBindings()call inComponent.onCompleted.
component-binding-movement.qml contributes only the commands array; all rendering, key-capture, and conflict-resolution logic is inherited from BindingList and BindingCell.
Omitted Movement Commands
Several engine commands that are conceptually movement-related are not included in this file and are instead placed in the Misc category (component-binding-misc.qml):
+moveup(Swim Up)+movedown(Swim Down)+lookup(Look Up)+lookdown(Look Down)+left(Turn Left)+right(Turn Right)
This split is a design choice: the six omitted commands are keyboard-only legacy controls rarely used with mouse-look, so they are grouped with miscellaneous bindings rather than the primary movement set.
component-binding-multiplayer.qml
component-binding-multiplayer.qml is a concrete BindingList subtype that defines the Multiplayer key-binding category in the bindings options page. It is the smallest of the five binding category files, containing exactly two commands.
Registration
The file is not registered in qmldir. It is loaded dynamically by routeview-bindings.qml via a Loader when the user selects the Multiplayer category from the left-hand category list. The load path is the bare filename string "component-binding-multiplayer.qml", resolved relative to the UI directory.
The corresponding category entry in routeview-bindings.qml is:
| Property | Value |
|---|---|
| Key | multiplayer
|
| Label | labels.binding_multiplayer (from L10n.strings.options.bindings)
|
| Type | "binding"
|
| Rank | 4
|
| Action | "nav"
|
| QML file | "component-binding-multiplayer.qml"
|
Rank 4 places Multiplayer last in the category list, after Movement (0), Combat (1), Misc (2), and Weapons (3).
Base type: BindingList
The root element is BindingList, registered as BindingList 1.0 component-binding.qml in qmldir. BindingList is an Item subtype that:
- Accepts a
commandsarray of binding config objects produced byInputBindingsManager.getBindingComponentConfig(). - Calls
InputBindingsManager.getBindings()to fetch the current key assignments for all commands in the list. - Renders each command as a
BindingCellrow (component-optionslist-input-bindingcell.qml) inside aListView. - Reacts to
InputBindingsManager.onBindingSet,onBindingClear, andonDefaultsRestoredsignals to refresh the displayed bindings.
Commands
The commands array contains two entries, both produced by InputBindingsManager.getBindingComponentConfig():
| # | Command string | Type | Description |
|---|---|---|---|
| 1 | chooseteam |
Impulse | Opens the team-selection menu in multiplayer. |
| 2 | +voicerecord |
Analog (hold) | Activates push-to-talk voice communication while held. |
getBindingComponentConfig() returns a plain object with the shape { label, type: 'binding', command, key1: '', key2: '' }. The label field is looked up from InputBindingsManager.commandMap, which maps each command string to its localized display name sourced from L10n.strings.options.bindings.
Interaction with InputBindingsManager
InputBindingsManager (input-bindings-manager.qml) maintains the commandMap IIFE that maps 'chooseteam' and '+voicerecord' to their respective localized label strings. Both commands are present in the map; if either were absent, getBindingComponentConfig() would return a config object with label: undefined, and the BindingCell row would render a blank label with no error.
The BindingList base class connects to InputBindingsManager.onBindingSet, onBindingClear, and onDefaultsRestored to call refreshBindings() whenever the binding state changes globally, keeping the two rows in sync with the rest of the bindings page.
component-binding-weapons.qml
component-binding-weapons.qml defines the Weapons key-binding category panel displayed in the right pane of the key bindings page (routeview-bindings.qml) when the user selects the "Weapons" category. It is a direct subtype of BindingList (component-binding.qml) and contains no logic of its own beyond declaring the 14 weapon-select commands it manages.
Registration
component-binding-weapons.qml is not registered in qmldir. It is loaded dynamically by routeview-bindings.qml via Loader.setSource() using the relative path string "component-binding-weapons.qml" when the user activates the Weapons category in the left-panel category list.
Base type: BindingList
The root element is BindingList, which maps to component-binding.qml (registered as BindingList 1.0 in qmldir). BindingList provides:
- A
commandsproperty (variant) — the array of binding config objects populated by the subtype. - A
bindingsproperty (variant) — the live key-binding map fetched fromconfig.cfgviaInputBindingsManager.getBindings(). - A
selectedproperty (bool) — passed down to each row delegate. - A
refreshBindings()function — re-fetches current bindings fromInputBindingsManagerand updates each row'skey1andkey2fields. - A
ListView(id: bindingsList) — renders each entry incommandsas anOptionsListRowloaded viaLoader.setSource('component-optionslist-row.qml', ...). - A
ScrollBar.vertical— shown only when the list content height exceeds the visible area. ConnectionstoInputBindingsManager— callsrefreshBindings()ononBindingSet,onBindingClear, andonDefaultsRestored.Component.onCompleted— callsrefreshBindings()on initial load.
commands array
The commands property is set to an array of 14 objects, each produced by InputBindingsManager.getBindingComponentConfig(command). That function returns:
{ label: commandMap[command], type: 'binding', command: command, key1: '', key2: '' }
The label is resolved from InputBindingsManager.commandMap, which maps each command string to a localized display name sourced from L10n.strings.options.bindings.
The 14 entries, in declaration order:
| Order | Command | commandMap key | L10n property |
|---|---|---|---|
| 1 | use weapon_crowbar |
weaponCrowbar |
labels.weaponCrowbar
|
| 2 | use weapon_glock |
weaponPistol |
labels.weaponPistol
|
| 3 | use weapon_357 |
weapon357 |
labels.weapon357
|
| 4 | use weapon_mp5 |
weaponMP5 |
labels.weaponMP5
|
| 5 | use weapon_shotgun |
weaponShotgun |
labels.weaponShotgun
|
| 6 | use weapon_crossbow |
weaponCrossbow |
labels.weaponCrossbow
|
| 7 | use weapon_rpg |
weaponRPG |
labels.weaponRPG
|
| 8 | use weapon_tau |
weaponTau |
labels.weaponTau
|
| 9 | use weapon_gluon |
weaponGluon |
labels.weaponGluon
|
| 10 | use weapon_hivehand |
weaponHiveHand |
labels.weaponHiveHand
|
| 11 | use weapon_frag |
weaponFrag |
labels.weaponFrag
|
| 12 | use weapon_tripmine |
weaponTripmine |
labels.weaponTripmine
|
| 13 | use weapon_satchel |
weaponSatchel |
labels.weaponSatchel
|
| 14 | use weapon_snark |
weaponSnarks |
labels.weaponSnarks
|
The use prefix is the Source engine console command for directly switching to a weapon by entity class name, as opposed to slot-based selection (slot1–slot6) or cycle commands (invnext, invprev).
Integration with routeview-bindings.qml
In routeview-bindings.qml, the Weapons category is defined as:
weapons: { label: labels.binding_weapons, type: "binding", rank: 3, action: "nav", category: "weapons", qmlFile: "component-binding-weapons.qml" }
It is the fourth category (rank 3) in the left-panel list, after Movement (rank 0), Combat (rank 1), and Misc (rank 2), and before Multiplayer (rank 4). When the user clicks the Weapons row in the category list, routeview-bindings.qml calls outlet.setCategory(categories.weapons) which loads component-binding-weapons.qml into the right-panel Loader.
Rendering
Each of the 14 commands is rendered as an OptionsListRow with type: "binding". The row loads component-optionslist-input-binding.qml, which in turn renders two BindingCell elements (key1 and key2) side by side. The BindingList base class sets rowHeight to Math.ceil(85 * Theme.heightScale). With visibleRows: 7 defined on routeview-bindings.qml, the right panel is 595 scaled pixels tall (7 × 85), so the 14-entry weapons list requires scrolling to reach entries 8–14.
component-carousel.qml
component-carousel.qml implements the horizontally paginated carousel widget used on the Campaign, Load Game, Save Game, and Workshop (Add-ons) screens. It is registered in qmldir as Carousel 1.0 and is the direct parent of all CarouselItem-derived delegates. The root is an Item (id: carousel) with anchors.fill: parent. It has no explicit objectName.
Properties
Data properties
| Property | Type | Default | Description |
|---|---|---|---|
levels |
ListModel |
(unset) | The data model passed to the internal ListView. Consumers must supply a populated ListModel.
|
itemComponent |
Component |
(unset) | The delegate Component instantiated for each entry in levels. Consumers assign a CarouselItem-derived Component here.
|
Layout properties
All dimensions are scaled at declaration time using Math.ceil and Theme.heightScale or Theme.widthScale.
| Property | Formula | Description |
|---|---|---|
buttonTopMargin |
Math.ceil(11 * Theme.heightScale) |
Top offset of the left/right navigation buttons relative to the mask top edge. |
buttonHorizontalMargin |
Math.ceil(25 * Theme.widthScale) |
Horizontal gap between each navigation button and the mask edge. |
maskHeight |
Math.ceil(400 * Theme.heightScale) |
Height of the clipping Item (mask) that contains the ListView.
|
maskPadding |
Math.ceil(100 * Theme.widthScale) * 2 |
Total horizontal padding subtracted from the parent width to derive maskWidth.
|
maskWidth |
parent.width - maskPadding |
Computed available width for the visible item area. |
itemHeight |
Math.ceil(400 * Theme.heightScale) |
Declared item height. Not used internally — see Observations. |
itemWidth |
Math.ceil(400 * Theme.widthScale) |
Width of each carousel item, used in pagination calculations and mask sizing. |
itemSpacing |
Math.ceil(8 * Theme.widthScale) |
Horizontal gap between items, passed to the ListView spacing property.
|
Pagination state properties
| Property | Type | Default | Description |
|---|---|---|---|
showRight |
bool |
false |
Controls visibility and enabled state of the right CarouselButton. Set to true when items exist beyond the right edge of the visible window.
|
showLeft |
bool |
false |
Controls visibility and enabled state of the left CarouselButton. Set to true when items exist to the left of the current view position.
|
visibleCount |
int (computed) |
— | Math.floor(maskWidth / (itemWidth + itemSpacing)). The number of items that fit in the mask at once. Drives mask width, ListView width, and pagination step size.
|
Function: changePagination(type)
The sole public function. Advances or retreats the carousel by one page. It is a no-op if paginateAnimSeq.running is true (i.e., a pagination animation is already in progress).
Parameters:
type = -1— scroll left (backward) byvisibleCountitems.type = 1— scroll right (forward) byvisibleCountitems.
Left pagination (type = -1)
- Computes
leftIndex = Math.floor(currX / itemW)whereitemW = carousel.itemWidth. - Computes
newIndex = leftIndex - visibleCount >= 0 ? leftIndex - visibleCount : 0. - Calls
itemsList.positionViewAtIndex(newIndex, ListView.Beginning)to snapcontentXto the target position, then reads back the newcontentXas the animation target. - Starts
paginateAnimSeqto animatecontentXfrom the old to the new value. - Updates
showRightbased on whether items remain beyond the new right edge. - Sets
showLeft = falseifnewIndex == 0.
Right pagination (type = 1)
- Computes
rightIndex = leftIndex + visibleCount - 1. - Computes
clippedRightCount = count - (visibleCount + leftIndex). - Computes
newIndex = clippedRightCount - visibleCount >= 0 ? rightIndex + visibleCount : count - 1. - Calls
itemsList.positionViewAtIndex(newIndex, ListView.End). - Starts
paginateAnimSeq. - Updates
showLeftbased on whethernewIndex - visibleCount >= 0. - Sets
showRight = falseifnewIndex == count - 1.
Child elements
Left CarouselButton
A CarouselButton (direction: "left") anchored to the right of the mask's left edge with buttonHorizontalMargin gap. enabled and opacity are both bound to showLeft. Opacity animates over 150 ms via a Behavior. Calls changePagination(-1) on click.
mask (Item)
An Item (id: mask) centered in the carousel root with clip: true.
height:maskHeightwidth:visibleCount * (itemWidth + itemSpacing)
Contains the ListView and the pagination SequentialAnimation.
itemsList (ListView)
| Property | Value |
|---|---|
orientation |
ListView.Horizontal
|
interactive |
false (no touch/mouse drag scrolling)
|
cacheBuffer |
8000 (hardcoded pixels)
|
spacing |
itemSpacing
|
model |
carousel.levels
|
delegate |
itemComponent
|
width |
parent.width - itemSpacing
|
height |
parent.height
|
Three unused properties are declared directly on the ListView: limit, offset, and page. These are dead code from an earlier pagination design.
On Component.onCompleted, showRight is set to count > 4 (hardcoded literal; see Observations).
paginateAnimSeq (SequentialAnimation)
A SequentialAnimation containing:
paginateAnim— aNumberAnimationtargetingitemsList.contentX, duration 100 ms, easingEasing.InOutQuint. Thefromandtovalues are set imperatively bychangePaginationbefore the sequence starts.- A
ScriptActionthat calls:BlackMesaUtils.parseTraversalTree(appRoot)— rebuilds the controller/keyboard navigation tree from the root.BlackMesaUtils.traversalDepth = 2— limits traversal depth to 2 levels.BlackMesaUtils.updateCurrentUISelection()— moves the current UI selection to the first focusable item in the new page.
Right CarouselButton
Symmetric to the left button. direction: "right", anchored to the left of the mask's right edge. Calls changePagination(1) on click.
CarouselButton is registered as CarouselButton 1.0 in qmldir and is used exclusively by component-carousel.qml.
Root type: MouseArea (id: carouselButton), hoverEnabled: true.
| Property | Formula | Description |
|---|---|---|
direction |
"left" or "right" |
Selects the chevron image source. |
buttonHeight |
Math.ceil(214 * Theme.widthScale) |
Button height (uses widthScale).
|
buttonWidth |
Math.ceil(100 * Theme.widthScale) |
Button width. |
States: blurred (image opacity 0.5) and focused (image opacity 1.0), with 150 ms NumberAnimation transitions in both directions. onEntered transitions to focused and plays Theme.sounds.buttonFocused. onExited transitions to blurred. onReleased plays Theme.sounds.buttonClicked.
The image is sourced from direction === "left" ? "image://game/ui/images/chevron-left.png" : "image://game/ui/images/chevron-right.png", scaled by Theme.widthScale.
Consumers
| File | Carousel id | Delegate | Data source |
|---|---|---|---|
routeview-newgame.qml |
newGameCarousel |
CarouselNewGameItem (campaign or chapter phase) |
BlackMesaEngine.listCampaignEntries() filtered to official campaigns
|
routeview-loadgame.qml |
loadGameCarousel |
CarouselLoadGameItem |
BlackMesaUtils.getSaveGames()
|
routeview-savegame.qml |
saveGameCarousel |
CarouselLoadGameItem |
BlackMesaUtils.getSaveGames() plus a "New Save" entry
|
routeview-addons.qml |
newGameCarousel |
CarouselNewGameItem (campaign or chapter phase) |
BlackMesaEngine.listCampaignEntries() filtered to non-official campaigns
|
Observations
1. showRight initialization uses a hardcoded literal 4. In Component.onCompleted, showRight = count > 4 uses the literal 4 instead of visibleCount. On a display where visibleCount computes to a value other than 4 (e.g. a very wide or narrow window), the initial arrow visibility will be incorrect. Consumers that repopulate levels after construction (routeview-newgame.qml, routeview-addons.qml) work around this by setting showRight explicitly in their onCurrentlySelectedCampaignChanged handler, but routeview-loadgame.qml and routeview-savegame.qml do not, leaving them exposed to this bug.
2. itemHeight is declared but never used. The property is defined as Math.ceil(400 * Theme.heightScale) but is not referenced anywhere inside component-carousel.qml. The mask height uses maskHeight (which has the same formula), and the ListView height is parent.height. itemHeight is also not read by any consumer. It is dead code.
3. leftIndex calculation ignores itemSpacing. changePagination computes leftIndex = Math.floor(currX / itemW) where itemW = carousel.itemWidth. The correct stride per item is itemWidth + itemSpacing. Because positionViewAtIndex always sets contentX to a multiple of the true stride, the fractional error is n * itemSpacing / itemWidth per page. With the default values (itemWidth = 400, itemSpacing = 8), the error reaches 1.0 at n = 50 pages, at which point Math.floor produces an incorrect leftIndex. This is a latent bug that does not manifest in practice given typical save/chapter counts.
4. itemsList.limit, offset, and page are dead code. These three properties are declared on the ListView but are never read or written by any code path in the file or by any consumer. They are remnants of an earlier offset-based pagination design.
5. cacheBuffer: 8000 is not scaled. The ListView pre-renders items within 8000 pixels of the visible area. This value is not multiplied by Theme.widthScale, so on high-DPI or scaled displays the effective cache coverage in logical units will differ from the intended amount.
6. CarouselButton.buttonHeight uses Theme.widthScale. The button height formula is Math.ceil(214 * Theme.widthScale). Using widthScale for a vertical dimension is inconsistent with the convention used throughout the rest of the UI, where Theme.heightScale governs vertical sizes.
7. Post-pagination ScriptAction re-traverses the entire UI tree. After every page turn, BlackMesaUtils.parseTraversalTree(appRoot) walks the full component tree from the root to rebuild the controller navigation graph. This is an O(n) operation over all UI elements and is called synchronously in the animation completion callback. On complex pages this may introduce a perceptible hitch at the end of the scroll animation.
8. var newIndex is declared twice in the same function scope. changePagination uses var newIndex in both the type == -1 and type == 1 branches. JavaScript var is function-scoped, so the second declaration is a silent re-declaration of the same variable. This is valid ES5 but is a code smell; let would scope each declaration to its block.
component-carousel-item.qml
component-carousel-item.qml is the base class for all carousel card delegates in the Black Mesa QML UI. It is registered as CarouselItem 1.0 in qmldir and subclassed by CarouselNewGameItem (component-carousel-item-newgame.qml) and CarouselLoadGameItem (component-carousel-item-loadgame.qml).
Registration
| Key | Value |
|---|---|
qmldir type name
|
CarouselItem 1.0
|
| Source file | component-carousel-item.qml
|
| Root element | Item (id: carouselItem)
|
objectName
|
"ui:carousel-item"
|
Properties
| Property | Type | Default | Description |
|---|---|---|---|
isLocked
|
bool
|
false
|
When true, hides the textComponent loader and shows a lock.png overlay on the thumbnail. The MouseArea is also disabled.
|
focusedSoundPath
|
string
|
Theme.sounds.buttonFocused
|
Sound played when the item enters the focused state. Overridable by subclasses; neither current subclass overrides it.
|
chapterName
|
string
|
"DEFAULT CHAPTER NAME"
|
Primary display name shown in the textComponent.
|
thumbnailUrl
|
string
|
"image://game/ui/images/background-reception.png"
|
Source URL for the thumbnail Image.
|
buttonText
|
string
|
"DEFAULT BUTTON TEXT"
|
Label for the primary action button. |
buttonTextSecondary
|
string
|
"DEFAULT BUTTON TEXT"
|
Label for the secondary action button. |
buttonType
|
string
|
"cta"
|
Determines which button QML file is loaded: "button-" + buttonType + ".qml". Valid values: "cta", "warning", "default".
|
secondaryButtonVisible
|
bool
|
false
|
Controls visibility of the secondary button loader. |
textComponent
|
Component
|
(unset) | Subclass-provided Component rendered below the thumbnail. Loaded by textComponentLoader.
|
itemWidth
|
int
|
Math.ceil(400 * Theme.widthScale)
|
Card width. |
itemHeight
|
int
|
Math.ceil(400 * Theme.heightScale)
|
Card height. |
thumbnailHeight
|
int
|
Math.ceil(214 * Theme.heightScale)
|
Declared but never used; actual thumbnail height is computed as Math.floor(width * 0.56).
|
thumbnailWidth
|
int
|
Math.ceil(380 * Theme.widthScale)
|
Declared but never used; thumbnail fills its container via anchors.fill.
|
thumbnailBorderSize
|
int
|
Math.ceil(2 * Theme.heightScale)
|
Border width of the thumbnail frame rectangle and the thumbnail image margin. |
verticalSpacing
|
int
|
Math.ceil(10 * Theme.heightScale)
|
Margin used for the inner content item and button anchors. |
thumbnailBottomMargin
|
int
|
Math.ceil(5 * Theme.heightScale)
|
Declared on thumbnailContainer but applied to anchors.bottomMargin, which has no effect since the container is top-anchored with no bottom anchor.
|
Signals
| Signal | Emitted by | Description |
|---|---|---|
selected()
|
Primary button clicked → loader.onLoaded connection
|
Fired when the primary action button is clicked. |
selectedWithDoubleClick()
|
mouseArea.onDoubleClicked
|
Fired on double-click of the card area. All current consumers call selected() from this handler, making it identical to selected().
|
selectedSecondary()
|
Secondary button clicked → loaderSecondary.onLoaded connection
|
Fired when the secondary action button is clicked. Only used by routeview-savegame.qml (Delete button).
|
Visual Structure
Background
Rectangle (id: background) fills the card. Its border.color is Theme.colors.highlight with a hardcoded border.width: 1 (not scaled). Its color is Theme.colors.modalBackground. Opacity is controlled by the active state: 0 in blurred, 0.90 in focused.
Thumbnail
thumbnailContainer (id: thumbnailContainer) is anchored to the top of the inner content item. Its height is computed as Math.floor(width * 0.56) (a 16:9 approximation), not from the thumbnailHeight property.
It contains four children:
| Child | Description |
|---|---|
Dark border Rectangle
|
color: "#40000000", border.color: Theme.colors.modalBackground, border.width: thumbnailBorderSize. Provides a subtle inset frame.
|
Image (id: thumbnail)
|
Loads thumbnailUrl asynchronously. Starts at opacity: 0 and fades to 1.0 over 250ms via OpacityAnimator once status === Image.Ready.
|
Rectangle (id: thumbnailSkrim)
|
color: Theme.colors.modalBackground. Opacity is 0.7 in blurred, 0 in focused, 0 in initializing.
|
Image (id: lockImage)
|
Loads "image://game/ui/images/lock.png" asynchronously. Visible only when isLocked is true. Fades in identically to thumbnail.
|
Text Component
Loader (id: textComponentLoader) is anchored below thumbnailContainer with verticalSpacing top margin. It loads the textComponent property provided by the subclass. It is hidden (visible: false) when isLocked is true. On load, it sets mouseArea.state to "blurred", ending the initializing phase.
Buttons
Two Loader elements are anchored to the bottom-left of the MouseArea:
| Loader | Visibility | Source | Signal connection |
|---|---|---|---|
loader (primary)
|
Controlled by state (opacity: 0 in blurred/initializing, 1 in focused)
|
"button-" + buttonType + ".qml"
|
item.clicked → carouselItem.selected()
|
loaderSecondary (secondary)
|
visible: carouselItem.secondaryButtonVisible; also opacity-controlled by state
|
"button-" + buttonType + ".qml" (same type as primary)
|
item.clicked → carouselItem.selectedSecondary()
|
State Machine
States are defined on mouseArea (id: mouseArea), not on the root carouselItem. The initial state is "initializing".
| State | Condition (when:)
|
background opacity
|
loader opacity
|
loaderSecondary opacity
|
textComponentLoader opacity
|
textComponentLoader.item opacity
|
thumbnailSkrim opacity
|
|---|---|---|---|---|---|---|---|
initializing
|
(initial, explicit) | 0
|
0
|
0
|
0
|
— | 0
|
blurred
|
!carouselItem.activeFocus
|
0
|
0
|
0
|
1
|
0.70
|
0.7
|
focused
|
carouselItem.activeFocus
|
0.90
|
1
|
1
|
1
|
1
|
0
|
Entering focused triggers a StateChangeScript that calls Sound.playEffect(carouselItem.focusedSoundPath).
Mouse hover is handled by onEntered (sets state to "focused") and onExited (sets state to "blurred"), overriding the when: conditions.
BlackMesaUtils.traverseUIElements() in utils.qml detects items with objectName === "ui:carousel-item" and adds them to the optionItems array. After traversal, afterTraverseCallback() sets the initial focus to optionItems[0] and calls updateCurrentUISelection(), which calls forceActiveFocus() on the item.
processCarouselItemSelection(sign) in utils.qml handles left/right keyboard navigation between carousel items. It also triggers pagination by directly calling clicked(null) on the left or right CarouselButton when the index crosses a page boundary. The boundary detection uses previousIndex % 4 and optionItemIndex % 4, hardcoding an assumption of 4 items per page.
On Qt.Key_Enter, navigationUIHandle() calls currentElement.selected() directly on the focused carousel item, bypassing the button's clicked signal.
Consumers
| Consumer | buttonType
|
secondaryButtonVisible
|
Notes |
|---|---|---|---|
routeview-newgame.qml (via CarouselNewGameItem)
|
"cta" (default)
|
false (default)
|
Fires loadMapRequest on selected.
|
routeview-addons.qml (via CarouselNewGameItem)
|
"cta" (default)
|
false (default)
|
Fires loadMapRequest on selected.
|
routeview-loadgame.qml (via CarouselLoadGameItem)
|
"cta" (default)
|
false (default)
|
Fires loadGameRequest on selected.
|
routeview-savegame.qml (via CarouselLoadGameItem)
|
"cta" (new save) or "warning" (existing save)
|
!!model.savename
|
Secondary button (Delete) uses same buttonType as primary. Fires saveGameRequest or shows confirmation alert on selected.
|
Notable Issues
1. thumbnailHeight and thumbnailWidth are dead properties. Both are declared and scaled but never referenced. The actual thumbnail dimensions are determined by anchors.fill and the Math.floor(width * 0.56) height formula.
2. thumbnailBottomMargin has no effect. It is assigned to anchors.bottomMargin on thumbnailContainer, but thumbnailContainer has no bottom anchor, so the margin is never applied.
3. background.border.width: 1 is not scaled. All other dimension properties use Theme.widthScale or Theme.heightScale, but the card border is a hardcoded 1px and will appear proportionally thinner at higher resolutions.
4. Both buttons load the same buttonType. loaderSecondary uses "button-" + buttonType + ".qml", identical to loader. In routeview-savegame.qml, existing-save cards have buttonType: "warning", so both the Overwrite and Delete buttons are rendered as WarningButton.
5. buttonType is an unvalidated string. A typo (e.g. "cta " with a trailing space) causes setSource() to silently fail to load the button, leaving the card with no action button and no error output.
6. selectedWithDoubleClick is universally aliased to selected(). Every consumer's onSelectedWithDoubleClick handler calls selected() with no distinction. The signal is effectively unused as a separate interaction.
7. when: conditions on blurred and focused reference carouselItem.activeFocus, but hover overrides them. onEntered and onExited set the state explicitly, bypassing the when: bindings. If the item gains activeFocus via keyboard navigation while the mouse is hovering over a different item, the when: condition for focused will be true but the explicit "blurred" set by onEntered on the hovered item takes precedence. The commented-out conditions (// || loader.item.activeFocus || loaderSecondary.item.activeFocus) suggest button-level focus was intended to also trigger the focused state but was disabled.
8. processCarouselItemSelection hardcodes modulo 4 for page boundary detection. The pagination trigger logic uses previousIndex % 4 and optionItemIndex % 4. At resolutions where visibleCount is not 4 (e.g. narrower windows), the pagination arrows will be triggered at the wrong index boundaries.
9. propagateComposedEvents: true on the MouseArea. Composed events (e.g. clicks) propagate to parent items. In the ListView → Carousel hierarchy, this is unlikely to cause issues since the ListView has interactive: false, but it is an unintentional permissiveness.
component-carousel-item-loadgame.qml
component-carousel-item-loadgame.qml defines the CarouselLoadGameItem type, a subclass of CarouselItem that renders a single save-game slot in the save/load carousel. It is registered in qmldir as CarouselLoadGameItem 1.0 and is used by both routeview-loadgame.qml and routeview-savegame.qml.
Registration
| Key | Value |
|---|---|
| QML type name | CarouselLoadGameItem
|
| Base type | CarouselItem (component-carousel-item.qml)
|
qmldir entry
|
CarouselLoadGameItem 1.0 component-carousel-item-loadgame.qml
|
| Consumers | routeview-loadgame.qml, routeview-savegame.qml
|
Inherited base class (CarouselItem)
CarouselItem provides the full visual shell. CarouselLoadGameItem only supplies the textComponent content and two additional data properties. The inherited interface relevant to consumers is:
| Property / Signal | Type | Description |
|---|---|---|
chapterName
|
string
|
Chapter or save slot display name shown in the text area. |
thumbnailUrl
|
string
|
URL of the save game screenshot image. |
buttonText
|
string
|
Label for the primary action button. |
buttonTextSecondary
|
string
|
Label for the secondary action button. |
buttonType
|
string
|
Button style: "cta" (default) or "warning". Controls which button-*.qml file is loaded.
|
secondaryButtonVisible
|
bool
|
Whether the secondary button is shown. Defaults to false.
|
isLocked
|
bool
|
Whether the slot is locked (hides text, shows lock icon). Always false for save/load items.
|
selected()
|
signal | Emitted when the primary button is clicked. |
selectedWithDoubleClick()
|
signal | Emitted on double-click of the card. |
selectedSecondary()
|
signal | Emitted when the secondary button is clicked. |
Dimensions are inherited from CarouselItem:
| Property | Value |
|---|---|
itemWidth
|
Math.ceil(400 * Theme.widthScale)
|
itemHeight
|
Math.ceil(400 * Theme.heightScale)
|
thumbnailHeight
|
Math.ceil(214 * Theme.heightScale)
|
thumbnailWidth
|
Math.ceil(380 * Theme.widthScale)
|
Properties
| Property | Type | Default | Description |
|---|---|---|---|
saveType
|
string
|
(unset) | Save slot category. Expected values: "autosave", "quick", "manual".
|
date
|
string
|
(unset) | Pre-formatted date/time string. Consumers pass Theme.getDateTimeString(model.date).
|
verticalSpacing
|
int
|
Math.ceil(2 * Theme.heightScale)
|
Spacing between the three text elements in the Column.
|
chapterNameFontSize
|
int
|
Math.ceil(26 * Theme.widthScale)
|
Font size for the chapter/save name label. |
dateFontSize
|
int
|
Math.ceil(16 * Theme.heightScale)
|
Font size for the date and save-type labels. |
textComponent
The textComponent property (defined on CarouselItem) is set to a Column containing three Text elements. It is loaded by textComponentLoader inside the base class and is hidden when isLocked is true.
chapterNameLabel
Displays chapterName (the save slot title, e.g. the chapter name at the time of saving).
| Property | Value |
|---|---|
font.pixelSize
|
chapterNameFontSize (Math.ceil(26 * Theme.widthScale))
|
font.family
|
Theme.fonts.regular
|
color
|
Theme.colors.headerText
|
dateText
Displays the date string as supplied by the consumer.
| Property | Value |
|---|---|
font.pixelSize
|
dateFontSize (Math.ceil(16 * Theme.heightScale))
|
font.family
|
Theme.fonts.regular
|
color
|
Theme.colors.text
|
saveTypeText
Displays a localized save-type badge. The text is resolved from a local inline map keyed on saveType:
saveType value
|
Displayed string | L10n key |
|---|---|---|
"autosave"
|
Auto Save | L10n.strings.labels.autoSave (#QTUI_Labels_AutoSave)
|
"quick"
|
Quick Save | L10n.strings.labels.quickSave (#QTUI_Labels_QuickSave)
|
"manual"
|
Manual Save | L10n.strings.labels.manualSave (#QTUI_Labels_ManualSave)
|
| (any other value) | (empty string) | — |
Styling rules for saveTypeText:
| Property | Value |
|---|---|
font.capitalization
|
Font.AllUppercase
|
font.pixelSize
|
dateFontSize
|
font.family
|
Theme.fonts.bold if saveType === "manual", otherwise Theme.fonts.regular
|
color
|
Theme.colors.dimmedText if saveType === "auto", otherwise Theme.colors.text
|
Consumer usage
routeview-loadgame.qml
Populates the carousel from BlackMesaUtils.getSaveGames(). All save types (autosave, quicksave, manual) are included.
| Property set by consumer | Value |
|---|---|
buttonText
|
L10n.strings.buttons.resume (#QTUI_Buttons_Resume)
|
secondaryButtonVisible
|
true (always — every slot shows a Delete button)
|
buttonTextSecondary
|
BlackMesaEngine.getLocalizedString("#GameUI_Delete")
|
onSelected
|
loadGame.loadGameRequest(model)
|
onSelectedWithDoubleClick
|
loadGame.loadGameRequest(model) (identical to onSelected)
|
onSelectedSecondary
|
Shows confirmDeleteAlert
|
routeview-savegame.qml
Prepends a synthetic "New Save" slot, then appends only manual saves (autosave and quicksave filenames matching /^(autosave|quick)\d*$/ are filtered out).
| Slot type | buttonText
|
buttonType
|
secondaryButtonVisible
|
|---|---|---|---|
| New Save (synthetic) | L10n.strings.buttons.createSave (#QTUI_Buttons_CreateSave)
|
"cta"
|
false (no savename)
|
| Existing manual save | L10n.strings.buttons.overwriteSave (#QTUI_Buttons_OverwriteSave)
|
"warning"
|
true (has savename)
|
onSelected and onSelectedWithDoubleClick are identical: if model.savename is set, confirmOverwriteAlert is shown; otherwise saveGame.saveGameRequest(null) is called directly (triggering an auto-generated filename). onSelectedSecondary shows confirmDeleteAlert.
Notable issues
1. saveType == "auto" color condition is a dead branch. saveTypeText applies Theme.colors.dimmedText when saveType === "auto", but the actual value supplied by BlackMesaUtils.getSaveGames() for autosaves is "autosave". The condition never evaluates to true, so autosave labels always render in Theme.colors.text rather than the intended dimmed colour.
2. chapterNameFontSize uses Theme.widthScale, dateFontSize uses Theme.heightScale. The two font sizes scale on different axes. On non-16:9 displays where widthScale and heightScale differ, the chapter name and date labels will scale disproportionately relative to each other.
3. date formatting is delegated to the consumer. Both routeview-loadgame.qml and routeview-savegame.qml call Theme.getDateTimeString(model.date) before passing the value in. The component itself performs no date formatting. The "New Save" synthetic slot in routeview-savegame.qml passes date: null, which Theme.getDateTimeString must handle gracefully.
4. onSelected and onSelectedWithDoubleClick are identical in both consumers. Single-click and double-click produce the same result with no distinction in behaviour.
5. Secondary button label bypasses L10n. Both consumers set buttonTextSecondary via BlackMesaEngine.getLocalizedString("#GameUI_Delete") directly, inconsistent with all other button labels which use the L10n singleton.
6. verticalSpacing shadows the base class property. CarouselItem also declares a verticalSpacing property (defaulting to Math.ceil(10 * Theme.heightScale)) used for thumbnail and button padding. CarouselLoadGameItem redeclares it as Math.ceil(2 * Theme.heightScale). This override affects the base class layout as well, reducing the padding around the thumbnail and action buttons from 10 px (scaled) to 2 px (scaled).
component-carousel-item-newgame.qml
component-carousel-item-newgame.qml defines CarouselNewGameItem, the carousel card delegate used by routeview-newgame.qml and routeview-addons.qml to display campaign and chapter selection cards. It extends CarouselItem (component-carousel-item.qml) and supplies a two-line textComponent showing a chapter name and a type/number label.
Registered in qmldir as CarouselNewGameItem 1.0.
Base class: CarouselItem
CarouselNewGameItem extends CarouselItem (component-carousel-item.qml), a 213-line Item that provides the full card visual structure. Understanding the base class is required to understand the derived component.
Dimensions
| Property | Value | Notes |
|---|---|---|
itemWidth |
Math.ceil(400 * Theme.widthScale) |
Card width |
itemHeight |
Math.ceil(400 * Theme.heightScale) |
Card height |
thumbnailBorderSize |
Math.ceil(2 * Theme.heightScale) |
Inner border around thumbnail image |
verticalSpacing |
Math.ceil(10 * Theme.heightScale) |
Padding around content area and text spacing; overridden to 2 by CarouselNewGameItem
|
thumbnailBottomMargin |
Math.ceil(5 * Theme.heightScale) |
Bottom margin below thumbnail container |
thumbnailHeight |
Math.ceil(214 * Theme.heightScale) |
Declared but never used in layout |
thumbnailWidth |
Math.ceil(380 * Theme.widthScale) |
Declared but never used in layout |
The thumbnail container height is computed as Math.floor(width * 0.56), enforcing a 16:9 aspect ratio. The thumbnailHeight and thumbnailWidth properties are dead declarations.
Base class properties
| Property | Type | Default | Description |
|---|---|---|---|
isLocked |
bool |
false |
Hides text, disables mouse area, shows lock icon overlay |
focusedSoundPath |
string |
Theme.sounds.buttonFocused |
Sound played on hover/focus |
chapterName |
string |
"DEFAULT CHAPTER NAME" |
Primary text; set by consumer |
thumbnailUrl |
string |
"image://game/ui/images/background-reception.png" |
Thumbnail image source |
buttonText |
string |
"DEFAULT BUTTON TEXT" |
Primary action button label |
buttonTextSecondary |
string |
"DEFAULT BUTTON TEXT" |
Secondary button label |
buttonType |
string |
"cta" |
Button QML file prefix; resolves to button-cta.qml
|
secondaryButtonVisible |
bool |
false |
Whether the secondary button is shown |
textComponent |
Component |
(none) | Injected by subclass; loaded below the thumbnail |
Base class signals
| Signal | Fired by |
|---|---|
selected() |
Primary button clicked, or consumer's onSelected handler
|
selectedWithDoubleClick() |
MouseArea.onDoubleClicked
|
selectedSecondary() |
Secondary button clicked
|
Visual structure (base class)
The card is composed of the following layers, bottom to top:
background(Rectangle)- 1 px border in
Theme.colors.highlight(#e47125, orange). FillTheme.colors.modalBackground(#222222). Opacity is0when blurred,0.90when focused.
thumbnailContainer(Item)- Height
Math.floor(width * 0.56). Contains:- An inner
Rectanglewith#40000000fill and athumbnailBorderSize-wideTheme.colors.modalBackgroundborder acting as a letterbox frame. thumbnail(Image):cache: false,fillMode: Image.PreserveAspectCrop, loaded asynchronously. Fades in from opacity0to1.0over 250 ms viaOpacityAnimatorwhenstatus = Image.Ready.thumbnailSkrim(Rectangle):Theme.colors.modalBackgroundfill, opacity0.7when blurred,0when focused.lockImage(Image):image://game/ui/images/lock.png, centered, visible only whenisLocked = true. Same async fade-in as thumbnail.
- An inner
textComponentLoader(Loader)- Loads the
textComponentinjected by the subclass. Hidden (visible: false) whenisLocked. Text opacity is0.70when blurred,1when focused.
loader/loaderSecondary(Loader)- Both load
button-{buttonType}.qml(defaultbutton-cta.qml) viasetSource. Positioned at the bottom-left of the card.loaderSecondaryis anchored to the right ofloaderand is only visible whensecondaryButtonVisible = true. Both are opacity0when blurred,1when focused.
Mouse area states
| State | Trigger | background opacity |
thumbnailSkrim opacity |
Text opacity | Buttons opacity |
|---|---|---|---|---|---|
initializing |
Initial (before textComponentLoader finishes) |
0 |
0 |
0 |
0
|
blurred |
!carouselItem.activeFocus |
0 |
0.7 |
0.70 |
0
|
focused |
carouselItem.activeFocus |
0.90 |
0 |
1 |
1
|
onEntered forces state = "focused"; onExited forces state = "blurred". The focused state also fires Sound.playEffect(focusedSoundPath) via StateChangeScript.
The MouseArea is disabled when isLocked || state = "initializing". scrollGestureEnabled: false prevents the mouse area from consuming scroll events, allowing the parent Carousel to handle horizontal scrolling.
CarouselNewGameItem properties
CarouselNewGameItem adds the following properties on top of the base class:
| Property | Type | Default | Description |
|---|---|---|---|
chapterNumber |
int |
0 |
Numeric index displayed in the subtitle line |
verticalSpacing |
int |
Math.ceil(2 * Theme.heightScale) |
Overrides base class default of 10; controls Column spacing
|
chapterNameFontSize |
int |
Math.ceil(24 * Theme.widthScale) |
Font size for the chapter name line |
numberFontSize |
int |
Math.ceil(15 * Theme.heightScale) |
Font size for the type/number line |
type |
string |
BlackMesaEngine.getLocalizedString("#GameUI_Chapter") |
Label prefix for the subtitle line; always overridden by consumers |
textComponent
The textComponent is a Column with spacing: verticalSpacing (2 px scaled) containing two Text elements:
| Element | id |
Text | Font size | Font family | Color |
|---|---|---|---|---|---|
| Chapter name | chapterNameText |
chapterName (from base class) |
Math.ceil(24 * Theme.widthScale) |
Theme.fonts.regular |
Theme.colors.headerText (white)
|
| Type + number | chapterNumberText |
type + " " + chapterNumber.toString() |
Math.ceil(15 * Theme.heightScale) |
Theme.fonts.light |
Theme.colors.text (white)
|
Consumers
routeview-newgame.qml
Uses two Component delegates that switch based on whether a campaign has been selected:
| Delegate | id |
type override |
onSelected behaviour
|
|---|---|---|---|
| Campaign phase | campaignDelegate |
BlackMesaEngine.getLocalizedString("#GameUI_NewGame") |
Sets newGameCarousel.currentlySelectedCampaign; switches to chapter phase
|
| Chapter phase | chapterDelegate |
BlackMesaEngine.getLocalizedString("#GameUI_Chapter") |
Fires newGame.loadMapRequest(model.levelName, localizedTitle)
|
itemComponent is bound to currentlySelectedCampaign !== null ? chapterDelegate : campaignDelegate.
Both delegates set isLocked: false unconditionally. A commented-out line shows the original intent was isLocked: (index + 1) > officialChaptersUnlockedCount && currentlySelectedCampaign.isOfficial, gating chapters behind sv_unlockedchapters.
routeview-addons.qml
Structurally identical to routeview-newgame.qml but filters campaigns with !campaign.isOfficial. Displays a fallback Text element with #BlackMesaUI_WorkshopList_Empty when levels.count = 0.
Notable issues
1. verticalSpacing override affects base class layout. The base class uses verticalSpacing for both the content area padding (anchors.rightMargin, anchors.leftMargin, anchors.topMargin) and the button bottom/left margins. Overriding it to 2 in CarouselNewGameItem reduces all of these paddings from 10 px (scaled) to 2 px (scaled), not just the Column spacing. This is a side effect of the base class reusing a single property for multiple layout roles.
2. Mixed scaling axes on font sizes. chapterNameFontSize scales by Theme.widthScale while numberFontSize scales by Theme.heightScale. On non-16:9 displays where the two scale factors differ, the two text lines will scale at different rates.
3. Both text colors are identical. chapterNameText uses Theme.colors.headerText and chapterNumberText uses Theme.colors.text. Both resolve to white. There is no visual color differentiation between the primary and secondary text lines.
4. type default is always overridden. The default value BlackMesaEngine.getLocalizedString("#GameUI_Chapter") is evaluated at construction time but is immediately replaced by both consumers. The evaluation is wasted.
5. isLocked is always false. The lock mechanism in the base class (lock icon, disabled mouse area, hidden text) is fully implemented but never activated. The chapter-locking logic based on sv_unlockedchapters is commented out in routeview-newgame.qml.
6. onSelectedWithDoubleClick: selected() in both consumers. Double-click and single-click produce identical behaviour. The selectedWithDoubleClick signal from the base class is never used distinctly.
7. thumbnailHeight and thumbnailWidth are dead properties. The base class declares these but the thumbnail container uses height: Math.floor(width * 0.56) for its dimensions. Neither property is referenced anywhere in the layout.
8. Secondary button is never shown. secondaryButtonVisible defaults to false and is never set to true by any consumer of CarouselNewGameItem. The loaderSecondary in the base class is always hidden.
component-devconsole.qml
component-devconsole.qml implements the in-game developer console overlay. It is registered in qmldir as DevConsole 1.0 and instantiated once in main.qml as a direct child of appRoot.
The component is 306 lines. It imports QtQuick 2.9, QtQuick.Controls 2.2, and CrowbarCollective 1.0.
Overview
The root element is Item (id: container). It is not a RouteView or FocusScope; it sits outside the router stack and is always present in the scene tree regardless of the active route.
| Property | Value | Notes |
|---|---|---|
height
|
parent.height * 0.375
|
37.5% of the screen height. Not scaled by Theme.heightScale.
|
opacity
|
0.0 (initial)
|
Animated between 0.0 and 1.0 by state transitions.
|
visible
|
opacity > 0.0009765625
|
Threshold is 1/1024, the smallest representable opacity step in Qt's 10-bit pipeline. Avoids rendering an effectively invisible item.
|
clip
|
true
|
Clips the slide-in animation so the console does not bleed above the screen edge. |
enabled
|
visible
|
Disables all mouse and keyboard input when the console is hidden. |
state
|
"closed" (initial)
|
Two states: "closed" and "opened".
|
Children
outputModel
ListModel (id: outputModel) stores all console output lines. Each element has two roles:
| Role | Type | Description |
|---|---|---|
elementColor
|
string
|
A color string (e.g. "gold", "lightgray"). Sourced from messageEntry.color.toString() when messages arrive.
|
elementText
|
string
|
The message text. |
dynamicRoles: false is set for performance. The model is pre-seeded with one ListElement: color "gold", text "Black Mesa Console Initialized".
onCountChanged calls outputView.positionViewAtEnd() whenever a new line is appended, but only if container.state == "opened". This prevents a scroll-to-end from firing while the console is closed.
background
Rectangle (id: background) fills the container. Color: Theme.devConsole.colors.background (#d0202020, semi-transparent dark).
outputView
ListView (id: outputView) displays the output lines.
| Property | Value |
|---|---|
| Anchors | Top and sides to parent; bottom to commandField.top
|
interactive
|
true (mouse scroll enabled)
|
boundsBehavior
|
Flickable.StopAtBounds
|
ScrollBar.vertical
|
VerticalScrollBar {} (always-on, stepSize: 0.02)
|
The delegate is a TextField (id: delegateRoot) configured as read-only:
| Property | Value |
|---|---|
readOnly
|
true
|
wrapMode
|
TextInput.Wrap
|
font.family
|
Theme.fonts.devConsole (Fira Mono Regular)
|
font.pixelSize
|
Math.ceil(16 * Theme.heightScale)
|
color
|
elementColor (from model role)
|
background
|
Empty Item (no visible background per delegate)
|
padding
|
0
|
commandField
TextField (id: commandField) is the command input bar, anchored to the bottom of the container.
| Property | Value |
|---|---|
color
|
Theme.devConsole.colors.inputText (#ffd0d0d0)
|
selectionColor
|
Theme.devConsole.colors.inputText (#ffd0d0d0)
|
selectedTextColor
|
Theme.devConsole.colors.background (#d0202020)
|
font.family
|
Theme.fonts.devConsole (Fira Mono Regular)
|
font.pixelSize
|
Math.ceil(16 * Theme.heightScale)
|
selectByMouse
|
true
|
placeholderText
|
BlackMesaEngine.getLocalizedString("#BlackMesaUI_Console_Hint")
|
background
|
Empty Item (no visible border or fill)
|
commandField contains two private QtObject children: history and autocomplete.
history
Manages the command history buffer.
| Property | Type | Description |
|---|---|---|
entries
|
var (array)
|
All submitted commands in order. Grows unboundedly; never trimmed. |
entryIndex
|
int
|
Current position in the history. Clamped to [0, entries.length].
|
onEntriesChanged resets entryIndex to entries.length (one past the end, representing a blank new entry) whenever a command is submitted.
onEntryIndexChanged clamps the index and updates commandField.text: if entryIndex < entries.length, the field is set to entries[entryIndex]; if entryIndex == entries.length, the field is cleared (representing the blank new-entry position).
autocomplete
Stores transient state for the Tab-completion cycle.
| Property | Type | Description |
|---|---|---|
autocompleteList
|
var (array)
|
The current list of completion candidates. Populated on the first Tab press. |
storedAutocompleteIndex
|
int
|
Current position in autocompleteList. -1 means no active completion cycle.
|
storedSearchString
|
string
|
The search term (the part after any prefix space). |
storedSearchStringPrefix
|
string
|
The prefix before the search term (the command name when completing an argument). |
Key handlers
onAccepted (Enter)
- If the trimmed, lowercased text is not
"clear", echoes"> " + text + "\n"to the console viaBlackMesaEngine.printConsoleMessageusingTheme.devConsole.colors.message. - Executes the command via
BlackMesaEngine.executeClientCommandUnrestricted(text). - Appends
texttohistory.entries, then reassigns the array to itself to trigger QML's property change notification (sincepush()mutates in place without notifying bindings).
Keys.onUpPressed / Keys.onDownPressed
Decrements or increments history.entryIndex, navigating backward or forward through the history buffer.
Keys.onPressed
If the key is not Qt.Key_Tab, resets autocomplete.storedAutocompleteIndex to -1, ending any active completion cycle.
Keys.onTabPressed
Tab-completion logic, executed in full on each Tab press:
- Sets
event.accepted = trueto suppress focus traversal. - Returns immediately if the field is empty.
- Normalizes whitespace:
text.replace(/\s+/g, " "). - If
storedAutocompleteIndex < 0(first Tab press in this cycle):- If the input contains a space, splits into a prefix (command name + space) and a search string (argument). Calls
BlackMesaEngine.listConsoleSuggestions(prefix, search)to get argument completions. - If no space, calls
BlackMesaEngine.listConsoleAutocompleteEntries(search)to get command completions. - Prints
"] " + inputStringto the console output. - If no suggestions, returns.
- Sets
storedAutocompleteIndex = 0and prints all suggestions tab-separated to the console output.
- If the input contains a space, splits into a prefix (command name + space) and a search string (argument). Calls
- Sets
commandField.texttoprefix + autocompleteList[storedAutocompleteIndex]. - Calls
select(searchString.length, text.length)to highlight the completed portion. - Increments
storedAutocompleteIndex, wrapping to0at the end of the list.
States and transitions
| State | y
|
opacity
|
|---|---|---|
"closed"
|
-container.height (above the screen)
|
0.0
|
"opened"
|
0
|
1.0
|
Both transitions use a SequentialAnimation with a 50 ms NumberAnimation on y and opacity using Easing.OutQuint, plus ScriptAction steps for side effects.
| Direction | ScriptAction (before animation) | ScriptAction (after animation) |
|---|---|---|
closed → opened
|
— | BlackMesaUtils.disableUINavigation = true; outputView.positionViewAtEnd(); commandField.forceActiveFocus()
|
opened → closed
|
commandField.focus = false; appRoot.forceActiveFocus()
|
BlackMesaUtils.disableUINavigation = false
|
Setting BlackMesaUtils.disableUINavigation to true while the console is open prevents the standard controller/keyboard navigation system from stealing focus from commandField.
Connections (BlackMesaEngine)
| Signal | Handler |
|---|---|
onGameConsoleMessagesReceived
|
Iterates messagesList, appending each {color, text} entry to outputModel.
|
onGameConsoleCleared
|
Calls outputModel.clear().
|
onGameConsoleActived
|
Sets container.state = "opened".
|
onGameConsoleHidden
|
Sets container.state = "closed".
|
The console is opened and closed exclusively by engine signals. There is no QML-side toggle button.
Theme integration
| Token | Value | Used for |
|---|---|---|
Theme.devConsole.colors.background
|
#d0202020
|
Background rectangle fill |
Theme.devConsole.colors.message
|
"lightgray"
|
Echo prefix color ("> ..." and "] ..." lines)
|
Theme.devConsole.colors.inputText
|
#ffd0d0d0
|
Input field text color and selection highlight color |
Theme.fonts.devConsole
|
Fira Mono Regular (vfs:///ui/fonts/firamono-regular.ttf)
|
All text in both outputView delegate and commandField
|
Related systems
The toggleconsole command is mapped in input-bindings-manager.qml to L10n.strings.options.bindings.devConsole (#QTUI_Option_Binding_Console), making the console toggle key user-configurable from the Bindings options page (routeview-bindings.qml, Misc category).
The con_enable CVar is exposed as a select-type row in routeview-game.qml (key game_devConsole), allowing the console to be enabled or disabled from the Game options page.
Notable observations
1. visible threshold is 0.0009765625. This value is 1/1024. It avoids the overhead of rendering and hit-testing a fully transparent item during the closed state, while still allowing the opacity animation to complete before the item is hidden.
2. clear is handled specially. When the user submits "clear", the echo step is skipped so the word "clear" does not appear in the output before outputModel.clear() is called by the engine's onGameConsoleCleared signal. However, the clear is not performed directly by QML — it depends on the engine firing onGameConsoleCleared in response to the command. If the engine does not fire that signal, the output is not cleared.
3. History mutation requires self-reassignment. history.entries.push(text) is followed by history.entries = history.entries to trigger QML's property change notification. This is a standard QML workaround for in-place array mutation.
4. outputView delegate uses TextField, not Text. Using TextField for read-only output lines allows the user to select and copy text from the console output. However, TextField is significantly heavier than Text; each console line creates a full TextField instance. Long sessions with many output lines will accumulate a large number of live TextField objects, since ListView does not recycle delegates when boundsBehavior: Flickable.StopAtBounds is set and the list is not virtualized beyond the visible area.
5. No maximum history or output size. Both history.entries and outputModel grow unboundedly. The only way to clear outputModel is via the engine's onGameConsoleCleared signal (triggered by the clear command). history.entries is never trimmed.
6. selectionColor equals color. The selection highlight background (selectionColor) is set to the same value as the text color (Theme.devConsole.colors.inputText, #ffd0d0d0). The selection is still visible because selectedTextColor is set to the dark background color, inverting the text. The highlight rectangle itself is light gray on a light gray background, which is semantically odd but functionally acceptable.
7. Height is not Theme-scaled. The height: parent.height * 0.375 expression uses a raw proportion of the parent height rather than a Theme.heightScale-based calculation. This is consistent with the console being a fixed-proportion overlay rather than a layout-managed component, but it means the console height does not respond to the same scaling system as all other UI elements.
component-footer.qml implements the persistent bottom bar of the Black Mesa main menu UI. It is registered as Footer 1.0 in qmldir and instantiated once in main.qml as part of a three-row GridLayout (Header → Router → Footer). The component switches between two entirely different layouts depending on whether a level is loading, using a Loader that swaps between two Component definitions.
Registration and instantiation
| Key | Value |
|---|---|
qmldir type name
|
Footer 1.0
|
| Source file | component-footer.qml
|
Instance id in main.qml
|
footer
|
| Layout slot | Third row of the root GridLayout, Layout.preferredHeight 72 * Theme.heightScale
|
Properties
Public interface
| Property | Type | Description |
|---|---|---|
routeRequest
|
signal(string routeName)
|
Emitted when a navigation action is triggered. Handled in main.qml by router.setRoute(routeName).
|
currentRoute
|
Route
|
The currently active route object, bound to router.currentRoute in main.qml.
|
isLoading
|
bool
|
When true, the loading footer is shown instead of the menu footer. Bound to appRoot.isLoadingLevel.
|
showLoadingProgress
|
bool
|
Controls whether the progress bar and quote text are shown during loading. Bound to !appRoot._isInitialLoad — false during the initial main menu background load, true for all subsequent loads.
|
levelName
|
string
|
The human-readable level name displayed above the progress bar. Set by main.qml from router.onLoadGameRequest (savegame.chapterName) or router.onLoadMapRequest (mapname), and reset to "" in onLevelLoadingFinished.
|
isInGame
|
bool
|
Controls quit/back button routing logic. Initially bound to appRoot.isInGame, but also directly assigned in main.qml's onLevelLoadingFinished and onDisconnectedFromServer handlers, which breaks the binding.
|
loadPercent
|
real
|
A 0.0–1.0 value driving the progress bar fill width. Bound to appRoot.loadPercent, which is updated by BlackMesaEngine.onUpdateProgressValue.
|
Private computed properties
| Property | Expression | Meaning |
|---|---|---|
_showBackButton
|
currentRoute.name !== Routes.index.name && currentRoute.name !== Routes.empty.name
|
true on any route other than the main index or empty route. Shows a "Back" button that pops the current route.
|
_showBackToGameButton
|
isInGame && (currentRoute.name === Routes.index.name || currentRoute.name === Routes.empty.name)
|
true when in-game and at the top-level index or empty route. Shows a "Back to Game" button that hides the UI.
|
The two properties are mutually exclusive by design: _showBackButton requires not being on index/empty, while _showBackToGameButton requires being on index/empty. The back button's visible is _showBackButton || _showBackToGameButton, so it is hidden only when the player is not in-game and is on the index or empty route.
Dimension properties
All dimensions are scaled. Font sizes for the loading screen use Theme.widthScale rather than Theme.heightScale.
| Property | Formula |
|---|---|
footerHeight
|
Math.ceil(72 * Theme.heightScale)
|
footerMargin
|
Math.ceil(32 * Theme.widthScale)
|
compassIconDimension
|
Math.ceil(40 * Theme.heightScale)
|
discordLinkWidth
|
Math.ceil(180 * Theme.widthScale)
|
discordLinkHeight
|
Math.ceil(40 * Theme.heightScale)
|
progressBarHeight
|
Math.ceil(16 * Theme.heightScale)
|
progressBarWidth
|
Math.ceil(1000 * Theme.widthScale)
|
loadingLabelFontSize
|
Math.ceil(40 * Theme.widthScale)
|
levelNameFontSize
|
Math.ceil(68 * Theme.widthScale)
|
levelNameMarginBottom
|
Math.ceil(24 * Theme.heightScale)
|
loadingQuoteFontSize
|
Math.ceil(24 * Theme.heightScale)
|
Background
A Rectangle (id: letterboxBackground) fills the entire footer area at all times, regardless of which mode is active. It uses color: Theme.colors.subNavBackground and opacity: Theme.opacity.subNav (0.5), matching the sub-navigation bar style used by component-header.qml.
Shown when isLoading is false. The layout is a Row anchored to fill the parent with footerMargin on left and right.
Compass icon
An Image (image://game/ui/images/compass.png) centered inside an Item (id: iconDpad) whose width equals footer.height. The icon is compassIconDimension × compassIconDimension (40 px scaled). It has no interactive behaviour and serves as a decorative controller navigation hint.
Quit button
A LetterboxButton (id: id_btn_quit, objectName: "ui:btn:action[quit]").
| Attribute | Value |
|---|---|
| Label | L10n.strings.buttons.quit (#QTUI_Buttons_Quit)
|
selected state
|
currentRoute.name === Routes.quit.name
|
Click when isInGame is true
|
Emits routeRequest(Routes.savebeforequit.name) → navigates to routeview-savebeforequit.qml
|
Click when isInGame is false
|
Emits routeRequest(Routes.quit.name) → navigates to routeview-quit.qml
|
Back / Back to Game button
A LetterboxButton (id: id_btn_back, objectName: "ui:btn:action[back]").
| Condition | Label | Action |
|---|---|---|
_showBackButton is true
|
L10n.strings.buttons.back (#QTUI_Buttons_Back)
|
Emits routeRequest(Routes.back.name) — pops the current route
|
_showBackToGameButton is true
|
L10n.strings.buttons.backToGame (#QTUI_Buttons_BackToGame)
|
Calls BlackMesaEngine.executeClientCommand('gameui_hide') — hides the UI and returns to the game
|
Both false
|
(either label) | Button is hidden (visible: false)
|
A MenuNavGuide (id: menuNavGuide) instance is placed inside the Row. It displays controller button hints for navigation. See component-menu-navigation-guide.qml for its full implementation.
Discord link
An Item (id: discordLinkItem) sized discordLinkWidth × discordLinkHeight, anchored to the right edge of the Row.
- A
MouseArea(id:discordLinkArea) withhoverEnabled: truecovers the item.onEntered: playsTheme.sounds.buttonFocusedviaSound.playEffect.onClicked: playsTheme.sounds.buttonClicked, then callsBlackMesaUtils.setTimeoutwith a 500 ms delay before callingQt.openUrlExternally(BlackMesaUtils.discordLink). The delay allows the click sound to finish before the browser opens.
- An
Imageswitches betweenimage://game/ui/images/discord-purple.png(hover) andimage://game/ui/images/discord-white.png(default) based ondiscordLinkArea.containsMouse.
Shown when isLoading is true. The comment in the source notes that animations are intentionally absent because the engine consumes too many resources during loading, causing animations to become jittery.
Quote timer
A Timer inside the loading footer cycles through loading quotes.
| Property | Value |
|---|---|
interval
|
5000 ms |
repeat
|
true
|
triggeredOnStart
|
true — a quote is shown immediately when loading begins
|
running
|
showLoadingProgress — the timer only runs when the progress bar is visible
|
On each trigger, a new random index is selected from L10n.strings.loading.quotes (5 quotes: #QTUI_Loading_Quote01 through #QTUI_Loading_Quote05). A while loop ensures the same quote is not shown twice in a row. A TODO comment in the source notes that this loop would be infinite if quotes.length == 1.
Loading quote text
A Text (id: loadingQuoteText) displayed when showLoadingProgress is true. Left-aligned with footerMargin, vertically centered. Uses Theme.fonts.light, Theme.colors.buttonText, and loadingQuoteFontSize.
"Loading Level" label
A Text displayed when showLoadingProgress is false (i.e. during the initial main menu background load). Text: L10n.strings.loading.loadingLevel (#QTUI_Loading_Level). Right-aligned with footerMargin, Font.AllUppercase, Theme.fonts.bold, Theme.colors.highlight, loadingLabelFontSize.
Progress bar
An Item (id: progressBar) visible when showLoadingProgress is true.
- Positioned with
anchors.bottom: parent.topandanchors.right: parent.right— it floats above the footer rectangle, overlapping the router content area below the footer. - Width:
progressBarWidth(1000 px scaled). Height:progressBarHeight(16 px scaled). - Background: a
Rectanglefilling the item withTheme.colors.dimmedText. - Fill: a
Rectanglewithwidth: progressBar.width * loadPercentandcolor: Theme.colors.highlight(orange). Grows left-to-right asloadPercentincreases from 0.0 to 1.0.
Level name text
A Text visible when showLoadingProgress is true. Displays levelName, positioned above the progress bar with levelNameMarginBottom gap. Uses levelNameFontSize, Theme.colors.buttonText.
Loader
A single Loader fills the footer area and selects the active component:
sourceComponent: isLoading ? loadingFooter : menuFooter
The swap is immediate with no transition, consistent with the comment that animations are suppressed during loading.
Notable quirks and issues
1. isInGame binding is broken by direct assignment. main.qml declares isInGame: appRoot.isInGame as a binding, but then directly assigns footer.isInGame in onLevelLoadingFinished and onDisconnectedFromServer. In QML, a direct property assignment destroys the declarative binding. After the first level load completes, footer.isInGame is no longer reactive to appRoot.isInGame changes.
2. Loading font sizes use Theme.widthScale instead of Theme.heightScale. loadingLabelFontSize and levelNameFontSize are scaled by Theme.widthScale, while loadingQuoteFontSize, progressBarHeight, and levelNameMarginBottom use Theme.heightScale. On non-16:9 displays where the two scales differ, the level name and "Loading Level" label will be disproportionately sized relative to the progress bar and quote text.
3. Progress bar floats outside the footer's own bounds. The progressBar item uses anchors.bottom: parent.top, placing it above the footer rectangle and into the router's layout area. This is intentional (the bar appears as an overlay above the footer), but it means the progress bar is not clipped by the footer and could overlap route content during loading.
4. MenuNavGuide anchor inside a Row is invalid. The MenuNavGuide instance sets anchors.right: discordLinkItem.left, but it is a child of a Row layout. Row manages its children's horizontal positions; anchor constraints on children of a Row are ignored by the layout engine. The guide will be positioned by the Row's flow, not by the anchor.
5. discordLinkItem uses anchors.right: parent.right inside a Row. Same issue as above — the anchor is ignored. The item will be placed at the end of the Row's flow, which happens to produce the correct visual result, but only incidentally.
6. showLoadingProgress: !appRoot._isInitialLoad hides the progress bar during the first load. During the initial main menu background load, the progress bar and quotes are suppressed and the "Loading Level" label is shown instead. This is intentional (the initial load is not a user-initiated action), but the logic is inverted from what the property name suggests — showLoadingProgress: false shows the "Loading Level" label, not nothing.
7. Quote timer has a latent infinite loop. The while loop that prevents repeating the same quote will spin forever if quotes.length == 1. The source contains a TODO comment acknowledging this. With the current 5-quote pool this is not a problem, but adding or removing quotes without fixing the loop is a latent risk.
8. No id on the loadingFooter root Item. Child elements inside loadingFooter cannot reference the root by id. The Timer accesses loadingQuoteText by id directly, which works via implicit QML scope but is fragile.
component-header.qml
component-header.qml implements the two-tier navigation bar displayed at the top of the Black Mesa main menu. It is registered as Header 1.0 in qmldir and instantiated once in main.qml as id: header.
The root element is an Item (id: header) that fills its parent. It exposes a routeRequest(string routeName) signal that main.qml connects to router.setRoute(routeName).
Properties
| Property | Type | Default | Description |
|---|---|---|---|
currentRoute |
Route |
— | Bound by main.qml to router.currentRoute. Drives state selection and tab highlight logic.
|
hide |
bool |
true |
When true, forces the "hidden" state regardless of the current route. Set by main.qml based on appRoot.visible and loading state.
|
suppressAnimations |
bool |
false |
Disables all state transitions when true. Set by main.qml during the initial show animation to prevent the header from animating in twice.
|
isInGame |
bool |
false |
Bound by main.qml to router.isInGame. Controls whether the Save Game sub-tab is enabled.
|
mainNavHeight |
int |
Math.ceil(64 * Theme.heightScale) |
Height of the main navigation bar. |
mainNavBackgroundHeight |
int |
Math.ceil(64 * Theme.heightScale) |
Height of the background image behind the main nav. Identical to mainNavHeight; a TODO comment notes this is a hack because the logo image is 63 px and should be 64 px.
|
subNavHeight |
int |
Math.ceil(128 * Theme.heightScale) |
Height of the sub-navigation bar. |
logoDimension |
int |
Math.ceil(40 * Theme.heightScale) |
Width and height of the BMS logo icon in the top-left corner. |
headerMargin |
int |
Math.ceil(24 * Theme.widthScale) |
Left margin applied to both the main nav list and the sub-nav list. |
Functions
checkButtonsActive()
Called from onIsInGameChanged and onHideChanged. Updates the isEnabled flags on two entries in campaignNavModel:
campaignNavModel.get(1)(Load Game) — enabled whenBlackMesaUtils.getSaveGames().length > 0andappRoot.isInMultiplayerModeisfalse.campaignNavModel.get(2)(Save Game) — enabled whenisInGameistrueandappRoot.isInMultiplayerModeisfalse.
The function is guarded by if (!hide) and does nothing while the header is hidden.
setState()
Called from onHideChanged and onCurrentRouteChanged. Selects one of the three states:
"hidden"— ifhideistrue, or ifcurrentRoute.alertistrue."subnav-open"— if the current route path contains a dot (i.e. is a sub-route such ascampaign.newgame)."subnav-closed"— if the current route path contains no dot (i.e. is a top-level route such asachievements).
Five ListModel objects are populated in Component.onCompleted using L10n.strings.menus labels. Each entry has label, routeName, and (for sub-nav models) isEnabled.
Used by the main navigation bar. Five entries, always enabled (no isEnabled field).
| routeName | L10n key (via L10n.strings.menus)
|
|---|---|
campaign |
labels.campaign
|
multiplayer |
labels.multiplayer
|
options |
labels.options
|
achievements |
labels.achievements
|
steamworkshop |
labels.workshop
|
Sub-nav for the campaign top-level route. Load Game and Save Game start disabled and are toggled by checkButtonsActive().
| routeName | L10n key | Default isEnabled |
|---|---|---|
newgame |
labels.newgame |
true
|
loadgame |
labels.loadgame |
false
|
savegame |
labels.savegame |
false
|
Sub-nav for the options top-level route. All seven entries are always enabled.
| routeName | L10n key |
|---|---|
game |
labels.game
|
input |
labels.input
|
bindings |
labels.bindings
|
video |
labels.video
|
audio |
labels.audio
|
policy |
labels.policy
|
translators |
labels.translators
|
Sub-nav for the multiplayer top-level route. Both entries are always enabled.
| routeName | L10n key |
|---|---|
join |
labels.join
|
host |
labels.host
|
Sub-nav for the steamworkshop top-level route.
| routeName | L10n key | Notes |
|---|---|---|
addons |
labels.installed |
Loads routeview-addons.qml.
|
browse |
labels.browse |
Routes.browse has no qmlFile; it carries action: "OPEN_STEAMWORKSHOP", which opens the Steam overlay without changing the active view.
|
Visual Structure
The header contains two stacked Item containers. mainNavContainer has z: 2 and subNavContainer has z: 1, so the main nav always renders above the sub-nav.
Height is mainNavHeight (64 scaled px). Contains:
- A background
Image(image://game/ui/images/nav-background.png) atopacity: Theme.opacity.mainNav(0.75), sized tomainNavBackgroundHeight. - A square
Item(id: navLogo) on the left containing a centeredImage(image://game/ui/images/nav-logo.png) atlogoDimension×logoDimension. - A horizontal
ListView(id: mainNavListView,interactive: false) to the right of the logo, usingmainNavModelas its model. Each delegate is aMainNavButtonwith:objectName: "ui:tab"selected: currentRoute && currentRoute.path.split('.')[0] === routeNameonClicked: header.routeRequest(routeName)
Height is subNavHeight (128 scaled px), positioned at y: 0 initially (slides up/down via state transitions). Contains:
- A full-fill
Rectangleatcolor: Theme.colors.subNavBackground(#111111) andopacity: Theme.opacity.subNav(0.5). - A horizontal
ListView(interactive: false) anchored tosubNavContainer.verticalCenterfor its top edge, left-padded byheaderMargin. Itsmodelis selected by aswitchoncurrentRoute.path.split('.')[0]:
| Path prefix | Model |
|---|---|
campaign |
campaignNavModel
|
multiplayer |
multiplayerNavModel
|
options |
optionsNavModel
|
steamworkshop |
workshopNavModel
|
| (any other) | null
|
Each delegate is a LetterboxButton with:
objectName: "ui:tab"disabled: !isEnabledselected: currentRoute && currentRoute.path.split('.')[1] === routeNameonClicked: header.routeRequest(routeName)
Button Types
MainNavButton extends LetterboxButton with the following overrides:
| Property | Value |
|---|---|
focusedColor |
Theme.colors.buttonText (white)
|
selectedColor |
Theme.colors.highlight (#e47125, orange)
|
focusShapeOpacity |
1 (fully opaque, vs. 0.75 default)
|
height |
Math.ceil(64 * Theme.heightScale)
|
The result is that a focused (hovered) main nav tab shows a white underbar, while a selected (active) tab shows an orange underbar.
Sub-nav tabs use LetterboxButton directly with its default color scheme: focused tabs show an orange (Theme.colors.highlight) underbar; selected tabs show a white (Theme.colors.buttonText) underbar with bold text. Disabled tabs use Theme.colors.dimmedText (#888888).
State Machine
The header has three states. Transitions between all pairs are animated with NumberAnimation at 250 ms and Easing.OutQuint. All transitions are suppressed when suppressAnimations is true.
| State | subNavContainer.y | mainNavContainer.y | When active |
|---|---|---|---|
subnav-open |
0 |
(default, 0) | Current route is a sub-route (path contains a dot). |
subnav-closed |
-subNavContainer.height |
(default, 0) | Current route is a top-level route with no sub-nav (e.g. achievements).
|
hidden |
-subNavContainer.height |
-mainNavContainer.height |
hide is true, or currentRoute.alert is true.
|
Six explicit Transition entries cover every directed pair:
| From | To | Animation target(s) |
|---|---|---|
subnav-open |
subnav-closed |
subNavContainer.y
|
subnav-closed |
subnav-open |
subNavContainer.y
|
subnav-closed |
hidden |
mainNavContainer.y
|
subnav-open |
hidden |
subNavContainer.y and mainNavContainer.y in parallel
|
hidden |
subnav-open |
subNavContainer.y and mainNavContainer.y in parallel
|
hidden |
subnav-closed |
mainNavContainer.y
|
Usage in main.qml
main.qml instantiates Header and wires it as follows:
header.currentRoute←router.currentRouteheader.isInGame←router.isInGameheader.hide— set totruewhen the UI is hidden or a level is loading;falseotherwise.header.suppressAnimations— set totrueduring the initial show sequence to prevent double-animation.header.onRouteRequest→router.setRoute(routeName)
Notable Observations / Bugs
1. multiplayerNavModel.Component.onCompleted executes a console command. The model's initializer calls BlackMesaEngine.executeClientCommandUnrestricted("exec server.cfg;"). This is a side effect embedded in a data model: server.cfg is executed every time the multiplayer sub-nav model is created, which happens at startup regardless of whether the user ever visits the multiplayer section.
2. setState() is not called from Component.onCompleted. The initial state is hardcoded as "hidden" on the root element. If currentRoute or hide were set before the component finishes loading, setState() would not be triggered and the header could display in the wrong state. In practice main.qml sets hide after construction, which triggers onHideChanged and corrects the state.
3. Sub-nav ListView is anchored to subNavContainer.verticalCenter. The anchors.top of the sub-nav list is bound to subNavContainer.verticalCenter, so the tabs only occupy the lower half of the 128-scaled-px sub-nav bar. The upper half is empty background.
4. workshopNavModel "Browse" entry routes to a non-view action. The browse entry calls header.routeRequest("browse"), which triggers router.setRoute("browse"). Routes.browse has no qmlFile and no path, only action: "OPEN_STEAMWORKSHOP". The router executes the action (opens the Steam overlay) and does not push a new view, leaving the header in the subnav-open state with the Workshop sub-nav still visible.
5. mainNavBackgroundHeight is a redundant duplicate of mainNavHeight. Both are Math.ceil(64 * Theme.heightScale). The TODO comment acknowledges this is a hack. A single property would suffice.
6. checkButtonsActive() accesses campaignNavModel by hardcoded index. campaignNavModel.get(1) and campaignNavModel.get(2) are used directly. If the model order ever changes, the wrong entries will be toggled with no compile-time or runtime error.
7. No id on the sub-nav ListView. The sub-nav list has no id, making it impossible to reference from outside the subNavContainer item (e.g. for programmatic scrolling or focus management).
8. MainNavButton is registered in qmldir but is only used in component-header.qml. It is a thin wrapper over LetterboxButton with three property overrides. It could equivalently be an inline LetterboxButton with those properties set directly in the delegate.
component-menu-navigation-guide.qml is registered as MenuNavGuide 1.0 in qmldir and implements the controller/keyboard hint strip displayed in the footer bar during normal menu navigation. It is instantiated once, inside the menuFooter component of component-footer.qml.
Registration
| Key | Value |
|---|---|
| Registered name | MenuNavGuide 1.0
|
| Source file | component-menu-navigation-guide.qml
|
| Type | Named component (non-singleton) |
| Sole consumer | component-footer.qml, menuFooter component (lines 109–114)
|
Root element
The root is an Item (id: controllerGuideNotification) with the following top-level properties:
| Property | Type | Default | Description |
|---|---|---|---|
containerWidth |
int |
Math.ceil(1024 * Theme.widthScale) |
Width of the root item, scaled to the current resolution. |
fontSize |
int |
Math.ceil(18 * Theme.heightScale) |
Font size for all hint labels. |
isControllerUsed |
int |
0 |
Tracks the active navigation source. 0 = keyboard/mouse; non-zero = controller. Updated by BlackMesaEngine.onNavigationSourceChanged.
|
The root item's width is bound to containerWidth and its height is bound to parent.height.
Engine connection
A Connections block listens to BlackMesaEngine.onNavigationSourceChanged(type) and assigns the received type integer directly to isControllerUsed. This is the only reactive update mechanism; there is no initial query of the navigation source on Component.onCompleted, so the displayed icons default to keyboard mode until the engine fires the signal.
Layout
A single GridLayout with anchors.fill: parent and rowSpacing: Math.ceil(32 * Theme.heightScale) contains four Column children, each wrapping one Row. Because GridLayout defaults to flow: LeftToRight with no column or row limit, all four groups are placed in a single horizontal row.
Each group consists of one or two Image elements followed by a Text label, all vertically centered within the row.
Hint groups
| # | Controller image(s) | Keyboard image(s) | Label string | Image width |
|---|---|---|---|---|
| 1 | lb-white.png, rb-white.png |
a-key.png, d-key.png |
L10n.strings.navigation.change_tabs |
Math.ceil(54 * Theme.widthScale) each
|
| 2 | controller-arrows.png |
keyboard-arrows.png |
L10n.strings.navigation.options |
Math.ceil(54 * Theme.widthScale)
|
| 3 | b-color.png |
backspace.png |
L10n.strings.navigation.discard |
Math.ceil(42 * Theme.widthScale)
|
| 4 | a-color.png |
enter-key.png |
L10n.strings.navigation.select |
Math.ceil(42 * Theme.widthScale)
|
All images use fillMode: Image.PreserveAspectFit. The controller images for groups 1 and 2 use white/monochrome variants (lb-white.png, rb-white.png, controller-arrows.png), while groups 3 and 4 use colored variants (b-color.png, a-color.png), matching the standard Xbox button color scheme (B = red, A = green).
All label Text elements use:
font.family: Theme.fonts.regularcolor: Theme.colors.text(white)font.capitalization: Font.AllUppercase- Left padding of
Math.ceil(20 * Theme.widthScale)(groups 1, 3, 4) orMath.ceil(18 * Theme.widthScale)(group 2).
Inside menuFooter, MenuNavGuide is placed inside a Row layout with:
MenuNavGuide {
id: menuNavGuide
anchors.verticalCenter: parent.verticalCenter
anchors.right: discordLinkItem.left
}
It sits between the Quit/Back buttons on the left and the Discord link item on the right. The menuFooter component is only active when isLoading is false; during level loading the footer switches to loadingFooter, which does not include MenuNavGuide.
Notable issues
1. isControllerUsed is typed as int but used as a boolean. All four ternary expressions treat it as truthy/falsy. The property name implies a boolean, but the engine signal passes a navigation source type integer. If the engine ever passes a value of 0 for a controller source, the component will incorrectly display keyboard icons.
2. No initial state query. There is no Component.onCompleted call to read the current navigation source from the engine. The component always starts in keyboard mode (isControllerUsed: 0) and only switches after the engine fires onNavigationSourceChanged. If the user opens the menu with a controller already active, the icons will briefly show keyboard glyphs.
3. rowSpacing has no effect. The GridLayout places all four groups in a single row (no wrapping), so rowSpacing — which controls vertical spacing between rows — is never applied.
4. Redundant Column wrappers. Each of the four Column elements contains exactly one Row child. The Column adds no layout behaviour and could be replaced by the Row directly.
5. containerWidth is 1024 logical pixels. At a 1920×1080 reference resolution this is 53% of the screen width. The Row in menuFooter does not clip its children, so on narrow resolutions or with long localized strings the guide may overlap the Quit and Back buttons to its left.
6. Left padding inconsistency. Group 2 uses leftPadding: Math.ceil(18 * Theme.widthScale) while groups 1, 3, and 4 use Math.ceil(20 * Theme.widthScale). The 2-pixel difference is not visually meaningful but is inconsistent.
7. L10n.strings.navigation key values are not confirmed. The exact localization keys (#QTUI_* strings) backing change_tabs, options, discard, and select could not be read from l10n.qml within the available search results.
component-optionslist.qml
component-optionslist.qml is registered as OptionsList 1.0 in qmldir. It is the shared settings panel used by every options route view in the game. It manages a list of OptionsListRow items, reads and writes engine CVars, supports both immediate and batched (pending) change modes, and optionally renders Apply/Discard buttons.
Registration
| Key | Value |
|---|---|
| Type | Named component (not singleton) |
| QML name | OptionsList
|
| Version | 1.0
|
| File | component-optionslist.qml
|
Root element
Rectangle (id: optionsView), color: "transparent". Width is fixed at Math.ceil(1500 * Theme.widthScale). Height is computed dynamically:
headerHeight * (batchUpdates ? 2 : 1) + (visibleRows * optionHeight) + (batchUpdates ? listPaddingBottomBatch : listPaddingBottom)
When batchUpdates is true, the footer bar is included in the height calculation by doubling headerHeight.
Signals
| Signal | Description |
|---|---|
requestSettingsChange(var model, var value) |
Emitted by a child OptionsListRow when the user changes a value. The root onRequestSettingsChange handler calls setValue(model, value).
|
settingsReset() |
Emitted by clearPendingChanges() after all pending changes are reverted. Consumers use this to update dependent UI state (e.g. re-enabling disabled rows).
|
Properties
Public properties
| Property | Type | Default | Description |
|---|---|---|---|
title |
string |
"<unbound title>" |
Displayed in the header bar in uppercase, Theme.colors.highlight orange.
|
model |
ListModel |
— | The list of row definitions. Each element must have at least a key and type property.
|
models |
variant |
— | A key→ListElement map built from model at Component.onCompleted. Consumers and child rows access settings by key through this map.
|
reloadPageAfterApplyChanges |
bool |
false |
If true, the current route is reloaded after flushPendingChanges() is called via the Apply button.
|
visibleRows |
int |
3 |
Number of rows visible without scrolling. Controls the body height. |
batchUpdates |
bool |
false |
If true, changes are queued in _pendingSettings and only written to the engine when the user clicks Apply. If false, each change is written immediately.
|
hasPendingChanges |
bool |
false |
true when _pendingSettings is non-empty. Controls the enabled state of the Apply and Discard buttons.
|
Private properties
| Property | Description |
|---|---|
_groupDebounce |
A plain JS object used as a set. Populated at the start of each setValue call and cleared before the next. Prevents a group setter function from being called more than once when multiple models in the same group are changed in a single batch.
|
_pendingSettings |
A plain JS object mapping key → pending value. Populated by _queueChange, consumed by flushPendingChanges, cleared by clearPendingChanges.
|
_originalSettings |
A plain JS object mapping key → value at last engine read. Used by _queueChange to detect whether a change reverts to the original (in which case it is removed from _pendingSettings).
|
Dimension properties
All dimensions are scaled by Theme.heightScale or Theme.widthScale.
| Property | Base value | Scale axis |
|---|---|---|
optionHeight |
75 | height |
headerHeight |
85 | width |
buttonMargin |
17 | width |
headerMargin |
35 | width |
headerFontSize |
32 | height |
listPaddingBottom |
15 | height |
listPaddingBottomBatch |
25 | height |
Extension-point properties (set by consumers)
These properties are not declared in component-optionslist.qml itself. Consumers attach them as child readonly property QtObject declarations on their OptionsList instance. The component accesses them via implicit QML scope.
| Property | Type | Description |
|---|---|---|
getComplex |
QtObject |
An object whose methods are named after row keys. Called by getEngineSetting when a row has no cvar property. Used for settings that require reading multiple CVars (e.g. captioning mode, audio quality).
|
setComplex |
QtObject |
An object whose methods are named after row keys. Called by setEngineSetting when a row has no cvar or group property. Used for settings that require writing multiple CVars.
|
groups |
QtObject |
An object whose methods are named after group identifiers. Called by setEngineSetting when a row has a model.group property. The group function is called once per group per setValue invocation, regardless of how many rows share the group. Used in routeview-game.qml to update the skin selector when the multiplayer model changes.
|
Functions
Engine I/O
| Function | Description |
|---|---|
getEngineSetting(key) |
Reads the current engine value for a row. If the row has a cvar property, calls BlackMesaEngine.getConsoleVariableAsString(model.cvar). Otherwise delegates to getComplex[key](). Logs a warning if neither is available (suppressed for separator rows).
|
setEngineSetting(key, value) |
Writes a value to the engine. Priority order: (1) cvar → BlackMesaEngine.setConsoleVariableAsString; (2) group → groups[model.group]() with debounce; (3) setComplex[key](value). Returns true on success, false on failure.
|
Change management
| Function | Description |
|---|---|
_setValueImmediate(key, value) |
Calls setEngineSetting, updates models[key].value, updates _originalSettings[key], removes the key from _pendingSettings, and calls mat_savechanges via BlackMesaEngine.executeClientCommandUnrestricted.
|
_queueChange(model, value) |
Adds key → value to _pendingSettings (or removes it if the value matches _originalSettings[key]). Updates model.value immediately for live UI feedback. Updates hasPendingChanges.
|
setValue(model, value) |
Resets _groupDebounce, then dispatches to _queueChange (if batchUpdates) or _setValueImmediate (if not).
|
flushPendingChanges() |
Iterates _pendingSettings and calls _setValueImmediate for each key. Calls mat_savechanges a final time. Sets hasPendingChanges = false. If the current route is "video", also calls savereloadaftersettingschange.
|
clearPendingChanges() |
Iterates _pendingSettings, deletes each key, and restores models[key].value from _originalSettings. Sets hasPendingChanges = false. Emits settingsReset().
|
refreshModelValues() |
Re-reads all values from the engine via getEngineSetting and updates both models[key].value and _originalSettings[key]. Called at Component.onCompleted and by consumers when the route is re-entered.
|
Visual structure
Header
An Item (id: header) spanning the full width at headerHeight pixels tall. Contains:
- A
Rectanglefilled withTheme.colors.modalBackgroundatTheme.opacity.modalopacity. - A
Textelement showingtitleinFont.AllUppercase,Theme.fonts.bold,Theme.colors.highlightorange, left-padded byheaderMargin.
Body
A Rectangle filled with Theme.colors.skrim at Theme.opacity.modal opacity, spanning from header.bottom to either footer.top (when batchUpdates) or parent.bottom. Contains:
ListView(id:optionsList):clip: true,interactive: true,boundsBehavior: Flickable.StopAtBounds,cacheBuffer: 5000,keyNavigationEnabled: false.VerticalScrollBar: visible only whenoptionsList.height + optionsList.bottomMargin + optionsList.topMargin + 2 < optionsList.contentHeight.- Delegate: a
Loaderthat callsloader.setSource('component-optionslist-row.qml', { model: model, inputWidth: parent.width / 2 - (Theme.widthScale * 300) })and connectsrequestSettingsChangeto the parentOptionsList.
An Item (id: footer), visible: batchUpdates, at headerHeight pixels tall, anchored to the bottom. Contains:
- A
Rectanglebackground matching the header style. - A
Rowright-aligned withbuttonMarginspacing, containing:WarningButton(id:discardButton):objectName: "ui:btn:action[discard]", disabled when!hasPendingChanges, callsclearPendingChanges().CTAButton(id:saveButton):objectName: "ui:btn:action[apply]", disabled when!hasPendingChanges, callsflushPendingChanges()then optionally reloads the route.
Initialization
Component.onCompleted initializes _originalSettings, _pendingSettings, and models to empty objects, then iterates model to populate models with live ListElement references keyed by model.get(i).key, then calls refreshModelValues().
Consumers
| Route view | batchUpdates |
visibleRows |
Extension points used |
|---|---|---|---|
routeview-video.qml |
true |
8 | getComplex, setComplex, groups
|
routeview-audio.qml |
true |
7 | getComplex, setComplex
|
routeview-game.qml |
false |
7 | getComplex, setComplex, groups
|
routeview-input.qml |
false |
7 | getComplex, setComplex
|
routeview-host.qml |
false |
6 | none (all rows use cvar directly)
|
Notable issues
1. reloadPageAfterApplyChanges is set to true after the reload. In the Apply button's onClicked handler, after calling router.setRoute(...), the code immediately sets reloadPageAfterApplyChanges = true. This re-arms the flag after the reload has already been triggered, meaning the next Apply click will also reload the route even if reloadPageAfterApplyChanges was intended to be a one-shot flag. The assignment should be false or omitted.
2. mat_savechanges is called N+1 times during flushPendingChanges(). _setValueImmediate calls mat_savechanges after every individual key write, and flushPendingChanges calls it again at the end. For a batch of N pending changes, the command is issued N+1 times.
3. router is accessed via implicit scope. flushPendingChanges() references router.currentRoute.name and router.setRoute(...) without declaring router as a property. This relies on QML's implicit scope chain resolving router to the Router id in main.qml. If OptionsList is ever used outside of main.qml's scope tree, this will throw a ReferenceError.
4. getComplex, setComplex, and groups are undeclared. The component accesses these as if they were properties, but they are not declared with property in the component definition. They are attached by consumers as child QtObject declarations. If a consumer omits them and a row requires them, the access will silently return undefined and the console.warn path will fire.
5. keyNavigationEnabled: false on the ListView. Keyboard navigation between rows is handled externally by utils.qml via BlackMesaUtils.traverseUIElements(). The ListView's built-in key navigation is disabled to prevent conflicts, but this means the list does not scroll automatically to keep the focused row visible when navigating with a controller or keyboard.
6. inputWidth is a hardcoded formula. The input column width passed to each OptionsListRow is parent.width / 2 - (Theme.widthScale * 300). This is not a named property and cannot be overridden per-consumer without modifying the delegate.
component-optionslist-input-binding.qml
component-optionslist-input-binding.qml is the binding input type for the options list system. It renders two side-by-side BindingCell instances — one for the primary key binding and one for the secondary key binding — for a single engine command. It is loaded dynamically by component-optionslist-row.qml and is not registered in qmldir.
Registration and loading
The file is not registered in qmldir. It is referenced by name in component-optionslist-row.qml's inputComponents registry:
readonly property string binding: "component-optionslist-input-binding.qml"
It is instantiated via a Loader when an OptionsListRow has model.type === "binding". All binding-type rows are created exclusively by routeview-bindings.qml.
Root element
The root element is a FocusScope (id: root) with a single property:
| Property | Type | Description |
|---|---|---|
model |
variant |
The binding row model object. Must contain command, key1, and key2.
|
Unlike all other input type components (slider, select, checkbox, map, text), the root FocusScope declares:
- No
objectName: "ui:option-item"— theBindingCellchildren carry this instead. - No
readonly property string type: "binding"— theBindingCellchildren carry this instead. - No
requestSettingsChangesignal — binding changes are dispatched directly toInputBindingsManager, bypassing the standard options signal chain. - No
selectedValueproperty.
Model structure
The model object is produced by InputBindingsManager.getBindingComponentConfig() and populated by InputBindingsManager.getBindings():
| Property | Type | Description |
|---|---|---|
label |
string | Human-readable label for the row (e.g. "Move Forward"), sourced from L10n.strings.options.bindings.
|
type |
string | Always "binding".
|
command |
string | The engine command string (e.g. "+forward"), used as the key into config.cfg.
|
key1 |
string | Primary bound key name (e.g. "w"). Empty string if unbound.
|
key2 |
string | Secondary bound key name. Empty string if unbound. |
requestSelection() function
function requestSelection(ordinal, begin, end)
Called by each BindingCell's onRequestInputSelection handler. It:
- Manually copies all own properties of
modelinto a new plain objectcfg(using afor...inloop withhasOwnPropertyguard, because Qt 5.9 lacksObject.assign). - Adds three extra fields to
cfg:ordinal— the string"key1"or"key2", identifying which slot is being edited.current— the current value ofmodel[ordinal](the key currently bound to that slot).beginandend— screen coordinates passed up fromBindingCell.requestInputSelection, used to position the conflict alert dialog.
- Calls
InputBindingsManager.selectBinding(cfg), which setsInputBindingsManager.selectedCfgtocfgand triggers the key-capture flow inBindingCell.
Layout
The layout is a single Item (width: parent.width - 32) containing a Row (spacing: 0, anchors.fill: parent) with two BindingCell children:
| Element | id | Width | Key property | Selected condition |
|---|---|---|---|---|
| Primary cell | primary |
parent.width / 2 + 16 |
model.key1 |
selectedCfg.ordinal === 'key1' && selectedCfg.command === model.command
|
| Secondary cell | secondary |
parent.width / 2 + 16 |
model.key2 |
selectedCfg.ordinal === 'key2' && selectedCfg.command === model.command
|
Each cell's onRequestInputSelection handler calls requestSelection with the appropriate ordinal ('key1' or 'key2') and the begin/end coordinates from the signal.
Interaction with InputBindingsManager
When a BindingCell is clicked, it calls requestSelection, which calls InputBindingsManager.selectBinding(cfg). This sets InputBindingsManager.selectedCfg, which the selected binding expressions on both cells observe reactively. The cell whose ordinal and command match selectedCfg transitions to the selected state in BindingCell, enabling key capture.
When routeview-bindings.qml's onRouteWillChange fires, it calls InputBindingsManager.clearSelection(), which sets selectedCfg to null, deselecting all cells.
Notable issues
1. Cell widths overflow the Row. The outer Item is parent.width - 32 wide. The Row fills it, so Row.width = parent.width - 32. Each BindingCell is Row.width / 2 + 16 [[=]] parent.width / 2 wide. The two cells together are parent.width wide, which is 32 pixels wider than the Row. The secondary cell overflows the right edge of the Item by 32 pixels. Since neither the Item nor the Row sets clip: true, this overflow is not clipped and the secondary cell visually extends beyond the intended boundary.
2. No type property on the root. utils.qml's keyboard/controller navigation dispatches Enter, Left, and Right key events by checking currentElement.type. Because the root FocusScope has no type property, the binding input type falls through all type checks in utils.qml and receives no keyboard navigation handling. The user cannot activate a binding cell via the controller Enter key from the row level; they must click directly on a BindingCell.
3. Bypasses the requestSettingsChange signal chain. All other input types emit requestSettingsChange(model, value), which propagates up through OptionsListRow → OptionsList → the route view's onRequestSettingsChange handler. Binding changes skip this entirely and call InputBindingsManager.selectBinding() directly. This means OptionsList's pending-change tracking and flushPendingChanges() mechanism are never involved in binding operations.
4. Object.assign workaround comment. The comment // qt 5.9 apparently lacks Object.assign documents a known engine limitation. The manual copy loop is correct but copies all enumerable own properties, including any QML-internal properties that hasOwnProperty returns true for on a ListElement-derived object. In practice this is harmless since InputBindingsManager only reads the known keys, but it is fragile.
component-optionslist-input-bindingcell.qml
component-optionslist-input-bindingcell.qml is the interactive cell widget that displays a single bound key name and manages the two-click key-capture flow for the bindings page. It is registered in qmldir as BindingCell 1.0 — the only input-type component in the options system to receive a named registration, because it is also used directly by component-binding.qml outside of the OptionsListRow context.
Properties
| Property | Type | Description |
|---|---|---|
key
|
string
|
The human-readable key name to display (e.g. "SPACE", "MOUSE1"). Sourced from model.key1 or model.key2 in the parent component-optionslist-input-binding.qml.
|
selected
|
bool
|
Whether this cell is the currently selected binding slot. Computed by the parent from InputBindingsManager.selectedCfg: true when selectedCfg.ordinal matches this cell's ordinal (key1 or key2) and selectedCfg.command matches the row's command.
|
Signal
| Signal | Parameters | Description |
|---|---|---|
requestInputSelection
|
var begin, var end
|
Emitted when the user first clicks the cell. begin is a callback that transitions the cell to binding state; end is a callback that returns it to focused or blurred after key capture completes or is cancelled.
|
Visual structure
The root Item (id: root) contains two children, both filling the parent:
background— aRectanglecoloredTheme.colors.highlight(orange) at variable opacity. Atopacity: 0it is invisible; atopacity: 1it renders as a solid orange fill during key capture.clicker— aMouseAreawithhoverEnabled: truethat owns the state machine, theTextlabel, and all interaction logic.
The Text element (id: text) inside clicker displays key in uppercase bold at Math.ceil(24 * Theme.heightScale) px, centered in the cell.
State machine
The state machine lives on clicker and has four states:
| State | text color
|
background opacity
|
Notes |
|---|---|---|---|
blurred
|
Theme.colors.buttonText (white)
|
0 (invisible) | Default state. |
focused
|
Theme.colors.highlight (orange)
|
0.2 | Entered on mouse hover. Plays Theme.sounds.buttonFocused via StateChangeScript.
|
selected
|
Theme.colors.text (white)
|
0.5 | Entered when InputBindingsManager.selectedCfg points to this cell (i.e. after the first click).
|
binding
|
transparent
|
1.0 (solid orange) | Active during key capture. The key label is hidden; the cell renders as a solid orange block. |
State transitions
| From | To | Animation |
|---|---|---|
blurred ↔ focused
|
focused ↔ blurred
|
ColorAnimation on text only, 150 ms, Easing.OutQuint. Background opacity change is instant.
|
focused ↔ selected
|
selected ↔ focused
|
ParallelAnimation: ColorAnimation on both text and background, 150 ms, Easing.OutQuint.
|
selected ↔ binding
|
binding ↔ selected
|
ParallelAnimation: ColorAnimation on both text and background, 150 ms, Easing.OutQuint.
|
binding → focused
|
(one-way) | ParallelAnimation: ColorAnimation on both text and background, 150 ms, Easing.OutQuint.
|
Interaction flow
The cell uses a deliberate two-click design to prevent accidental rebinds.
Step 1: Selection (first click)
Clicking the cell from blurred or focused calls makeSelectionRequest(), which emits requestInputSelection(beginBinding, endBinding). The parent (component-optionslist-input-binding.qml) calls InputBindingsManager.selectBinding(cfg), storing the config object (including the begin and end callbacks) in InputBindingsManager.selectedCfg. Because selected is a computed binding on selectedCfg, it becomes true, triggering onSelectedChanged, which sets clicker.state to "selected".
Step 2: Key capture (second click)
Clicking the cell from selected calls startBinding(), which calls InputBindingsManager.startBindingRequest(). This function:
- Calls
clearSelection()(setsselectedCfgtonull). - Calls
cfg.begin()→beginBinding()→clicker.statebecomes"binding". - Calls
BlackMesaEngine.requestKeyCapture()to begin listening for a key press. - Registers an
inputBindingCallbackclosure that will handle the engine's response.
Step 3: Key press or cancel
When the engine captures a key, it emits onBindingResponse (handled in main.qml), which calls InputBindingsManager.handleBindingResponse(event). The registered inputBindingCallback then:
- ESC — calls
cancel(): resets conflict state and callscfg.end()with the original key, returning the cell tofocusedorblurred. - Any other key (no conflict) — calls
execBindings(): issuesunbindandbindconsole commands, saves viaexec userconfig.cfg; host_writeconfig, callscfg.end(event)→endBinding()→ cell returns tofocusedorblurred, and emitsbindingSet()to trigger a refresh. - Any other key (conflict) — if the key is already bound to a different command,
InputBindingsManager.conflictsandInputBindingsManager.conflictCfgare set.cfg.end()is not called yet.routeview-bindings.qmlwatchesconflictsand shows a conflict-resolution alert. The user can confirm (callsconflictCfg.confirm()→execBindings()) or cancel (callsconflictCfg.cancel()→cancel()).
Hover during binding
onEntered and onExited both guard against state === "binding" and state === "selected", so hovering in or out during key capture or selection does not alter the state.
Usage
BindingCell is instantiated exclusively by component-optionslist-input-binding.qml, which creates two cells side by side — primary (key1) and secondary (key2) — each occupying half the row width. component-optionslist-input-binding.qml is in turn loaded dynamically by OptionsListRow when model.type is "binding". component-binding.qml (BindingList) also uses OptionsListRow with binding-type models, so BindingCell is indirectly used there as well.
Notable issues
1. id: text conflicts with the text property. The Text element is given id: text, which shadows the text string property of the same element. Referencing text.text is valid QML but is confusing and error-prone.
2. mouse.accepted references wrong parameter name. The onClicked handler is declared as onClicked: function(event) { ... }, naming the parameter event. The final line then writes mouse.accepted {{=}} true. Since the parameter is event, not mouse, this references MouseArea's implicit mouse property (the last event object), not the current event. The assignment may silently succeed but does not reliably accept the current event.
3. StateChangeScript in focused plays hover sound on every entry. This includes the transition from binding back to focused after a key is successfully bound, causing an unintentional hover sound to play at the end of every key-capture sequence.
4. blurred ↔ focused transition only animates text. The background opacity change (0 → 0.2) is instant on hover, while the text color animates over 150 ms. All other transitions animate both text and background in parallel.
5. selected ↔ binding is reversible: true but the reverse path is never used. endBinding() always sets state to focused or blurred, never back to selected. The binding → selected reverse transition is dead code. The separate explicit binding → focused transition is the one that actually fires.
6. Conflict resolution leaves the cell in binding state. When a conflict is detected, cfg.end() is not called, so the cell remains in binding state (solid orange, key label hidden) while the conflict alert is displayed. If the user dismisses the alert without confirming or cancelling (which is not possible in the current UI but is not structurally prevented), the cell would be permanently stuck in binding state.
component-optionslist-input-checkbox.qml
component-optionslist-input-checkbox.qml is the checkbox input widget for the options list system. It renders a square toggle control that switches between checked ("true") and unchecked ("false") states. It is not registered in qmldir; it is loaded dynamically by component-optionslist-row.qml via Loader.setSource() when a row's type property equals "checkbox".
Properties
| Property | Type | Description |
|---|---|---|
type
|
readonly string
|
Always "checkbox". Used by utils.qml to dispatch keyboard/controller input to the correct handler.
|
model
|
variant
|
The row data object. Expected fields: value (string, "true" or "false"), disabled (bool).
|
selectedValue
|
bool
|
Mirrors model.value via a Binding. Not used internally after assignment; the onSelectedValueChanged handler is an empty no-op.
|
Signal
| Signal | Description |
|---|---|
requestSettingsChange(var model, var value)
|
Emitted on click with the toggled string value ("true" or "false"). Propagates up through OptionsListRow to OptionsList, which writes the new value to the engine.
|
Visual Structure
The component is an Item (id: checkboxInput) that fills its parent via anchors.fill: parent.
Background rectangle
A Rectangle (id: background) sized Math.ceil(50 * Theme.heightScale) × Math.ceil(50 * Theme.heightScale), centered in the parent via anchors.centerIn: parent, filled with Theme.colors.modalBackground (#222222). This is the outer box of the checkbox.
Fill rectangle
A Rectangle (id: fill) nested inside background. It is only visible when model.value === "true". It fills background with an inset margin of Math.ceil(7 * Theme.widthScale) pixels, creating the visual "checked" indicator. Its color animates over 75 ms via a ColorAnimation Behavior when the state changes.
MouseArea
A MouseArea fills background. It is disabled when model.disabled is true. On click it plays Theme.sounds.buttonClicked and emits requestSettingsChange with the toggled value: model.value !== 'true' ? 'true' : 'false'.
States
The component starts in the "blurred" state. The state is driven externally by component-optionslist-row.qml, which binds loader.item.state to its own state property.
| State | fill.color
|
fill.border.color
|
|---|---|---|
"focused"
|
Theme.colors.highlight (#e47125, orange)
|
Theme.colors.highlight
|
"blurred"
|
Theme.colors.buttonText (white)
|
Theme.colors.dimmedText (#888888)
|
"disabled"
|
Theme.dimmedSlider (see Notable Issues)
|
Theme.colors.dimmedText
|
utils.qml handles keyboard/controller input for all option item types. For "checkbox", both Qt.Key_Left and Qt.Key_Right execute the same action:
currentElement.children[0].children[0].clicked(null)
This resolves to background.MouseArea.clicked(null), which triggers the toggle. Both left and right arrow keys (and their controller equivalents) toggle the checkbox identically.
Consumers
For example, the "checkbox" type is used in two route views:
| Route view | Row id | Label key | CVar |
|---|---|---|---|
routeview-host.qml
|
teams
|
#BlackMesaUI_Multiplayer_TeamPlay
|
mp_teamplay
|
routeview-host.qml
|
respawn
|
#BlackMesaUI_Multiplayer_ForceRespawn
|
mp_forcerespawn
|
routeview-video.qml contains a commented-out checkbox row for an "Unlock Potato" quality preset toggle (key: "video_unlockPotato"). It is not active in the shipped UI.
Notable Issues
1. Theme.dimmedSlider typo in the "disabled" state. The PropertyChanges for the disabled state references Theme.dimmedSlider directly on the Theme singleton root, but the correct path is Theme.colors.dimmedSlider. Since Theme.dimmedSlider is undefined, the fill color in the disabled state will be undefined, which QML silently treats as transparent. The border color is correct (Theme.colors.dimmedText).
2. onSelectedValueChanged is an empty no-op. The handler is declared but contains no logic. The selectedValue property is bound from model.value but is never read back by any internal logic — the component reads model.value directly for both the fill.visible condition and the toggle expression.
3. Both left and right arrow keys produce identical behavior. Unlike "select" (left decrements, right increments) and "slider" (left decrements, right increments), the checkbox has no directional distinction. Pressing left or right both toggle the value. This is functionally correct for a binary toggle but is inconsistent with the directional model used by other input types.
4. fill has conflicting anchor declarations. fill sets both anchors.fill: parent and anchors.centerIn: parent. In QML, anchors.fill and anchors.centerIn are mutually exclusive; setting both is an anchor conflict. QML will emit a warning at runtime and apply one set of anchors while ignoring the other. In practice anchors.fill takes effect (the fill covers the background minus margins), so the visual result is correct, but the conflict is a latent source of runtime warnings.
5. Value is stored as a string, not a boolean. model.value is compared with the string literal 'true' throughout. routeview-host.qml initialises the value via BlackMesaEngine.getConsoleVariableAsBoolean(), which presumably returns a string. If the engine ever returns a numeric "1" or "0" instead of "true" / "false", the toggle logic and fill.visible condition will both silently fail.
6. No hover sound at the component level. Sound.playEffect(Theme.sounds.buttonFocused) is not called inside this component. Hover feedback is provided by the parent OptionsListRow's MouseArea.onEntered, which plays the focus sound for all non-separator row types. This is consistent with the other input widgets but means the checkbox itself has no independent hover feedback if used outside of OptionsListRow.
component-optionslist-input-map.qml
component-optionslist-input-map.qml is the map-picker input widget for the options list system. It is not registered in qmldir and is not a named QML type; it is loaded dynamically by component-optionslist-row.qml via Loader.setSource when a row's model.type equals "map". It is the only input type that renders a visual thumbnail image rather than text.
Registration and Usage
The file is not registered in qmldir. It is referenced by name in the inputComponents object inside component-optionslist-row.qml:
readonly property QtObject inputComponents: QtObject {
readonly property string map: "component-optionslist-input-map.qml"
// ...
}
It is used in exactly one place in the production UI: the map row in routeview-host.qml (the Host Game dialog), where it presents a list of 11 hardcoded multiplayer map names with their widescreen background thumbnails.
Top-level Properties
| Property | Type | Description |
|---|---|---|
type
|
readonly string
|
Always "map". Identifies this component to the options list system.
|
model
|
variant
|
The row's data object. Must expose value (current map name string), options (plain JS array of map name strings), and disabled (bool).
|
selectedValue
|
bool
|
Declared as bool but stores the current map name string. Synced from model.value via a Binding element.
|
chevronWidth
|
int
|
Width of the left/right chevron images. 16 * Theme.widthScale.
|
chevronHeight
|
int
|
Height of the left/right chevron images. 32 * Theme.heightScale.
|
Signal
| Signal | Parameters | Description |
|---|---|---|
requestSettingsChange
|
var model, var value
|
Emitted when the user clicks a chevron. The parent OptionsListRow connects this to its own requestSettingsChange signal, which propagates to component-optionslist.qml for pending-change tracking.
|
States
| State name | Trigger | Effect |
|---|---|---|
focused
|
when: activeFocus
|
Sets mapText.color to Theme.colors.highlight (orange).
|
blurred
|
when: !activeFocus
|
Sets mapText.color to Theme.colors.buttonText (white). Default state.
|
disabled
|
Set explicitly via initial property from component-optionslist-row.qml
|
Sets mapText.color to Theme.colors.dimmedSlider (#aaaaaa).
|
Layout
The root Item fills its parent (anchors.fill: parent). Three child elements are positioned relative to each other:
| Element id | Type | Position | Description |
|---|---|---|---|
chevronLeft
|
Image
|
Anchored to thumbnail.left with rightMargin: 8 * Theme.widthScale, vertically centered on thumbnail
|
Left navigation arrow. Source: image://game/ui/images/chevron-left.png. Default opacity 0.5, animates to 1.0 on hover.
|
thumbnail
|
Image
|
anchors.fill: parent with leftMargin and rightMargin of 32 * Theme.widthScale
|
The map background image. Source is constructed at runtime (see below). Loaded asynchronously. |
chevronRight
|
Image
|
Anchored to thumbnail.right with leftMargin: 8 * Theme.widthScale, vertically centered on thumbnail
|
Right navigation arrow. Source: image://game/ui/images/chevron-right.png. Default opacity 0.5, animates to 1.0 on hover.
|
thumbnail
The thumbnail image source is constructed by concatenating three strings:
source: [
"image://game/materials/vgui/multiplayer/map_backgrounds/",
model.value,
"_0_widescreen.vtf"
].join('')
For example, when model.value is "dm_stalkyard", the source resolves to image://game/materials/vgui/multiplayer/map_backgrounds/dm_stalkyard_0_widescreen.vtf.
The image is loaded with asynchronous: true to avoid blocking the UI thread.
Inside the thumbnail, a semi-transparent Rectangle overlay is anchored to the bottom of the image. It contains a Text element (id: mapText) that displays the raw map filename (model.value) centered in the overlay bar.
Both chevrons use model.options.indexOf(model.value) to find the current index in the plain JS array. Navigation wraps around at both ends:
| Direction | Wrap condition | New index expression |
|---|---|---|
| Left | currentIndex === 0
|
model.options.length - 1 (wraps to last)
|
| Right | currentIndex === model.options.length - 1
|
0 (wraps to first)
|
On click, requestSettingsChange(model, model.options[index]) is emitted with the new map name string as the value.
On hover enter, Sound.playEffect(Theme.sounds.buttonFocused) is called and the chevron opacity animates to 1.0 over 75 ms. On hover exit, opacity returns to 0.5.
Both MouseArea elements set enabled: !model.disabled, disabling interaction when the row is disabled.
model.options Format
Unlike the select input type, which uses a QML ListModel, the map type expects model.options to be a plain JavaScript array of strings. The navigation logic uses standard JS array methods (.indexOf(), .length, bracket indexing). In routeview-host.qml, this is declared as a property variant on a ListElement:
property variant options: [
'dm_bounce',
'dm_chopper',
'dm_crossfire',
// ...
'dm_undertow'
]
Notable Issues
1. selectedValue is typed as bool. The property is declared property bool selectedValue but is bound to model.value, which is a map name string. QML will coerce the string to a boolean (non-empty string = true), making selectedValue always true for any valid map name. The property is effectively unused — onSelectedValueChanged is an empty handler.
2. onSelectedValueChanged: {} is dead code. The handler is declared but empty. The component reacts to value changes only through the Binding element updating selectedValue, which triggers no meaningful logic.
3. mapText.font.pixelSize: 12 is hardcoded. The map name label uses a fixed pixel size not scaled by Theme.heightScale or Theme.widthScale, unlike every other text element in the options system. On high-resolution or non-1080p displays, the label will appear disproportionately small.
4. mapText.text shows the raw BSP filename. The overlay displays the internal map filename (e.g. dm_stalkyard) rather than a human-readable display name. There is no lookup table or localization key for map display names.
5. No keyboard or controller navigation. The component has no callback property and no Keys.onPressed handler. The select input type supports left/right key navigation via utils.qml's navigationUIHandle; the map type does not. Controller and keyboard users cannot change the map selection.
6. QtGraphicalEffects 1.0 is imported but unused. No graphical effect (drop shadow, blur, colorize, etc.) is applied anywhere in the file. The import is a leftover.
7. disabled state has no when: condition. The focused and blurred states use when: activeFocus / when: !activeFocus and are reactive. The disabled state has no when: and must be set via the initial property passed from component-optionslist-row.qml. If the row's disabled status changes after the loader completes, the map input's state will not update.
8. Wrapping behavior differs from select. The select input hides the left arrow at index 0 and the right arrow at the last index, preventing wrap-around. The map input wraps silently in both directions with no visual indication that the list is circular.
9. Sole consumer is routeview-host.qml. The map input type is used in exactly one OptionsListRow in the entire codebase. The routeview-join.qml server browser does not use it; map names in the join view are plain data fields in the server list, not interactive inputs.
component-optionslist-input-select.qml
component-optionslist-input-select.qml is the discrete-option selector input type used by the OptionsListRow system. It renders a left/right arrow pair (TriangleButton) with a centered label and an optional tab-strip position indicator, allowing the user to cycle through a fixed list of named options. It is not registered in qmldir and is loaded exclusively by component-optionslist-row.qml via Loader.setSource() when a row's model.type is "select".
Properties
| Property | Type | Description |
|---|---|---|
type
|
readonly string
|
Always "select". Used by component-optionslist-row.qml to identify the input type.
|
model
|
variant
|
The row data object. Must expose options (a ListModel), disabled (bool), label (string), and optionally cvar (string).
|
selectedIndex
|
int
|
Zero-based index of the currently selected option within model.options.
|
selectedValue
|
variant
|
Mirrors model.value via a Binding. Changing this triggers onSelectedValueChanged, which scans model.options to update selectedIndex.
|
valueTextFontSize
|
int
|
Math.ceil(22 * Theme.heightScale). Font size of the centered option label.
|
triangleButtonWidth
|
int
|
Math.ceil(40 * Theme.widthScale). Width of each TriangleButton arrow.
|
tabHeight
|
int
|
Math.ceil(3 * Theme.heightScale). Height of each position-indicator tab rectangle.
|
tabSpacing
|
int
|
Math.ceil(5 * Theme.widthScale). Spacing between tab rectangles.
|
triangleHeight
|
int
|
Math.ceil(20 * Theme.heightScale). Height (and width) of the triangle glyph inside each arrow button.
|
Signals
| Signal | Description |
|---|---|
requestSettingsChange(var model, var value)
|
Emitted by leftArrow.onClicked and rightArrow.onClicked with the adjacent option's value string. Connected upstream by component-optionslist-row.qml's Loader.onLoaded handler, which propagates it to component-optionslist.qml.
|
States
| State | Trigger | Effect |
|---|---|---|
focused
|
selectInput.activeFocus == true
|
selectedValueText.color → Theme.colors.highlight (orange)
|
blurred
|
!selectInput.activeFocus
|
selectedValueText.color → Theme.colors.buttonText (white)
|
disabled
|
Set externally by the parent route view | selectedValueText.color → Theme.colors.dimmedText (grey)
|
Transitions between blurred and focused animate over 75 ms; transitions between blurred and disabled animate over 350 ms. Both transitions are reversible: true.
Child Elements
leftArrow (TriangleButton)
A left-pointing TriangleButton anchored to the left edge of the component.
visible:selectedIndex !== 0— hidden when the first option is selected.enabled:!model.disabled— disabled when the row is disabled.opacity:1.0when enabled,0.0when disabled, animated over 350 ms.onClicked: playsTheme.sounds.buttonClickedviaSound.playEffect, then emitsrequestSettingsChange(model, model.options.get(selectedIndex - 1).value).
selectedValueText (Text)
A centered Text element displaying the localized label of the currently selected option.
text:L10n.getString(model.options.get(selectedIndex).label)— passes the option'slabelkey throughBlackMesaEngine.getLocalizedString().font.family:Theme.fonts.boldfont.capitalization:Font.AllUppercaseanchors.verticalCenterOffset:model.options.count ? -2 : 0— shifts the label 2 px upward when any options exist, to leave visual room for the tab strip below.
tabsContainer (Row)
A horizontal strip of thin Rectangle elements, one per option, acting as a position indicator (similar to a pagination dot strip).
visible:model.options.count > 2— hidden for binary (two-option) selects.- Width:
parent.width - leftArrow.width * 2, centered between the two arrows. - Each tab rectangle's
color:Theme.colors.dimmedText(grey) for unselected tabs;Theme.colors.highlight(orange) when focused,Theme.colors.buttonText(white) when blurred, for the selected tab. Color animates over 75 ms. - Tab opacity is fixed at
0.75.
rightArrow (TriangleButton)
A right-pointing TriangleButton anchored to the right edge of the component. Mirror of leftArrow.
visible:selectedIndex !== model.options.count - 1— hidden when the last option is selected.onClicked: playsTheme.sounds.buttonClicked, then emitsrequestSettingsChange(model, model.options.get(selectedIndex + 1).value).
warningSign (Image)
A 32×32 px warning icon (image://game/ui/images/warning.png) anchored to the right of the component's right edge, with an 8 px left margin.
visible:model.options.get(selectedIndex).warning ? 1 : 0— shown when the currently selected option has a truthywarningproperty.onVisibleChanged: callsupdateHeaderWarningVisibility()if that function exists in the enclosing scope (checked viatypeof(updateHeaderWarningVisibility) !== "undefined"). This is used exclusively byrouteview-video.qml, which definesupdateHeaderWarningVisibility()to count all active warnings and toggle the header warning banner.
model.options ListModel Schema
Each item in model.options must have the following roles:
| Role | Type | Description |
|---|---|---|
value
|
string
|
The raw value written to the engine CVar or passed to a complex setter. |
label
|
string
|
A localization key passed to L10n.getString() to produce the display text.
|
warning
|
int (0 or 1)
|
Optional. If 1, the warning icon is shown when this option is selected. Used only in routeview-video.qml for performance-intensive settings.
|
Examples of Usage by Route Views
| Route view | Select rows (examples) |
|---|---|
routeview-video.qml
|
Display mode, resolution, aspect ratio, refresh rate, antialiasing, model detail, texture detail, texture filtering, motion blur, water detail, CSM quality, CSM memory, dynamic shadow quality/memory/softness, dynamic lights quality, god rays, lens flare, chromatic aberration, radioactive noise, unlock high-end unsupported. Several options carry warning: 1 (e.g. Water High, CSM Insane, Dynamic Lights Ultra/Insane).
|
routeview-game.qml
|
Difficulty, crosshair style, HUD style, auto-crouch jump, multiplayer model, multiplayer skin, and others. |
routeview-input.qml
|
Mouse acceleration mode, controller layout, gyro look axis, and others. |
routeview-audio.qml
|
Speaker configuration (snd_surround), sound quality (dsp_slow_cpu + snd_pitchquality), captioning type (closecaption + cc_subtitles), captioning language (cc_lang).
|
Quirks and Issues
1. tabsContainer is hidden for exactly two options. The tab strip is only shown when model.options.count > 2. Binary selects (e.g. On/Off toggles) show no position indicator at all — only the arrows convey position, and those disappear at the boundary indices. A user at index 0 of a two-option select sees only the right arrow with no indication that there is a second option.
2. anchors.verticalCenterOffset is always −2 when options exist. The offset is model.options.count ? -2 : 0, so it applies even for two-option selects where tabsContainer is invisible. The label is shifted upward for no visual reason in those cases.
3. tabsContainer.anchors.rightMargin has no effect. The container is anchored on its left side to leftArrow.right and has no right anchor, so anchors.rightMargin: triangleButtonWidth/2 is silently ignored by the QML layout engine.
4. rightArrow.anchors.leftMargin has no effect. rightArrow is anchored to parent.right, not to a left anchor, so anchors.leftMargin: triangleButtonWidth/2 is silently ignored.
5. warningSign uses integer comparison instead of boolean. model.options.get(selectedIndex).warning ? 1 : 0 converts the result to an integer before assigning to visible, which expects a boolean. QML coerces non-zero integers to true, so this works, but it is inconsistent with the boolean visible convention used everywhere else.
6. updateHeaderWarningVisibility is resolved via dynamic scope. The call relies on the QML property lookup chain finding updateHeaderWarningVisibility in an ancestor scope (specifically routeview-video.qml's OptionsList). This is fragile: if the component is ever used in a context where that function is not in scope, the typeof guard silently suppresses the call with no warning.
7. Arrow opacity and visible are independently controlled. visible is tied to the index boundary; opacity is tied to enabled. A disabled select at a non-boundary index will show a fully transparent (but still layout-occupying) arrow. The Behavior on opacity animates the fade, but since visible is not animated, the arrow disappears instantly when the index reaches a boundary even if the opacity animation is mid-flight.
8. Click sound is played inside the select component, not the row. Both leftArrow.onClicked and rightArrow.onClicked call Sound.playEffect(Theme.sounds.buttonClicked) directly. The hover sound (Theme.sounds.buttonFocused) is played by component-optionslist-row.qml's MouseArea.onEntered, creating an asymmetry where hover and click sounds originate from different components.
9. No wrapping. Clicking the left arrow at index 0 or the right arrow at the last index is prevented by hiding the respective arrow, but there is no wrap-around option. Keyboard/controller left-right navigation (handled by utils.qml) also does not wrap.
component-optionslist-input-separator.qml
Undone, unused. No visual content is rendered by this file. The file is 6 lines long and contains only an empty Item with an unimplemented comment: "Maybe add an horizontal line, or something like that". All separator styling is handled entirely by component-optionslist-row.qml.
component-optionslist-input-slider.qml
component-optionslist-input-slider.qml is the slider input type for the options list system. It is not registered in qmldir and is never instantiated directly; instead, component-optionslist-row.qml loads it dynamically via Loader.setSource() when a row model has type: "slider". The root element is an Item (id: sliderInput) with objectName: "ui:option-item", which causes BlackMesaUtils.traverseUIElements() to register it in the optionItems array for keyboard and controller navigation.
Properties
| Property | Type | Description |
|---|---|---|
type
|
readonly string
|
Always "slider". Used by component-optionslist-row.qml to select this component.
|
model
|
variant
|
The row model object from the parent ListModel. Provides value, minValue, maxValue, stepValue, precision, formatter, replaceMinByOff, and disabled.
|
selectedValue
|
real
|
Bound to model.value via a Binding element. Changing it triggers onSelectedValueChanged, which calls setSliderValue(model.value) to update the visual position.
|
sliderValue
|
real
|
The current value reflected by the slider's visual position. Updated by setSliderCoords() and setSliderValue(). Used as the argument to the active formatter for valueText.
|
Signal
requestSettingsChange(var model, var value) is emitted on MouseArea.onReleased with the row model and the new value as a string. component-optionslist-row.qml connects this signal to its own requestSettingsChange, which propagates it up to the parent OptionsList.
Formatters
The formatters QtObject provides three named display functions. The active formatter is selected by model.formatter and called as formatters[model.formatter](sliderValue) to produce the text shown in valueText.
| Key | Behaviour | Used by |
|---|---|---|
percent
|
Number(value * 100).toFixed(0) — multiplies by 100 and truncates to an integer string (e.g. 0.75 → "75").
|
All three audio volume sliders. |
decimal
|
Number(value).toFixed(model.precision) — formats to model.precision decimal places. If model.replaceMinByOff = "1" and the value equals model.minValue, returns L10n.strings.options.values.off instead.
|
Mouse sensitivity, mouse acceleration, zoom acceleration, controller sensitivity, gyro sensitivity, view roll sliders. |
whole
|
Number(value).toFixed(0) — truncates to an integer string.
|
Defined but unused by any slider row in the codebase. |
Coordinate/Value Conversion
Two functions map between pixel coordinates and model values:
valueToCoords(value)— maps a value in[minValue, maxValue]to a pixel x position in[0, sliderContainer.width - handleWidth]:
(value - minValue) / (maxValue - minValue) * (sliderContainer.width - handleWidth)
coordsToValue(x)— inverse mapping, with step snapping viaMath.floor(outval / stepValue) * stepValue. This always rounds down to the nearest step, not to the nearest step.
setSliderValue(value)— clamps the input to[minValue, maxValue], then callsvalueToCoordsand updates bothsliderHighlight.widthandsliderHandle.x.
setSliderCoords(coords)— setssliderValueand visual positions directly from a pixel coordinate, bypassing clamping.
States
| State | Condition | sliderHighlight color
|
sliderHandle color / opacity
|
valueText color
|
|---|---|---|---|---|
focused
|
sliderInput.activeFocus
|
Theme.colors.highlight (orange)
|
Theme.colors.highlight / 1
|
Theme.colors.highlight
|
blurred
|
!sliderInput.activeFocus
|
Theme.colors.buttonText (white)
|
Theme.colors.buttonText / 1
|
Theme.colors.buttonText
|
disabled
|
Set externally via Binding from parent row
|
Theme.colors.dimmedSlider (#aaaaaa)
|
Theme.colors.dimmedText / 0 (invisible)
|
Theme.colors.dimmedText (#888888)
|
All color transitions use a 75 ms ColorAnimation. Position transitions (sliderHighlight.width and sliderHandle.x) use a 350 ms NumberAnimation with Easing.OutQuint, but only when the mouse is not actively dragging (enabled: !mouseArea.drag.active).
Visual Structure
Dimension Properties
All dimensions are scaled. Note that handleWidth uses Theme.heightScale rather than Theme.widthScale.
| Property | Formula | Purpose |
|---|---|---|
sliderWidthPadding
|
Math.ceil(60 * Theme.widthScale)
|
Defined but never referenced. Dead property. |
sliderMargin
|
Math.ceil(40 * Theme.widthScale)
|
Left and right margin of sliderContainer inside the parent item.
|
sliderHeight
|
Math.ceil(10 * Theme.heightScale)
|
Height of the track rectangle. |
handleHeight
|
Math.ceil(30 * Theme.heightScale)
|
Height of the draggable thumb. |
handleWidth
|
Math.ceil(15 * Theme.heightScale)
|
Width of the draggable thumb. Uses heightScale, not widthScale.
|
handleBorderWidth
|
Math.ceil(2 * Theme.widthScale)
|
Border width of the thumb rectangle. |
valueTextFontSize
|
Math.ceil(22 * Theme.heightScale)
|
Font size of the value label. |
valueTextWidth
|
Math.ceil(50 * Theme.widthScale)
|
Width of the value label. |
Layout
The component is divided into two horizontal sections:
1. sliderContainer (Item) — occupies the left portion of the row, inset by sliderMargin on each side. Contains the track and handle.
2. sliderBackground (Rectangle) — full-width grey track at 75% opacity, vertically centred.
4. sliderHandle (Rectangle) — the draggable thumb, vertically centred; its x position mirrors sliderHighlight.width. Border colour is Theme.colors.modalBackground (#222222).
5. mouseArea (MouseArea) — fills sliderContainer; drag target is sliderHandle on the X axis, constrained to [0, sliderContainer.width - handleWidth].
6. valueText (Text) — anchored to the right of sliderContainer with a hardcoded (unscaled) left margin of 8 px. Displays the formatted current value using Theme.fonts.bold.
Mouse Interaction
The MouseArea handles three events:
| Event | Behaviour |
|---|---|
onPositionChanged
|
Plays Theme.sounds.buttonClicked once on the first drag move (guarded by didDrag), then calls setSliderCoords(sliderHandle.x) to update the value display in real time.
|
onClicked
|
Calls sliderInput.forceActiveFocus() and manually sets sliderInput.state = "focused".
|
onReleased
|
If the user dragged, uses sliderHandle.x as the coordinate; if the user clicked without dragging, uses mouseX. Calls coordsToValue(coords).toFixed(model.precision) and emits requestSettingsChange(model, value.toString()). Resets didDrag to false.
|
The slider has no internal key handler. Keyboard and controller navigation is managed externally by BlackMesaUtils.navigationUIHandle() in utils.qml, which calls processOptionsNavigation(sign) when the left or right arrow (or D-pad) is pressed. That function locates the current optionItem in the optionItems array and, for slider-type items, calls setSliderValue with a step increment derived from model.stepValue.
Usage Examples — Slider Rows Across Route Views
| Route view | Row key | CVar | Range | Step | Formatter |
|---|---|---|---|---|---|
routeview-audio.qml
|
audio_gameVolume
|
volume
|
0.0 – 1.0 | 0.05 | percent
|
routeview-audio.qml
|
audio_fxvolume
|
snd_fxvolume
|
0.0 – 1.0 | 0.05 | percent
|
routeview-audio.qml
|
audio_musicVolume
|
snd_musicvolume
|
0.0 – 1.0 | 0.05 | percent
|
routeview-input.qml
|
mouse_sensitivity
|
sensitivity
|
0.1 – 6.0 | 0.1 | decimal
|
routeview-input.qml
|
mouse_acceleration
|
m_customaccel_exponent
|
1.0 – 1.4 | 0.1 | decimal
|
routeview-input.qml
|
mouse_zoomAcceleration
|
zoom_sensitivity_ratio
|
0.0 – 2.0 | 0.1 | decimal
|
routeview-input.qml
|
controller_lookVerticalSensitivity
|
in_joy_look_pitch_sensitivity
|
0.0 – 2.0 | 0.01 | decimal
|
routeview-input.qml
|
controller_lookHorizontalSensitivity
|
in_joy_look_yaw_sensitivity
|
0.0 – 2.0 | 0.01 | decimal
|
routeview-input.qml
|
controller_gyroVerticalSensitivity
|
in_gyro_look_pitch_sensitivity
|
0.0 – 2.0 | 0.01 | decimal
|
routeview-input.qml
|
controller_gyroHorizontalSensitivity
|
in_gyro_look_yaw_sensitivity
|
0.0 – 2.0 | 0.01 | decimal
|
routeview-game.qml
|
game_viewRoll
|
cl_view_roll
|
0.0 – 3.5 | 0.1 | decimal
|
The replaceMinByOff feature is used by the auto-aim slider (sk_autoaim_enabled) in routeview-game.qml, which replaces the minimum value display with the localised "Off" string.
Notable Issues
1. sliderWidthPadding is a dead property. It is defined as Math.ceil(60 * Theme.widthScale) but is never referenced anywhere in the file. The actual horizontal inset is controlled by sliderMargin.
2. handleWidth uses Theme.heightScale. The handle width is Math.ceil(15 * Theme.heightScale) instead of Theme.widthScale. On non-16:9 displays where the two scales differ, the handle will be proportionally wider or narrower than intended, and the drag range calculation (drag.maximumX: parent.width - handleWidth) will be slightly off.
3. Step snapping always rounds down. coordsToValue uses Math.floor(outval / stepValue) * stepValue. This always snaps to the lower step rather than the nearest step. A drag position that maps to 0.159 with stepValue: 0.1 will snap to 0.1 rather than 0.2.
4. onClicked redundantly sets state manually. The focused and blurred states already have when: conditions bound to sliderInput.activeFocus. The explicit sliderInput.state = "focused" in onClicked is redundant and can conflict with the declarative state binding.
5. valueText left margin is unscaled. anchors.leftMargin: 8 is a hardcoded pixel value not multiplied by Theme.widthScale, unlike every other margin in the file.
6. whole formatter is unused. No slider row in any route view specifies formatter: "whole". The function is dead code.
7. disabled state hides the handle but not the track fill. When disabled, sliderHandle.opacity is set to 0 (invisible), but sliderHighlight remains visible with Theme.colors.dimmedSlider colour. The track fill still shows the current value position even though the control cannot be interacted with.
8. onReleased applies toFixed after step snapping. The call chain is coordsToValue(coords).toFixed(model.precision). Since coordsToValue already snaps to stepValue, the toFixed call only affects string formatting, not the stored value. However, if model.precision is less than the number of significant digits in stepValue, the stored string will be rounded differently from the snapped value (e.g. stepValue: 0.010000, precision: 2 → value 0.01 stored as "0.01", which is correct, but stepValue: 0.001, precision: 1 → value 0.123 stored as "0.1", discarding precision).
component-optionslist-input-text.qml
component-optionslist-input-text.qml is the free-text input delegate for the options list system. It is not registered in qmldir and is never instantiated directly; it is loaded dynamically by component-optionslist-row.qml when a row model has type: "text".
The file is 68 lines. Its root element is an Item (id: textInput) with objectName: "ui:option-item" and readonly property string type: "text", conforming to the standard input component contract expected by OptionsListRow.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
model
|
variant
|
— | The row model object supplied by OptionsListRow via Loader.setSource.
|
selectedValue
|
bool
|
— | Bound to model.value via a Binding element (active when model is truthy). Declared as bool despite model.value being a string for text rows — a type mismatch.
|
valueTextFontSize
|
int
|
Math.ceil(22 * Theme.heightScale)
|
Font size for the text field content, scaled to screen height. |
Signal
| Signal | Description |
|---|---|
requestSettingsChange(var model, var value)
|
Emitted on every keystroke (onTextChanged). Connected by OptionsListRow.onLoaded to the parent row's own requestSettingsChange signal, which propagates to OptionsList and ultimately calls BlackMesaEngine.setConsoleVariable.
|
TextField
The sole child is a TextField (id: textField) from QtQuick.Controls 2.2, filling the right half of the row with the following insets:
| Margin | Value |
|---|---|
| Top / Bottom | 8 * Theme.heightScale
|
| Left / Right | 32 * Theme.widthScale
|
The field's initial text is set to model.value. Its background is a Rectangle filled with Theme.colors.modalBackground (#222222). Font family is Theme.fonts.regular; font size is valueTextFontSize.
A Behavior block containing a ColorAnimation of 75 ms duration is declared inside the TextField. However, it is missing the required on <property> clause (correct syntax: Behavior on color { ... }). Without it, the Behavior is malformed and is silently ignored by the QML engine; color transitions on the text field are therefore instantaneous despite the intent.
States
The component has three states, all targeting textField.color (the text color):
| State | textField.color
|
Trigger |
|---|---|---|
focused
|
Theme.colors.highlight (#e47125)
|
Mouse hover or keyboard/controller focus on the parent row. |
blurred
|
Theme.colors.buttonText (white)
|
Default; mouse leaves the row. |
disabled
|
Theme.colors.dimmedText (#888888)
|
model.disabled is true.
|
State is driven by the parent OptionsListRow via a Binding that writes textInput.state from the row's own state property.
Usage
The only route view that uses type: "text" rows is routeview-host.qml (the multiplayer host/server settings page), where it is used for free-text server configuration fields such as the server name and RCON password. No other route view in the BMS UI uses this input type.
Notable Issues
1. selectedValue is declared as bool. The property type should be string (or variant) to match the string values stored in text-type model entries. As declared, QML will coerce model.value to a boolean, making selectedValue useless as a string mirror of the current value.
2. onSelectedValueChanged is commented out. The handler is present but disabled (// onSelectedValueChanged: {}). As a result, if model.value changes externally after the component is loaded, textField.text is not updated — it retains the value set at construction time via the text: model.value binding. Note that text: model.value is a one-time assignment in QtQuick.Controls 2.2 once the user edits the field, so external model updates are silently dropped.
3. requestSettingsChange fires on every keystroke. There is no debounce, no onEditingFinished, and no onAccepted handler. Every character typed immediately triggers a setConsoleVariable call through the signal chain, which may cause excessive engine writes for long strings.
4. Malformed Behavior block. The Behavior { ColorAnimation { duration: 75 } } declaration inside textField is missing the mandatory on color clause. The QML engine ignores it, so the intended 75 ms color animation on focus/blur transitions does not occur.
5. Unused QtQuick.Controls.Styles 1.4 import. This is the Qt Quick Controls 1 styling API, which is incompatible with the QtQuick.Controls 2.2 TextField used in the same file. The import is a leftover and has no effect.
6. No placeholderText. An empty text field gives no visual hint about the expected input. All other text-type rows in routeview-host.qml rely on the label column for context, but the field itself provides no in-field guidance.
7. background uses Theme.colors.modalBackground. The background color (#222222) is the same dark tone used for modal dialog backgrounds, not the standard options list row background. This is visually consistent with the dark UI aesthetic but is semantically mismatched — the field background is not a modal.
component-optionslist-row.qml
component-optionslist-row.qml is the delegate component for a single row inside an OptionsList. It is registered in qmldir as OptionsListRow 1.0. Each row consists of a left-side label and a right-side input control. The input control is loaded dynamically at runtime from one of seven sub-components, selected by the row's model.type string.
Registration and Instantiation
OptionsListRow is registered in qmldir as a named type, but it is not instantiated by name inside component-optionslist.qml. Instead, component-optionslist.qml's ListView delegate uses loader.setSource('component-optionslist-row.qml', { model: model, inputWidth: ... }) to load it dynamically. The only place that uses the OptionsListRow type name directly is routeview-host.qml, which instantiates it 6 times without going through OptionsList.
Root Element
The root element is a FocusScope (id: optionRow). Its state is driven by activeFocus:
state: activeFocus ? "focused" : "blurred"
Properties
| Property | Type | Description |
|---|---|---|
model
|
variant
|
The ListModel element for this row, supplied by the parent OptionsList.
|
labelFontSize
|
int
|
Math.ceil(24 * Theme.heightScale). Font size for the label text.
|
labelPaddingRight
|
int
|
Math.ceil(48 * Theme.widthScale). Right padding on the label, creating a gap between label and input.
|
inputComponents
|
readonly QtObject
|
Maps model.type strings to QML filenames. See Input Types below.
|
Signal
| Signal | Description |
|---|---|
requestSettingsChange(var model, var value)
|
Emitted by the loaded input sub-component and re-emitted by the row. Connected upward to OptionsList.requestSettingsChange by the parent delegate loader.
|
Structure
MouseArea (optionRowArea)
Covers the full row. enabled is false when model.disabled is true.
onEntered: playsTheme.sounds.buttonFocused, setsstate = "focused". Also callsonSelectionChanged(model)if that function exists in the dynamic scope (used byrouteview-host.qml).onExited: setsstate = "blurred".onEnabledChanged: transitions to"disabled"whenenabledbecomesfalse, or back to"focused"/"blurred"based oncontainsMousewhen re-enabled.
Separator rows are explicitly excluded from mouse state changes: if (model.type !== "separator").
Label (labelText)
A Text element occupying the left half of the row (width: parent.width / 2), right-aligned with Font.AllUppercase capitalization.
Component.onCompleted applies special formatting for the separator type:
| Property | Normal row | Separator row |
|---|---|---|
font.family
|
Theme.fonts.regular
|
Theme.fonts.bold
|
color
|
State-driven (see States) | Theme.colors.highlight
|
font.pixelSize
|
labelFontSize (24 scaled)
|
headerFontSize (32 scaled, from parent scope)
|
horizontalAlignment
|
Text.AlignRight
|
Text.AlignLeft
|
leftPadding
|
(none) | headerMargin (35 scaled, from parent scope)
|
If the label text exceeds 30 characters, the font size is reduced: labelFontSize * 22 / 28.
Input Loader (loader)
A Loader occupying the right half of the row, minus a fixed margin:
width: (parent.width / 2) - (128 * Theme.widthScale)
Component.onCompleted calls loader.setSource(inputComponents[model.type], { model: model, state: optionRow.state }).
onLoaded connects item.requestSettingsChange to the row's own requestSettingsChange signal.
A Binding keeps the loaded item's state in sync with the row's state after loading:
Binding { target: loader.item; property: "state"; value: state; when: loader.item }
Input Types
The inputComponents object maps model.type to a filename:
model.type
|
File | objectName
|
Description |
|---|---|---|---|
select
|
component-optionslist-input-select.qml
|
ui:option-item
|
Left/right TriangleButton arrows cycle through model.options. A Row of tab indicator rectangles is shown when model.options.count > 2. A warning icon (ui/images/warning.png) appears to the right when the selected option has warning: 1.
|
slider
|
component-optionslist-input-slider.qml
|
ui:option-item
|
Draggable handle over a highlight bar. Supports three display formatters: percent, decimal (with optional replaceMinByOff mode), and whole. Value is snapped to model.stepValue increments. Animated with Easing.OutQuint (350 ms) when not dragging.
|
checkbox
|
component-optionslist-input-checkbox.qml
|
ui:option-item
|
A 50×50 scaled square (Theme.colors.modalBackground background) with an inner fill rectangle visible when model.value [[=]][[=]] "true". Clicking toggles between the strings "true" and "false".
|
binding
|
component-optionslist-input-binding.qml
|
(none) | Two BindingCell instances side by side for model.key1 and model.key2. Calls InputBindingsManager.selectBinding() on click. Does not emit requestSettingsChange.
|
map
|
component-optionslist-input-map.qml
|
ui:option-item
|
Displays a map thumbnail loaded from materials/vgui/multiplayer/map_backgrounds/{value}_0_widescreen.vtf with left/right chevron images for cycling through model.options (a plain JS array, not a ListModel). Loaded asynchronously.
|
text
|
component-optionslist-input-text.qml
|
ui:option-item
|
A QtQuick.Controls 2.2 TextField with a Theme.colors.modalBackground background rectangle. Emits requestSettingsChange on every onTextChanged event.
|
separator
|
component-optionslist-input-separator.qml
|
(none) | An empty Item with a TODO comment. Renders nothing on the right side. The label side is reformatted as a section header (see Label above).
|
States and Transitions
States are applied to labelText color only. The loaded input sub-component receives the same state string via the Binding and manages its own visual response independently.
| State | labelText color
|
Transition duration |
|---|---|---|
focused
|
Theme.colors.highlight
|
75 ms (from/to blurred)
|
blurred
|
Theme.colors.warning if model.fake [[=]][[=]] true, otherwise Theme.colors.buttonText
|
75 ms (from/to focused); 350 ms (from/to disabled)
|
disabled
|
Theme.colors.dimmedText
|
350 ms (from/to blurred)
|
There are no transitions defined for focused and disabled.
Notable Issues
1. headerFontSize and headerMargin are unresolved in standalone use. The separator branch in labelText.Component.onCompleted references headerFontSize and headerMargin, which are not declared in component-optionslist-row.qml. They are resolved via QML's dynamic scope from the parent component-optionslist.qml (where they are defined as Math.ceil(32 * Theme.heightScale) and Math.ceil(35 * Theme.widthScale) respectively). When OptionsListRow is used directly — as in routeview-host.qml — these identifiers are undefined, and the separator formatting silently fails.
2. onSelectionChanged and updateHeaderWarningVisibility are dynamic-scope calls. Neither function is declared in the component. They are resolved at runtime from the enclosing scope. If the row is used outside a context that provides these functions, the typeof guard prevents a crash, but the behavior is silently absent.
3. inputWidth is a dead property. component-optionslist.qml passes inputWidth to the row via setSource, but component-optionslist-row.qml never declares or uses it. The loader width is hardcoded as (parent.width / 2) - (128 * Theme.widthScale).
4. State conflict on slider and select sub-components. The slider and select input types declare when conditions on their states (e.g. when: sliderInput.activeFocus), which causes QML to manage their state automatically. The row's Binding also writes to loader.item.state. These two mechanisms compete: the when condition takes precedence in QML's state evaluation, so the Binding may be silently overridden.
5. binding type does not emit requestSettingsChange. component-optionslist-input-binding.qml has no requestSettingsChange signal. The onLoaded handler in the row attempts to connect it unconditionally via item.requestSettingsChange && item.requestSettingsChange.connect(...), which is safe due to the guard, but means binding changes bypass the OptionsList settings pipeline entirely and go directly to InputBindingsManager.
6. checkbox disabled state references Theme.dimmedSlider instead of Theme.colors.dimmedSlider. The disabled state in component-optionslist-input-checkbox.qml sets fill.color: Theme.dimmedSlider, omitting the .colors qualifier. Theme.dimmedSlider does not exist; the property resolves to undefined, leaving the fill color unchanged when the checkbox is disabled.
7. map type uses a hardcoded font.pixelSize: 12. The map name label inside the thumbnail overlay uses a fixed pixel size not scaled by Theme.heightScale or Theme.widthScale, unlike every other text element in the options system.
8. text type imports the deprecated QtQuick.Controls.Styles 1.4. This module is not used anywhere in the file; the import is a leftover. QtQuick.Controls.Styles is the Qt 5 Quick Controls 1 styling API and is incompatible with the QtQuick.Controls 2.2 TextField used in the same file.
9. separator input component is an empty stub. component-optionslist-input-separator.qml contains only an empty Item and a TODO comment suggesting a horizontal line or similar visual. No separator decoration is rendered on the right side of separator rows.
component-scrollbar-vertical.qml
component-scrollbar-vertical.qml is registered in qmldir as VerticalScrollBar 1.0 and provides the single shared vertical scrollbar style used throughout the Black Mesa UI. It is a thin wrapper around the QtQuick.Controls 2.2 ScrollBar type that applies the game's visual theme and enforces a fixed display policy. The root element is ScrollBar, not Item. VerticalScrollBar is therefore a styled specialization of the Qt Controls scrollbar, not a custom-drawn component.
Properties
| Property | Value | Description |
|---|---|---|
visible
|
true
|
Hardcoded. The scrollbar is always rendered unless a caller overrides this. |
policy
|
ScrollBar.AlwaysOn
|
Forces the scrollbar to remain visible regardless of whether the content overflows. Callers that want conditional visibility must override visible themselves.
|
wheelEnabled
|
true
|
Enables mouse wheel scrolling on the attached Flickable or ListView.
|
stepSize
|
0.02
|
Each scroll step moves 2% of the total content height. This is a fixed ratio: on very long lists a single step covers a larger absolute distance than on short lists. |
scrollbarDimension
|
Math.ceil(16 * Theme.widthScale)
|
Computed pixel size used for both the thumb width and the minimum thumb height. Scales with screen width. |
contentItem
The contentItem property replaces the default Qt Controls thumb with a plain Rectangle:
| Property | Value |
|---|---|
implicitWidth
|
scrollbarDimension (track width)
|
implicitHeight
|
scrollbarDimension (minimum thumb height)
|
color
|
Theme.colors.highlight (#e47125, orange)
|
No background track background property is defined. The track area behind the thumb uses the default ScrollBar background, which is transparent in the Qt Quick Controls 2 Basic style. The thumb is the only visible element.
Usage
VerticalScrollBar is always attached via the ScrollBar.vertical attached property on a ListView or Flickable. Callers fall into two patterns:
Always-visible (no override)
The scrollbar is shown unconditionally, matching the base class visible: true:
| File | Context |
|---|---|
component-devconsole.qml
|
Attached to outputView (the console message ListView). Always shown.
|
Conditionally visible (caller overrides visible)
The caller sets visible to a boolean expression to hide the scrollbar when content fits:
| File | Visibility condition |
|---|---|
component-optionslist.qml
|
optionsList.height + optionsList.bottomMargin + optionsList.topMargin + 2 < optionsList.contentHeight — shown only when content overflows the list area.
|
routeview-achievements.qml
|
visible: true — hardcoded, always shown regardless of achievement count.
|
routeview-join.qml
|
Attached to the server list ListView.
|
routeview-policy.qml
|
Attached to the policy text ListView.
|
routeview-translators.qml
|
Attached to the translators card ListView.
|
Notable Issues
1. visible: true is redundant with policy: ScrollBar.AlwaysOn. ScrollBar.AlwaysOn already keeps the scrollbar rendered at all times. The explicit visible: true adds no additional effect and creates a false impression that visibility is being managed at the base class level.
2. scrollbarDimension uses Theme.widthScale for both axes. The thumb height minimum (implicitHeight: scrollbarDimension) scales with screen width rather than screen height. On non-16:9 displays where widthScale and heightScale differ, the thumb minimum height will be proportionally incorrect relative to the vertical axis.
3. No track background. The background property of the ScrollBar is not overridden, leaving the track area transparent. The scrollbar thumb floats over the list content with no visual track indicator, which can make it difficult to perceive the scrollable range.
4. stepSize: 0.02 is content-length-agnostic. A fixed 2% step means that on a list with 5 items, one scroll step moves ~0.1 items; on a list with 100 items, one step moves ~2 items. There is no adaptive step size based on visible row count.
5. routeview-achievements.qml hardcodes visible: true. This is identical to the base class default and provides no conditional logic. The scrollbar is always shown on the achievements page even if all achievements fit within the page height, which is possible for games with very few achievements.
component-wallpaper.qml
component-wallpaper.qml is the full-screen background layer rendered behind all other UI elements. It is registered in qmldir as Wallpaper 1.0 and instantiated once in main.qml as id: wallpaper, filling appRoot.
The component manages four independently animated visual layers stacked in Z-order: a background photograph, a Mesa logo watermark, two gradient overlays, and a dark skrim. All four layers share a common suppressAnimations flag that disables their Behavior animations during level loads.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
backgroundImageUrl
|
alias
|
— | Alias for backgroundImage.source. Set internally by updateBackgroundImage().
|
showImage
|
bool
|
true
|
Controls the opacity of the background photograph (1.0 when true, 0.0 when false). Animated over 1250 ms.
|
showExtras
|
bool
|
false
|
Controls the opacity of both gradient overlay rectangles. Never set to true by any caller in the codebase; the gradients are always hidden at runtime.
|
showSkrim
|
bool
|
false
|
Controls the opacity of the dark skrim rectangle. Animated over 600 ms. |
darkenSkrim
|
bool
|
false
|
Selects between Theme.opacity.pageSkrimLight (0.75) and Theme.opacity.pageSkrimDark (0.85) for the skrim opacity target.
|
suppressAnimations
|
bool
|
false
|
When true, disables all four Behavior on opacity animations. Set to isLoadingLevel by main.qml so transitions are instant during level loads.
|
_skrimOpacity
|
real
|
computed | Private. darkenSkrim ? Theme.opacity.pageSkrimDark : Theme.opacity.pageSkrimLight.
|
_mapname
|
string
|
""
|
Private. Stores the last map name passed to updateBackgroundImage() so subsequent calls without an argument can reuse it (e.g. on window resize).
|
_maps
|
variant
|
set in Component.onCompleted
|
Private. JavaScript object mapping map name strings to background key strings. |
_files
|
variant
|
set in Component.onCompleted
|
Private. JavaScript object mapping background key strings to image://game/ VTF URLs.
|
Component.onCompleted — Data Initialization
On construction, two JavaScript objects are built and assigned to _files and _maps.
_files
Maps 19 background keys (background01 through background19) to VTF image URLs under image://game/materials/console/. Each key has a standard variant and a _widescreen variant, giving 38 entries total.
_maps
Maps source strings to background keys. For the 19 numbered backgrounds the mapping is trivially 1-1 (background01 → 'background01', etc.). Four additional entries map specific BSP map names to background keys for use during inter-chapter loads:
| Map name | Background key |
|---|---|
bm_c0a0a
|
background01
|
bm_c0a0b
|
background01
|
bm_c0a0c
|
background01
|
bm_c1a0a
|
background02
|
A TODO comment in the source notes that only four map-name aliases exist and that the mapping is incomplete.
Functions
updateBackgroundImage(mapname)
Public. Called by main.qml from onWidthChanged and onHeightChanged (without an argument, to recompute widescreen selection on resize), and from routeview-video.qml after a resolution change.
If mapname is provided, it is stored in _mapname. The function then calls _getUrl(_mapname, widescreen) where the widescreen flag is appRoot.width / appRoot.height >= 1.586 (approximately a 16:10 aspect ratio threshold). If the resolved URL differs from the current backgroundImageUrl, it is assigned, triggering the 1250 ms fade animation (unless suppressAnimations is true).
_getUrl(mapname, widescreen)
Private. Looks up _maps[mapname] to get a background key, appends '_widescreen' if widescreen is true, then returns _files[key]. Returns undefined if mapname is not in _maps.
Visual Children
backgroundImage
An Image that fills the parent. Its opacity is 1.0 when showImage is true and 0.0 otherwise, animated over 1250 ms. The source is controlled via the backgroundImageUrl alias.
bottomLeftMesaLogo
An Image displaying ui/images/logo-mark.png, anchored to the bottom-right corner of the parent with zero margin. Width and height are both Math.ceil(750 * Theme.widthScale) (750×738 native pixels). This element has no opacity control and is always visible regardless of any property flags.
subBackgroundGradient
A Rectangle rotated −90° around its top-left corner, producing a vertical gradient that runs from bottom to top of the screen. The gradient goes from subNavBackground (first stop, position 0.0) to transparent (position 1.0). Opacity is 0.7 when showExtras is true, otherwise 0.0, animated over 1250 ms.
backgroundGradient
Identical rotation and sizing to subBackgroundGradient. The gradient goes from Theme.colors.highlight (#e47125, orange) at position 0.0 to transparent at position 1.0. Opacity is 0.15 when showExtras is true, otherwise 0.0, animated over 1250 ms.
skrim
A Rectangle filling the parent with color Theme.colors.skrim (#2d2d2d). Opacity is _skrimOpacity when showSkrim is true, otherwise 0.0, animated over 600 ms (shorter than the image/gradient animations).
Usage in main.qml
| Binding | Value | Effect |
|---|---|---|
showSkrim
|
isInGame || router.currentRoute !== Routes.index
|
Skrim is shown on all pages except the main menu index, and always when in-game. |
darkenSkrim
|
isInGame
|
Uses the darker opacity (0.85) when in-game, lighter (0.75) on menu pages. |
suppressAnimations
|
isLoadingLevel
|
All opacity transitions are instant during level loads. |
wallpaper.updateBackgroundImage() (no argument) is called from onWidthChanged and onHeightChanged to reselect the standard or widescreen image variant when the window is resized. wallpaper.updateBackgroundImage(mapname) is called with a map name when a level begins loading.
Notable Issues
1. subNavBackground is an unqualified identifier. On line 147, the first GradientStop of subBackgroundGradient uses subNavBackground as its color value without the Theme.colors. prefix. subNavBackground is not defined anywhere in the component's scope or any ancestor scope. At runtime this resolves to undefined, and QML will silently substitute a default color (typically black or transparent), making the gradient visually incorrect. The correct reference is Theme.colors.subNavBackground (#111111).
2. Widescreen VTF mismatches in _files. Several widescreen keys point to the wrong VTF file:
| Key | Assigned VTF | Expected VTF |
|---|---|---|
background06_widescreen
|
background02_widescreen.vtf
|
background06_widescreen.vtf
|
background09_widescreen
|
background10_widescreen.vtf
|
background09_widescreen.vtf
|
background10_widescreen
|
background11_widescreen.vtf
|
background10_widescreen.vtf
|
background11_widescreen
|
background12_widescreen.vtf
|
background11_widescreen.vtf
|
These appear to be copy-paste or off-by-one errors. background12_widescreen correctly maps to background12_widescreen.vtf, so the sequence resumes correctly from key 12 onward.
3. _mapname starts empty. On construction, _mapname is "". If updateBackgroundImage() is called without an argument before any map name has been provided (e.g. on the first onWidthChanged event), _getUrl("", ...) returns undefined and backgroundImageUrl is not updated. The background image remains unset until a map name is supplied.
4. bottomLeftMesaLogo uses Theme.widthScale for both dimensions. The height is Math.ceil(750 * Theme.widthScale) rather than Math.ceil(738 * Theme.heightScale). This preserves the aspect ratio of the logo relative to screen width, but the logo will appear slightly distorted on non-16:9 displays where widthScale and heightScale differ.
5. _maps 1-1 section is redundant. The TODO comment expresses a desire for a 1-1 mapping between map names and background filenames. The 19 numbered entries in _maps already are 1-1 (background01 → 'background01'), making the entire _maps lookup unnecessary for those keys — _files[mapname] would produce the same result directly. Only the four BSP map name aliases at the bottom justify the indirection.