Class TCastleNotifications

Unit

Declaration

type TCastleNotifications = class(TUIControlFont)

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 TUIControl descendant, so to use it — just add it to TCastleWindowCustom.Controls or TCastleControlCustom.Controls. Use TUIControl anchors to automatically position it on the screen, for example:

Notifications := TCastleNotifications.Create(Owner);
Notifications.Anchor(hpMiddle);
Notifications.Anchor(vpMiddle);
Notifications.TextAlignment := hpMiddle; // looks best, when anchor is also in the middle

Hierarchy

Overview

Fields

Public internal const DefaultMaxMessages = 4;
Public internal const DefaultTimeout = 5.0;
Public internal const DefaultFade = 1.0;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Show(const s: string); overload;
Public procedure Show(s: TStringList); overload;
Public procedure Clear;
Public procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override;
Public procedure Render; override;
Public function Rect: TRectangle; override;

Properties

Public property Color: TCastleColor read FColor write FColor;
Public property History: TCastleStringList read FHistory;
Published property MaxMessages: integer read FMaxMessages write FMaxMessages default DefaultMaxMessages;
Published property Timeout: Single read FTimeout write FTimeout default DefaultTimeout;
Published property Fade: Single read FFade write FFade default DefaultFade;
Published property CollectHistory: boolean read FCollectHistory write FCollectHistory default false;
Published property TextAlignment: THorizontalPosition read FTextAlignment write FTextAlignment default hpLeft;

Description

Fields

Public internal const DefaultMaxMessages = 4;
 
Public internal const DefaultTimeout = 5.0;
 
Public internal const DefaultFade = 1.0;
 

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public 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.

Public procedure Show(s: TStringList); overload;
 
Public procedure Clear;

Clear all messages.

Public procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override;
 
Public procedure Render; override;
 
Public function Rect: TRectangle; override;
 

Properties

Public property Color: TCastleColor read FColor write FColor;

Color used to draw subsequent messages. Default value is white.

Public property History: TCastleStringList read FHistory;

All the messages passed to Show, collected only if CollectHistory. May be Nil when not CollectHistory.

Published property MaxMessages: integer read FMaxMessages write FMaxMessages default DefaultMaxMessages;

How many message lines should be visible on the screen, at maximum.

Published 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).

Published property Fade: Single read FFade write FFade default DefaultFade;
 
Published 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).

Published property TextAlignment: THorizontalPosition read FTextAlignment write FTextAlignment default hpLeft;

Alignment of the text inside.


Generated by PasDoc 0.15.0.