AlertStrip
An AlertStrip is a row of alert icons, as in a grand strategy game. Each icon is one kind of alert, such as idle factories or low supply. The icon has a color for its severity, a count badge and a tooltip with the details. A click on the icon goes to the cause. A right click dismisses the alert.
How to add a strip:
<tb:AlertStrip name="alerts" />
<tb:AlertStrip name="cityAlerts" vertical="true" tooltip-placement="Right" />
var alerts = root.Q<AlertStrip>("alerts");
// Add an alert, or change it. The same id changes the same icon.
alerts.Set("supply", crateIcon, Severity.Warning, count: 2,
title: "Low supply", details: "2 armies have low supply.", priority: 4);
// The count grows, and the alert becomes an error: the icon flashes and the notification sound plays
alerts.Set("supply", crateIcon, Severity.Error, 4, "Low supply", "4 armies have low supply.", 4);
// The cause is gone: the icon slides out
alerts.Remove("supply");
alerts.Clicked += id => ShowRegion(id);
alerts.Dismissed += id => snoozedUntil[id] = day + 5;
The alerts come from code, so the strip is empty in UI Builder. There, it shows a faint dashed outline with the name "AlertStrip".
| Member | Description |
|---|---|
Set(id, icon, severity, count, title, details, priority) |
Adds the alert id, or changes it when the strip has it. Returns the AlertStripItem. A new icon slides in, and the icons after it slide to their new places. |
Remove(id) |
Removes the alert. The icon slides out, and the icons after it slide into the gap. Returns false when the strip does not have the alert. |
Dismiss(id) |
Removes the alert and raises Dismissed, as a right click does. |
Clear() |
Removes every alert. |
Get(id), Contains(id) |
The icon of an alert, or null. True when the strip has the alert. |
Items, Count |
The alerts in the order of the strip. An icon that slides out is not in the list. |
Clicked |
Raised with the id when the user clicks an icon, or presses Enter or the submit button on the focused icon. |
Dismissed |
Raised with the id when the user right-clicks an icon, or presses Delete or Backspace on the focused icon. |
Vertical (vertical) |
Puts the icons in a column, for a strip on the side of the screen. |
TooltipPlacement (tooltip-placement) |
Where the tooltips show. The default is Below, for a strip at the top. Use Right for a vertical strip on the left. |
FlashErrors (flash-errors) |
Makes the Error icons flash with AttentionFlash (default true). |
ErrorSound (error-sound) |
Plays the notification sound when an alert becomes Error (default true). |
Dismissible (dismissible) |
Lets the user dismiss an alert (default true). |
AlertStrip.Compare(a, b) |
The order of the strip. |
AlertStripItem is one icon:
| Member | Description |
|---|---|
Id, Severity, Count, Title, Details, Priority, Icon |
The values of the last Set. You can also change them on the item. |
CountBadge |
The Badge on the corner. A count of 0 hides it. A count above 99 shows "99+". |
Tip |
The ToolTip. Title is its header and Details its text. Rich text tags work in the details. |
Sequence |
The order of the first Set. |
IsRemoved |
True while the icon slides out. |
Severity is Info, Success, Warning or Error. Alert, NotificationBubble and Callout use the same enum.
| Severity | Icon | Badge tone | Tooltip |
|---|---|---|---|
Info |
Accent color | Accent |
ToolTip.ACCENT_CLASS |
Success |
Success color | Success |
ToolTip.SUCCESS_CLASS |
Warning |
Warning color | Warning |
ToolTip.WARNING_CLASS |
Error |
Danger color, flashes | Error |
ToolTip.ERROR_CLASS |
- The order is stable. The most severe alert comes first. Then the alert with the highest priority. Then the oldest alert. A change of the count or the text does not move an icon.
- The icon is a picture that the strip tints with the color of the severity. Use a white picture on a transparent background.
- A click on an icon plays the button sound of the workspace. An alert that becomes
Errorplays the notification sound. The panel must have anWorkspaceAudio. - The icons are focusable, so the strip works with the keyboard and a gamepad.
- An alert with no details shows its title as the tooltip.
Tips:
- Let the count set the severity. For example: 1 to 3 armies with low supply is a warning, 4 or more is an error.
- Use
Dismissedto snooze an alert for some time, so the game does not raise it again at once. - Use the priority to keep the most important kinds of alerts first in each severity.
Styling
| Class | Element |
|---|---|
tb-alert-strip |
The strip: a row that wraps. |
tb-alert-strip--vertical |
A strip with Vertical on: a column. |
tb-alert-strip__item |
One icon: a 36 px square with a border and a radius. It grows a little under the pointer. |
tb-alert-strip__item--info, --success, --warning, --error |
The severity. It sets the border color and the tint of the icon. |
tb-alert-strip__item--error.tb-attention--on |
The flash of an Error icon: a danger background. |
tb-alert-strip__icon |
The picture, 22 px, tinted with -unity-background-image-tint-color. |
tb-alert-strip__count |
The count badge, a corner Badge. |
tb-alert-strip__item--hidden |
Where the slide in starts and the slide out ends: transparent and 12 px up (12 px left in a vertical strip). |
tb-alert-strip__item--anim-in, --anim-out |
The transitions of the slide in and the slide out. |
tb-alert-strip__item--shift |
The transition while an icon slides to its new place, when an icon before it comes or goes. |
To make the icons larger:
.tb-alert-strip__item { width: 48px; height: 48px; }
.tb-alert-strip__icon { width: 32px; height: 32px; }
The AlertStripDemo scene shows a grand strategy strip with a day clock and a vertical strip for a city builder.