Class TCastleNotifications
Unit
CastleNotifications
Declaration
type TCastleNotifications = class(TCastleUserInterfaceFont)
Description
Notifications displayed on the screen. Each message disappears after a short time. Suitable for game messages like "Picked up 20 ammo". Call Show to display a message.
This is a TCastleUserInterface descendant, so to use it — just add it to TCastleWindow.Controls or TCastleControl.Controls. Use TCastleUserInterface anchors to automatically position it on the screen, for example:
Notifications := TCastleNotifications.Create(Owner);
Notifications.Anchor(hpMiddle);
Notifications.Anchor(vpMiddle);
Notifications.TextAlignment := hpMiddle;
Hierarchy
Overview
Fields
Methods
|
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Show(const s: string); overload; |
|
procedure Show(s: TStringList); overload; |
|
procedure Clear; |
|
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
procedure Render; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
Properties
Description
Fields
|
nested const DefaultMaxMessages = 4; |
|
|
nested const DefaultTimeout = 5.0; |
|
|
nested const DefaultFade = 1.0; |
|
Methods
|
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
|
constructor Create(AOwner: TComponent); override; |
|
|
destructor Destroy; override; |
|
|
procedure Show(const s: string); overload; |
Show new message. An overloaded version that takes a single string will detect newlines in the string automatically so a message may be multi-line. The messages will be automatically broken to fit on the screen width with given font.
|
|
procedure Show(s: TStringList); overload; |
|
|
procedure Clear; |
Clear all messages.
|
|
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
|
procedure Render; override; |
|
Properties
|
property Color: TCastleColor read FColor write FColor; |
Color used to draw subsequent messages. Default value is white.
|
|
property MaxMessages: integer
read FMaxMessages write FMaxMessages default DefaultMaxMessages; |
How many message lines should be visible on the screen, at maximum.
|
|
property Timeout: Single
read FTimeout write FTimeout default DefaultTimeout; |
How long a given message should be visible on the screen, in seconds. Message stops being visible when this timeout passed, or when we need more space for new messages (see MaxMessages).
Note that the Fade time is already included in this value, so a message is normally visible only for the Timeout - Fade seconds, and then it starts fading out.
|
|
property Fade: Single read FFade write FFade default DefaultFade; |
|
|
property CollectHistory: boolean read FCollectHistory write FCollectHistory
default false; |
Turn this on to have all the messages you pass to Show be collected inside History string list. History is expanded by Show, it is cleared by Clear, just like the notifications on screen. However, unlike the visible messages, it has unlimited size (messages there are not removed when MaxMessages or Timeout take action), and messages inside are not broken to honour screen width.
This is useful if you want to show the player a history of messages (in case they missed the message in game).
|
|
property TextAlignment: THorizontalPosition
read FTextAlignment write FTextAlignment default hpLeft; |
Alignment of the text inside.
|
|
property DesignTestMessagesInterval: Single
read FDesignTestMessagesInterval write FDesignTestMessagesInterval
default 1; |
In design mode (within CGE editor) we can spawn test messages (so you can see how the notifications look). This property determines how often we do it. 0 means to not do it.
|
|
property ColorPersistent: TCastleColorPersistent read FColorPersistent ; |
Color that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Color directly.
See also
- Color
- Color used to draw subsequent messages.
|
Generated by PasDoc 0.16.0.