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
,
52 Box
: Array [0..8] of TGLTexture
;
53 MarkerID
: array [Boolean] of TGLTexture
;
54 ScrollLeft
, ScrollRight
, ScrollMiddle
, ScrollMarker
: TGLTexture
;
55 EditLeft
, EditRight
, EditMiddle
: TGLTexture
;
56 BScrollUp
, BScrollDown
: array [Boolean] of TGLTexture
;
57 BScrollMiddle
: TGLTexture
;
59 Font
: array [boolean] of TGLFont
; (* Small[FALSE] / Big[TRUE] *)
63 Background
: THereTexture
;
64 ImageControl
: THereTexture
;
66 procedure r_GUI_FreeThis (var here
: THereTexture
);
69 if here
.id
<> nil then
74 function r_GUI_LoadThis (const name
: AnsiString; var here
: THereTexture
): Boolean;
77 if (name
<> '') and (here
.name
<> name
) then
78 here
.id
:= r_Textures_LoadFromFile(name
);
79 result
:= here
.id
<> nil;
85 Font
[FALSE] := smallfont
;
86 Font
[TRUE] := menufont
;
88 MarkerID
[FALSE] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/MARKER1');
89 MarkerID
[TRUE] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/MARKER2');
92 Box
[i
] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/BOX' + IntToStr(i
+ 1));
94 ScrollLeft
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SLEFT');
95 ScrollRight
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SRIGHT');
96 ScrollMiddle
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SMIDDLE');
97 ScrollMarker
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SMARKER');
99 EditLeft
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/ELEFT');
100 EditRight
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/ERIGHT');
101 EditMiddle
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/EMIDDLE');
103 BScrollUp
[true] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SCROLLUPA');
104 BScrollUp
[false] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SCROLLUPU');
105 BScrollDown
[true] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SCROLLDOWNA');
106 BScrollDown
[false] := r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SCROLLDOWNU');
107 BScrollMiddle
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/SCROLLMIDDLE');
109 LogoTex
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/MAINLOGO');
110 nopic
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/NOPIC');
113 procedure r_GUI_Free
;
119 MarkerID
[FALSE].Free
;
134 BScrollUp
[true].Free
;
135 BScrollUp
[false].Free
;
136 BScrollDown
[true].Free
;
137 BScrollDown
[false].Free
;
143 r_GUI_FreeThis(Background
);
144 r_GUI_FreeThis(ImageControl
);
147 procedure r_GUI_GetMaxFontSize (BigFont
: Boolean; out w
, h
: Integer);
151 w
:= f
.GetMaxWidth();
152 h
:= f
.GetMaxHeight();
155 procedure r_GUI_GetStringSize (BigFont
: Boolean; str
: String; out w
, h
: Integer);
157 r_Draw_GetTextSize(str
, Font
[BigFont
], w
, h
);
160 procedure r_GUI_GetLogoSize (out w
, h
: Integer);
163 if LogoTex
<> nil then
170 procedure r_GUI_GetSize_TextButton (ctrl
: TGUITextButton
; out w
, h
: Integer);
172 r_Draw_GetTextSize(ctrl
.Caption
, Font
[ctrl
.BigFont
], w
, h
);
175 procedure r_GUI_GetSize_Label (ctrl
: TGUILabel
; out w
, h
: Integer);
178 f
:= Font
[ctrl
.BigFont
];
179 r_Draw_GetTextSize(ctrl
.Text, f
, w
, h
);
180 if ctrl
.FixedLength
<> 0 then
181 w
:= f
.GetMaxWidth() * ctrl
.FixedLength
;
184 procedure r_GUI_GetSize_Switch (ctrl
: TGUISwitch
; out w
, h
: Integer);
188 if ctrl
.Items
<> nil then
189 for i
:= 0 to High(ctrl
.Items
) do
190 r_Draw_GetTextSize(ctrl
.Items
[i
], Font
[ctrl
.BigFont
], w
, h
);
193 procedure r_GUI_GetSize_KeyRead (ctrl
: TGUIKeyRead
; out w
, h
: Integer);
194 var i
, ww
, hh
: Integer; f
: TGLFont
;
196 w
:= 0; h
:= 0; // ??? h always 0
197 f
:= Font
[ctrl
.BigFont
];
200 r_Draw_GetTextSize(e_KeyNames
[i
], f
, ww
, hh
);
203 r_Draw_GetTextSize(KEYREAD_QUERY
, f
, ww
, hh
);
205 r_Draw_GetTextSize(KEYREAD_CLEAR
, f
, ww
, hh
);
209 procedure r_GUI_GetSize (ctrl
: TGUIControl
; out w
, h
: Integer);
213 if ctrl
is TGUITextButton
then
214 r_GUI_GetSize_TextButton(ctrl
as TGUITextButton
, w
, h
)
215 else if ctrl
is TGUILabel
then
216 r_GUI_GetSize_Label(ctrl
as TGUILabel
, w
, h
)
217 else if ctrl
is TGUIScroll
then
218 w
:= 16 + ((ctrl
as TGUIScroll
).Max
+ 1) * 8 // ??? but h = 0
219 else if ctrl
is TGUISwitch
then
220 r_GUI_GetSize_Switch(ctrl
as TGUISwitch
, w
, h
)
221 else if ctrl
is TGUIEdit
then
222 w
:= 16 + (ctrl
as TGUIEdit
).Width
* 16 // ??? but h = 0
223 else if ctrl
is TGUIKeyRead
then
224 r_GUI_GetSize_KeyRead(ctrl
as TGUIKeyRead
, w
, h
)
225 else if ctrl
is TGUIKeyRead2
then
226 w
:= (ctrl
as TGUIKeyRead2
).MaxKeyNameWdt
* 2 + 8 + 8 + 16 // ??? but h = 0
227 else if ctrl
is TGUIListBox
then
229 w
:= 8 + ((ctrl
as TGUIListBox
).Width
+ 1) * 16; // recheck w & h
230 h
:= 8 + (ctrl
as TGUIListBox
).Height
* 16;
232 else if ctrl
is TGUIMemo
then
234 w
:= 8 + ((ctrl
as TGUIMemo
).Width
+ 1) * 16;
235 h
:= 8 + (ctrl
as TGUIMemo
).Height
* 16;
239 w
:= ctrl
.GetWidth();
240 h
:= ctrl
.GetHeight();
244 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
); forward;
246 procedure r_GUI_Draw_TextButton (ctrl
: TGUITextButton
);
248 r_Draw_Text(ctrl
.Caption
, ctrl
.x
, ctrl
.y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
251 procedure r_GUI_Draw_Label (ctrl
: TGUILabel
);
252 var w
, h
: Integer; f
: TGLFont
;
254 f
:= Font
[ctrl
.BigFont
];
255 if ctrl
.RightAlign
then
257 r_Draw_GetTextSize(ctrl
.Text, f
, w
, h
);
258 r_Draw_Text(ctrl
.Text, ctrl
.X
+ ctrl
.CMaxWidth
- w
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, f
);
261 r_Draw_Text(ctrl
.Text, ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, f
);
264 procedure r_GUI_Draw_Scroll (ctrl
: TGUIScroll
);
266 r_Draw_Texture(ScrollLeft
, ctrl
.X
, ctrl
.Y
, ScrollLeft
.width
, ScrollLeft
.height
, false, 255, 255, 255, 255, false);
267 r_Draw_TextureRepeat(ScrollMiddle
, ctrl
.X
+ 8 + 0 * 8, ctrl
.Y
, 8 + ctrl
.Max
* 8, ScrollMiddle
.height
, false, 255, 255, 255, 255, false);
268 r_Draw_Texture(ScrollRight
, ctrl
.X
+ 8 + (ctrl
.Max
+ 1) * 8, ctrl
.Y
, ScrollRight
.width
, ScrollRight
.height
, false, 255, 255, 255, 255, false);
269 r_Draw_Texture(ScrollMarker
, ctrl
.X
+ 8 + ctrl
.Value
* 8, ctrl
.Y
, ScrollMarker
.width
, ScrollMarker
.height
, false, 255, 255, 255, 255, false);
272 procedure r_GUI_Draw_Switch (ctrl
: TGUISwitch
);
274 r_Draw_Text(ctrl
.Items
[ctrl
.ItemIndex
], ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
277 procedure r_GUI_Draw_Edit (ctrl
: TGUIEdit
);
278 var w
, h
: Integer; r
, g
, b
: Byte; f
: TGLFont
;
280 r_Draw_Texture(EditLeft
, ctrl
.X
, ctrl
.Y
, EditLeft
.width
, EditLeft
.height
, false, 255, 255, 255, 255, false);
281 r_Draw_TextureRepeat(EditMiddle
, ctrl
.X
+ 8, ctrl
.Y
, 8 + (ctrl
.Width
- 1) * 16, EditMiddle
.height
, false, 255, 255, 255, 255, false);
282 r_Draw_Texture(EditRight
, ctrl
.X
+ 8 + ctrl
.Width
* 16, ctrl
.Y
, EditRight
.width
, EditRight
.height
, false, 255, 255, 255, 255, false);
286 if ctrl
.Invalid
and (ctrl
.Window
.ActiveControl
<> ctrl
) then
292 f
:= Font
[ctrl
.BigFont
];
293 r_Draw_Text(ctrl
.Text, ctrl
.X
+ 8, ctrl
.Y
, r
, g
, b
, 255, f
);
294 if ctrl
.Window
.ActiveControl
= ctrl
then
296 r_Draw_GetTextSize(Copy(ctrl
.Text, 1, ctrl
.CaretPos
), f
, w
, h
);
297 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);
301 procedure r_GUI_Draw_KeyRead (ctrl
: TGUIKeyRead
);
306 else if ctrl
.Key
<> 0 then
307 k
:= e_KeyNames
[ctrl
.Key
]
310 r_Draw_Text(k
, ctrl
.X
, ctrl
.Y
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
, 255, Font
[ctrl
.BigFont
]);
313 procedure r_GUI_Draw_KeyRead2 (ctrl
: TGUIKeyRead2
);
315 procedure drawText (idx
: Integer);
316 var x
, y
: Integer; r
, g
, b
: Byte; kk
: DWORD
; str
: AnsiString;
318 if idx
= 0 then kk
:= ctrl
.Key0
else kk
:= ctrl
.Key1
;
320 if idx
= 0 then x
:= ctrl
.X
+ 8 else x
:= ctrl
.X
+ 8 + ctrl
.MaxKeyNameWdt
+ 16;
321 r
:= 255; g
:= 0; b
:= 0;
322 if ctrl
.KeyIdx
= idx
then
324 r
:= 255; g
:= 255; b
:= 255;
326 if ctrl
.IsQuery
and (ctrl
.KeyIdx
= idx
) then
329 str
:= e_KeyNames
[kk
]
331 str
:= KEYREAD_CLEAR
;
332 r_Draw_Text(str
, x
, y
, r
, g
, b
, 255, Font
[ctrl
.BigFont
]);
340 procedure DrawBox (x
, y
, w
, h
: Integer);
342 r_Draw_Texture(Box
[0], x
, y
, 4, 4, false, 255, 255, 255, 255, false);
343 r_Draw_TextureRepeat(Box
[1], x
+ 4, y
, w
* 16, 4, false, 255, 255, 255, 255, false);
344 r_Draw_Texture(Box
[2], x
+ 4 + w
* 16, y
, 4, 4, false, 255, 255, 255, 255, false);
346 r_Draw_TextureRepeat(Box
[3], x
, y
+ 4, 4, h
* 16, false, 255, 255, 255, 255, false);
347 r_Draw_TextureRepeat(Box
[4], x
+ 4, y
+ 4, w
* 16, h
* 16, false, 255, 255, 255, 255, false);
348 r_Draw_TextureRepeat(Box
[5], x
+ 4 + w
* 16, y
+ 4, 4, h
* 16, false, 255, 255, 255, 255, false);
350 r_Draw_Texture(Box
[6], x
, y
+ 4 + h
* 16, 4, 4, false, 255, 255, 255, 255, false);
351 r_Draw_TextureRepeat(Box
[7], x
+ 4, y
+ 4 + h
* 16, w
* 16, 4, false, 255, 255, 255, 255, false);
352 r_Draw_Texture(Box
[8], x
+ 4 + w
* 16, y
+ 4 + h
* 16, 4, 4, false, 255, 255, 255, 255, false);
355 procedure r_GUI_Draw_ModelView (ctrl
: TGUIModelView
);
357 DrawBox(ctrl
.X
, ctrl
.Y
, 4, 4);
358 if ctrl
.Model
<> nil then
359 r_Map_DrawPlayerModel(ctrl
.Model
, ctrl
.X
+ 4, ctrl
.Y
+ 4, 255);
362 procedure r_GUI_Draw_MapPreview (ctrl
: TGUIMapPreview
);
363 var a
: Integer; r
, g
, b
: Byte;
365 DrawBox(ctrl
.X
, ctrl
.Y
, MAPPREVIEW_WIDTH
, MAPPREVIEW_HEIGHT
);
366 if (ctrl
.MapSize
.X
<= 0) or (ctrl
.MapSize
.Y
<= 0) then
368 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);
369 if ctrl
.MapData
<> nil then
370 for a
:= 0 to High(ctrl
.MapData
) do
371 with ctrl
.MapData
[a
] do
373 if X1
> MAPPREVIEW_WIDTH
* 16 then Continue
;
374 if Y1
> MAPPREVIEW_HEIGHT
* 16 then Continue
;
375 if X2
< 0 then Continue
;
376 if Y2
< 0 then Continue
;
377 if X2
> MAPPREVIEW_WIDTH
* 16 then X2
:= MAPPREVIEW_WIDTH
* 16;
378 if Y2
> MAPPREVIEW_HEIGHT
* 16 then Y2
:= MAPPREVIEW_HEIGHT
* 16;
379 if X1
< 0 then X1
:= 0;
380 if Y1
< 0 then Y1
:= 0;
384 r
:= 255; g
:= 255; b
:= 255;
388 r
:= 255; g
:= 255; b
:= 0;
392 r
:= 0; g
:= 0; b
:= 192;
396 r
:= 0; g
:= 176; b
:= 0;
400 r
:= 176; g
:= 0; b
:= 0;
403 r
:= 128; g
:= 128; b
:= 128;
405 if ((X2
- X1
) > 0) and ((Y2
- Y1
) > 0) then
406 r_Draw_FillRect(ctrl
.X
+ 4 + X1
, ctrl
.Y
+ 4 + Y1
, ctrl
.X
+ 4 + X2
, ctrl
.Y
+ 4 + Y2
, r
, g
, b
, 255);
410 procedure r_GUI_Draw_Image (ctrl
: TGUIImage
);
414 if ctrl
.ImageRes
<> '' then
415 if r_GUI_LoadThis(ctrl
.ImageRes
, ImageControl
) then
416 pic
:= ImageControl
.id
;
418 r_Draw_Texture(pic
, ctrl
.x
, ctrl
.y
, pic
.width
, pic
.height
, false, 255, 255, 255, 255, false);
421 procedure DrawScroll(x
, y
, h
: Integer; Up
, Down
: Boolean);
427 r_Draw_Texture(t
, x
, y
, t
.width
, t
.height
, false, 255, 255, 255, 255, false);
428 t
:= BScrollDown
[Down
];
429 r_Draw_Texture(t
, x
, y
+ (h
- 1) * 16, t
.width
, t
.height
, false, 255, 255, 255, 255, false);
431 r_Draw_TextureRepeat(t
, x
, y
+ 16, t
.width
, (h
- 2) * 16, false, 255, 255, 255, 255, false);
435 procedure r_GUI_Draw_ListBox (ctrl
: TGUIListBox
); // + TGUIFileListBox
436 var a
, w2
, h2
: Integer; s
: string; col
: TRGB
; f
: TGLFont
;
438 if ctrl
.DrawBack
then
439 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
440 if ctrl
.DrawScrollBar
then
441 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));
442 if ctrl
.Items
<> nil then
444 f
:= Font
[ctrl
.BigFont
];
445 for a
:= ctrl
.StartLine
to Min(High(ctrl
.Items
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
448 r_Draw_GetTextSize(s
, f
, w2
, h2
);
449 while (Length(s
) > 0) and (w2
> ctrl
.Width
* 16) do
451 SetLength(s
, Length(s
) - 1);
452 r_Draw_GetTextSize(s
, f
, w2
, h2
);
454 if a
= ctrl
.ItemIndex
then col
:= ctrl
.ActiveColor
else col
:= ctrl
.UnActiveColor
;
455 r_Draw_Text(s
, ctrl
.X
+ 4, ctrl
.Y
+ 4 + (a
- ctrl
.StartLine
) * 16, col
.r
, col
.g
, col
.b
, 255, f
);
460 procedure r_GUI_Draw_Memo (ctrl
: TGUIMemo
);
463 if ctrl
.DrawBack
then
464 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
465 if ctrl
.DrawScrollBar
then
466 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));
467 if ctrl
.Lines
<> nil then
468 for i
:= ctrl
.StartLine
to Min(High(ctrl
.Lines
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
469 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
]);
472 procedure r_GUI_Draw_MainMenu (ctrl
: TGUIMainMenu
);
473 var i
, w
, h
: Integer; ID
: TGLTexture
;
475 if ctrl
.Header
<> nil then
477 r_GUI_Draw_Label(ctrl
.Header
)
479 else if LogoTex
<> nil then
481 r_GUI_GetLogoSize(w
, h
);
482 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);
484 if ctrl
.Buttons
<> nil then
486 for i
:= 0 to High(ctrl
.Buttons
) do
487 if ctrl
.Buttons
[i
] <> nil then
488 r_GUI_Draw_TextButton(ctrl
.Buttons
[i
]);
489 if ctrl
.Index
<> -1 then
491 ID
:= MarkerID
[ctrl
.Counter
DIV MAINMENU_MARKERDELAY
MOD 2 <> 0];
492 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);
497 procedure r_GUI_Draw_Menu (ctrl
: TGUIMenu
);
498 var a
, locx
, locy
: Integer; f
: TGLFont
;
500 if ctrl
.Header
<> nil then
501 r_GUI_Draw_Label(ctrl
.Header
);
502 if ctrl
.Items
<> nil then
504 for a
:= 0 to High(ctrl
.Items
) do
506 if ctrl
.Items
[a
].Text <> nil then
507 r_GUI_Draw_Control(ctrl
.Items
[a
].Text);
508 if ctrl
.Items
[a
].Control
<> nil then
509 r_GUI_Draw_Control(ctrl
.Items
[a
].Control
);
512 if (ctrl
.Index
<> -1) and (ctrl
.Counter
> MENU_MARKERDELAY
div 2) then
516 if ctrl
.Items
[ctrl
.Index
].Text <> nil then
518 locx
:= ctrl
.Items
[ctrl
.Index
].Text.X
;
519 locy
:= ctrl
.Items
[ctrl
.Index
].Text.Y
;
521 if ctrl
.Items
[ctrl
.Index
].Text.RightAlign
then
523 locx
:= locx
+ ctrl
.Items
[ctrl
.Index
].Text.CMaxWidth
- ctrl
.Items
[ctrl
.Index
].Text.GetWidth
;
526 else if ctrl
.Items
[ctrl
.Index
].Control
<> nil then
528 locx
:= ctrl
.Items
[ctrl
.Index
].Control
.X
;
529 locy
:= ctrl
.Items
[ctrl
.Index
].Control
.Y
;
531 f
:= Font
[ctrl
.BigFont
];
532 locx
:= locx
- f
.GetMaxWidth();
533 r_Draw_Text(#16, locx
, locy
, 255, 0, 0, 255, f
);
537 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
);
539 if ctrl
is TGUITextButton
then
540 r_GUI_Draw_TextButton(TGUITextButton(ctrl
))
541 else if ctrl
is TGUILabel
then
542 r_GUI_Draw_Label(TGUILabel(ctrl
))
543 else if ctrl
is TGUIScroll
then
544 r_GUI_Draw_Scroll(TGUIScroll(ctrl
))
545 else if ctrl
is TGUISwitch
then
546 r_GUI_Draw_Switch(TGUISwitch(ctrl
))
547 else if ctrl
is TGUIEdit
then
548 r_GUI_Draw_Edit(TGUIEdit(ctrl
))
549 else if ctrl
is TGUIKeyRead
then
550 r_GUI_Draw_KeyRead(TGUIKeyRead(ctrl
))
551 else if ctrl
is TGUIKeyRead2
then
552 r_GUI_Draw_KeyRead2(TGUIKeyRead2(ctrl
))
553 else if ctrl
is TGUIModelView
then
554 r_GUI_Draw_ModelView(TGUIModelView(ctrl
))
555 else if ctrl
is TGUIMapPreview
then
556 r_GUI_Draw_MapPreview(TGUIMapPreview(ctrl
))
557 else if ctrl
is TGUIImage
then
558 r_GUI_Draw_Image(TGUIImage(ctrl
))
559 else if ctrl
is TGUIListBox
then
560 r_GUI_Draw_ListBox(TGUIListBox(ctrl
)) // + TGUIFileListBox
561 else if ctrl
is TGUIMemo
then
562 r_GUI_Draw_Memo(TGUIMemo(ctrl
))
563 else if ctrl
is TGUIMainMenu
then
564 r_GUI_Draw_MainMenu(TGUIMainMenu(ctrl
))
565 else if ctrl
is TGUIMenu
then
566 r_GUI_Draw_Menu(TGUIMenu(ctrl
))
571 procedure r_GUI_Draw_Window (win
: TGUIWindow
);
572 var i
, tw
, th
: Integer;
574 // Here goes code duplication from g_game.pas:DrawMenuBackground()
575 if win
.BackTexture
<> '' then
576 if r_GUI_LoadThis(win
.BackTexture
, Background
) then
578 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 255);
579 tw
:= Background
.id
.width
;
580 th
:= Background
.id
.height
;
582 tw
:= round(tw
* 1.333 * (gScreenHeight
/ th
))
584 tw
:= trunc(tw
* (gScreenHeight
/ th
));
585 r_Draw_Texture(Background
.id
, (gScreenWidth
- tw
) div 2, 0, tw
, gScreenHeight
, false, 255, 255, 255, 255, false);
588 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 127, 127, 127, 255);
591 if win
.Name
= 'AuthorsMenu' then
592 r_Draw_FillRect(0, 0, gScreenWidth
- 1, gScreenHeight
- 1, 0, 0, 0, 105);
593 for i
:= 0 to High(win
.Childs
) do
594 if win
.Childs
[i
] <> nil then
595 r_GUI_Draw_Control(win
.Childs
[i
]);