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}
25 procedure r_GUI_GetSize (ctrl
: TGUIControl
; out w
, h
: Integer);
26 procedure r_GUI_GetLogoSize (out w
, h
: Integer);
27 procedure r_GUI_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
28 procedure r_GUI_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
30 procedure r_GUI_Draw_Window (win
: TGUIWindow
);
35 Classes
, Math
, SysUtils
,
37 g_basic
, g_base
, e_input
, g_options
,
38 r_draw
, r_textures
, r_common
, r_map
,
46 Box
: Array [0..8] of TGLTexture
;
47 MarkerID
: array [Boolean] of TGLTexture
;
48 ScrollLeft
, ScrollRight
, ScrollMiddle
, ScrollMarker
: TGLTexture
;
49 EditLeft
, EditRight
, EditMiddle
: TGLTexture
;
50 BScrollUp
, BScrollDown
: array [Boolean] of TGLTexture
;
51 BScrollMiddle
: TGLTexture
;
53 Font
: array [boolean] of TGLFont
; (* Small[FALSE] / Big[TRUE] *)
57 Background
: THereTexture
;
58 ImageControl
: THereTexture
;
63 Font
[FALSE] := smallfont
;
64 Font
[TRUE] := menufont
;
66 r_Common_SetLoading('GUI', 2 + 9 + 14);
68 MarkerID
[FALSE] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/MARKER1', [TGLHints
.txNoRepeat
]);
69 MarkerID
[TRUE] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/MARKER2', [TGLHints
.txNoRepeat
]);
72 Box
[i
] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/BOX' + IntToStr(i
+ 1), []); // !!!
74 ScrollLeft
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SLEFT', [TGLHints
.txNoRepeat
]);
75 ScrollRight
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SRIGHT', [TGLHints
.txNoRepeat
]);
76 ScrollMiddle
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SMIDDLE', []);
77 ScrollMarker
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SMARKER', [TGLHints
.txNoRepeat
]);
79 EditLeft
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/ELEFT', [TGLHints
.txNoRepeat
]);
80 EditRight
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/ERIGHT', [TGLHints
.txNoRepeat
]);
81 EditMiddle
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/EMIDDLE', []);
83 BScrollUp
[true] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SCROLLUPA', [TGLHints
.txNoRepeat
]);
84 BScrollUp
[false] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SCROLLUPU', [TGLHints
.txNoRepeat
]);
85 BScrollDown
[true] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SCROLLDOWNA', [TGLHints
.txNoRepeat
]);
86 BScrollDown
[false] := r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SCROLLDOWNU', [TGLHints
.txNoRepeat
]);
87 BScrollMiddle
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/SCROLLMIDDLE', []);
89 LogoTex
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/MAINLOGO', [TGLHints
.txNoRepeat
]);
90 nopic
:= r_Common_LoadTextureFromFile(GameWad
+ ':TEXTURES/NOPIC', [TGLHints
.txNoRepeat
]);
99 r_Common_FreeAndNil(MarkerID
[FALSE]);
100 r_Common_FreeAndNil(MarkerID
[TRUE]);
103 r_Common_FreeAndNil(Box
[i
]);
105 r_Common_FreeAndNil(ScrollLeft
);
106 r_Common_FreeAndNil(ScrollRight
);
107 r_Common_FreeAndNil(ScrollMiddle
);
108 r_Common_FreeAndNil(ScrollMarker
);
110 r_Common_FreeAndNil(EditLeft
);
111 r_Common_FreeAndNil(EditRight
);
112 r_Common_FreeAndNil(EditMiddle
);
114 r_Common_FreeAndNil(BScrollUp
[true]);
115 r_Common_FreeAndNil(BScrollUp
[false]);
116 r_Common_FreeAndNil(BScrollDown
[true]);
117 r_Common_FreeAndNil(BScrollDown
[false]);
118 r_Common_FreeAndNil(BScrollMiddle
);
120 r_Common_FreeAndNil(LogoTex
);
121 r_Common_FreeAndNil(nopic
);
123 r_Common_FreeThis(Background
);
124 r_Common_FreeThis(ImageControl
);
127 procedure r_GUI_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
131 w
:= f
.GetMaxWidth();
132 h
:= f
.GetMaxHeight();
135 procedure r_GUI_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
137 r_Draw_GetTextSize(str
, Font
[BigFont
], w
, h
);
140 procedure r_GUI_GetLogoSize (out w
, h
: Integer);
143 if LogoTex
<> nil then
150 procedure r_GUI_GetSize_TextButton (ctrl
: TGUITextButton
; out w
, h
: Integer);
152 r_Draw_GetTextSize(ctrl
.Caption
, Font
[ctrl
.BigFont
], w
, h
);
155 procedure r_GUI_GetSize_Label (ctrl
: TGUILabel
; out w
, h
: Integer);
158 f
:= Font
[ctrl
.BigFont
];
159 r_Draw_GetTextSize(ctrl
.Text, f
, w
, h
);
160 if ctrl
.FixedLength
<> 0 then
161 w
:= f
.GetMaxWidth() * ctrl
.FixedLength
;
164 procedure r_GUI_GetSize_Switch (ctrl
: TGUISwitch
; out w
, h
: Integer);
168 if ctrl
.Items
<> nil then
169 for i
:= 0 to High(ctrl
.Items
) do
170 r_Draw_GetTextSize(ctrl
.Items
[i
], Font
[ctrl
.BigFont
], w
, h
);
173 procedure r_GUI_GetSize_KeyRead (ctrl
: TGUIKeyRead
; out w
, h
: Integer);
174 var i
, ww
, hh
: Integer; f
: TGLFont
;
176 w
:= 0; h
:= 0; // ??? h always 0
177 f
:= Font
[ctrl
.BigFont
];
180 r_Draw_GetTextSize(e_KeyNames
[i
], f
, ww
, hh
);
183 r_Draw_GetTextSize(KEYREAD_QUERY
, f
, ww
, hh
);
185 r_Draw_GetTextSize(KEYREAD_CLEAR
, f
, ww
, hh
);
189 procedure r_GUI_GetSize (ctrl
: TGUIControl
; out w
, h
: Integer);
193 if ctrl
is TGUITextButton
then
194 r_GUI_GetSize_TextButton(ctrl
as TGUITextButton
, w
, h
)
195 else if ctrl
is TGUILabel
then
196 r_GUI_GetSize_Label(ctrl
as TGUILabel
, w
, h
)
197 else if ctrl
is TGUIScroll
then
198 w
:= 16 + ((ctrl
as TGUIScroll
).Max
+ 1) * 8 // ??? but h = 0
199 else if ctrl
is TGUISwitch
then
200 r_GUI_GetSize_Switch(ctrl
as TGUISwitch
, w
, h
)
201 else if ctrl
is TGUIEdit
then
202 w
:= 16 + (ctrl
as TGUIEdit
).Width
* 16 // ??? but h = 0
203 else if ctrl
is TGUIKeyRead
then
204 r_GUI_GetSize_KeyRead(ctrl
as TGUIKeyRead
, w
, h
)
205 else if ctrl
is TGUIKeyRead2
then
206 w
:= (ctrl
as TGUIKeyRead2
).MaxKeyNameWdt
* 2 + 8 + 8 + 16 // ??? but h = 0
207 else if ctrl
is TGUIListBox
then
209 w
:= 8 + ((ctrl
as TGUIListBox
).Width
+ 1) * 16; // recheck w & h
210 h
:= 8 + (ctrl
as TGUIListBox
).Height
* 16;
212 else if ctrl
is TGUIMemo
then
214 w
:= 8 + ((ctrl
as TGUIMemo
).Width
+ 1) * 16;
215 h
:= 8 + (ctrl
as TGUIMemo
).Height
* 16;
219 w
:= ctrl
.GetWidth();
220 h
:= ctrl
.GetHeight();
224 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
); forward;
226 procedure r_GUI_Draw_TextButton (ctrl
: TGUITextButton
);
228 r_Draw_Text(ctrl
.Caption
, ctrl
.x
, ctrl
.y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
231 procedure r_GUI_Draw_Label (ctrl
: TGUILabel
);
232 var w
, h
: Integer; f
: TGLFont
;
234 f
:= Font
[ctrl
.BigFont
];
235 if ctrl
.RightAlign
then
237 r_Draw_GetTextSize(ctrl
.Text, f
, w
, h
);
238 r_Draw_Text(ctrl
.Text, ctrl
.X
+ ctrl
.CMaxWidth
- w
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, f
);
241 r_Draw_Text(ctrl
.Text, ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, f
);
244 procedure r_GUI_Draw_Scroll (ctrl
: TGUIScroll
);
246 r_Draw_Texture(ScrollLeft
, ctrl
.X
, ctrl
.Y
, ScrollLeft
.width
, ScrollLeft
.height
, false, 255, 255, 255, 255, false);
247 r_Draw_TextureRepeat(ScrollMiddle
, ctrl
.X
+ 8 + 0 * 8, ctrl
.Y
, 8 + ctrl
.Max
* 8, ScrollMiddle
.height
, false, 255, 255, 255, 255, false);
248 r_Draw_Texture(ScrollRight
, ctrl
.X
+ 8 + (ctrl
.Max
+ 1) * 8, ctrl
.Y
, ScrollRight
.width
, ScrollRight
.height
, false, 255, 255, 255, 255, false);
249 r_Draw_Texture(ScrollMarker
, ctrl
.X
+ 8 + ctrl
.Value
* 8, ctrl
.Y
, ScrollMarker
.width
, ScrollMarker
.height
, false, 255, 255, 255, 255, false);
252 procedure r_GUI_Draw_Switch (ctrl
: TGUISwitch
);
254 r_Draw_Text(ctrl
.Items
[ctrl
.ItemIndex
], ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
257 procedure r_GUI_Draw_Edit (ctrl
: TGUIEdit
);
258 var w
, h
: Integer; r
, g
, b
: Byte; f
: TGLFont
;
260 r_Draw_Texture(EditLeft
, ctrl
.X
, ctrl
.Y
, EditLeft
.width
, EditLeft
.height
, false, 255, 255, 255, 255, false);
261 r_Draw_TextureRepeat(EditMiddle
, ctrl
.X
+ 8, ctrl
.Y
, 8 + ctrl
.Width
* 16, EditMiddle
.height
, false, 255, 255, 255, 255, false);
262 r_Draw_Texture(EditRight
, ctrl
.X
+ 8 + ctrl
.Width
* 16, ctrl
.Y
, EditRight
.width
, EditRight
.height
, false, 255, 255, 255, 255, false);
266 if ctrl
.Invalid
and (ctrl
.Window
.ActiveControl
<> ctrl
) then
272 f
:= Font
[ctrl
.BigFont
];
273 r_Draw_Text(ctrl
.Text, ctrl
.X
+ 8, ctrl
.Y
, r
, g
, b
, 255, f
);
274 if ctrl
.Window
.ActiveControl
= ctrl
then
276 r_Draw_GetTextSize(Copy(ctrl
.Text, 1, ctrl
.CaretPos
), f
, w
, h
);
277 r_Draw_FillRect(ctrl
.X
+ 8 + w
, ctrl
.Y
+ h
- 4, ctrl
.X
+ 8 + w
+ EDIT_CURSORLEN
, ctrl
.Y
+ h
- 2, 200, 0, 0, 255);
281 procedure r_GUI_Draw_KeyRead (ctrl
: TGUIKeyRead
);
286 else if ctrl
.Key
<> 0 then
287 k
:= e_KeyNames
[ctrl
.Key
]
290 r_Draw_Text(k
, ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
293 procedure r_GUI_Draw_KeyRead2 (ctrl
: TGUIKeyRead2
);
295 procedure drawText (idx
: Integer);
296 var x
, y
: Integer; r
, g
, b
: Byte; kk
: DWORD
; str
: AnsiString;
298 if idx
= 0 then kk
:= ctrl
.Key0
else kk
:= ctrl
.Key1
;
300 if idx
= 0 then x
:= ctrl
.X
+ 8 else x
:= ctrl
.X
+ 8 + ctrl
.MaxKeyNameWdt
+ 16;
301 r
:= 255; g
:= 0; b
:= 0;
302 if ctrl
.KeyIdx
= idx
then
304 r
:= 255; g
:= 255; b
:= 255;
306 if ctrl
.IsQuery
and (ctrl
.KeyIdx
= idx
) then
309 str
:= e_KeyNames
[kk
]
311 str
:= KEYREAD_CLEAR
;
312 r_Draw_Text(str
, x
, y
, r
, g
, b
, 255, Font
[ctrl
.BigFont
]);
320 procedure DrawBox (x
, y
, w
, h
: Integer);
322 r_Draw_Texture(Box
[0], x
, y
, 4, 4, false, 255, 255, 255, 255, false);
323 r_Draw_TextureRepeat(Box
[1], x
+ 4, y
, w
* 16, 4, false, 255, 255, 255, 255, false);
324 r_Draw_Texture(Box
[2], x
+ 4 + w
* 16, y
, 4, 4, false, 255, 255, 255, 255, false);
326 r_Draw_TextureRepeat(Box
[3], x
, y
+ 4, 4, h
* 16, false, 255, 255, 255, 255, false);
327 r_Draw_TextureRepeat(Box
[4], x
+ 4, y
+ 4, w
* 16, h
* 16, false, 255, 255, 255, 255, false);
328 r_Draw_TextureRepeat(Box
[5], x
+ 4 + w
* 16, y
+ 4, 4, h
* 16, false, 255, 255, 255, 255, false);
330 r_Draw_Texture(Box
[6], x
, y
+ 4 + h
* 16, 4, 4, false, 255, 255, 255, 255, false);
331 r_Draw_TextureRepeat(Box
[7], x
+ 4, y
+ 4 + h
* 16, w
* 16, 4, false, 255, 255, 255, 255, false);
332 r_Draw_Texture(Box
[8], x
+ 4 + w
* 16, y
+ 4 + h
* 16, 4, 4, false, 255, 255, 255, 255, false);
335 procedure r_GUI_Draw_ModelView (ctrl
: TGUIModelView
);
337 DrawBox(ctrl
.X
, ctrl
.Y
, 4, 4);
338 if ctrl
.Model
<> nil then
339 r_Map_DrawPlayerModel(ctrl
.Model
, ctrl
.X
+ 4, ctrl
.Y
+ 4, 255);
342 procedure r_GUI_Draw_MapPreview (ctrl
: TGUIMapPreview
);
343 var a
: Integer; r
, g
, b
: Byte;
345 DrawBox(ctrl
.X
, ctrl
.Y
, MAPPREVIEW_WIDTH
, MAPPREVIEW_HEIGHT
);
346 if (ctrl
.MapSize
.X
<= 0) or (ctrl
.MapSize
.Y
<= 0) then
348 r_Draw_FillRect(ctrl
.X
+ 4, ctrl
.Y
+ 4, ctrl
.X
+ 4 + Trunc(ctrl
.MapSize
.X
/ ctrl
.Scale
), ctrl
.Y
+ 4 + Trunc(ctrl
.MapSize
.Y
/ ctrl
.Scale
), 32, 32, 32, 255);
349 if ctrl
.MapData
<> nil then
350 for a
:= 0 to High(ctrl
.MapData
) do
351 with ctrl
.MapData
[a
] do
353 if X1
> MAPPREVIEW_WIDTH
* 16 then Continue
;
354 if Y1
> MAPPREVIEW_HEIGHT
* 16 then Continue
;
355 if X2
< 0 then Continue
;
356 if Y2
< 0 then Continue
;
357 if X2
> MAPPREVIEW_WIDTH
* 16 then X2
:= MAPPREVIEW_WIDTH
* 16;
358 if Y2
> MAPPREVIEW_HEIGHT
* 16 then Y2
:= MAPPREVIEW_HEIGHT
* 16;
359 if X1
< 0 then X1
:= 0;
360 if Y1
< 0 then Y1
:= 0;
364 r
:= 255; g
:= 255; b
:= 255;
368 r
:= 255; g
:= 255; b
:= 0;
372 r
:= 0; g
:= 0; b
:= 192;
376 r
:= 0; g
:= 176; b
:= 0;
380 r
:= 176; g
:= 0; b
:= 0;
383 r
:= 128; g
:= 128; b
:= 128;
385 if ((X2
- X1
) > 0) and ((Y2
- Y1
) > 0) then
386 r_Draw_FillRect(ctrl
.X
+ 4 + X1
, ctrl
.Y
+ 4 + Y1
, ctrl
.X
+ 4 + X2
, ctrl
.Y
+ 4 + Y2
, r
, g
, b
, 255);
390 procedure r_GUI_Draw_Image (ctrl
: TGUIImage
);
394 if ctrl
.ImageRes
<> '' then
395 if r_Common_LoadThis(ctrl
.ImageRes
, ImageControl
) then
396 pic
:= ImageControl
.id
;
398 r_Draw_Texture(pic
, ctrl
.x
, ctrl
.y
, pic
.width
, pic
.height
, false, 255, 255, 255, 255, false);
401 procedure DrawScroll(x
, y
, h
: Integer; Up
, Down
: Boolean);
407 r_Draw_Texture(t
, x
, y
, t
.width
, t
.height
, false, 255, 255, 255, 255, false);
408 t
:= BScrollDown
[Down
];
409 r_Draw_Texture(t
, x
, y
+ (h
- 1) * 16, t
.width
, t
.height
, false, 255, 255, 255, 255, false);
411 r_Draw_TextureRepeat(t
, x
, y
+ 16, t
.width
, (h
- 2) * 16, false, 255, 255, 255, 255, false);
415 procedure r_GUI_Draw_ListBox (ctrl
: TGUIListBox
); // + TGUIFileListBox
416 var a
, w2
, h2
: Integer; s
: string; col
: TRGB
; f
: TGLFont
;
418 if ctrl
.DrawBack
then
419 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
420 if ctrl
.DrawScrollBar
then
421 DrawScroll(ctrl
.X
+ 4 + ctrl
.Width
* 16, ctrl
.Y
+ 4, ctrl
.Height
, (ctrl
.StartLine
> 0) and (ctrl
.Items
<> nil), (ctrl
.StartLine
+ ctrl
.Height
- 1 < High(ctrl
.Items
)) and (ctrl
.Items
<> nil));
422 if ctrl
.Items
<> nil then
424 f
:= Font
[ctrl
.BigFont
];
425 for a
:= ctrl
.StartLine
to Min(High(ctrl
.Items
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
428 r_Draw_GetTextSize(s
, f
, w2
, h2
);
429 while (Length(s
) > 0) and (w2
> ctrl
.Width
* 16) do
431 SetLength(s
, Length(s
) - 1);
432 r_Draw_GetTextSize(s
, f
, w2
, h2
);
434 if a
= ctrl
.ItemIndex
then col
:= ctrl
.ActiveColor
else col
:= ctrl
.UnActiveColor
;
435 r_Draw_Text(s
, ctrl
.X
+ 4, ctrl
.Y
+ 4 + (a
- ctrl
.StartLine
) * 16, col
.r
, col
.g
, col
.b
, 255, f
);
440 procedure r_GUI_Draw_Memo (ctrl
: TGUIMemo
);
443 if ctrl
.DrawBack
then
444 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
445 if ctrl
.DrawScrollBar
then
446 DrawScroll(ctrl
.X
+ 4 + ctrl
.Width
* 16, ctrl
.Y
+ 4, ctrl
.Height
, (ctrl
.StartLine
> 0) and (ctrl
.Lines
<> nil), (ctrl
.StartLine
+ ctrl
.Height
- 1 < High(ctrl
.Lines
)) and (ctrl
.Lines
<> nil));
447 if ctrl
.Lines
<> nil then
448 for i
:= ctrl
.StartLine
to Min(High(ctrl
.Lines
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
449 r_Draw_Text(ctrl
.Lines
[i
], ctrl
.X
+ 4, ctrl
.Y
+ 4 + (i
- ctrl
.StartLine
) * 16, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
452 procedure r_GUI_Draw_MainMenu (ctrl
: TGUIMainMenu
);
453 var i
, w
, h
: Integer; ID
: TGLTexture
;
455 if ctrl
.Header
<> nil then
457 r_GUI_Draw_Label(ctrl
.Header
)
459 else if LogoTex
<> nil then
461 r_GUI_GetLogoSize(w
, h
);
462 r_Draw_Texture(LogoTex
, ((gScreenWidth
div 2) - (w
div 2)), ctrl
.Buttons
[0].Y
- ctrl
.Buttons
[0].GetHeight
- h
, w
, h
, false, 255, 255, 255, 255, false);
464 if ctrl
.Buttons
<> nil then
466 for i
:= 0 to High(ctrl
.Buttons
) do
467 if ctrl
.Buttons
[i
] <> nil then
468 r_GUI_Draw_TextButton(ctrl
.Buttons
[i
]);
469 if ctrl
.Index
<> -1 then
471 ID
:= MarkerID
[ctrl
.Counter
DIV MAINMENU_MARKERDELAY
MOD 2 <> 0];
472 r_Draw_Texture(ID
, ctrl
.Buttons
[ctrl
.Index
].X
- 48, ctrl
.Buttons
[ctrl
.Index
].Y
, ID
.width
, ID
.height
, false, 255, 255, 255, 255, false);
477 procedure r_GUI_Draw_Menu (ctrl
: TGUIMenu
);
478 var a
, locx
, locy
: Integer; f
: TGLFont
;
480 if ctrl
.Header
<> nil then
481 r_GUI_Draw_Label(ctrl
.Header
);
482 if ctrl
.Items
<> nil then
484 for a
:= 0 to High(ctrl
.Items
) do
486 if ctrl
.Items
[a
].Text <> nil then
487 r_GUI_Draw_Control(ctrl
.Items
[a
].Text);
488 if ctrl
.Items
[a
].Control
<> nil then
489 r_GUI_Draw_Control(ctrl
.Items
[a
].Control
);
492 if (ctrl
.Index
<> -1) and (ctrl
.Counter
> MENU_MARKERDELAY
div 2) then
496 if ctrl
.Items
[ctrl
.Index
].Text <> nil then
498 locx
:= ctrl
.Items
[ctrl
.Index
].Text.X
;
499 locy
:= ctrl
.Items
[ctrl
.Index
].Text.Y
;
501 if ctrl
.Items
[ctrl
.Index
].Text.RightAlign
then
503 locx
:= locx
+ ctrl
.Items
[ctrl
.Index
].Text.CMaxWidth
- ctrl
.Items
[ctrl
.Index
].Text.GetWidth
;
506 else if ctrl
.Items
[ctrl
.Index
].Control
<> nil then
508 locx
:= ctrl
.Items
[ctrl
.Index
].Control
.X
;
509 locy
:= ctrl
.Items
[ctrl
.Index
].Control
.Y
;
511 f
:= Font
[ctrl
.BigFont
];
512 locx
:= locx
- f
.GetMaxWidth();
513 r_Draw_Text(#16, locx
, locy
, 255, 0, 0, 255, f
);
517 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
);
519 if ctrl
is TGUITextButton
then
520 r_GUI_Draw_TextButton(TGUITextButton(ctrl
))
521 else if ctrl
is TGUILabel
then
522 r_GUI_Draw_Label(TGUILabel(ctrl
))
523 else if ctrl
is TGUIScroll
then
524 r_GUI_Draw_Scroll(TGUIScroll(ctrl
))
525 else if ctrl
is TGUISwitch
then
526 r_GUI_Draw_Switch(TGUISwitch(ctrl
))
527 else if ctrl
is TGUIEdit
then
528 r_GUI_Draw_Edit(TGUIEdit(ctrl
))
529 else if ctrl
is TGUIKeyRead
then
530 r_GUI_Draw_KeyRead(TGUIKeyRead(ctrl
))
531 else if ctrl
is TGUIKeyRead2
then
532 r_GUI_Draw_KeyRead2(TGUIKeyRead2(ctrl
))
533 else if ctrl
is TGUIModelView
then
534 r_GUI_Draw_ModelView(TGUIModelView(ctrl
))
535 else if ctrl
is TGUIMapPreview
then
536 r_GUI_Draw_MapPreview(TGUIMapPreview(ctrl
))
537 else if ctrl
is TGUIImage
then
538 r_GUI_Draw_Image(TGUIImage(ctrl
))
539 else if ctrl
is TGUIListBox
then
540 r_GUI_Draw_ListBox(TGUIListBox(ctrl
)) // + TGUIFileListBox
541 else if ctrl
is TGUIMemo
then
542 r_GUI_Draw_Memo(TGUIMemo(ctrl
))
543 else if ctrl
is TGUIMainMenu
then
544 r_GUI_Draw_MainMenu(TGUIMainMenu(ctrl
))
545 else if ctrl
is TGUIMenu
then
546 r_GUI_Draw_Menu(TGUIMenu(ctrl
))
551 procedure r_GUI_Draw_Window (win
: TGUIWindow
);
552 var i
, tw
, th
: Integer;
554 // Here goes code duplication from g_game.pas:DrawMenuBackground()
555 if win
.BackTexture
<> '' then
556 if r_Common_LoadThis(win
.BackTexture
, Background
) then
558 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 255);
559 tw
:= Background
.id
.width
;
560 th
:= Background
.id
.height
;
562 tw
:= round(tw
* 1.333 * (gScreenHeight
/ th
))
564 tw
:= trunc(tw
* (gScreenHeight
/ th
));
565 r_Draw_Texture(Background
.id
, (gScreenWidth
- tw
) div 2, 0, tw
, gScreenHeight
, false, 255, 255, 255, 255, false);
568 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 127, 127, 127, 255);
571 if win
.Name
= 'AuthorsMenu' then
572 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
573 for i
:= 0 to High(win
.Childs
) do
574 if win
.Childs
[i
] <> nil then
575 r_GUI_Draw_Control(win
.Childs
[i
]);