7 e_graphics
, e_input
, g_playermodel
, g_basic
, MAPSTRUCT
, wadreader
;
10 MAINMENU_HEADER_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
11 MAINMENU_ITEMS_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
12 MAINMENU_UNACTIVEITEMS_COLOR
: TRGB
= (R
:192; G
:192; B
:192);
13 MAINMENU_CLICKSOUND
= 'MENU_SELECT';
14 MAINMENU_CHANGESOUND
= 'MENU_CHANGE';
16 MAINMENU_MARKER1
= 'MAINMENU_MARKER1';
17 MAINMENU_MARKER2
= 'MAINMENU_MARKER2';
18 MAINMENU_MARKERDELAY
= 24;
19 WINDOW_CLOSESOUND
= 'MENU_CLOSE';
20 MENU_HEADERCOLOR
: TRGB
= (R
:255; G
:255; B
:255);
21 MENU_ITEMSTEXT_COLOR
: TRGB
= (R
:255; G
:255; B
:255);
22 MENU_UNACTIVEITEMS_COLOR
: TRGB
= (R
:128; G
:128; B
:128);
23 MENU_ITEMSCTRL_COLOR
: TRGB
= (R
:255; G
:0; B
:0);
26 MENU_CLICKSOUND
= 'MENU_SELECT';
27 MENU_CHANGESOUND
= 'MENU_CHANGE';
28 MENU_MARKERDELAY
= 24;
29 SCROLL_LEFT
= 'SCROLL_LEFT';
30 SCROLL_RIGHT
= 'SCROLL_RIGHT';
31 SCROLL_MIDDLE
= 'SCROLL_MIDDLE';
32 SCROLL_MARKER
= 'SCROLL_MARKER';
33 SCROLL_ADDSOUND
= 'SCROLL_ADD';
34 SCROLL_SUBSOUND
= 'SCROLL_SUB';
35 EDIT_LEFT
= 'EDIT_LEFT';
36 EDIT_RIGHT
= 'EDIT_RIGHT';
37 EDIT_MIDDLE
= 'EDIT_MIDDLE';
38 EDIT_CURSORCOLOR
: TRGB
= (R
:200; G
:0; B
:0);
40 KEYREAD_QUERY
= '<...>';
41 KEYREAD_CLEAR
= '???';
44 MAPPREVIEW_HEIGHT
= 8;
54 BSCROLL_UPA
= 'BSCROLL_UP_A';
55 BSCROLL_UPU
= 'BSCROLL_UP_U';
56 BSCROLL_DOWNA
= 'BSCROLL_DOWN_A';
57 BSCROLL_DOWNU
= 'BSCROLL_DOWN_U';
58 BSCROLL_MIDDLE
= 'BSCROLL_MIDDLE';
70 TFontType
= (FONT_TEXTURE
, FONT_CHAR
);
72 TFont
= class(TObject
)
78 constructor Create(FontID
: DWORD
; FontType
: TFontType
);
79 destructor Destroy
; override;
80 procedure Draw(X
, Y
: Integer; Text: string; R
, G
, B
: Byte);
81 procedure GetTextSize(Text: string; var w
, h
: Word);
82 property Scale
: Single read FScale write FScale
;
88 TOnKeyDownEvent
= procedure(Key
: Byte);
89 TOnKeyDownEventEx
= procedure(win
: TGUIWindow
; Key
: Byte);
90 TOnCloseEvent
= procedure;
91 TOnShowEvent
= procedure;
92 TOnClickEvent
= procedure;
93 TOnChangeEvent
= procedure(Sender
: TGUIControl
);
94 TOnEnterEvent
= procedure(Sender
: TGUIControl
);
100 FWindow
: TGUIWindow
;
105 procedure OnMessage(var Msg
: TMessage
); virtual;
106 procedure Update
; virtual;
107 procedure Draw
; virtual;
108 property X
: Integer read FX write FX
;
109 property Y
: Integer read FY write FY
;
110 property Enabled
: Boolean read FEnabled write FEnabled
;
111 property Name
: string read FName write FName
;
112 property UserData
: Pointer read FUserData write FUserData
;
117 FActiveControl
: TGUIControl
;
119 FPrevWindow
: TGUIWindow
;
121 FBackTexture
: string;
122 FMainWindow
: Boolean;
123 FOnKeyDown
: TOnKeyDownEvent
;
124 FOnKeyDownEx
: TOnKeyDownEventEx
;
125 FOnCloseEvent
: TOnCloseEvent
;
126 FOnShowEvent
: TOnShowEvent
;
129 Childs
: array of TGUIControl
;
130 constructor Create(Name
: string);
131 destructor Destroy
; override;
132 function AddChild(Child
: TGUIControl
): TGUIControl
;
133 procedure OnMessage(var Msg
: TMessage
);
136 procedure SetActive(Control
: TGUIControl
);
137 function GetControl(Name
: string): TGUIControl
;
138 property OnKeyDown
: TOnKeyDownEvent read FOnKeyDown write FOnKeyDown
;
139 property OnKeyDownEx
: TOnKeyDownEventEx read FOnKeyDownEx write FOnKeyDownEx
;
140 property OnClose
: TOnCloseEvent read FOnCloseEvent write FOnCloseEvent
;
141 property OnShow
: TOnShowEvent read FOnShowEvent write FOnShowEvent
;
142 property Name
: string read FName
;
143 property DefControl
: string read FDefControl write FDefControl
;
144 property BackTexture
: string read FBackTexture write FBackTexture
;
145 property MainWindow
: Boolean read FMainWindow write FMainWindow
;
146 property UserData
: Pointer read FUserData write FUserData
;
149 TGUITextButton
= class(TGUIControl
)
158 ProcEx
: procedure (sender
: TGUITextButton
);
159 constructor Create(Proc
: Pointer; FontID
: DWORD
; Text: string);
160 destructor Destroy(); override;
161 procedure OnMessage(var Msg
: TMessage
); override;
162 procedure Update(); override;
163 procedure Draw(); override;
164 function GetWidth(): Integer;
165 function GetHeight(): Integer;
166 procedure Click(Silent
: Boolean = False);
167 property Caption
: string read FText write FText
;
168 property Color
: TRGB read FColor write FColor
;
169 property Font
: TFont read FFont write FFont
;
170 property ShowWindow
: string read FShowWindow write FShowWindow
;
173 TGUILabel
= class(TGUIControl
)
179 FOnClickEvent
: TOnClickEvent
;
181 constructor Create(Text: string; FontID
: DWORD
);
182 procedure OnMessage(var Msg
: TMessage
); override;
183 procedure Draw
; override;
184 function GetWidth
: Integer;
185 function GetHeight
: Integer;
186 property OnClick
: TOnClickEvent read FOnClickEvent write FOnClickEvent
;
187 property FixedLength
: Word read FFixedLen write FFixedLen
;
188 property Text: string read FText write FText
;
189 property Color
: TRGB read FColor write FColor
;
190 property Font
: TFont read FFont write FFont
;
193 TGUIScroll
= class(TGUIControl
)
201 FOnChangeEvent
: TOnChangeEvent
;
202 procedure FSetValue(a
: Integer);
204 constructor Create();
205 procedure OnMessage(var Msg
: TMessage
); override;
206 procedure Update
; override;
207 procedure Draw
; override;
208 function GetWidth(): Word;
209 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
210 property Max
: Word read FMax write FMax
;
211 property Value
: Integer read FValue write FSetValue
;
214 TGUISwitch
= class(TGUIControl
)
217 FItems
: array of string;
220 FOnChangeEvent
: TOnChangeEvent
;
222 constructor Create(FontID
: DWORD
);
223 procedure OnMessage(var Msg
: TMessage
); override;
224 procedure AddItem(Item
: string);
225 procedure Update
; override;
226 procedure Draw
; override;
227 function GetWidth(): Word;
228 function GetText
: string;
229 property ItemIndex
: Integer read FIndex write FIndex
;
230 property Color
: TRGB read FColor write FColor
;
231 property Font
: TFont read FFont write FFont
;
232 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
235 TGUIEdit
= class(TGUIControl
)
243 FOnlyDigits
: Boolean;
247 FOnChangeEvent
: TOnChangeEvent
;
248 FOnEnterEvent
: TOnEnterEvent
;
249 procedure SetText(Text: string);
251 constructor Create(FontID
: DWORD
);
252 procedure OnMessage(var Msg
: TMessage
); override;
253 procedure Update
; override;
254 procedure Draw
; override;
255 function GetWidth(): Word;
256 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
257 property OnEnter
: TOnEnterEvent read FOnEnterEvent write FOnEnterEvent
;
258 property Width
: Word read FWidth write FWidth
;
259 property MaxLength
: Word read FMaxLength write FMaxLength
;
260 property OnlyDigits
: Boolean read FOnlyDigits write FOnlyDigits
;
261 property Text: string read FText write SetText
;
262 property Color
: TRGB read FColor write FColor
;
263 property Font
: TFont read FFont write FFont
;
266 TGUIKeyRead
= class(TGUIControl
)
273 constructor Create(FontID
: DWORD
);
274 procedure OnMessage(var Msg
: TMessage
); override;
275 procedure Draw
; override;
276 function GetWidth(): Word;
277 property Key
: Word read FKey write FKey
;
278 property Color
: TRGB read FColor write FColor
;
279 property Font
: TFont read FFont write FFont
;
282 TGUIModelView
= class(TGUIControl
)
284 FModel
: TPlayerModel
;
288 destructor Destroy
; override;
289 procedure OnMessage(var Msg
: TMessage
); override;
290 procedure SetModel(ModelName
: string);
291 procedure SetColor(Red
, Green
, Blue
: Byte);
292 procedure NextAnim();
293 procedure NextWeapon();
294 procedure Update
; override;
295 procedure Draw
; override;
296 property Model
: TPlayerModel read FModel
;
299 TPreviewPanel
= record
300 X1
, Y1
, X2
, Y2
: Integer;
304 TGUIMapPreview
= class(TGUIControl
)
306 FMapData
: array of TPreviewPanel
;
310 constructor Create();
311 destructor Destroy(); override;
312 procedure OnMessage(var Msg
: TMessage
); override;
313 procedure SetMap(Res
: string);
314 procedure ClearMap();
315 procedure Update(); override;
316 procedure Draw(); override;
317 function GetScaleStr
: String;
320 TGUIImage
= class(TGUIControl
)
325 constructor Create();
326 destructor Destroy(); override;
327 procedure OnMessage(var Msg
: TMessage
); override;
328 procedure SetImage(Res
: string);
329 procedure ClearImage();
330 procedure Update(); override;
331 procedure Draw(); override;
332 property DefaultRes
: string read FDefaultRes write FDefaultRes
;
335 TGUIListBox
= class(TGUIControl
)
339 FUnActiveColor
: TRGB
;
347 FDrawScroll
: Boolean;
348 FOnChangeEvent
: TOnChangeEvent
;
350 procedure FSetItems(Items
: SArray
);
351 procedure FSetIndex(aIndex
: Integer);
354 constructor Create(FontID
: DWORD
; Width
, Height
: Word);
355 procedure OnMessage(var Msg
: TMessage
); override;
356 procedure Draw(); override;
357 procedure AddItem(Item
: String);
358 procedure SelectItem(Item
: String);
360 function GetWidth(): Word;
361 function GetHeight(): Word;
362 function SelectedItem(): String;
364 property OnChange
: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent
;
365 property Sort
: Boolean read FSort write FSort
;
366 property ItemIndex
: Integer read FIndex write FSetIndex
;
367 property Items
: SArray read FItems write FSetItems
;
368 property DrawBack
: Boolean read FDrawBack write FDrawBack
;
369 property DrawScrollBar
: Boolean read FDrawScroll write FDrawScroll
;
370 property ActiveColor
: TRGB read FActiveColor write FActiveColor
;
371 property UnActiveColor
: TRGB read FUnActiveColor write FUnActiveColor
;
372 property Font
: TFont read FFont write FFont
;
375 TGUIFileListBox
= class (TGUIListBox
)
382 procedure OpenDir(path
: String);
385 procedure OnMessage(var Msg
: TMessage
); override;
386 procedure SetBase(path
: String);
387 function SelectedItem(): String;
388 procedure UpdateFileList();
390 property Dirs
: Boolean read FDirs write FDirs
;
391 property FileMask
: String read FFileMask write FFileMask
;
392 property Path
: String read FPath
;
395 TGUIMemo
= class(TGUIControl
)
404 FDrawScroll
: Boolean;
406 constructor Create(FontID
: DWORD
; Width
, Height
: Word);
407 procedure OnMessage(var Msg
: TMessage
); override;
408 procedure Draw
; override;
410 function GetWidth(): Word;
411 function GetHeight(): Word;
412 procedure SetText(Text: string);
413 property DrawBack
: Boolean read FDrawBack write FDrawBack
;
414 property DrawScrollBar
: Boolean read FDrawScroll write FDrawScroll
;
415 property Color
: TRGB read FColor write FColor
;
416 property Font
: TFont read FFont write FFont
;
419 TGUIMainMenu
= class(TGUIControl
)
421 FButtons
: array of TGUITextButton
;
429 constructor Create(FontID
: DWORD
; Header
: string);
430 destructor Destroy
; override;
431 procedure OnMessage(var Msg
: TMessage
); override;
432 function AddButton(fProc
: Pointer; Caption
: string; ShowWindow
: string = ''): TGUITextButton
;
433 function GetButton(Name
: string): TGUITextButton
;
434 procedure EnableButton(Name
: string; e
: Boolean);
435 procedure AddSpace();
436 procedure Update
; override;
437 procedure Draw
; override;
440 TControlType
= class of TGUIControl
;
442 PMenuItem
= ^TMenuItem
;
445 ControlType
: TControlType
;
446 Control
: TGUIControl
;
449 TGUIMenu
= class(TGUIControl
)
451 FItems
: array of TMenuItem
;
459 function NewItem(): Integer;
461 constructor Create(HeaderFont
, ItemsFont
: DWORD
; Header
: string);
462 destructor Destroy
; override;
463 procedure OnMessage(var Msg
: TMessage
); override;
464 procedure AddSpace();
465 procedure AddLine(fText
: string);
466 procedure AddText(fText
: string; MaxWidth
: Word);
467 function AddLabel(fText
: string): TGUILabel
;
468 function AddButton(Proc
: Pointer; fText
: string; _ShowWindow
: string = ''): TGUITextButton
;
469 function AddScroll(fText
: string): TGUIScroll
;
470 function AddSwitch(fText
: string): TGUISwitch
;
471 function AddEdit(fText
: string): TGUIEdit
;
472 function AddKeyRead(fText
: string): TGUIKeyRead
;
473 function AddList(fText
: string; Width
, Height
: Word): TGUIListBox
;
474 function AddFileList(fText
: string; Width
, Height
: Word): TGUIFileListBox
;
475 function AddMemo(fText
: string; Width
, Height
: Word): TGUIMemo
;
477 function GetControl(Name
: string): TGUIControl
;
478 function GetControlsText(Name
: string): TGUILabel
;
479 procedure Draw
; override;
480 procedure Update
; override;
481 procedure UpdateIndex();
482 property Align
: Boolean read FAlign write FAlign
;
483 property Left
: Integer read FLeft write FLeft
;
484 property YesNo
: Boolean read FYesNo write FYesNo
;
488 g_GUIWindows
: array of TGUIWindow
;
489 g_ActiveWindow
: TGUIWindow
= nil;
491 procedure g_GUI_Init();
492 function g_GUI_AddWindow(Window
: TGUIWindow
): TGUIWindow
;
493 function g_GUI_GetWindow(Name
: string): TGUIWindow
;
494 procedure g_GUI_ShowWindow(Name
: string);
495 procedure g_GUI_HideWindow(PlaySound
: Boolean = True);
496 function g_GUI_Destroy(): Boolean;
497 procedure g_GUI_SaveMenuPos();
498 procedure g_GUI_LoadMenuPos();
503 GL
, GLExt
, g_textures
, g_sound
, SysUtils
,
504 g_game
, Math
, StrUtils
, g_player
, g_options
, MAPREADER
,
505 g_map
, MAPDEF
, g_weapons
;
508 Box
: Array [0..8] of DWORD
;
509 Saved_Windows
: SArray
;
511 procedure g_GUI_Init();
513 g_Texture_Get(BOX1
, Box
[0]);
514 g_Texture_Get(BOX2
, Box
[1]);
515 g_Texture_Get(BOX3
, Box
[2]);
516 g_Texture_Get(BOX4
, Box
[3]);
517 g_Texture_Get(BOX5
, Box
[4]);
518 g_Texture_Get(BOX6
, Box
[5]);
519 g_Texture_Get(BOX7
, Box
[6]);
520 g_Texture_Get(BOX8
, Box
[7]);
521 g_Texture_Get(BOX9
, Box
[8]);
524 function g_GUI_Destroy(): Boolean;
528 Result
:= (Length(g_GUIWindows
) > 0);
530 for i
:= 0 to High(g_GUIWindows
) do
531 g_GUIWindows
[i
].Free();
534 g_ActiveWindow
:= nil;
537 function g_GUI_AddWindow(Window
: TGUIWindow
): TGUIWindow
;
539 SetLength(g_GUIWindows
, Length(g_GUIWindows
)+1);
540 g_GUIWindows
[High(g_GUIWindows
)] := Window
;
545 function g_GUI_GetWindow(Name
: string): TGUIWindow
;
551 if g_GUIWindows
<> nil then
552 for i
:= 0 to High(g_GUIWindows
) do
553 if g_GUIWindows
[i
].FName
= Name
then
555 Result
:= g_GUIWindows
[i
];
559 Assert(Result
<> nil, 'GUI_Window "'+Name
+'" not found');
562 procedure g_GUI_ShowWindow(Name
: string);
566 if g_GUIWindows
= nil then
569 for i
:= 0 to High(g_GUIWindows
) do
570 if g_GUIWindows
[i
].FName
= Name
then
572 g_GUIWindows
[i
].FPrevWindow
:= g_ActiveWindow
;
573 g_ActiveWindow
:= g_GUIWindows
[i
];
575 if g_ActiveWindow
.MainWindow
then
576 g_ActiveWindow
.FPrevWindow
:= nil;
578 if g_ActiveWindow
.FDefControl
<> '' then
579 g_ActiveWindow
.SetActive(g_ActiveWindow
.GetControl(g_ActiveWindow
.FDefControl
))
581 g_ActiveWindow
.SetActive(nil);
583 if @g_ActiveWindow
.FOnShowEvent
<> nil then
584 g_ActiveWindow
.FOnShowEvent();
590 procedure g_GUI_HideWindow(PlaySound
: Boolean = True);
592 if g_ActiveWindow
<> nil then
594 if @g_ActiveWindow
.OnClose
<> nil then
595 g_ActiveWindow
.OnClose();
596 g_ActiveWindow
:= g_ActiveWindow
.FPrevWindow
;
598 g_Sound_PlayEx(WINDOW_CLOSESOUND
);
602 procedure g_GUI_SaveMenuPos();
607 SetLength(Saved_Windows
, 0);
608 win
:= g_ActiveWindow
;
612 len
:= Length(Saved_Windows
);
613 SetLength(Saved_Windows
, len
+ 1);
615 Saved_Windows
[len
] := win
.Name
;
617 if win
.MainWindow
then
620 win
:= win
.FPrevWindow
;
624 procedure g_GUI_LoadMenuPos();
626 i
, j
, k
, len
: Integer;
629 g_ActiveWindow
:= nil;
630 len
:= Length(Saved_Windows
);
635 // Îêíî ñ ãëàâíûì ìåíþ:
636 g_GUI_ShowWindow(Saved_Windows
[len
-1]);
638 // Íå ïåðåêëþ÷èëîñü (èëè íåêóäà äàëüøå):
639 if (len
= 1) or (g_ActiveWindow
= nil) then
642 // Èùåì êíîïêè â îñòàëüíûõ îêíàõ:
643 for k
:= len
-1 downto 1 do
647 for i
:= 0 to Length(g_ActiveWindow
.Childs
)-1 do
649 if g_ActiveWindow
.Childs
[i
] is TGUIMainMenu
then
650 begin // GUI_MainMenu
651 with TGUIMainMenu(g_ActiveWindow
.Childs
[i
]) do
652 for j
:= 0 to Length(FButtons
)-1 do
653 if FButtons
[j
].ShowWindow
= Saved_Windows
[k
-1] then
655 FButtons
[j
].Click(True);
661 if g_ActiveWindow
.Childs
[i
] is TGUIMenu
then
662 with TGUIMenu(g_ActiveWindow
.Childs
[i
]) do
663 for j
:= 0 to Length(FItems
)-1 do
664 if FItems
[j
].ControlType
= TGUITextButton
then
665 if TGUITextButton(FItems
[j
].Control
).ShowWindow
= Saved_Windows
[k
-1] then
667 TGUITextButton(FItems
[j
].Control
).Click(True);
678 (g_ActiveWindow
.Name
= Saved_Windows
[k
]) then
683 procedure DrawBox(X
, Y
: Integer; Width
, Height
: Word);
685 e_Draw(Box
[0], X
, Y
, 0, False, False);
686 e_DrawFill(Box
[1], X
+4, Y
, Width
*4, 1, 0, False, False);
687 e_Draw(Box
[2], X
+4+Width
*16, Y
, 0, False, False);
688 e_DrawFill(Box
[3], X
, Y
+4, 1, Height
*4, 0, False, False);
689 e_DrawFill(Box
[4], X
+4, Y
+4, Width
, Height
, 0, False, False);
690 e_DrawFill(Box
[5], X
+4+Width
*16, Y
+4, 1, Height
*4, 0, False, False);
691 e_Draw(Box
[6], X
, Y
+4+Height
*16, 0, False, False);
692 e_DrawFill(Box
[7], X
+4, Y
+4+Height
*16, Width
*4, 1, 0, False, False);
693 e_Draw(Box
[8], X
+4+Width
*16, Y
+4+Height
*16, 0, False, False);
696 procedure DrawScroll(X
, Y
: Integer; Height
: Word; Up
, Down
: Boolean);
700 if Height
< 3 then Exit
;
703 g_Texture_Get(BSCROLL_UPA
, ID
)
705 g_Texture_Get(BSCROLL_UPU
, ID
);
706 e_Draw(ID
, X
, Y
, 0, False, False);
709 g_Texture_Get(BSCROLL_DOWNA
, ID
)
711 g_Texture_Get(BSCROLL_DOWNU
, ID
);
712 e_Draw(ID
, X
, Y
+(Height
-1)*16, 0, False, False);
714 g_Texture_Get(BSCROLL_MIDDLE
, ID
);
715 e_DrawFill(ID
, X
, Y
+16, 1, Height
-2, 0, False, False);
720 constructor TGUIWindow
.Create(Name
: string);
723 FActiveControl
:= nil;
727 FOnCloseEvent
:= nil;
731 destructor TGUIWindow
.Destroy
;
738 for i
:= 0 to High(Childs
) do
742 function TGUIWindow
.AddChild(Child
: TGUIControl
): TGUIControl
;
744 Child
.FWindow
:= Self
;
746 SetLength(Childs
, Length(Childs
) + 1);
747 Childs
[High(Childs
)] := Child
;
752 procedure TGUIWindow
.Update
;
756 for i
:= 0 to High(Childs
) do
757 if Childs
[i
] <> nil then Childs
[i
].Update
;
760 procedure TGUIWindow
.Draw
;
765 if FBackTexture
<> '' then
766 if g_Texture_Get(FBackTexture
, ID
) then
767 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
769 e_Clear(GL_COLOR_BUFFER_BIT
, 0.5, 0.5, 0.5);
771 for i
:= 0 to High(Childs
) do
772 if Childs
[i
] <> nil then Childs
[i
].Draw
;
775 procedure TGUIWindow
.OnMessage(var Msg
: TMessage
);
777 if FActiveControl
<> nil then FActiveControl
.OnMessage(Msg
);
778 if @FOnKeyDown
<> nil then FOnKeyDown(Msg
.wParam
);
779 if @FOnKeyDownEx
<> nil then FOnKeyDownEx(self
, Msg
.wParam
);
781 if Msg
.Msg
= WM_KEYDOWN
then
782 if Msg
.wParam
= IK_ESCAPE
then
789 procedure TGUIWindow
.SetActive(Control
: TGUIControl
);
791 FActiveControl
:= Control
;
794 function TGUIWindow
.GetControl(Name
: String): TGUIControl
;
800 if Childs
<> nil then
801 for i
:= 0 to High(Childs
) do
802 if Childs
[i
] <> nil then
803 if LowerCase(Childs
[i
].FName
) = LowerCase(Name
) then
809 Assert(Result
<> nil, 'Window Control "'+Name
+'" not Found!');
814 constructor TGUIControl
.Create();
822 procedure TGUIControl
.OnMessage(var Msg
: TMessage
);
828 procedure TGUIControl
.Update();
833 procedure TGUIControl
.Draw();
840 procedure TGUITextButton
.Click(Silent
: Boolean = False);
842 if (FSound
<> '') and (not Silent
) then g_Sound_PlayEx(FSound
);
844 if @Proc
<> nil then Proc();
845 if @ProcEx
<> nil then ProcEx(self
);
847 if FShowWindow
<> '' then g_GUI_ShowWindow(FShowWindow
);
850 constructor TGUITextButton
.Create(Proc
: Pointer; FontID
: DWORD
; Text: string);
857 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
862 destructor TGUITextButton
.Destroy
;
868 procedure TGUITextButton
.Draw
;
870 FFont
.Draw(FX
, FY
, FText
, FColor
.R
, FColor
.G
, FColor
.B
)
873 function TGUITextButton
.GetHeight
: Integer;
877 FFont
.GetTextSize(FText
, w
, h
);
881 function TGUITextButton
.GetWidth
: Integer;
885 FFont
.GetTextSize(FText
, w
, h
);
889 procedure TGUITextButton
.OnMessage(var Msg
: TMessage
);
891 if not FEnabled
then Exit
;
898 IK_RETURN
, IK_KPRETURN
: Click();
903 procedure TGUITextButton
.Update
;
910 constructor TFont
.Create(FontID
: DWORD
; FontType
: TFontType
);
915 FFontType
:= FontType
;
918 destructor TFont
.Destroy
;
924 procedure TFont
.Draw(X
, Y
: Integer; Text: string; R
, G
, B
: Byte);
926 if FFontType
= FONT_CHAR
then e_CharFont_PrintEx(ID
, X
, Y
, Text, _RGB(R
, G
, B
), FScale
)
927 else e_TextureFontPrintEx(X
, Y
, Text, ID
, R
, G
, B
, FScale
);
930 procedure TFont
.GetTextSize(Text: string; var w
, h
: Word);
934 if FFontType
= FONT_CHAR
then e_CharFont_GetSize(ID
, Text, w
, h
)
937 e_TextureFontGetSize(ID
, cw
, ch
);
938 w
:= cw
*Length(Text);
942 w
:= Round(w
*FScale
);
943 h
:= Round(h
*FScale
);
948 function TGUIMainMenu
.AddButton(fProc
: Pointer; Caption
: string; ShowWindow
: string = ''): TGUITextButton
;
955 SetLength(FButtons
, Length(FButtons
)+1);
956 FButtons
[High(FButtons
)] := TGUITextButton
.Create(fProc
, FFontID
, Caption
);
957 FButtons
[High(FButtons
)].ShowWindow
:= ShowWindow
;
958 with FButtons
[High(FButtons
)] do
960 if (fProc
<> nil) or (ShowWindow
<> '') then FColor
:= MAINMENU_ITEMS_COLOR
961 else FColor
:= MAINMENU_UNACTIVEITEMS_COLOR
;
962 FSound
:= MAINMENU_CLICKSOUND
;
965 _x
:= gScreenWidth
div 2;
967 for a
:= 0 to High(FButtons
) do
968 if FButtons
[a
] <> nil then
969 _x
:= Min(_x
, (gScreenWidth
div 2)-(FButtons
[a
].GetWidth
div 2));
971 hh
:= FHeader
.GetHeight
;
973 h
:= hh
*(2+Length(FButtons
))+MAINMENU_SPACE
*(Length(FButtons
)-1);
974 h
:= (gScreenHeight
div 2)-(h
div 2);
984 for a
:= 0 to High(FButtons
) do
986 if FButtons
[a
] <> nil then
993 Inc(h
, hh
+MAINMENU_SPACE
);
996 Result
:= FButtons
[High(FButtons
)];
999 procedure TGUIMainMenu
.AddSpace
;
1001 SetLength(FButtons
, Length(FButtons
)+1);
1002 FButtons
[High(FButtons
)] := nil;
1005 constructor TGUIMainMenu
.Create(FontID
: DWORD
; Header
: string);
1011 FCounter
:= MAINMENU_MARKERDELAY
;
1013 g_Texture_Get(MAINMENU_MARKER1
, FMarkerID1
);
1014 g_Texture_Get(MAINMENU_MARKER2
, FMarkerID2
);
1016 FHeader
:= TGUILabel
.Create(Header
, FFontID
);
1019 FColor
:= MAINMENU_HEADER_COLOR
;
1020 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1021 FY
:= (gScreenHeight
div 2)-(GetHeight
div 2);
1025 destructor TGUIMainMenu
.Destroy
;
1029 if FButtons
<> nil then
1030 for a
:= 0 to High(FButtons
) do
1038 procedure TGUIMainMenu
.Draw
;
1046 if FButtons
<> nil then
1048 for a
:= 0 to High(FButtons
) do
1049 if FButtons
[a
] <> nil then FButtons
[a
].Draw
;
1051 if FIndex
<> -1 then
1052 e_Draw(FMarkerID1
, FButtons
[FIndex
].FX
-48, FButtons
[FIndex
].FY
, 0, True, False);
1056 procedure TGUIMainMenu
.EnableButton(Name
: string; e
: Boolean);
1060 if FButtons
= nil then Exit
;
1062 for a
:= 0 to High(FButtons
) do
1063 if (FButtons
[a
] <> nil) and (FButtons
[a
].Name
= Name
) then
1065 if e
then FButtons
[a
].FColor
:= MAINMENU_ITEMS_COLOR
1066 else FButtons
[a
].FColor
:= MAINMENU_UNACTIVEITEMS_COLOR
;
1067 FButtons
[a
].Enabled
:= e
;
1072 function TGUIMainMenu
.GetButton(Name
: string): TGUITextButton
;
1078 if FButtons
= nil then Exit
;
1080 for a
:= 0 to High(FButtons
) do
1081 if (FButtons
[a
] <> nil) and (FButtons
[a
].Name
= Name
) then
1083 Result
:= FButtons
[a
];
1088 procedure TGUIMainMenu
.OnMessage(var Msg
: TMessage
);
1093 if not FEnabled
then Exit
;
1097 if FButtons
= nil then Exit
;
1100 for a
:= 0 to High(FButtons
) do
1101 if FButtons
[a
] <> nil then
1107 if not ok
then Exit
;
1116 if FIndex
< 0 then FIndex
:= High(FButtons
);
1117 until FButtons
[FIndex
] <> nil;
1119 g_Sound_PlayEx(MENU_CHANGESOUND
);
1125 if FIndex
> High(FButtons
) then FIndex
:= 0;
1126 until FButtons
[FIndex
] <> nil;
1128 g_Sound_PlayEx(MENU_CHANGESOUND
);
1130 IK_RETURN
, IK_KPRETURN
: if (FIndex
<> -1) and FButtons
[FIndex
].FEnabled
then FButtons
[FIndex
].Click
;
1135 procedure TGUIMainMenu
.Update
;
1141 if FCounter
= 0 then
1144 FMarkerID1
:= FMarkerID2
;
1147 FCounter
:= MAINMENU_MARKERDELAY
;
1148 end else Dec(FCounter
);
1153 constructor TGUILabel
.Create(Text: string; FontID
: DWORD
);
1157 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
1161 FOnClickEvent
:= nil;
1164 procedure TGUILabel
.Draw
;
1166 FFont
.Draw(FX
, FY
, FText
, FColor
.R
, FColor
.G
, FColor
.B
);
1169 function TGUILabel
.GetHeight
: Integer;
1173 FFont
.GetTextSize(FText
, w
, h
);
1177 function TGUILabel
.GetWidth
: Integer;
1181 if FFixedLen
= 0 then
1182 FFont
.GetTextSize(FText
, w
, h
)
1184 w
:= e_CharFont_GetMaxWidth(FFont
.ID
)*FFixedLen
;
1188 procedure TGUILabel
.OnMessage(var Msg
: TMessage
);
1190 if not FEnabled
then Exit
;
1197 IK_RETURN
, IK_KPRETURN
: if @FOnClickEvent
<> nil then FOnClickEvent();
1204 function TGUIMenu
.AddButton(Proc
: Pointer; fText
: string; _ShowWindow
: string = ''): TGUITextButton
;
1211 Control
:= TGUITextButton
.Create(Proc
, FFontID
, fText
);
1212 with Control
as TGUITextButton
do
1214 ShowWindow
:= _ShowWindow
;
1215 FColor
:= MENU_ITEMSCTRL_COLOR
;
1219 ControlType
:= TGUITextButton
;
1221 Result
:= (Control
as TGUITextButton
);
1224 if FIndex
= -1 then FIndex
:= i
;
1229 procedure TGUIMenu
.AddLine(fText
: string);
1236 Text := TGUILabel
.Create(fText
, FFontID
);
1239 FColor
:= MENU_ITEMSTEXT_COLOR
;
1248 procedure TGUIMenu
.AddText(fText
: string; MaxWidth
: Word);
1253 l
:= GetLines(fText
, FFontID
, MaxWidth
);
1255 if l
= nil then Exit
;
1257 for a
:= 0 to High(l
) do
1262 Text := TGUILabel
.Create(l
[a
], FFontID
);
1265 with Text do begin FColor
:= _RGB(255, 0, 0); end;
1269 with Text do begin FColor
:= MENU_ITEMSTEXT_COLOR
; end;
1279 procedure TGUIMenu
.AddSpace
;
1293 constructor TGUIMenu
.Create(HeaderFont
, ItemsFont
: DWORD
; Header
: string);
1299 FFontID
:= ItemsFont
;
1300 FCounter
:= MENU_MARKERDELAY
;
1304 FHeader
:= TGUILabel
.Create(Header
, HeaderFont
);
1307 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1309 FColor
:= MAINMENU_HEADER_COLOR
;
1313 destructor TGUIMenu
.Destroy
;
1317 if FItems
<> nil then
1318 for a
:= 0 to High(FItems
) do
1332 procedure TGUIMenu
.Draw
;
1338 if FHeader
<> nil then FHeader
.Draw
;
1340 if FItems
<> nil then
1341 for a
:= 0 to High(FItems
) do
1343 if FItems
[a
].Text <> nil then FItems
[a
].Text.Draw
;
1344 if FItems
[a
].Control
<> nil then FItems
[a
].Control
.Draw
;
1347 if (FIndex
<> -1) and (FCounter
> MENU_MARKERDELAY
div 2) then
1352 if FItems
[FIndex
].Text <> nil then
1354 x
:= FItems
[FIndex
].Text.FX
;
1355 y
:= FItems
[FIndex
].Text.FY
;
1357 else if FItems
[FIndex
].Control
<> nil then
1359 x
:= FItems
[FIndex
].Control
.FX
;
1360 y
:= FItems
[FIndex
].Control
.FY
;
1363 x
:= x
-e_CharFont_GetMaxWidth(FFontID
);
1365 e_CharFont_PrintEx(FFontID
, x
, y
, #16, _RGB(255, 0, 0));
1369 function TGUIMenu
.GetControl(Name
: String): TGUIControl
;
1375 if FItems
<> nil then
1376 for a
:= 0 to High(FItems
) do
1377 if FItems
[a
].Control
<> nil then
1378 if LowerCase(FItems
[a
].Control
.Name
) = LowerCase(Name
) then
1380 Result
:= FItems
[a
].Control
;
1384 Assert(Result
<> nil, 'GUI control "'+Name
+'" not found!');
1387 function TGUIMenu
.GetControlsText(Name
: String): TGUILabel
;
1393 if FItems
<> nil then
1394 for a
:= 0 to High(FItems
) do
1395 if FItems
[a
].Control
<> nil then
1396 if LowerCase(FItems
[a
].Control
.Name
) = LowerCase(Name
) then
1398 Result
:= FItems
[a
].Text;
1402 Assert(Result
<> nil, 'GUI control''s text "'+Name
+'" not found!');
1405 function TGUIMenu
.NewItem
: Integer;
1407 SetLength(FItems
, Length(FItems
)+1);
1408 Result
:= High(FItems
);
1411 procedure TGUIMenu
.OnMessage(var Msg
: TMessage
);
1416 if not FEnabled
then Exit
;
1420 if FItems
= nil then Exit
;
1423 for a
:= 0 to High(FItems
) do
1424 if FItems
[a
].Control
<> nil then
1430 if not ok
then Exit
;
1441 if c
> Length(FItems
) then
1448 if FIndex
< 0 then FIndex
:= High(FItems
);
1449 until (FItems
[FIndex
].Control
<> nil) and
1450 (FItems
[FIndex
].Control
.Enabled
);
1454 g_Sound_PlayEx(MENU_CHANGESOUND
);
1462 if c
> Length(FItems
) then
1469 if FIndex
> High(FItems
) then FIndex
:= 0;
1470 until (FItems
[FIndex
].Control
<> nil) and
1471 (FItems
[FIndex
].Control
.Enabled
);
1475 g_Sound_PlayEx(MENU_CHANGESOUND
);
1478 IK_LEFT
, IK_RIGHT
, IK_KPLEFT
, IK_KPRIGHT
:
1480 if FIndex
<> -1 then
1481 if FItems
[FIndex
].Control
<> nil then
1482 FItems
[FIndex
].Control
.OnMessage(Msg
);
1484 IK_RETURN
, IK_KPRETURN
:
1486 if FIndex
<> -1 then
1488 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1490 g_Sound_PlayEx(MENU_CLICKSOUND
);
1494 if FYesNo
and (length(FItems
) > 1) then
1496 Msg
.wParam
:= IK_RETURN
; // to register keypress
1497 FIndex
:= High(FItems
)-1;
1498 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1501 if FYesNo
and (length(FItems
) > 1) then
1503 Msg
.wParam
:= IK_RETURN
; // to register keypress
1504 FIndex
:= High(FItems
);
1505 if FItems
[FIndex
].Control
<> nil then FItems
[FIndex
].Control
.OnMessage(Msg
);
1512 procedure TGUIMenu
.ReAlign();
1514 a
, tx
, cx
, w
, h
: Integer;
1516 if FItems
= nil then Exit
;
1518 if not FAlign
then tx
:= FLeft
else
1521 for a
:= 0 to High(FItems
) do
1524 if FItems
[a
].Text <> nil then w
:= FItems
[a
].Text.GetWidth
;
1525 if FItems
[a
].Control
<> nil then
1529 if FItems
[a
].ControlType
= TGUILabel
then
1530 w
:= w
+(FItems
[a
].Control
as TGUILabel
).GetWidth
1531 else if FItems
[a
].ControlType
= TGUITextButton
then
1532 w
:= w
+(FItems
[a
].Control
as TGUITextButton
).GetWidth
1533 else if FItems
[a
].ControlType
= TGUIScroll
then
1534 w
:= w
+(FItems
[a
].Control
as TGUIScroll
).GetWidth
1535 else if FItems
[a
].ControlType
= TGUISwitch
then
1536 w
:= w
+(FItems
[a
].Control
as TGUISwitch
).GetWidth
1537 else if FItems
[a
].ControlType
= TGUIEdit
then
1538 w
:= w
+(FItems
[a
].Control
as TGUIEdit
).GetWidth
1539 else if FItems
[a
].ControlType
= TGUIKeyRead
then
1540 w
:= w
+(FItems
[a
].Control
as TGUIKeyRead
).GetWidth
1541 else if (FItems
[a
].ControlType
= TGUIListBox
) then
1542 w
:= w
+(FItems
[a
].Control
as TGUIListBox
).GetWidth
1543 else if (FItems
[a
].ControlType
= TGUIFileListBox
) then
1544 w
:= w
+(FItems
[a
].Control
as TGUIFileListBox
).GetWidth
1545 else if FItems
[a
].ControlType
= TGUIMemo
then
1546 w
:= w
+(FItems
[a
].Control
as TGUIMemo
).GetWidth
;
1549 tx
:= Min(tx
, (gScreenWidth
div 2)-(w
div 2));
1554 for a
:= 0 to High(FItems
) do
1558 if (Text <> nil) and (Control
= nil) then Continue
;
1560 if Text <> nil then w
:= tx
+Text.GetWidth
;
1561 if w
> cx
then cx
:= w
;
1565 cx
:= cx
+MENU_HSPACE
;
1567 h
:= FHeader
.GetHeight
*2+MENU_VSPACE
*(Length(FItems
)-1);
1569 for a
:= 0 to High(FItems
) do
1573 if (ControlType
= TGUIListBox
) or (ControlType
= TGUIFileListBox
) then
1574 h
:= h
+(FItems
[a
].Control
as TGUIListBox
).GetHeight()
1576 h
:= h
+e_CharFont_GetMaxHeight(FFontID
);
1580 h
:= (gScreenHeight
div 2)-(h
div 2);
1584 FX
:= (gScreenWidth
div 2)-(GetWidth
div 2);
1587 Inc(h
, GetHeight
*2);
1590 for a
:= 0 to High(FItems
) do
1600 if Control
<> nil then
1613 if (ControlType
= TGUIListBox
) or (ControlType
= TGUIFileListBox
) then
1614 Inc(h
, (Control
as TGUIListBox
).GetHeight
+MENU_VSPACE
)
1615 else if ControlType
= TGUIMemo
then
1616 Inc(h
, (Control
as TGUIMemo
).GetHeight
+MENU_VSPACE
)
1618 Inc(h
, e_CharFont_GetMaxHeight(FFontID
)+MENU_VSPACE
);
1621 // another ugly hack
1622 if FYesNo
and (length(FItems
) > 1) then
1625 for a
:= High(FItems
)-1 to High(FItems
) do
1627 if (FItems
[a
].Control
<> nil) and (FItems
[a
].ControlType
= TGUITextButton
) then
1629 cx
:= (FItems
[a
].Control
as TGUITextButton
).GetWidth
;
1630 if cx
> w
then w
:= cx
;
1635 for a
:= High(FItems
)-1 to High(FItems
) do
1637 if (FItems
[a
].Control
<> nil) and (FItems
[a
].ControlType
= TGUITextButton
) then
1639 FItems
[a
].Control
.FX
:= (gScreenWidth
-w
) div 2;
1646 function TGUIMenu
.AddScroll(fText
: string): TGUIScroll
;
1653 Control
:= TGUIScroll
.Create();
1655 Text := TGUILabel
.Create(fText
, FFontID
);
1658 FColor
:= MENU_ITEMSTEXT_COLOR
;
1661 ControlType
:= TGUIScroll
;
1663 Result
:= (Control
as TGUIScroll
);
1666 if FIndex
= -1 then FIndex
:= i
;
1671 function TGUIMenu
.AddSwitch(fText
: string): TGUISwitch
;
1678 Control
:= TGUISwitch
.Create(FFontID
);
1679 (Control
as TGUISwitch
).FColor
:= MENU_ITEMSCTRL_COLOR
;
1681 Text := TGUILabel
.Create(fText
, FFontID
);
1684 FColor
:= MENU_ITEMSTEXT_COLOR
;
1687 ControlType
:= TGUISwitch
;
1689 Result
:= (Control
as TGUISwitch
);
1692 if FIndex
= -1 then FIndex
:= i
;
1697 function TGUIMenu
.AddEdit(fText
: string): TGUIEdit
;
1704 Control
:= TGUIEdit
.Create(FFontID
);
1705 with Control
as TGUIEdit
do
1707 FWindow
:= Self
.FWindow
;
1708 FColor
:= MENU_ITEMSCTRL_COLOR
;
1711 if fText
= '' then Text := nil else
1713 Text := TGUILabel
.Create(fText
, FFontID
);
1714 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1717 ControlType
:= TGUIEdit
;
1719 Result
:= (Control
as TGUIEdit
);
1722 if FIndex
= -1 then FIndex
:= i
;
1727 procedure TGUIMenu
.Update
;
1733 if FCounter
= 0 then FCounter
:= MENU_MARKERDELAY
else Dec(FCounter
);
1735 if FItems
<> nil then
1736 for a
:= 0 to High(FItems
) do
1737 if FItems
[a
].Control
<> nil then
1738 (FItems
[a
].Control
as FItems
[a
].ControlType
).Update
;
1741 function TGUIMenu
.AddKeyRead(fText
: string): TGUIKeyRead
;
1748 Control
:= TGUIKeyRead
.Create(FFontID
);
1749 with Control
as TGUIKeyRead
do
1751 FWindow
:= Self
.FWindow
;
1752 FColor
:= MENU_ITEMSCTRL_COLOR
;
1755 Text := TGUILabel
.Create(fText
, FFontID
);
1758 FColor
:= MENU_ITEMSTEXT_COLOR
;
1761 ControlType
:= TGUIKeyRead
;
1763 Result
:= (Control
as TGUIKeyRead
);
1766 if FIndex
= -1 then FIndex
:= i
;
1771 function TGUIMenu
.AddList(fText
: string; Width
, Height
: Word): TGUIListBox
;
1778 Control
:= TGUIListBox
.Create(FFontID
, Width
, Height
);
1779 with Control
as TGUIListBox
do
1781 FWindow
:= Self
.FWindow
;
1782 FActiveColor
:= MENU_ITEMSCTRL_COLOR
;
1783 FUnActiveColor
:= MENU_ITEMSTEXT_COLOR
;
1786 Text := TGUILabel
.Create(fText
, FFontID
);
1789 FColor
:= MENU_ITEMSTEXT_COLOR
;
1792 ControlType
:= TGUIListBox
;
1794 Result
:= (Control
as TGUIListBox
);
1797 if FIndex
= -1 then FIndex
:= i
;
1802 function TGUIMenu
.AddFileList(fText
: string; Width
, Height
: Word): TGUIFileListBox
;
1809 Control
:= TGUIFileListBox
.Create(FFontID
, Width
, Height
);
1810 with Control
as TGUIFileListBox
do
1812 FWindow
:= Self
.FWindow
;
1813 FActiveColor
:= MENU_ITEMSCTRL_COLOR
;
1814 FUnActiveColor
:= MENU_ITEMSTEXT_COLOR
;
1817 if fText
= '' then Text := nil else
1819 Text := TGUILabel
.Create(fText
, FFontID
);
1820 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1823 ControlType
:= TGUIFileListBox
;
1825 Result
:= (Control
as TGUIFileListBox
);
1828 if FIndex
= -1 then FIndex
:= i
;
1833 function TGUIMenu
.AddLabel(fText
: string): TGUILabel
;
1840 Control
:= TGUILabel
.Create('', FFontID
);
1841 with Control
as TGUILabel
do
1843 FWindow
:= Self
.FWindow
;
1844 FColor
:= MENU_ITEMSCTRL_COLOR
;
1847 Text := TGUILabel
.Create(fText
, FFontID
);
1850 FColor
:= MENU_ITEMSTEXT_COLOR
;
1853 ControlType
:= TGUILabel
;
1855 Result
:= (Control
as TGUILabel
);
1858 if FIndex
= -1 then FIndex
:= i
;
1863 function TGUIMenu
.AddMemo(fText
: string; Width
, Height
: Word): TGUIMemo
;
1870 Control
:= TGUIMemo
.Create(FFontID
, Width
, Height
);
1871 with Control
as TGUIMemo
do
1873 FWindow
:= Self
.FWindow
;
1874 FColor
:= MENU_ITEMSTEXT_COLOR
;
1877 if fText
= '' then Text := nil else
1879 Text := TGUILabel
.Create(fText
, FFontID
);
1880 Text.FColor
:= MENU_ITEMSTEXT_COLOR
;
1883 ControlType
:= TGUIMemo
;
1885 Result
:= (Control
as TGUIMemo
);
1888 if FIndex
= -1 then FIndex
:= i
;
1893 procedure TGUIMenu
.UpdateIndex();
1901 if (FIndex
< 0) or (FIndex
> High(FItems
)) then
1907 if FItems
[FIndex
].Control
.Enabled
then
1916 constructor TGUIScroll
.Create
;
1921 FOnChangeEvent
:= nil;
1923 g_Texture_Get(SCROLL_LEFT
, FLeftID
);
1924 g_Texture_Get(SCROLL_RIGHT
, FRightID
);
1925 g_Texture_Get(SCROLL_MIDDLE
, FMiddleID
);
1926 g_Texture_Get(SCROLL_MARKER
, FMarkerID
);
1929 procedure TGUIScroll
.Draw
;
1935 e_Draw(FLeftID
, FX
, FY
, 0, True, False);
1936 e_Draw(FRightID
, FX
+8+(FMax
+1)*8, FY
, 0, True, False);
1938 for a
:= 0 to FMax
do
1939 e_Draw(FMiddleID
, FX
+8+a
*8, FY
, 0, True, False);
1941 e_Draw(FMarkerID
, FX
+8+FValue
*8, FY
, 0, True, False);
1944 procedure TGUIScroll
.FSetValue(a
: Integer);
1946 if a
> FMax
then FValue
:= FMax
else FValue
:= a
;
1949 function TGUIScroll
.GetWidth
: Word;
1951 Result
:= 16+(FMax
+1)*8;
1954 procedure TGUIScroll
.OnMessage(var Msg
: TMessage
);
1956 if not FEnabled
then Exit
;
1968 g_Sound_PlayEx(SCROLL_SUBSOUND
);
1969 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
1971 IK_RIGHT
, IK_KPRIGHT
:
1972 if FValue
< FMax
then
1975 g_Sound_PlayEx(SCROLL_ADDSOUND
);
1976 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
1983 procedure TGUIScroll
.Update
;
1991 procedure TGUISwitch
.AddItem(Item
: string);
1993 SetLength(FItems
, Length(FItems
)+1);
1994 FItems
[High(FItems
)] := Item
;
1996 if FIndex
= -1 then FIndex
:= 0;
1999 constructor TGUISwitch
.Create(FontID
: DWORD
);
2005 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
2008 procedure TGUISwitch
.Draw
;
2012 FFont
.Draw(FX
, FY
, FItems
[FIndex
], FColor
.R
, FColor
.G
, FColor
.B
);
2015 function TGUISwitch
.GetText
: string;
2017 if FIndex
<> -1 then Result
:= FItems
[FIndex
]
2021 function TGUISwitch
.GetWidth
: Word;
2028 if FItems
= nil then Exit
;
2030 for a
:= 0 to High(FItems
) do
2032 FFont
.GetTextSize(FItems
[a
], w
, h
);
2033 if w
> Result
then Result
:= w
;
2037 procedure TGUISwitch
.OnMessage(var Msg
: TMessage
);
2039 if not FEnabled
then Exit
;
2043 if FItems
= nil then Exit
;
2048 IK_RETURN
, IK_RIGHT
, IK_KPRETURN
, IK_KPRIGHT
:
2050 if FIndex
< High(FItems
) then
2055 if @FOnChangeEvent
<> nil then
2056 FOnChangeEvent(Self
);
2064 FIndex
:= High(FItems
);
2066 if @FOnChangeEvent
<> nil then
2067 FOnChangeEvent(Self
);
2073 procedure TGUISwitch
.Update
;
2081 constructor TGUIEdit
.Create(FontID
: DWORD
);
2085 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
2090 g_Texture_Get(EDIT_LEFT
, FLeftID
);
2091 g_Texture_Get(EDIT_RIGHT
, FRightID
);
2092 g_Texture_Get(EDIT_MIDDLE
, FMiddleID
);
2095 procedure TGUIEdit
.Draw
;
2101 e_Draw(FLeftID
, FX
, FY
, 0, True, False);
2102 e_Draw(FRightID
, FX
+8+FWidth
*16, FY
, 0, True, False);
2104 for c
:= 0 to FWidth
-1 do
2105 e_Draw(FMiddleID
, FX
+8+c
*16, FY
, 0, True, False);
2107 FFont
.Draw(FX
+8, FY
, FText
, FColor
.R
, FColor
.G
, FColor
.B
);
2109 if FWindow
.FActiveControl
= Self
then
2111 FFont
.GetTextSize(Copy(FText
, 1, FCaretPos
), w
, h
);
2112 h
:= e_CharFont_GetMaxHeight(FFont
.ID
);
2113 e_DrawLine(2, FX
+8+w
, FY
+h
-3, FX
+8+w
+EDIT_CURSORLEN
, FY
+h
-3,
2114 EDIT_CURSORCOLOR
.R
, EDIT_CURSORCOLOR
.G
, EDIT_CURSORCOLOR
.B
);
2118 function TGUIEdit
.GetWidth
: Word;
2120 Result
:= 16+FWidth
*16;
2123 procedure TGUIEdit
.OnMessage(var Msg
: TMessage
);
2125 if not FEnabled
then Exit
;
2134 if (wParam
in [48..57]) and (Chr(wParam
) <> '`') then
2135 if Length(Text) < FMaxLength
then
2137 Insert(Chr(wParam
), FText
, FCaretPos
+ 1);
2143 if (wParam
in [32..255]) and (Chr(wParam
) <> '`') then
2144 if Length(Text) < FMaxLength
then
2146 Insert(Chr(wParam
), FText
, FCaretPos
+ 1);
2154 Delete(FText
, FCaretPos
, 1);
2155 if FCaretPos
> 0 then Dec(FCaretPos
);
2157 IK_DELETE
: Delete(FText
, FCaretPos
+ 1, 1);
2158 IK_END
, IK_KPEND
: FCaretPos
:= Length(FText
);
2159 IK_HOME
, IK_KPHOME
: FCaretPos
:= 0;
2160 IK_LEFT
, IK_KPLEFT
: if FCaretPos
> 0 then Dec(FCaretPos
);
2161 IK_RIGHT
, IK_KPRIGHT
: if FCaretPos
< Length(FText
) then Inc(FCaretPos
);
2162 IK_RETURN
, IK_KPRETURN
:
2165 if FActiveControl
<> Self
then
2168 if @FOnEnterEvent
<> nil then FOnEnterEvent(Self
);
2172 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
2173 else SetActive(nil);
2174 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2181 procedure TGUIEdit
.SetText(Text: string);
2183 if Length(Text) > FMaxLength
then SetLength(Text, FMaxLength
);
2185 FCaretPos
:= Length(FText
);
2188 procedure TGUIEdit
.Update
;
2195 constructor TGUIKeyRead
.Create(FontID
: DWORD
);
2199 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
2202 procedure TGUIKeyRead
.Draw
;
2206 FFont
.Draw(FX
, FY
, IfThen(FIsQuery
, KEYREAD_QUERY
, IfThen(FKey
<> 0, e_KeyNames
[FKey
], KEYREAD_CLEAR
)),
2207 FColor
.R
, FColor
.G
, FColor
.B
);
2210 function TGUIKeyRead
.GetWidth
: Word;
2217 for a
:= 0 to 255 do
2219 FFont
.GetTextSize(e_KeyNames
[a
], w
, h
);
2220 Result
:= Max(Result
, w
);
2223 FFont
.GetTextSize(KEYREAD_QUERY
, w
, h
);
2224 if w
> Result
then Result
:= w
;
2226 FFont
.GetTextSize(KEYREAD_CLEAR
, w
, h
);
2227 if w
> Result
then Result
:= w
;
2230 procedure TGUIKeyRead
.OnMessage(var Msg
: TMessage
);
2234 if not FEnabled
then
2245 if FDefControl
<> '' then
2246 SetActive(GetControl(FDefControl
))
2252 IK_RETURN
, IK_KPRETURN
:
2254 if not FIsQuery
then
2257 if FActiveControl
<> Self
then
2264 FKey
:= IK_ENTER
; // <Enter>
2268 if FDefControl
<> '' then
2269 SetActive(GetControl(FDefControl
))
2277 if FIsQuery
and (wParam
<> IK_ENTER
) and (wParam
<> IK_KPRETURN
) then // Not <Enter
2279 if e_KeyNames
[wParam
] <> '' then
2284 if FDefControl
<> '' then
2285 SetActive(GetControl(FDefControl
))
2294 constructor TGUIModelView
.Create
;
2301 destructor TGUIModelView
.Destroy
;
2308 procedure TGUIModelView
.Draw
;
2312 DrawBox(FX
, FY
, 4, 4);
2314 if FModel
<> nil then FModel
.Draw(FX
+4, FY
+4);
2317 procedure TGUIModelView
.NextAnim();
2319 if FModel
= nil then
2322 if FModel
.Animation
< A_PAIN
then
2323 FModel
.ChangeAnimation(FModel
.Animation
+1, True)
2325 FModel
.ChangeAnimation(A_STAND
, True);
2328 procedure TGUIModelView
.NextWeapon();
2330 if FModel
= nil then
2333 if FModel
.Weapon
< WEAPON_SUPERPULEMET
then
2334 FModel
.SetWeapon(FModel
.Weapon
+1)
2336 FModel
.SetWeapon(WEAPON_KASTET
);
2339 procedure TGUIModelView
.OnMessage(var Msg
: TMessage
);
2345 procedure TGUIModelView
.SetColor(Red
, Green
, Blue
: Byte);
2347 if FModel
<> nil then FModel
.SetColor(Red
, Green
, Blue
);
2350 procedure TGUIModelView
.SetModel(ModelName
: string);
2354 FModel
:= g_PlayerModel_Get(ModelName
);
2357 procedure TGUIModelView
.Update
;
2364 if FModel
<> nil then FModel
.Update
;
2369 constructor TGUIMapPreview
.Create();
2375 destructor TGUIMapPreview
.Destroy();
2381 procedure TGUIMapPreview
.Draw();
2388 DrawBox(FX
, FY
, MAPPREVIEW_WIDTH
, MAPPREVIEW_HEIGHT
);
2390 if (FMapSize
.X
<= 0) or (FMapSize
.Y
<= 0) then
2393 e_DrawFillQuad(FX
+4, FY
+4,
2394 FX
+4 + Trunc(FMapSize
.X
/ FScale
) - 1,
2395 FY
+4 + Trunc(FMapSize
.Y
/ FScale
) - 1,
2398 if FMapData
<> nil then
2399 for a
:= 0 to High(FMapData
) do
2402 if X1
> MAPPREVIEW_WIDTH
*16 then Continue
;
2403 if Y1
> MAPPREVIEW_HEIGHT
*16 then Continue
;
2405 if X2
< 0 then Continue
;
2406 if Y2
< 0 then Continue
;
2408 if X2
> MAPPREVIEW_WIDTH
*16 then X2
:= MAPPREVIEW_WIDTH
*16;
2409 if Y2
> MAPPREVIEW_HEIGHT
*16 then Y2
:= MAPPREVIEW_HEIGHT
*16;
2411 if X1
< 0 then X1
:= 0;
2412 if Y1
< 0 then Y1
:= 0;
2453 if ((X2
-X1
) > 0) and ((Y2
-Y1
) > 0) then
2454 e_DrawFillQuad(FX
+4 + X1
, FY
+4 + Y1
,
2455 FX
+4 + X2
- 1, FY
+4 + Y2
- 1, r
, g
, b
, 0);
2459 procedure TGUIMapPreview
.OnMessage(var Msg
: TMessage
);
2465 procedure TGUIMapPreview
.SetMap(Res
: string);
2468 MapReader
: TMapReader_1
;
2469 panels
: TPanelsRec1Array
;
2470 header
: TMapHeaderRec_1
;
2472 FileName
, SectionName
, ResName
: string;
2477 g_ProcessResourceStr(Res
, FileName
, SectionName
, ResName
);
2479 WAD
:= TWADFile
.Create();
2480 if not WAD
.ReadFile(FileName
) then
2486 if not WAD
.GetResource('', ResName
, Data
, Len
) then
2494 MapReader
:= TMapReader_1
.Create();
2496 if not MapReader
.LoadMap(Data
) then
2509 panels
:= MapReader
.GetPanels();
2510 header
:= MapReader
.GetMapHeader();
2512 FMapSize
.X
:= header
.Width
div 16;
2513 FMapSize
.Y
:= header
.Height
div 16;
2515 rX
:= Ceil(header
.Width
/ (MAPPREVIEW_WIDTH
*256.0));
2516 rY
:= Ceil(header
.Height
/ (MAPPREVIEW_HEIGHT
*256.0));
2517 FScale
:= max(rX
, rY
);
2521 if panels
<> nil then
2522 for a
:= 0 to High(panels
) do
2523 if WordBool(panels
[a
].PanelType
and (PANEL_WALL
or PANEL_CLOSEDOOR
or
2524 PANEL_STEP
or PANEL_WATER
or
2525 PANEL_ACID1
or PANEL_ACID2
)) then
2527 SetLength(FMapData
, Length(FMapData
)+1);
2528 with FMapData
[High(FMapData
)] do
2530 X1
:= panels
[a
].X
div 16;
2531 Y1
:= panels
[a
].Y
div 16;
2533 X2
:= (panels
[a
].X
+ panels
[a
].Width
) div 16;
2534 Y2
:= (panels
[a
].Y
+ panels
[a
].Height
) div 16;
2536 X1
:= Trunc(X1
/FScale
+ 0.5);
2537 Y1
:= Trunc(Y1
/FScale
+ 0.5);
2538 X2
:= Trunc(X2
/FScale
+ 0.5);
2539 Y2
:= Trunc(Y2
/FScale
+ 0.5);
2541 if (X1
<> X2
) or (Y1
<> Y2
) then
2549 PanelType
:= panels
[a
].PanelType
;
2558 procedure TGUIMapPreview
.ClearMap();
2560 SetLength(FMapData
, 0);
2567 procedure TGUIMapPreview
.Update();
2573 function TGUIMapPreview
.GetScaleStr(): String;
2575 if FScale
> 0.0 then
2577 Result
:= FloatToStrF(FScale
*16.0, ffFixed
, 3, 3);
2578 while (Result
[Length(Result
)] = '0') do
2579 Delete(Result
, Length(Result
), 1);
2580 if (Result
[Length(Result
)] = ',') or (Result
[Length(Result
)] = '.') then
2581 Delete(Result
, Length(Result
), 1);
2582 Result
:= '1 : ' + Result
;
2590 procedure TGUIListBox
.AddItem(Item
: string);
2592 SetLength(FItems
, Length(FItems
)+1);
2593 FItems
[High(FItems
)] := Item
;
2595 if FSort
then g_Basic
.Sort(FItems
);
2598 procedure TGUIListBox
.Clear();
2606 constructor TGUIListBox
.Create(FontID
: DWORD
; Width
, Height
: Word);
2610 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
2615 FOnChangeEvent
:= nil;
2617 FDrawScroll
:= True;
2620 procedure TGUIListBox
.Draw
;
2628 if FDrawBack
then DrawBox(FX
, FY
, FWidth
+1, FHeight
);
2630 DrawScroll(FX
+4+FWidth
*16, FY
+4, FHeight
, (FStartLine
> 0) and (FItems
<> nil),
2631 (FStartLine
+FHeight
-1 < High(FItems
)) and (FItems
<> nil));
2633 if FItems
<> nil then
2634 for a
:= FStartLine
to Min(High(FItems
), FStartLine
+FHeight
-1) do
2638 FFont
.GetTextSize(s
, w2
, h2
);
2639 while (Length(s
) > 0) and (w2
> FWidth
*16) do
2641 SetLength(s
, Length(s
)-1);
2642 FFont
.GetTextSize(s
, w2
, h2
);
2646 FFont
.Draw(FX
+4, FY
+4+(a
-FStartLine
)*16, s
, FActiveColor
.R
, FActiveColor
.G
, FActiveColor
.B
)
2648 FFont
.Draw(FX
+4, FY
+4+(a
-FStartLine
)*16, s
, FUnActiveColor
.R
, FUnActiveColor
.G
, FUnActiveColor
.B
);
2652 function TGUIListBox
.GetHeight
: Word;
2654 Result
:= 8+FHeight
*16;
2657 function TGUIListBox
.GetWidth
: Word;
2659 Result
:= 8+(FWidth
+1)*16;
2662 procedure TGUIListBox
.OnMessage(var Msg
: TMessage
);
2666 if not FEnabled
then Exit
;
2670 if FItems
= nil then Exit
;
2683 FIndex
:= High(FItems
);
2684 FStartLine
:= Max(High(FItems
)-FHeight
+1, 0);
2686 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
:
2690 if FIndex
< FStartLine
then Dec(FStartLine
);
2691 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2693 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
:
2694 if FIndex
< High(FItems
) then
2697 if FIndex
> FStartLine
+FHeight
-1 then Inc(FStartLine
);
2698 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2700 IK_RETURN
, IK_KPRETURN
:
2703 if FActiveControl
<> Self
then SetActive(Self
)
2705 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
2706 else SetActive(nil);
2710 for a
:= 0 to High(FItems
) do
2711 if (Length(FItems
[a
]) > 0) and (LowerCase(FItems
[a
][1]) = LowerCase(Chr(wParam
))) then
2714 FStartLine
:= Min(Max(FIndex
-1, 0), Length(FItems
)-FHeight
);
2715 if @FOnChangeEvent
<> nil then FOnChangeEvent(Self
);
2721 function TGUIListBox
.SelectedItem(): String;
2725 if (FIndex
< 0) or (FItems
= nil) or
2726 (FIndex
> High(FItems
)) then
2729 Result
:= FItems
[FIndex
];
2732 procedure TGUIListBox
.FSetItems(Items
: SArray
);
2734 if FItems
<> nil then
2742 if FSort
then g_Basic
.Sort(FItems
);
2745 procedure TGUIListBox
.SelectItem(Item
: String);
2749 if FItems
= nil then
2753 Item
:= LowerCase(Item
);
2755 for a
:= 0 to High(FItems
) do
2756 if LowerCase(FItems
[a
]) = Item
then
2762 if FIndex
< FHeight
then
2765 FStartLine
:= Min(FIndex
, Length(FItems
)-FHeight
);
2768 procedure TGUIListBox
.FSetIndex(aIndex
: Integer);
2770 if FItems
= nil then
2773 if (aIndex
< 0) or (aIndex
> High(FItems
)) then
2778 if FIndex
<= FHeight
then
2781 FStartLine
:= Min(FIndex
, Length(FItems
)-FHeight
);
2786 procedure TGUIFileListBox
.OnMessage(var Msg
: TMessage
);
2790 if not FEnabled
then
2793 if FItems
= nil then
2804 if @FOnChangeEvent
<> nil then
2805 FOnChangeEvent(Self
);
2810 FIndex
:= High(FItems
);
2811 FStartLine
:= Max(High(FItems
)-FHeight
+1, 0);
2812 if @FOnChangeEvent
<> nil then
2813 FOnChangeEvent(Self
);
2816 IK_PAGEUP
, IK_KPPAGEUP
:
2818 if FIndex
> FHeight
then
2819 FIndex
:= FIndex
-FHeight
2823 if FStartLine
> FHeight
then
2824 FStartLine
:= FStartLine
-FHeight
2829 IK_PAGEDN
, IK_KPPAGEDN
:
2831 if FIndex
< High(FItems
)-FHeight
then
2832 FIndex
:= FIndex
+FHeight
2834 FIndex
:= High(FItems
);
2836 if FStartLine
< High(FItems
)-FHeight
then
2837 FStartLine
:= FStartLine
+FHeight
2839 FStartLine
:= High(FItems
)-FHeight
+1;
2842 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
:
2846 if FIndex
< FStartLine
then
2848 if @FOnChangeEvent
<> nil then
2849 FOnChangeEvent(Self
);
2852 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
:
2853 if FIndex
< High(FItems
) then
2856 if FIndex
> FStartLine
+FHeight
-1 then
2858 if @FOnChangeEvent
<> nil then
2859 FOnChangeEvent(Self
);
2862 IK_RETURN
, IK_KPRETURN
:
2865 if FActiveControl
<> Self
then
2869 if FItems
[FIndex
][1] = #29 then // Ïàïêà
2871 OpenDir(FPath
+Copy(FItems
[FIndex
], 2, 255));
2876 if FDefControl
<> '' then
2877 SetActive(GetControl(FDefControl
))
2885 for a
:= 0 to High(FItems
) do
2886 if ( (Length(FItems
[a
]) > 0) and
2887 (LowerCase(FItems
[a
][1]) = LowerCase(Chr(wParam
))) ) or
2888 ( (Length(FItems
[a
]) > 1) and
2889 (FItems
[a
][1] = #29) and // Ïàïêà
2890 (LowerCase(FItems
[a
][2]) = LowerCase(Chr(wParam
))) ) then
2893 FStartLine
:= Min(Max(FIndex
-1, 0), Length(FItems
)-FHeight
);
2894 if @FOnChangeEvent
<> nil then
2895 FOnChangeEvent(Self
);
2901 procedure TGUIFileListBox
.OpenDir(path
: String);
2909 path
:= IncludeTrailingPathDelimiter(path
);
2910 path
:= ExpandFileName(path
);
2915 if FindFirst(path
+'*', faDirectory
, SR
) = 0 then
2917 if not LongBool(SR
.Attr
and faDirectory
) then
2919 if (SR
.Name
= '.') or
2920 ((SR
.Name
= '..') and (path
= ExpandFileName(FBasePath
))) then
2923 AddItem(#1 + SR
.Name
);
2924 until FindNext(SR
) <> 0;
2934 if i
= 0 then i
:= length(sm
)+1;
2935 sc
:= Copy(sm
, 1, i
-1);
2937 if FindFirst(path
+sc
, faAnyFile
, SR
) = 0 then repeat AddItem(SR
.Name
); until FindNext(SR
) <> 0;
2941 for i
:= 0 to High(FItems
) do
2942 if FItems
[i
][1] = #1 then
2943 FItems
[i
][1] := #29;
2948 procedure TGUIFileListBox
.SetBase(path
: String);
2954 function TGUIFileListBox
.SelectedItem(): String;
2958 if (FIndex
= -1) or (FItems
= nil) or
2959 (FIndex
> High(FItems
)) or
2960 (FItems
[FIndex
][1] = '/') or
2961 (FItems
[FIndex
][1] = '\') then
2964 Result
:= FPath
+ FItems
[FIndex
];
2967 procedure TGUIFileListBox
.UpdateFileList();
2971 if (FIndex
= -1) or (FItems
= nil) or
2972 (FIndex
> High(FItems
)) or
2973 (FItems
[FIndex
][1] = '/') or
2974 (FItems
[FIndex
][1] = '\') then
2977 fn
:= FItems
[FIndex
];
2987 procedure TGUIMemo
.Clear
;
2993 constructor TGUIMemo
.Create(FontID
: DWORD
; Width
, Height
: Word);
2997 FFont
:= TFont
.Create(FontID
, FONT_CHAR
);
3002 FDrawScroll
:= True;
3005 procedure TGUIMemo
.Draw
;
3011 if FDrawBack
then DrawBox(FX
, FY
, FWidth
+1, FHeight
);
3013 DrawScroll(FX
+4+FWidth
*16, FY
+4, FHeight
, (FStartLine
> 0) and (FLines
<> nil),
3014 (FStartLine
+FHeight
-1 < High(FLines
)) and (FLines
<> nil));
3016 if FLines
<> nil then
3017 for a
:= FStartLine
to Min(High(FLines
), FStartLine
+FHeight
-1) do
3018 FFont
.Draw(FX
+4, FY
+4+(a
-FStartLine
)*16, FLines
[a
], FColor
.R
, FColor
.G
, FColor
.B
);
3021 function TGUIMemo
.GetHeight
: Word;
3023 Result
:= 8+FHeight
*16;
3026 function TGUIMemo
.GetWidth
: Word;
3028 Result
:= 8+(FWidth
+1)*16;
3031 procedure TGUIMemo
.OnMessage(var Msg
: TMessage
);
3033 if not FEnabled
then Exit
;
3037 if FLines
= nil then Exit
;
3043 IK_UP
, IK_LEFT
, IK_KPUP
, IK_KPLEFT
:
3044 if FStartLine
> 0 then
3046 IK_DOWN
, IK_RIGHT
, IK_KPDOWN
, IK_KPRIGHT
:
3047 if FStartLine
< Length(FLines
)-FHeight
then
3049 IK_RETURN
, IK_KPRETURN
:
3052 if FActiveControl
<> Self
then
3058 if FDefControl
<> '' then SetActive(GetControl(FDefControl
))
3059 else SetActive(nil);
3065 procedure TGUIMemo
.SetText(Text: string);
3068 FLines
:= GetLines(Text, FFont
.ID
, FWidth
*16);
3073 procedure TGUIimage
.ClearImage();
3075 if FImageRes
= '' then Exit
;
3077 g_Texture_Delete(FImageRes
);
3081 constructor TGUIimage
.Create();
3088 destructor TGUIimage
.Destroy();
3093 procedure TGUIimage
.Draw();
3099 if FImageRes
= '' then
3101 if g_Texture_Get(FDefaultRes
, ID
) then e_Draw(ID
, FX
, FY
, 0, True, False);
3104 if g_Texture_Get(FImageRes
, ID
) then e_Draw(ID
, FX
, FY
, 0, True, False);
3107 procedure TGUIimage
.OnMessage(var Msg
: TMessage
);
3112 procedure TGUIimage
.SetImage(Res
: string);
3116 if g_Texture_CreateWADEx(Res
, Res
) then FImageRes
:= Res
;
3119 procedure TGUIimage
.Update();