1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
24 g_base
, g_playermodel
, MAPDEF
, utils
29 MAINMENU_ITEMS_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
30 MAINMENU_UNACTIVEITEMS_COLOR
: TRGB
= (R
:192; G
:192; B
:192);
31 MAINMENU_HEADER_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
33 MAINMENU_MARKERDELAY
= 24;
35 MENU_ITEMSTEXT_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
36 MENU_UNACTIVEITEMS_COLOR
: TRGB
= (R
:128; G
:128; B
:128);
37 MENU_ITEMSCTRL_COLOR
: TRGB
= (R
:255; G
:0; B
:0);
40 MENU_MARKERDELAY
= 24;
43 MAPPREVIEW_HEIGHT
= 8;
45 KEYREAD_QUERY
= '<...>';
46 KEYREAD_CLEAR
= '???';
48 WINDOW_CLOSESOUND
= 'MENU_CLOSE';
49 MAINMENU_CLICKSOUND
= 'MENU_SELECT';
50 MAINMENU_CHANGESOUND
= 'MENU_CHANGE';
51 MENU_CLICKSOUND
= 'MENU_SELECT';
52 MENU_CHANGESOUND
= 'MENU_CHANGE';
53 SCROLL_ADDSOUND
= 'SCROLL_ADD';
54 SCROLL_SUBSOUND
= 'SCROLL_SUB';
60 MESSAGE_DIKEY
= WM_USER
+ 1;
72 TOnKeyDownEvent
= procedure(Key
: Byte);
73 TOnKeyDownEventEx
= procedure(win
: TGUIWindow
; Key
: Byte);
74 TOnCloseEvent
= procedure;
75 TOnShowEvent
= procedure;
76 TOnClickEvent
= procedure;
77 TOnChangeEvent
= procedure(Sender
: TGUIControl
);
78 TOnEnterEvent
= procedure(Sender
: TGUIControl
);
80 TGUIControl
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
87 FRightAlign
: Boolean; //HACK! this works only for "normal" menus, only for menu text labels, and generally sux. sorry.
88 FMaxWidth
: Integer; //HACK! used for right-aligning labels
91 procedure OnMessage(var Msg
: TMessage
); virtual;
92 procedure Update
; virtual;
93 function GetWidth(): Integer; virtual;
94 function GetHeight(): Integer; virtual;
95 function WantActivationKey (key
: LongInt): Boolean; virtual;
96 property X
: Integer read FX write FX
;
97 property Y
: Integer read FY write FY
;
98 property Enabled
: Boolean read FEnabled write FEnabled
;
99 property Name
: string read FName write FName
;
100 property UserData
: Pointer read FUserData write FUserData
;
101 property RightAlign
: Boolean read FRightAlign write FRightAlign
; // for menu
102 property CMaxWidth
: Integer read FMaxWidth
;
104 property Window
: TGUIWindow read FWindow
;
107 TGUIWindow
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
109 FActiveControl
: TGUIControl
;
111 FPrevWindow
: TGUIWindow
;
113 FBackTexture
: string;
114 FMainWindow
: Boolean;
115 FOnKeyDown
: TOnKeyDownEvent
;
116 FOnKeyDownEx
: TOnKeyDownEventEx
;
117 FOnCloseEvent
: TOnCloseEvent
;
118 FOnShowEvent
: TOnShowEvent
;
121 Childs
: array of TGUIControl
;
122 constructor Create(Name
: string);
123 destructor Destroy
; override;
124 function AddChild(Child
: TGUIControl
): TGUIControl
;
125 procedure OnMessage(var Msg
: TMessage
);
127 procedure SetActive(Control
: TGUIControl
);
128 function GetControl(Name
: string): TGUIControl
;
129 property OnKeyDown
: TOnKeyDownEvent read FOnKeyDown write FOnKeyDown
;
130 property OnKeyDownEx
: TOnKeyDownEventEx read FOnKeyDownEx write FOnKeyDownEx
;
131 property OnClose
: TOnCloseEvent read FOnCloseEvent write FOnCloseEvent
;
132 property OnShow
: TOnShowEvent read FOnShowEvent write FOnShowEvent
;
133 property Name
: string read FName
;
134 property DefControl
: string read FDefControl write FDefControl
;
135 property BackTexture
: string read FBackTexture write FBackTexture
;
136 property MainWindow
: Boolean read FMainWindow write FMainWindow
;
137 property UserData
: Pointer read FUserData write FUserData
;
139 property ActiveControl
: TGUIControl read FActiveControl
;
142 TGUITextButton
= class(TGUIControl
)
151 ProcEx
: procedure (sender
: TGUITextButton
);
152 constructor Create(aProc
: Pointer; BigFont
: Boolean; Text: string);
153 destructor Destroy(); override;
154 procedure OnMessage(var Msg
: TMessage
); override;
155 procedure Update(); override;
156 procedure Click(Silent
: Boolean = False);
157 property Caption
: string read FText write FText
;
158 property Color
: TRGB read FColor write FColor
;
159 property BigFont
: Boolean read FBigFont write FBigFont
;
160 property ShowWindow
: string read FShowWindow write FShowWindow
;
163 TGUILabel
= class(TGUIControl
)
169 FOnClickEvent
: TOnClickEvent
;
171 constructor Create(Text: string; BigFont
: Boolean);
172 procedure OnMessage(var Msg
: TMessage
); override;
173 property OnClick
: TOnClickEvent read FOnClickEvent write FOnClickEvent
;
174 property FixedLength
: Word read FFixedLen write FFixedLen
;
175 property Text: string read FText write FText
;
176 property Color
: TRGB read FColor write FColor
;
177 property BigFont
: Boolean read FBigFont write FBigFont
;
180 TGUIScroll
= class(TGUIControl
)
184 FOnChangeEvent
: TOnChangeEvent
;
185 procedure FSetValue(a
: Integer);
187 constructor Create();
188 procedure OnMessage(var Msg
: TMessage
); override;
189 procedure Update
; override;
190 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
191 property Max
: Word read FMax write FMax
;
192 property Value
: Integer read FValue write FSetValue
;
195 TGUIItemsList
= array of string;
197 TGUISwitch
= class(TGUIControl
)
200 FItems
: TGUIItemsList
;
203 FOnChangeEvent
: TOnChangeEvent
;
205 constructor Create(BigFont
: Boolean);
206 procedure OnMessage(var Msg
: TMessage
); override;
207 procedure AddItem(Item
: string);
208 procedure Update
; override;
209 function GetText
: string;
210 property ItemIndex
: Integer read FIndex write FIndex
;
211 property Color
: TRGB read FColor write FColor
;
212 property BigFont
: Boolean read FBigFont write FBigFont
;
213 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
214 property Items
: TGUIItemsList read FItems
;
217 TGUIEdit
= class(TGUIControl
)
225 FOnlyDigits
: Boolean;
226 FOnChangeEvent
: TOnChangeEvent
;
227 FOnEnterEvent
: TOnEnterEvent
;
229 procedure SetText(Text: string);
231 constructor Create(BigFont
: Boolean);
232 procedure OnMessage(var Msg
: TMessage
); override;
233 procedure Update
; override;
234 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
235 property OnEnter
: TOnEnterEvent read FOnEnterEvent write FOnEnterEvent
;
236 property Width
: Word read FWidth write FWidth
;
237 property MaxLength
: Word read FMaxLength write FMaxLength
;
238 property OnlyDigits
: Boolean read FOnlyDigits write FOnlyDigits
;
239 property Text: string read FText write SetText
;
240 property Color
: TRGB read FColor write FColor
;
241 property BigFont
: Boolean read FBigFont write FBigFont
;
242 property Invalid
: Boolean read FInvalid write FInvalid
;
244 property CaretPos
: Integer read FCaretPos
;
247 TGUIKeyRead
= class(TGUIControl
)
254 constructor Create(BigFont
: Boolean);
255 procedure OnMessage(var Msg
: TMessage
); override;
256 function WantActivationKey (key
: LongInt): Boolean; override;
257 property Key
: Word read FKey write FKey
;
258 property Color
: TRGB read FColor write FColor
;
259 property BigFont
: Boolean read FBigFont write FBigFont
;
261 property IsQuery
: Boolean read FIsQuery
;
265 TGUIKeyRead2
= class(TGUIControl
)
269 FKey0
, FKey1
: Word; // this should be an array. sorry.
272 FMaxKeyNameWdt
: Integer;
274 constructor Create(BigFont
: Boolean);
275 procedure OnMessage(var Msg
: TMessage
); override;
276 function WantActivationKey (key
: LongInt): Boolean; override;
277 property Key0
: Word read FKey0 write FKey0
;
278 property Key1
: Word read FKey1 write FKey1
;
279 property Color
: TRGB read FColor write FColor
;
280 property BigFont
: Boolean read FBigFont write FBigFont
;
282 property IsQuery
: Boolean read FIsQuery
;
283 property MaxKeyNameWdt
: Integer read FMaxKeyNameWdt
;
284 property KeyIdx
: Integer read FKeyIdx
;
287 TGUIModelView
= class(TGUIControl
)
289 FModel
: TPlayerModel
;
293 destructor Destroy
; override;
294 procedure OnMessage(var Msg
: TMessage
); override;
295 procedure SetModel(ModelName
: string);
296 procedure SetColor(Red
, Green
, Blue
: Byte);
297 procedure NextAnim();
298 procedure NextWeapon();
299 procedure Update
; override;
300 property Model
: TPlayerModel read FModel
;
303 TPreviewPanel
= record
304 X1
, Y1
, X2
, Y2
: Integer;
308 TPreviewPanelArray
= array of TPreviewPanel
;
310 TGUIMapPreview
= class(TGUIControl
)
312 FMapData
: TPreviewPanelArray
;
316 constructor Create();
317 destructor Destroy(); override;
318 procedure OnMessage(var Msg
: TMessage
); override;
319 procedure SetMap(Res
: string);
320 procedure ClearMap();
321 procedure Update(); override;
322 function GetScaleStr
: String;
324 property MapData
: TPreviewPanelArray read FMapData
;
325 property MapSize
: TDFPoint read FMapSize
;
326 property Scale
: Single read FScale
;
329 TGUIImage
= class(TGUIControl
)
334 constructor Create();
335 destructor Destroy(); override;
336 procedure OnMessage(var Msg
: TMessage
); override;
337 procedure SetImage(Res
: string);
338 procedure ClearImage();
339 procedure Update(); override;
341 property DefaultRes
: string read FDefaultRes write FDefaultRes
;
342 property ImageRes
: string read FImageRes
;
345 TGUIListBox
= class(TGUIControl
)
349 FUnActiveColor
: TRGB
;
357 FDrawScroll
: Boolean;
358 FOnChangeEvent
: TOnChangeEvent
;
360 procedure FSetItems(Items
: SSArray
);
361 procedure FSetIndex(aIndex
: Integer);
364 constructor Create(BigFont
: Boolean; Width
, Height
: Word);
365 procedure OnMessage(var Msg
: TMessage
); override;
366 procedure AddItem(Item
: String);
367 function ItemExists (item
: String): Boolean;
368 procedure SelectItem(Item
: String);
370 function SelectedItem(): String;
372 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
373 property Sort
: Boolean read FSort write FSort
;
374 property ItemIndex
: Integer read FIndex write FSetIndex
;
375 property Items
: SSArray read FItems write FSetItems
;
376 property DrawBack
: Boolean read FDrawBack write FDrawBack
;
377 property DrawScrollBar
: Boolean read FDrawScroll write FDrawScroll
;
378 property ActiveColor
: TRGB read FActiveColor write FActiveColor
;
379 property UnActiveColor
: TRGB read FUnActiveColor write FUnActiveColor
;
380 property BigFont
: Boolean read FBigFont write FBigFont
;
382 property Width
: Word read FWidth
;
383 property Height
: Word read FHeight
;
384 property StartLine
: Integer read FStartLine
;
387 TGUIFileListBox
= class(TGUIListBox
)
392 FBaseList
: SSArray
; // highter index have highter priority
397 procedure OnMessage (var Msg
: TMessage
); override;
398 procedure SetBase (dirs
: SSArray
; path
: String = '');
399 function SelectedItem(): String;
400 procedure UpdateFileList
;
402 property Dirs
: Boolean read FDirs write FDirs
;
403 property FileMask
: String read FFileMask write FFileMask
;
406 TGUIMemo
= class(TGUIControl
)
415 FDrawScroll
: Boolean;
417 constructor Create(BigFont
: Boolean; Width
, Height
: Word);
418 procedure OnMessage(var Msg
: TMessage
); override;
420 procedure SetText(Text: string);
421 property DrawBack
: Boolean read FDrawBack write FDrawBack
;
422 property DrawScrollBar
: Boolean read FDrawScroll write FDrawScroll
;
423 property Color
: TRGB read FColor write FColor
;
424 property BigFont
: Boolean read FBigFont write FBigFont
;
426 property Width
: Word read FWidth
;
427 property Height
: Word read FHeight
;
428 property StartLine
: Integer read FStartLine
;
429 property Lines
: SSArray read FLines
;
432 TGUITextButtonList
= array of TGUITextButton
;
434 TGUIMainMenu
= class(TGUIControl
)
436 FButtons
: TGUITextButtonList
;
440 FCounter
: Byte; // !!! update it within render
442 constructor Create(BigFont
: Boolean; Header
: string);
443 destructor Destroy
; override;
444 procedure OnMessage(var Msg
: TMessage
); override;
445 function AddButton(fProc
: Pointer; Caption
: string; ShowWindow
: string = ''): TGUITextButton
;
446 function GetButton(aName
: string): TGUITextButton
;
447 procedure EnableButton(aName
: string; e
: Boolean);
448 procedure AddSpace();
449 procedure Update
; override;
451 property Header
: TGUILabel read FHeader
;
452 property Buttons
: TGUITextButtonList read FButtons
;
453 property Index
: Integer read FIndex
;
454 property Counter
: Byte read FCounter
;
457 TControlType
= class of TGUIControl
;
459 PMenuItem
= ^TMenuItem
;
462 ControlType
: TControlType
;
463 Control
: TGUIControl
;
465 TMenuItemList
= array of TMenuItem
;
467 TGUIMenu
= class(TGUIControl
)
469 FItems
: TMenuItemList
;
477 function NewItem(): Integer;
479 constructor Create(HeaderBigFont
, ItemsBigFont
: Boolean; Header
: string);
480 destructor Destroy
; override;
481 procedure OnMessage(var Msg
: TMessage
); override;
482 procedure AddSpace();
483 procedure AddLine(fText
: string);
484 procedure AddText(fText
: string; MaxWidth
: Word);
485 function AddLabel(fText
: string): TGUILabel
;
486 function AddButton(Proc
: Pointer; fText
: string; _ShowWindow
: string = ''): TGUITextButton
;
487 function AddScroll(fText
: string): TGUIScroll
;
488 function AddSwitch(fText
: string): TGUISwitch
;
489 function AddEdit(fText
: string): TGUIEdit
;
490 function AddKeyRead(fText
: string): TGUIKeyRead
;
491 function AddKeyRead2(fText
: string): TGUIKeyRead2
;
492 function AddList(fText
: string; Width
, Height
: Word): TGUIListBox
;
493 function AddFileList(fText
: string; Width
, Height
: Word): TGUIFileListBox
;
494 function AddMemo(fText
: string; Width
, Height
: Word): TGUIMemo
;
496 function GetControl(aName
: string): TGUIControl
;
497 function GetControlsText(aName
: string): TGUILabel
;
498 procedure Update
; override;
499 procedure UpdateIndex();
500 property Align
: Boolean read FAlign write FAlign
;
501 property Left
: Integer read FLeft write FLeft
;
502 property YesNo
: Boolean read FYesNo write FYesNo
;
504 property Header
: TGUILabel read FHeader
;
505 property Counter
: Byte read FCounter
;
506 property Index
: Integer read FIndex
;
507 property Items
: TMenuItemList read FItems
;
508 property BigFont
: Boolean read FBigFont
;
512 g_GUIWindows
: array of TGUIWindow
;
513 g_ActiveWindow
: TGUIWindow
= nil;
514 g_GUIGrabInput
: Boolean = False;
516 function g_GUI_AddWindow(Window
: TGUIWindow
): TGUIWindow
;
517 function g_GUI_GetWindow(Name
: string): TGUIWindow
;
518 procedure g_GUI_ShowWindow(Name
: string);
519 procedure g_GUI_HideWindow(PlaySound
: Boolean = True);
520 function g_GUI_Destroy(): Boolean;
521 procedure g_GUI_SaveMenuPos();
522 procedure g_GUI_LoadMenuPos();
528 {$IFDEF ENABLE_TOUCH}
531 {$IFDEF ENABLE_RENDER}
535 g_sound
, SysUtils
, e_res
,
536 g_game
, Math
, StrUtils
, g_player
, g_options
, g_console
,
537 g_map
, g_weapons
, xdynrec
, wadreader
;
541 Saved_Windows
: SSArray
;
543 function GetLines (text: string; BigFont
: Boolean; MaxWidth
: Word): SSArray
;
547 i
, len
, lastsep
: Integer;
549 function PrepareStep (): Boolean; inline;
551 // Skip leading spaces.
552 while PChar(text)[k
-1] = ' ' do k
+= 1;
557 function GetLine (j
: Integer; Strip
: Boolean): String; inline;
559 // Exclude trailing spaces from the line.
561 while text[j
] = ' ' do j
-= 1;
563 Result
:= Copy(text, k
, j
-k
+1);
566 function LineWidth (): Integer; inline;
567 {$IFDEF ENABLE_RENDER}
571 {$IFDEF ENABLE_RENDER}
572 r_Render_GetStringSize(BigFont
, GetLine(i
, False), w
, h
);
582 //e_LogWritefln('GetLines @%s len=%s [%s]', [MaxWidth, len, text]);
584 while PrepareStep() do
586 // Get longest possible sequence (this is not constant because fonts are not monospaced).
589 if text[i
] in [' ', '.', ',', ':', ';']
592 until (i
> len
) or (LineWidth() > MaxWidth
);
594 // Do not include part of a word if possible.
595 if (lastsep
-k
> 3) and (i
<= len
) and (text[i
] <> ' ')
596 then i
:= lastsep
+ 1;
599 SetLength(Result
, lines
+ 1);
600 Result
[lines
] := GetLine(i
-1, True);
601 //e_LogWritefln(' -> (%s:%s::%s) [%s]', [k, i, LineWidth(), Result[lines]]);
608 procedure Sort(var a
: SSArray
);
613 if a
= nil then Exit
;
615 for i
:= High(a
) downto Low(a
) do
616 for j
:= Low(a
) to High(a
)-1 do
617 if LowerCase(a
[j
]) > LowerCase(a
[j
+1]) then
625 function g_GUI_Destroy(): Boolean;
629 Result
:= (Length(g_GUIWindows
) > 0);
631 for i
:= 0 to High(g_GUIWindows
) do
632 g_GUIWindows
[i
].Free();
635 g_ActiveWindow
:= nil;
638 function g_GUI_AddWindow(Window
: TGUIWindow
): TGUIWindow
;
640 SetLength(g_GUIWindows
, Length(g_GUIWindows
)+1);
641 g_GUIWindows
[High(g_GUIWindows
)] := Window
;
646 function g_GUI_GetWindow(Name
: string): TGUIWindow
;
652 if g_GUIWindows
<> nil then
653 for i
:= 0 to High(g_GUIWindows
) do
654 if g_GUIWindows
[i
].FName
= Name
then
656 Result
:= g_GUIWindows
[i
];
660 Assert(Result
<> nil, 'GUI_Window "'+Name
+'" not found');
663 procedure g_GUI_ShowWindow(Name
: string);
667 if g_GUIWindows
= nil then
670 for i
:= 0 to High(g_GUIWindows
) do
671 if g_GUIWindows
[i
].FName
= Name
then
673 g_GUIWindows
[i
].FPrevWindow
:= g_ActiveWindow
;
674 g_ActiveWindow
:= g_GUIWindows
[i
];
676 if g_ActiveWindow
.MainWindow
then
677 g_ActiveWindow
.FPrevWindow
:= nil;
679 if g_ActiveWindow
.FDefControl
<> '' then
680 g_ActiveWindow
.SetActive(g_ActiveWindow
.GetControl(g_ActiveWindow
.FDefControl
))
682 g_ActiveWindow
.SetActive(nil);
684 if @g_ActiveWindow
.FOnShowEvent
<> nil then
685 g_ActiveWindow
.FOnShowEvent();
691 procedure g_GUI_HideWindow(PlaySound
: Boolean = True);
693 if g_ActiveWindow
<> nil then
695 if @g_ActiveWindow
.OnClose
<> nil then
696 g_ActiveWindow
.OnClose();
697 g_ActiveWindow
:= g_ActiveWindow
.FPrevWindow
;
699 g_Sound_PlayEx(WINDOW_CLOSESOUND
);
703 procedure g_GUI_SaveMenuPos();
708 SetLength(Saved_Windows
, 0);
709 win
:= g_ActiveWindow
;
713 len
:= Length(Saved_Windows
);
714 SetLength(Saved_Windows
, len
+ 1);
716 Saved_Windows
[len
] := win
.Name
;
718 if win
.MainWindow
then
721 win
:= win
.FPrevWindow
;
725 procedure g_GUI_LoadMenuPos();
727 i
, j
, k
, len
: Integer;
730 g_ActiveWindow
:= nil;
731 len
:= Length(Saved_Windows
);
736 // Îêíî ñ ãëàâíûì ìåíþ:
737 g_GUI_ShowWindow(Saved_Windows
[len
-1]);
739 // Íå ïåðåêëþ÷èëîñü (èëè íåêóäà äàëüøå):
740 if (len
= 1) or (g_ActiveWindow
= nil) then
743 // Èùåì êíîïêè â îñòàëüíûõ îêíàõ:
744 for k
:= len
-1 downto 1 do
748 for i
:= 0 to Length(g_ActiveWindow
.Childs
)-1 do
750 if g_ActiveWindow
.Childs
[i
] is TGUIMainMenu
then
751 begin // GUI_MainMenu
752 with TGUIMainMenu(g_ActiveWindow
.Childs
[i
]) do
753 for j
:= 0 to Length(FButtons
)-1 do
754 if FButtons
[j
].ShowWindow
= Saved_Windows
[k
-1] then
756 FButtons
[j
].Click(True);
762 if g_ActiveWindow
.Childs
[i
] is TGUIMenu
then
763 with TGUIMenu(g_ActiveWindow
.Childs
[i
]) do
764 for j
:= 0 to Length(FItems
)-1 do
765 if FItems
[j
].ControlType
= TGUITextButton
then
766 if TGUITextButton(FItems
[j
].Control
).ShowWindow
= Saved_Windows
[k
-1] then
768 TGUITextButton(FItems
[j
].Control
).Click(True);
779 (g_ActiveWindow
.Name
= Saved_Windows
[k
]) then
786 constructor TGUIWindow
.Create(Name
: string);
789 FActiveControl
:= nil;
793 FOnCloseEvent
:= nil;
797 destructor TGUIWindow
.Destroy
;
804 for i
:= 0 to High(Childs
) do
808 function TGUIWindow
.AddChild(Child
: TGUIControl
): TGUIControl
;
810 Child
.FWindow
:= Self
;
812 SetLength(Childs
, Length(Childs
) + 1);
813 Childs
[High(Childs
)] := Child
;
818 procedure TGUIWindow
.Update
;
822 for i
:= 0 to High(Childs
) do
823 if Childs
[i
] <> nil then Childs
[i
].Update
;
826 procedure TGUIWindow
.OnMessage(var Msg
: TMessage
);
828 if FActiveControl
<> nil then FActiveControl
.OnMessage(Msg
);
829 if @FOnKeyDown
<> nil then FOnKeyDown(Msg
.wParam
);
830 if @FOnKeyDownEx
<> nil then FOnKeyDownEx(self
, Msg
.wParam
);
832 if Msg
.Msg
= WM_KEYDOWN
then
844 procedure TGUIWindow
.SetActive(Control
: TGUIControl
);
846 FActiveControl
:= Control
;
849 function TGUIWindow
.GetControl(Name
: String): TGUIControl
;
855 if Childs
<> nil then
856 for i
:= 0 to High(Childs
) do
857 if Childs
[i
] <> nil then
858 if LowerCase(Childs
[i
].FName
) = LowerCase(Name
) then
864 Assert(Result
<> nil, 'Window Control "'+Name
+'" not Found!');
869 constructor TGUIControl
.Create();
875 FRightAlign
:= false;
879 procedure TGUIControl
.OnMessage(var Msg
: TMessage
);
885 procedure TGUIControl
.Update();
889 function TGUIControl
.WantActivationKey (key
: LongInt): Boolean;
894 function TGUIControl
.GetWidth (): Integer;
895 {$IFDEF ENABLE_RENDER}
899 {$IFDEF ENABLE_RENDER}
900 r_Render_GetControlSize(Self
, Result
, h
);
906 function TGUIControl
.GetHeight (): Integer;
907 {$IFDEF ENABLE_RENDER}
911 {$IFDEF ENABLE_RENDER}
912 r_Render_GetControlSize(Self
, w
, Result
);
920 procedure TGUITextButton
.Click(Silent
: Boolean = False);
922 if (FSound
<> '') and (not Silent
) then g_Sound_PlayEx(FSound
);
924 if @Proc
<> nil then Proc();
925 if @ProcEx
<> nil then ProcEx(self
);
927 if FShowWindow
<> '' then g_GUI_ShowWindow(FShowWindow
);
930 constructor TGUITextButton
.Create(aProc
: Pointer; BigFont
: Boolean; Text: string);
941 destructor TGUITextButton
.Destroy
;
947 procedure TGUITextButton
.OnMessage(var Msg
: TMessage
);
949 if not FEnabled
then Exit
;
956 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
: Click();
961 procedure TGUITextButton
.Update
;
968 function TGUIMainMenu
.AddButton(fProc
: Pointer; Caption
: string; ShowWindow
: string = ''): TGUITextButton
;
970 {$IFDEF ENABLE_RENDER}
979 SetLength(FButtons
, Length(FButtons
)+1);
980 FButtons
[High(FButtons
)] := TGUITextButton
.Create(fProc
, FBigFont
, Caption
);
981 FButtons
[High(FButtons
)].ShowWindow
:= ShowWindow
;
982 with FButtons
[High(FButtons
)] do
984 if (fProc
<> nil) or (ShowWindow
<> '') then FColor
:= MAINMENU_ITEMS_COLOR
985 else FColor
:= MAINMENU_UNACTIVEITEMS_COLOR
;
986 FSound
:= MAINMENU_CLICKSOUND
;
989 _x
:= gScreenWidth
div 2;
991 for a
:= 0 to High(FButtons
) do
992 if FButtons
[a
] <> nil then
993 _x
:= Min(_x
, (gScreenWidth
div 2)-(FButtons
[a
].GetWidth
div 2));
997 {$IFDEF ENABLE_RENDER}
998 if FHeader
= nil then
999 r_Render_GetLogoSize(lw
, lh
);
1001 hh
:= FButtons
[High(FButtons
)].GetHeight
;
1003 if FHeader
= nil then h
:= lh
+ hh
* (1 + Length(FButtons
)) + MAINMENU_SPACE
* (Length(FButtons
) - 1)
1004 else h
:= hh
* (2 + Length(FButtons
)) + MAINMENU_SPACE
* (Length(FButtons
) - 1);
1005 h
:= (gScreenHeight
div 2) - (h
div 2);
1007 if FHeader
<> nil then with FHeader
do
1013 if FHeader
= nil then Inc(h
, lh
)
1016 for a
:= 0 to High(FButtons
) do
1018 if FButtons
[a
] <> nil then
1025 Inc(h
, hh
+MAINMENU_SPACE
);
1028 Result
:= FButtons
[High(FButtons
)];
1031 procedure TGUIMainMenu
.AddSpace
;
1033 SetLength(FButtons
, Length(FButtons
)+1);
1034 FButtons
[High(FButtons
)] := nil;
1037 constructor TGUIMainMenu
.Create(BigFont
: Boolean; Header
: string);
1042 FBigFont
:= BigFont
;
1043 FCounter
:= MAINMENU_MARKERDELAY
;
1045 if Header
<> '' then
1047 FHeader
:= TGUILabel
.Create(Header
, BigFont
);
1050 FColor
:= MAINMENU_HEADER_COLOR
;
1051 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1052 FY
:= (gScreenHeight
div 2)-(GetHeight
div 2);
1057 destructor TGUIMainMenu
.Destroy
;
1061 if FButtons
<> nil then
1062 for a
:= 0 to High(FButtons
) do
1070 procedure TGUIMainMenu
.EnableButton(aName
: string; e
: Boolean);
1074 if FButtons
= nil then Exit
;
1076 for a
:= 0 to High(FButtons
) do
1077 if (FButtons
[a
] <> nil) and (FButtons
[a
].Name
= aName
) then
1079 if e
then FButtons
[a
].FColor
:= MAINMENU_ITEMS_COLOR
1080 else FButtons
[a
].FColor
:= MAINMENU_UNACTIVEITEMS_COLOR
;
1081 FButtons
[a
].Enabled
:= e
;
1086 function TGUIMainMenu
.GetButton(aName
: string): TGUITextButton
;
1092 if FButtons
= nil then Exit
;
1094 for a
:= 0 to High(FButtons
) do
1095 if (FButtons
[a
] <> nil) and (FButtons
[a
].Name
= aName
) then
1097 Result
:= FButtons
[a
];
1102 procedure TGUIMainMenu
.OnMessage(var Msg
: TMessage
);
1107 if not FEnabled
then Exit
;
1111 if FButtons
= nil then Exit
;
1114 for a
:= 0 to High(FButtons
) do
1115 if FButtons
[a
] <> nil then
1121 if not ok
then Exit
;
1126 IK_UP
, IK_KPUP
, VK_UP
, JOY0_UP
, JOY1_UP
, JOY2_UP
, JOY3_UP
:
1130 if FIndex
< 0 then FIndex
:= High(FButtons
);
1131 until FButtons
[FIndex
] <> nil;
1133 g_Sound_PlayEx(MENU_CHANGESOUND
);
1135 IK_DOWN
, IK_KPDOWN
, VK_DOWN
, JOY0_DOWN
, JOY1_DOWN
, JOY2_DOWN
, JOY3_DOWN
:
1139 if FIndex
> High(FButtons
) then FIndex
:= 0;
1140 until FButtons
[FIndex
] <> nil;
1142 g_Sound_PlayEx(MENU_CHANGESOUND
);
1144 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
: if (FIndex
<> -1) and FButtons
[FIndex
].FEnabled
then FButtons
[FIndex
].Click
;
1149 procedure TGUIMainMenu
.Update
;
1152 FCounter
:= (FCounter
+ 1) MOD (2 * MAINMENU_MARKERDELAY
)
1157 constructor TGUILabel
.Create(Text: string; BigFont
: Boolean);
1161 FBigFont
:= BigFont
;
1164 FOnClickEvent
:= nil;
1167 procedure TGUILabel
.OnMessage(var Msg
: TMessage
);
1169 if not FEnabled
then Exit
;
1176 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
: if @FOnClickEvent
<> nil then FOnClickEvent();
1183 function TGUIMenu
.AddButton(Proc
: Pointer; fText
: string; _ShowWindow
: string = ''): TGUITextButton
;
1190 Control
:= TGUITextButton
.Create(Proc
, FBigFont
, fText
);
1191 with Control
as TGUITextButton
do
1193 ShowWindow
:= _ShowWindow
;
1194 FColor
:= MENU_ITEMSCTRL_COLOR
;
1198 ControlType
:= TGUITextButton
;
1200 Result
:= (Control
as TGUITextButton
);
1203 if FIndex
= -1 then FIndex
:= i
;
1208 procedure TGUIMenu
.AddLine(fText
: string);
1215 Text := TGUILabel
.Create(fText
, FBigFont
);
1218 FColor
:= MENU_ITEMSTEXT_COLOR
;
1227 procedure TGUIMenu
.AddText(fText
: string; MaxWidth
: Word);
1232 l
:= GetLines(fText
, FBigFont
, MaxWidth
);
1234 if l
= nil then Exit
;
1236 for a
:= 0 to High(l
) do
1241 Text := TGUILabel
.Create(l
[a
], FBigFont
);
1244 with Text do begin FColor
:= _RGB(255, 0, 0); end;
1248 with Text do begin FColor
:= MENU_ITEMSTEXT_COLOR
; end;
1258 procedure TGUIMenu
.AddSpace
;
1272 constructor TGUIMenu
.Create(HeaderBigFont
, ItemsBigFont
: Boolean; Header
: string);
1278 FBigFont
:= ItemsBigFont
;
1279 FCounter
:= MENU_MARKERDELAY
;
1283 FHeader
:= TGUILabel
.Create(Header
, HeaderBigFont
);
1286 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1288 FColor
:= MAINMENU_HEADER_COLOR
;
1292 destructor TGUIMenu
.Destroy
;
1296 if FItems
<> nil then
1297 for a
:= 0 to High(FItems
) do
1311 function TGUIMenu
.GetControl(aName
: String): TGUIControl
;
1317 if FItems
<> nil then
1318 for a
:= 0 to High(FItems
) do
1319 if FItems
[a
].Control
<> nil then
1320 if LowerCase(FItems
[a
].Control
.Name
) = LowerCase(aName
) then
1322 Result
:= FItems
[a
].Control
;
1326 Assert(Result
<> nil, 'GUI control "'+aName
+'" not found!');
1329 function TGUIMenu
.GetControlsText(aName
: String): TGUILabel
;
1335 if FItems
<> nil then
1336 for a
:= 0 to High(FItems
) do
1337 if FItems
[a
].Control
<> nil then
1338 if LowerCase(FItems
[a
].Control
.Name
) = LowerCase(aName
) then
1340 Result
:= FItems
[a
].Text;
1344 Assert(Result
<> nil, 'GUI control''s text "'+aName
+'" not found!');
1347 function TGUIMenu
.NewItem
: Integer;
1349 SetLength(FItems
, Length(FItems
)+1);
1350 Result
:= High(FItems
);
1353 procedure TGUIMenu
.OnMessage(var Msg
: TMessage
);
1358 if not FEnabled
then Exit
;
1362 if FItems
= nil then Exit
;
1365 for a
:= 0 to High(FItems
) do
1366 if FItems
[a
].Control
<> nil then
1372 if not ok
then Exit
;
1374 if (Msg
.Msg
= WM_KEYDOWN
) and (FIndex
<> -1) and (FItems
[FIndex
].Control
<> nil) and
1375 (FItems
[FIndex
].Control
.WantActivationKey(Msg
.wParam
)) then
1377 FItems
[FIndex
].Control
.OnMessage(Msg
);
1378 g_Sound_PlayEx(MENU_CLICKSOUND
);
1386 IK_UP
, IK_KPUP
, VK_UP
,JOY0_UP
, JOY1_UP
, JOY2_UP
, JOY3_UP
:
1391 if c
> Length(FItems
) then
1398 if FIndex
< 0 then FIndex
:= High(FItems
);
1399 until (FItems
[FIndex
].Control
<> nil) and
1400 (FItems
[FIndex
].Control
.Enabled
);
1404 g_Sound_PlayEx(MENU_CHANGESOUND
);
1407 IK_DOWN
, IK_KPDOWN
, VK_DOWN
, JOY0_DOWN
, JOY1_DOWN
, JOY2_DOWN
, JOY3_DOWN
:
1412 if c
> Length(FItems
) then
1419 if FIndex
> High(FItems
) then FIndex
:= 0;
1420 until (FItems
[FIndex
].Control
<> nil) and
1421 (FItems
[FIndex
].Control
.Enabled
);
1425 g_Sound_PlayEx(MENU_CHANGESOUND
);
1428 IK_LEFT
, IK_RIGHT
, IK_KPLEFT
, IK_KPRIGHT
, VK_LEFT
, VK_RIGHT
,
1429 JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
,
1430 JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
1432 if FIndex
<> -1 then
1433 if FItems
[FIndex
].Control
<> nil then
1434 FItems
[FIndex
].Control
.OnMessage(Msg
);
1436 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
1438 if FIndex
<> -1 then
1440 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1442 g_Sound_PlayEx(MENU_CLICKSOUND
);
1446 if FYesNo
and (length(FItems
) > 1) then
1448 Msg
.wParam
:= IK_RETURN
; // to register keypress
1449 FIndex
:= High(FItems
)-1;
1450 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1453 if FYesNo
and (length(FItems
) > 1) then
1455 Msg
.wParam
:= IK_RETURN
; // to register keypress
1456 FIndex
:= High(FItems
);
1457 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1464 procedure TGUIMenu
.ReAlign();
1466 {$IFDEF ENABLE_RENDER}
1469 a
, tx
, cx
, w
, h
: Integer;
1470 cww
: array of Integer; // cached widths
1473 if FItems
= nil then Exit
;
1475 SetLength(cww
, length(FItems
));
1477 for a
:= 0 to High(FItems
) do
1479 if FItems
[a
].Text <> nil then
1481 cww
[a
] := FItems
[a
].Text.GetWidth
;
1482 if maxcww
< cww
[a
] then maxcww
:= cww
[a
];
1493 for a
:= 0 to High(FItems
) do
1496 if FItems
[a
].Text <> nil then w
:= FItems
[a
].Text.GetWidth
;
1497 if FItems
[a
].Control
<> nil then
1500 if FItems
[a
].ControlType
= TGUILabel
then w
:= w
+(FItems
[a
].Control
as TGUILabel
).GetWidth
1501 else if FItems
[a
].ControlType
= TGUITextButton
then w
:= w
+(FItems
[a
].Control
as TGUITextButton
).GetWidth
1502 else if FItems
[a
].ControlType
= TGUIScroll
then w
:= w
+(FItems
[a
].Control
as TGUIScroll
).GetWidth
1503 else if FItems
[a
].ControlType
= TGUISwitch
then w
:= w
+(FItems
[a
].Control
as TGUISwitch
).GetWidth
1504 else if FItems
[a
].ControlType
= TGUIEdit
then w
:= w
+(FItems
[a
].Control
as TGUIEdit
).GetWidth
1505 else if FItems
[a
].ControlType
= TGUIKeyRead
then w
:= w
+(FItems
[a
].Control
as TGUIKeyRead
).GetWidth
1506 else if FItems
[a
].ControlType
= TGUIKeyRead2
then w
:= w
+(FItems
[a
].Control
as TGUIKeyRead2
).GetWidth
1507 else if FItems
[a
].ControlType
= TGUIListBox
then w
:= w
+(FItems
[a
].Control
as TGUIListBox
).GetWidth
1508 else if FItems
[a
].ControlType
= TGUIFileListBox
then w
:= w
+(FItems
[a
].Control
as TGUIFileListBox
).GetWidth
1509 else if FItems
[a
].ControlType
= TGUIMemo
then w
:= w
+(FItems
[a
].Control
as TGUIMemo
).GetWidth
;
1511 tx
:= Min(tx
, (gScreenWidth
div 2)-(w
div 2));
1516 for a
:= 0 to High(FItems
) do
1520 if (Text <> nil) and (Control
= nil) then Continue
;
1522 if Text <> nil then w
:= tx
+Text.GetWidth
;
1523 if w
> cx
then cx
:= w
;
1527 cx
:= cx
+MENU_HSPACE
;
1529 h
:= FHeader
.GetHeight
*2+MENU_VSPACE
*(Length(FItems
)-1);
1531 for a
:= 0 to High(FItems
) do
1535 if (ControlType
= TGUIListBox
) or (ControlType
= TGUIFileListBox
) then
1536 h
:= h
+(FItems
[a
].Control
as TGUIListBox
).GetHeight()
1539 {$IFDEF ENABLE_RENDER}
1540 r_Render_GetMaxFontSize(FBigFont
, fw
, fh
);
1547 h
:= (gScreenHeight
div 2)-(h
div 2);
1551 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1554 Inc(h
, GetHeight
*2);
1557 for a
:= 0 to High(FItems
) do
1569 if Text.RightAlign
and (length(cww
) > a
) then
1571 //Text.FX := Text.FX+maxcww;
1572 Text.FMaxWidth
:= maxcww
;
1576 if Control
<> nil then
1593 if (ControlType
= TGUIListBox
) or (ControlType
= TGUIFileListBox
) then Inc(h
, (Control
as TGUIListBox
).GetHeight
+MENU_VSPACE
)
1594 else if ControlType
= TGUIMemo
then Inc(h
, (Control
as TGUIMemo
).GetHeight
+MENU_VSPACE
)
1597 {$IFDEF ENABLE_RENDER}
1598 r_Render_GetMaxFontSize(FBigFont
, fw
, fh
);
1599 h
:= h
+ fh
+ MENU_VSPACE
;
1601 h
:= h
+ MENU_VSPACE
;
1607 // another ugly hack
1608 if FYesNo
and (length(FItems
) > 1) then
1611 for a
:= High(FItems
)-1 to High(FItems
) do
1613 if (FItems
[a
].Control
<> nil) and (FItems
[a
].ControlType
= TGUITextButton
) then
1615 cx
:= (FItems
[a
].Control
as TGUITextButton
).GetWidth
;
1616 if cx
> w
then w
:= cx
;
1621 for a
:= High(FItems
)-1 to High(FItems
) do
1623 if (FItems
[a
].Control
<> nil) and (FItems
[a
].ControlType
= TGUITextButton
) then
1625 FItems
[a
].Control
.FX
:= (gScreenWidth
-w
) div 2;
1632 function TGUIMenu
.AddScroll(fText
: string): TGUIScroll
;
1639 Control
:= TGUIScroll
.Create();
1641 Text := TGUILabel
.Create(fText
, FBigFont
);
1644 FColor
:= MENU_ITEMSTEXT_COLOR
;
1647 ControlType
:= TGUIScroll
;
1649 Result
:= (Control
as TGUIScroll
);
1652 if FIndex
= -1 then FIndex
:= i
;
1657 function TGUIMenu
.AddSwitch(fText
: string): TGUISwitch
;
1664 Control
:= TGUISwitch
.Create(FBigFont
);
1665 (Control
as TGUISwitch
).FColor
:= MENU_ITEMSCTRL_COLOR
;
1667 Text := TGUILabel
.Create(fText
, FBigFont
);
1670 FColor
:= MENU_ITEMSTEXT_COLOR
;
1673 ControlType
:= TGUISwitch
;
1675 Result
:= (Control
as TGUISwitch
);
1678 if FIndex
= -1 then FIndex
:= i
;
1683 function TGUIMenu
.AddEdit(fText
: string): TGUIEdit
;
1690 Control
:= TGUIEdit
.Create(FBigFont
);
1691 with Control
as TGUIEdit
do
1693 FWindow
:= Self
.FWindow
;
1694 FColor
:= MENU_ITEMSCTRL_COLOR
;
1697 if fText
= '' then Text := nil else
1699 Text := TGUILabel
.Create(fText
, FBigFont
);
1700 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1703 ControlType
:= TGUIEdit
;
1705 Result
:= (Control
as TGUIEdit
);
1708 if FIndex
= -1 then FIndex
:= i
;
1713 procedure TGUIMenu
.Update
;
1719 if FCounter
= 0 then FCounter
:= MENU_MARKERDELAY
else Dec(FCounter
);
1721 if FItems
<> nil then
1722 for a
:= 0 to High(FItems
) do
1723 if FItems
[a
].Control
<> nil then
1724 (FItems
[a
].Control
as FItems
[a
].ControlType
).Update
;
1727 function TGUIMenu
.AddKeyRead(fText
: string): TGUIKeyRead
;
1734 Control
:= TGUIKeyRead
.Create(FBigFont
);
1735 with Control
as TGUIKeyRead
do
1737 FWindow
:= Self
.FWindow
;
1738 FColor
:= MENU_ITEMSCTRL_COLOR
;
1741 Text := TGUILabel
.Create(fText
, FBigFont
);
1744 FColor
:= MENU_ITEMSTEXT_COLOR
;
1747 ControlType
:= TGUIKeyRead
;
1749 Result
:= (Control
as TGUIKeyRead
);
1752 if FIndex
= -1 then FIndex
:= i
;
1757 function TGUIMenu
.AddKeyRead2(fText
: string): TGUIKeyRead2
;
1764 Control
:= TGUIKeyRead2
.Create(FBigFont
);
1765 with Control
as TGUIKeyRead2
do
1767 FWindow
:= Self
.FWindow
;
1768 FColor
:= MENU_ITEMSCTRL_COLOR
;
1771 Text := TGUILabel
.Create(fText
, FBigFont
);
1774 FColor
:= MENU_ITEMSCTRL_COLOR
; //MENU_ITEMSTEXT_COLOR;
1778 ControlType
:= TGUIKeyRead2
;
1780 Result
:= (Control
as TGUIKeyRead2
);
1783 if FIndex
= -1 then FIndex
:= i
;
1788 function TGUIMenu
.AddList(fText
: string; Width
, Height
: Word): TGUIListBox
;
1795 Control
:= TGUIListBox
.Create(FBigFont
, Width
, Height
);
1796 with Control
as TGUIListBox
do
1798 FWindow
:= Self
.FWindow
;
1799 FActiveColor
:= MENU_ITEMSCTRL_COLOR
;
1800 FUnActiveColor
:= MENU_ITEMSTEXT_COLOR
;
1803 Text := TGUILabel
.Create(fText
, FBigFont
);
1806 FColor
:= MENU_ITEMSTEXT_COLOR
;
1809 ControlType
:= TGUIListBox
;
1811 Result
:= (Control
as TGUIListBox
);
1814 if FIndex
= -1 then FIndex
:= i
;
1819 function TGUIMenu
.AddFileList(fText
: string; Width
, Height
: Word): TGUIFileListBox
;
1826 Control
:= TGUIFileListBox
.Create(FBigFont
, Width
, Height
);
1827 with Control
as TGUIFileListBox
do
1829 FWindow
:= Self
.FWindow
;
1830 FActiveColor
:= MENU_ITEMSCTRL_COLOR
;
1831 FUnActiveColor
:= MENU_ITEMSTEXT_COLOR
;
1834 if fText
= '' then Text := nil else
1836 Text := TGUILabel
.Create(fText
, FBigFont
);
1837 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1840 ControlType
:= TGUIFileListBox
;
1842 Result
:= (Control
as TGUIFileListBox
);
1845 if FIndex
= -1 then FIndex
:= i
;
1850 function TGUIMenu
.AddLabel(fText
: string): TGUILabel
;
1857 Control
:= TGUILabel
.Create('', FBigFont
);
1858 with Control
as TGUILabel
do
1860 FWindow
:= Self
.FWindow
;
1861 FColor
:= MENU_ITEMSCTRL_COLOR
;
1864 Text := TGUILabel
.Create(fText
, FBigFont
);
1867 FColor
:= MENU_ITEMSTEXT_COLOR
;
1870 ControlType
:= TGUILabel
;
1872 Result
:= (Control
as TGUILabel
);
1875 if FIndex
= -1 then FIndex
:= i
;
1880 function TGUIMenu
.AddMemo(fText
: string; Width
, Height
: Word): TGUIMemo
;
1887 Control
:= TGUIMemo
.Create(FBigFont
, Width
, Height
);
1888 with Control
as TGUIMemo
do
1890 FWindow
:= Self
.FWindow
;
1891 FColor
:= MENU_ITEMSTEXT_COLOR
;
1894 if fText
= '' then Text := nil else
1896 Text := TGUILabel
.Create(fText
, FBigFont
);
1897 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1900 ControlType
:= TGUIMemo
;
1902 Result
:= (Control
as TGUIMemo
);
1905 if FIndex
= -1 then FIndex
:= i
;
1910 procedure TGUIMenu
.UpdateIndex();
1918 if (FIndex
< 0) or (FIndex
> High(FItems
)) then
1924 if FItems
[FIndex
].Control
.Enabled
then
1933 constructor TGUIScroll
.Create
;
1938 FOnChangeEvent
:= nil;
1941 procedure TGUIScroll
.FSetValue(a
: Integer);
1943 if a
> FMax
then FValue
:= FMax
else FValue
:= a
;
1946 procedure TGUIScroll
.OnMessage(var Msg
: TMessage
);
1948 if not FEnabled
then Exit
;
1956 IK_LEFT
, IK_KPLEFT
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
1960 g_Sound_PlayEx(SCROLL_SUBSOUND
);
1961 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
1963 IK_RIGHT
, IK_KPRIGHT
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
1964 if FValue
< FMax
then
1967 g_Sound_PlayEx(SCROLL_ADDSOUND
);
1968 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
1975 procedure TGUIScroll
.Update
;
1983 procedure TGUISwitch
.AddItem(Item
: string);
1985 SetLength(FItems
, Length(FItems
)+1);
1986 FItems
[High(FItems
)] := Item
;
1988 if FIndex
= -1 then FIndex
:= 0;
1991 constructor TGUISwitch
.Create(BigFont
: Boolean);
1997 FBigFont
:= BigFont
;
2000 function TGUISwitch
.GetText
: string;
2002 if FIndex
<> -1 then Result
:= FItems
[FIndex
]
2006 procedure TGUISwitch
.OnMessage(var Msg
: TMessage
);
2008 if not FEnabled
then Exit
;
2012 if FItems
= nil then Exit
;
2017 IK_RETURN
, IK_RIGHT
, IK_KPRETURN
, IK_KPRIGHT
, VK_FIRE
, VK_OPEN
, VK_RIGHT
,
2018 JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
,
2019 JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2021 if FIndex
< High(FItems
) then
2026 g_Sound_PlayEx(SCROLL_ADDSOUND
);
2028 if @FOnChangeEvent
<> nil then
2029 FOnChangeEvent(Self
);
2032 IK_LEFT
, IK_KPLEFT
, VK_LEFT
,
2033 JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
2038 FIndex
:= High(FItems
);
2040 g_Sound_PlayEx(SCROLL_SUBSOUND
);
2042 if @FOnChangeEvent
<> nil then
2043 FOnChangeEvent(Self
);
2049 procedure TGUISwitch
.Update
;
2057 constructor TGUIEdit
.Create(BigFont
: Boolean);
2061 FBigFont
:= BigFont
;
2067 procedure TGUIEdit
.OnMessage(var Msg
: TMessage
);
2069 if not FEnabled
then Exit
;
2078 if (wParam
in [48..57]) and (Chr(wParam
) <> '`') then
2079 if Length(Text) < FMaxLength
then
2081 Insert(Chr(wParam
), FText
, FCaretPos
+ 1);
2087 if (wParam
in [32..255]) and (Chr(wParam
) <> '`') then
2088 if Length(Text) < FMaxLength
then
2090 Insert(Chr(wParam
), FText
, FCaretPos
+ 1);
2098 Delete(FText
, FCaretPos
, 1);
2099 if FCaretPos
> 0 then Dec(FCaretPos
);
2101 IK_DELETE
: Delete(FText
, FCaretPos
+ 1, 1);
2102 IK_END
, IK_KPEND
: FCaretPos
:= Length(FText
);
2103 IK_HOME
, IK_KPHOME
: FCaretPos
:= 0;
2104 IK_LEFT
, IK_KPLEFT
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
: if FCaretPos
> 0 then Dec(FCaretPos
);
2105 IK_RIGHT
, IK_KPRIGHT
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
: if FCaretPos
< Length(FText
) then Inc(FCaretPos
);
2106 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2109 if FActiveControl
<> Self
then
2112 if @FOnEnterEvent
<> nil then FOnEnterEvent(Self
);
2116 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
2117 else SetActive(nil);
2118 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2124 g_GUIGrabInput
:= (@FOnEnterEvent
= nil) and (FWindow
.FActiveControl
= Self
);
2126 {$IFDEF ENABLE_TOUCH}
2127 sys_ShowKeyboard(g_GUIGrabInput
)
2131 procedure TGUIEdit
.SetText(Text: string);
2133 if Length(Text) > FMaxLength
then SetLength(Text, FMaxLength
);
2135 FCaretPos
:= Length(FText
);
2138 procedure TGUIEdit
.Update
;
2145 constructor TGUIKeyRead
.Create(BigFont
: Boolean);
2150 FBigFont
:= BigFont
;
2153 function TGUIKeyRead
.WantActivationKey (key
: LongInt): Boolean;
2156 (key
= IK_BACKSPACE
) or
2160 procedure TGUIKeyRead
.OnMessage(var Msg
: TMessage
);
2161 procedure actDefCtl ();
2164 if FDefControl
<> '' then
2165 SetActive(GetControl(FDefControl
))
2173 if not FEnabled
then
2179 if not FIsQuery
then
2182 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2185 if FActiveControl
<> Self
then
2189 IK_BACKSPACE
: // clear keybinding if we aren't waiting for a key
2202 VK_FIRSTKEY
..VK_LASTKEY
: // do not allow to bind virtual keys
2208 if (e_KeyNames
[wParam
] <> '') and not g_Console_MatchBind(wParam
, 'togglemenu') then
2216 g_GUIGrabInput
:= FIsQuery
2221 constructor TGUIKeyRead2
.Create(BigFont
: Boolean);
2222 {$IFDEF ENABLE_RENDER}
2223 var a
: Byte; w
, h
: Integer;
2233 FBigFont
:= BigFont
;
2235 FMaxKeyNameWdt
:= 0;
2237 {$IFDEF ENABLE_RENDER}
2238 for a
:= 0 to 255 do
2240 r_Render_GetStringSize(BigFont
, e_KeyNames
[a
], w
, h
);
2241 FMaxKeyNameWdt
:= Max(FMaxKeyNameWdt
, w
);
2243 FMaxKeyNameWdt
:= FMaxKeyNameWdt
-(FMaxKeyNameWdt
div 3);
2244 r_Render_GetStringSize(BigFont
, KEYREAD_QUERY
, w
, h
);
2245 if w
> FMaxKeyNameWdt
then FMaxKeyNameWdt
:= w
;
2246 r_Render_GetStringSize(BigFont
, KEYREAD_CLEAR
, w
, h
);
2247 if w
> FMaxKeyNameWdt
then FMaxKeyNameWdt
:= w
;
2251 function TGUIKeyRead2
.WantActivationKey (key
: LongInt): Boolean;
2254 IK_BACKSPACE
, IK_LEFT
, IK_RIGHT
, IK_KPLEFT
, IK_KPRIGHT
, VK_LEFT
, VK_RIGHT
,
2255 JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
,
2256 JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
2263 procedure TGUIKeyRead2
.OnMessage(var Msg
: TMessage
);
2264 procedure actDefCtl ();
2267 if FDefControl
<> '' then
2268 SetActive(GetControl(FDefControl
))
2276 if not FEnabled
then
2282 if not FIsQuery
then
2285 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2288 if FActiveControl
<> Self
then
2292 IK_BACKSPACE
: // clear keybinding if we aren't waiting for a key
2294 if (FKeyIdx
= 0) then FKey0
:= 0 else FKey1
:= 0;
2297 IK_LEFT
, IK_KPLEFT
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
2302 IK_RIGHT
, IK_KPRIGHT
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
2315 VK_FIRSTKEY
..VK_LASTKEY
: // do not allow to bind virtual keys
2321 if (e_KeyNames
[wParam
] <> '') and not g_Console_MatchBind(wParam
, 'togglemenu') then
2323 if (FKeyIdx
= 0) then FKey0
:= wParam
else FKey1
:= wParam
;
2331 g_GUIGrabInput
:= FIsQuery
2337 constructor TGUIModelView
.Create
;
2344 destructor TGUIModelView
.Destroy
;
2351 procedure TGUIModelView
.NextAnim();
2353 if FModel
= nil then
2356 if FModel
.Animation
< A_PAIN
then
2357 FModel
.ChangeAnimation(FModel
.Animation
+1, True)
2359 FModel
.ChangeAnimation(A_STAND
, True);
2362 procedure TGUIModelView
.NextWeapon();
2364 if FModel
= nil then
2367 if FModel
.Weapon
< WP_LAST
then
2368 FModel
.SetWeapon(FModel
.Weapon
+1)
2370 FModel
.SetWeapon(WEAPON_KASTET
);
2373 procedure TGUIModelView
.OnMessage(var Msg
: TMessage
);
2379 procedure TGUIModelView
.SetColor(Red
, Green
, Blue
: Byte);
2381 if FModel
<> nil then FModel
.SetColor(Red
, Green
, Blue
);
2384 procedure TGUIModelView
.SetModel(ModelName
: string);
2388 FModel
:= g_PlayerModel_Get(ModelName
);
2391 procedure TGUIModelView
.Update
;
2398 if FModel
<> nil then FModel
.Update
;
2403 constructor TGUIMapPreview
.Create();
2409 destructor TGUIMapPreview
.Destroy();
2415 procedure TGUIMapPreview
.OnMessage(var Msg
: TMessage
);
2421 procedure TGUIMapPreview
.SetMap(Res
: string);
2426 //header: TMapHeaderRec_1;
2431 map
: TDynRecord
= nil;
2438 FileName
:= g_ExtractWadName(Res
);
2440 WAD
:= TWADFile
.Create();
2441 if not WAD
.ReadFile(FileName
) then
2447 //k8: ignores path again
2448 if not WAD
.GetMapResource(g_ExtractFileName(Res
), Data
, Len
) then
2457 map
:= g_Map_ParseMap(Data
, Len
);
2467 if (map
= nil) then exit
;
2470 panlist
:= map
.field
['panel'];
2471 //header := GetMapHeader(map);
2473 FMapSize
.X
:= map
.Width
div 16;
2474 FMapSize
.Y
:= map
.Height
div 16;
2476 rX
:= Ceil(map
.Width
/ (MAPPREVIEW_WIDTH
*256.0));
2477 rY
:= Ceil(map
.Height
/ (MAPPREVIEW_HEIGHT
*256.0));
2478 FScale
:= max(rX
, rY
);
2482 if (panlist
<> nil) then
2484 for pan
in panlist
do
2486 if (pan
.PanelType
and (PANEL_WALL
or PANEL_CLOSEDOOR
or
2487 PANEL_STEP
or PANEL_WATER
or
2488 PANEL_ACID1
or PANEL_ACID2
)) <> 0 then
2490 SetLength(FMapData
, Length(FMapData
)+1);
2491 with FMapData
[High(FMapData
)] do
2496 X2
:= (pan
.X
+ pan
.Width
) div 16;
2497 Y2
:= (pan
.Y
+ pan
.Height
) div 16;
2499 X1
:= Trunc(X1
/FScale
+ 0.5);
2500 Y1
:= Trunc(Y1
/FScale
+ 0.5);
2501 X2
:= Trunc(X2
/FScale
+ 0.5);
2502 Y2
:= Trunc(Y2
/FScale
+ 0.5);
2504 if (X1
<> X2
) or (Y1
<> Y2
) then
2512 PanelType
:= pan
.PanelType
;
2518 //writeln('freeing map');
2523 procedure TGUIMapPreview
.ClearMap();
2525 SetLength(FMapData
, 0);
2532 procedure TGUIMapPreview
.Update();
2538 function TGUIMapPreview
.GetScaleStr(): String;
2540 if FScale
> 0.0 then
2542 Result
:= FloatToStrF(FScale
*16.0, ffFixed
, 3, 3);
2543 while (Result
[Length(Result
)] = '0') do
2544 Delete(Result
, Length(Result
), 1);
2545 if (Result
[Length(Result
)] = ',') or (Result
[Length(Result
)] = '.') then
2546 Delete(Result
, Length(Result
), 1);
2547 Result
:= '1 : ' + Result
;
2555 procedure TGUIListBox
.AddItem(Item
: string);
2557 SetLength(FItems
, Length(FItems
)+1);
2558 FItems
[High(FItems
)] := Item
;
2560 if FSort
then g_gui
.Sort(FItems
);
2563 function TGUIListBox
.ItemExists (item
: String): Boolean;
2567 while (i
<= High(FItems
)) and (FItems
[i
] <> item
) do Inc(i
);
2568 result
:= i
<= High(FItems
)
2571 procedure TGUIListBox
.Clear
;
2579 constructor TGUIListBox
.Create(BigFont
: Boolean; Width
, Height
: Word);
2583 FBigFont
:= BigFont
;
2587 FOnChangeEvent
:= nil;
2589 FDrawScroll
:= True;
2592 procedure TGUIListBox
.OnMessage(var Msg
: TMessage
);
2596 if not FEnabled
then Exit
;
2600 if FItems
= nil then Exit
;
2613 FIndex
:= High(FItems
);
2614 FStartLine
:= Max(High(FItems
)-FHeight
+1, 0);
2616 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
2620 if FIndex
< FStartLine
then Dec(FStartLine
);
2621 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2623 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
2624 if FIndex
< High(FItems
) then
2627 if FIndex
> FStartLine
+FHeight
-1 then Inc(FStartLine
);
2628 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2630 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2633 if FActiveControl
<> Self
then SetActive(Self
)
2635 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
2636 else SetActive(nil);
2640 for a
:= 0 to High(FItems
) do
2641 if (Length(FItems
[a
]) > 0) and (LowerCase(FItems
[a
][1]) = LowerCase(Chr(wParam
))) then
2644 FStartLine
:= Min(Max(FIndex
-1, 0), Length(FItems
)-FHeight
);
2645 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2651 function TGUIListBox
.SelectedItem(): String;
2655 if (FIndex
< 0) or (FItems
= nil) or
2656 (FIndex
> High(FItems
)) then
2659 Result
:= FItems
[FIndex
];
2662 procedure TGUIListBox
.FSetItems(Items
: SSArray
);
2664 if FItems
<> nil then
2672 if FSort
then g_gui
.Sort(FItems
);
2675 procedure TGUIListBox
.SelectItem(Item
: String);
2679 if FItems
= nil then
2683 Item
:= LowerCase(Item
);
2685 for a
:= 0 to High(FItems
) do
2686 if LowerCase(FItems
[a
]) = Item
then
2692 if FIndex
< FHeight
then
2695 FStartLine
:= Min(FIndex
, Length(FItems
)-FHeight
);
2698 procedure TGUIListBox
.FSetIndex(aIndex
: Integer);
2700 if FItems
= nil then
2703 if (aIndex
< 0) or (aIndex
> High(FItems
)) then
2708 if FIndex
<= FHeight
then
2711 FStartLine
:= Min(FIndex
, Length(FItems
)-FHeight
);
2716 procedure TGUIFileListBox
.OnMessage(var Msg
: TMessage
);
2718 a
, b
: Integer; s
: AnsiString;
2720 if not FEnabled
then
2723 if FItems
= nil then
2734 if @FOnChangeEvent
<> nil then
2735 FOnChangeEvent(Self
);
2740 FIndex
:= High(FItems
);
2741 FStartLine
:= Max(High(FItems
)-FHeight
+1, 0);
2742 if @FOnChangeEvent
<> nil then
2743 FOnChangeEvent(Self
);
2746 IK_PAGEUP
, IK_KPPAGEUP
:
2748 if FIndex
> FHeight
then
2749 FIndex
:= FIndex
-FHeight
2753 if FStartLine
> FHeight
then
2754 FStartLine
:= FStartLine
-FHeight
2759 IK_PAGEDN
, IK_KPPAGEDN
:
2761 if FIndex
< High(FItems
)-FHeight
then
2762 FIndex
:= FIndex
+FHeight
2764 FIndex
:= High(FItems
);
2766 if FStartLine
< High(FItems
)-FHeight
then
2767 FStartLine
:= FStartLine
+FHeight
2769 FStartLine
:= High(FItems
)-FHeight
+1;
2772 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
, VK_UP
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
2776 if FIndex
< FStartLine
then
2778 if @FOnChangeEvent
<> nil then
2779 FOnChangeEvent(Self
);
2782 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
, VK_DOWN
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
2783 if FIndex
< High(FItems
) then
2786 if FIndex
> FStartLine
+FHeight
-1 then
2788 if @FOnChangeEvent
<> nil then
2789 FOnChangeEvent(Self
);
2792 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2795 if FActiveControl
<> Self
then
2799 if FItems
[FIndex
][1] = #29 then // Ïàïêà
2801 if FItems
[FIndex
] = #29 + '..' then
2803 //e_LogWritefln('TGUIFileListBox: Upper dir "%s" -> "%s"', [FSubPath, e_UpperDir(FSubPath)]);
2804 FSubPath
:= e_UpperDir(FSubPath
)
2808 s
:= Copy(AnsiString(FItems
[FIndex
]), 2);
2809 //e_LogWritefln('TGUIFileListBox: Enter dir "%s" -> "%s"', [FSubPath, e_CatPath(FSubPath, s)]);
2810 FSubPath
:= e_CatPath(FSubPath
, s
);
2817 if FDefControl
<> '' then
2818 SetActive(GetControl(FDefControl
))
2826 for b
:= FIndex
+ 1 to High(FItems
) + FIndex
do
2828 a
:= b
mod Length(FItems
);
2829 if ( (Length(FItems
[a
]) > 0) and
2830 (LowerCase(FItems
[a
][1]) = LowerCase(Chr(wParam
))) ) or
2831 ( (Length(FItems
[a
]) > 1) and
2832 (FItems
[a
][1] = #29) and // Ïàïêà
2833 (LowerCase(FItems
[a
][2]) = LowerCase(Chr(wParam
))) ) then
2836 FStartLine
:= Min(Max(FIndex
-1, 0), Length(FItems
)-FHeight
);
2837 if @FOnChangeEvent
<> nil then
2838 FOnChangeEvent(Self
);
2845 procedure TGUIFileListBox
.ScanDirs
;
2846 var i
, j
: Integer; path
: AnsiString; SR
: TSearchRec
; sm
, sc
: String;
2850 i
:= High(FBaseList
);
2853 path
:= e_CatPath(FBaseList
[i
], FSubPath
);
2856 if FindFirst(path
+ '/' + '*', faDirectory
, SR
) = 0 then
2859 if LongBool(SR
.Attr
and faDirectory
) then
2860 if (SR
.Name
<> '.') and ((FSubPath
<> '') or (SR
.Name
<> '..')) then
2861 if Self
.ItemExists(#1 + SR
.Name
) = false then
2862 Self
.AddItem(#1 + SR
.Name
)
2863 until FindNext(SR
) <> 0
2870 i
:= High(FBaseList
);
2873 path
:= e_CatPath(FBaseList
[i
], FSubPath
);
2879 j
:= length(sm
) + 1;
2880 sc
:= Copy(sm
, 1, j
- 1);
2882 if FindFirst(path
+ '/' + sc
, faAnyFile
, SR
) = 0 then
2885 if Self
.ItemExists(SR
.Name
) = false then
2887 until FindNext(SR
) <> 0
2894 for i
:= 0 to High(FItems
) do
2895 if FItems
[i
][1] = #1 then
2896 FItems
[i
][1] := #29;
2899 procedure TGUIFileListBox
.SetBase (dirs
: SSArray
; path
: String = '');
2906 function TGUIFileListBox
.SelectedItem (): String;
2910 if (FIndex
>= 0) and (FIndex
<= High(FItems
)) and (FItems
[FIndex
][1] <> '/') and (FItems
[FIndex
][1] <> '\') then
2912 s
:= e_CatPath(FSubPath
, FItems
[FIndex
]);
2913 if e_FindResource(FBaseList
, s
) = true then
2914 result
:= ExpandFileName(s
)
2916 e_LogWritefln('TGUIFileListBox.SelectedItem -> "%s"', [result
]);
2919 procedure TGUIFileListBox
.UpdateFileList();
2923 if (FIndex
= -1) or (FItems
= nil) or
2924 (FIndex
> High(FItems
)) or
2925 (FItems
[FIndex
][1] = '/') or
2926 (FItems
[FIndex
][1] = '\') then
2929 fn
:= FItems
[FIndex
];
2940 procedure TGUIMemo
.Clear
;
2946 constructor TGUIMemo
.Create(BigFont
: Boolean; Width
, Height
: Word);
2950 FBigFont
:= BigFont
;
2954 FDrawScroll
:= True;
2957 procedure TGUIMemo
.OnMessage(var Msg
: TMessage
);
2959 if not FEnabled
then Exit
;
2963 if FLines
= nil then Exit
;
2969 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
, VK_UP
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
2970 if FStartLine
> 0 then
2972 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
, VK_DOWN
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
2973 if FStartLine
< Length(FLines
)-FHeight
then
2975 IK_RETURN
, IK_KPRETURN
, VK_FIRE
, VK_OPEN
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
2978 if FActiveControl
<> Self
then
2984 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
2985 else SetActive(nil);
2991 procedure TGUIMemo
.SetText(Text: string);
2994 FLines
:= GetLines(Text, FBigFont
, FWidth
* 16);
2999 procedure TGUIimage
.ClearImage();
3004 constructor TGUIimage
.Create();
3011 destructor TGUIimage
.Destroy();
3016 procedure TGUIimage
.OnMessage(var Msg
: TMessage
);
3021 procedure TGUIimage
.SetImage(Res
: string);
3026 procedure TGUIimage
.Update();