Castle Game Engine
Functions and Procedures
Dialog windows (to display some information, or ask user for confirmation, or ask user to input a simple value) as a user-interface state (TUIState). This unit defines the user-interface state classes (TUIState descendants) to display given dialog.
If you use TCastleWindow with most platforms (but not iOS), then it's usually more comfortable to use the unit CastleMessages instead of this unit. Using the CastleMessages, you get comfortable functions like MessageOK and MessageYesNo that wait until user presses a button (like "OK", "Yes", "No") to close the dialog. This is comfortable to use, as you can write code like this:
if MessageYesNo(Window, 'Are you sure you want to delete this file?') then DeleteFile(...);
However, if you need to work on iOS, then you cannot use most of routines from the CastleMessages unit. You can use MessageOK if you turn on the MessageOKPushesState flag, but nothing else. E.g. MessageYesNo cannot work on iOS now. Making modal boxes like that is not supported on iOS.
In this case you should use this unit and instantiate the user-interface classes yourself, and you need to organize your whole game using TUIState classes. See https://castle-engine.io/manual_2d_user_interface.php#section_ui_state about how to use TUIState. Like this:
type TMyGameState = class(TUIState) private DialogAskDeleteFile: TStateDialogYesNo; public function Press(const Event: TInputPressRelease): boolean; override; procedure Resume; override; end; function Press(const Event: TInputPressRelease): boolean; override; begin Result := inherited; if Result then Exit; if Event.IsKey(K_Enter) then begin DialogAskDeleteFile := TStateDialogYesNo.Create(Self); DialogAskDeleteFile.Caption := 'Are you sure you want to delete this file?'; TUIState.Push(DialogAskDeleteFile); end; end; procedure TStatePlay.Resume; begin inherited; if DialogAskDeleteFile <> nil then // returning from DialogAskDeleteFile begin if DialogAskDeleteFile.Answer then DeleteFile(...); FreeAndNil(DialogAskDeleteFile); end; end;
Classes, Interfaces, Objects and Records
Generated by PasDoc 0.15.0.