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
: WORD);
27 procedure r_GUI_Draw_Window (win
: TGUIWindow
);
34 g_basic
, g_base
, e_input
, g_options
,
35 r_graphics
, r_textures
, r_playermodel
, r_game
,
51 Box
: Array [0..8] of DWORD
;
52 MarkerID
: array [Boolean] of DWORD
;
53 ScrollLeft
, ScrollRight
, ScrollMiddle
, ScrollMarker
: DWORD
;
54 EditLeft
, EditRight
, EditMiddle
: DWORD
;
56 Font
: array [boolean] of TFont
; (* Small[FALSE] / Big[TRUE] *)
59 procedure r_GUI_GetLogoSize (out w
, h
: WORD);
64 e_GetTextureSize(LogoTex
, @w
, @h
);
69 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD
+ ':TEXTURES\MAINLOGO');
70 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD
+ ':TEXTURES\MARKER1');
71 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD
+ ':TEXTURES\MARKER2');
72 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD
+ ':TEXTURES\SLEFT');
73 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD
+ ':TEXTURES\SRIGHT');
74 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD
+ ':TEXTURES\SMIDDLE');
75 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD
+ ':TEXTURES\SMARKER');
76 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD
+ ':TEXTURES\ELEFT');
77 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD
+ ':TEXTURES\ERIGHT');
78 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD
+ ':TEXTURES\EMIDDLE');
79 g_Texture_CreateWADEx('BOX1', GameWAD
+ ':TEXTURES\BOX1');
80 g_Texture_CreateWADEx('BOX2', GameWAD
+ ':TEXTURES\BOX2');
81 g_Texture_CreateWADEx('BOX3', GameWAD
+ ':TEXTURES\BOX3');
82 g_Texture_CreateWADEx('BOX4', GameWAD
+ ':TEXTURES\BOX4');
83 g_Texture_CreateWADEx('BOX5', GameWAD
+ ':TEXTURES\BOX5');
84 g_Texture_CreateWADEx('BOX6', GameWAD
+ ':TEXTURES\BOX6');
85 g_Texture_CreateWADEx('BOX7', GameWAD
+ ':TEXTURES\BOX7');
86 g_Texture_CreateWADEx('BOX8', GameWAD
+ ':TEXTURES\BOX8');
87 g_Texture_CreateWADEx('BOX9', GameWAD
+ ':TEXTURES\BOX9');
88 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD
+ ':TEXTURES\SCROLLUPA');
89 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD
+ ':TEXTURES\SCROLLUPU');
90 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD
+ ':TEXTURES\SCROLLDOWNA');
91 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD
+ ':TEXTURES\SCROLLDOWNU');
92 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD
+ ':TEXTURES\SCROLLMIDDLE');
93 g_Texture_CreateWADEx('NOPIC', GameWAD
+ ':TEXTURES\NOPIC');
95 g_Texture_Get(MAINMENU_MARKER1
, MarkerID
[FALSE]);
96 g_Texture_Get(MAINMENU_MARKER2
, MarkerID
[TRUE]);
98 g_Texture_Get(BOX1
, Box
[0]);
99 g_Texture_Get(BOX2
, Box
[1]);
100 g_Texture_Get(BOX3
, Box
[2]);
101 g_Texture_Get(BOX4
, Box
[3]);
102 g_Texture_Get(BOX5
, Box
[4]);
103 g_Texture_Get(BOX6
, Box
[5]);
104 g_Texture_Get(BOX7
, Box
[6]);
105 g_Texture_Get(BOX8
, Box
[7]);
106 g_Texture_Get(BOX9
, Box
[8]);
108 g_Texture_Get(SCROLL_LEFT
, ScrollLeft
);
109 g_Texture_Get(SCROLL_RIGHT
, ScrollRight
);
110 g_Texture_Get(SCROLL_MIDDLE
, ScrollMiddle
);
111 g_Texture_Get(SCROLL_MARKER
, ScrollMarker
);
113 g_Texture_Get(EDIT_LEFT
, EditLeft
);
114 g_Texture_Get(EDIT_RIGHT
, EditRight
);
115 g_Texture_Get(EDIT_MIDDLE
, EditMiddle
);
117 Font
[FALSE] := TFont
.Create(gMenuSmallFont
, TFontType
.Character
);
118 Font
[TRUE] := TFont
.Create(gMenuFont
, TFontType
.Character
);
120 g_Texture_Get('MAINMENU_LOGO', LogoTex
)
123 procedure r_GUI_Free
;
125 g_Texture_Delete('MAINMENU_LOGO');
126 g_Texture_Delete('MAINMENU_MARKER1');
127 g_Texture_Delete('MAINMENU_MARKER2');
128 g_Texture_Delete('SCROLL_LEFT');
129 g_Texture_Delete('SCROLL_RIGHT');
130 g_Texture_Delete('SCROLL_MIDDLE');
131 g_Texture_Delete('SCROLL_MARKER');
132 g_Texture_Delete('EDIT_LEFT');
133 g_Texture_Delete('EDIT_RIGHT');
134 g_Texture_Delete('EDIT_MIDDLE');
135 g_Texture_Delete('BOX1');
136 g_Texture_Delete('BOX2');
137 g_Texture_Delete('BOX3');
138 g_Texture_Delete('BOX4');
139 g_Texture_Delete('BOX5');
140 g_Texture_Delete('BOX6');
141 g_Texture_Delete('BOX7');
142 g_Texture_Delete('BOX8');
143 g_Texture_Delete('BOX9');
144 g_Texture_Delete('BSCROLL_UP_A');
145 g_Texture_Delete('BSCROLL_UP_U');
146 g_Texture_Delete('BSCROLL_DOWN_A');
147 g_Texture_Delete('BSCROLL_DOWN_U');
148 g_Texture_Delete('BSCROLL_MIDDLE');
149 g_Texture_Delete('NOPIC');
152 procedure r_GUI_GetSize_TextButton (ctrl
: TGUITextButton
; out w
, h
: Integer);
155 ctrl
.Font
.GetTextSize(ctrl
.Caption
, ww
, hh
);
160 procedure r_GUI_GetSize_Label (ctrl
: TGUILabel
; out w
, h
: Integer);
163 ctrl
.Font
.GetTextSize(ctrl
.Text, ww
, hh
);
165 if ctrl
.FixedLength
= 0 then
168 w
:= e_CharFont_GetMaxWidth(ctrl
.Font
.ID
) * ctrl
.FixedLength
171 procedure r_GUI_GetSize_Switch (ctrl
: TGUISwitch
; out w
, h
: Integer);
172 var i
: Integer; ww
, hh
: WORD;
176 if ctrl
.Items
<> nil then
178 for i
:= 0 to High(ctrl
.Items
) do
180 ctrl
.Font
.GetTextSize(ctrl
.Items
[i
], ww
, hh
);
187 procedure r_GUI_GetSize_KeyRead (ctrl
: TGUIKeyRead
; out w
, h
: Integer);
188 var i
: Integer; ww
, hh
: WORD;
191 h
:= 0; // ??? always 0
194 ctrl
.Font
.GetTextSize(e_KeyNames
[i
], ww
, hh
);
197 ctrl
.Font
.GetTextSize(KEYREAD_QUERY
, ww
, hh
);
198 if ww
> w
then w
:= ww
;
199 ctrl
.Font
.GetTextSize(KEYREAD_CLEAR
, ww
, hh
);
200 if ww
> w
then w
:= ww
;
203 procedure r_GUI_GetSize (ctrl
: TGUIControl
; out w
, h
: Integer);
207 if ctrl
is TGUITextButton
then
208 r_GUI_GetSize_TextButton(ctrl
as TGUITextButton
, w
, h
)
209 else if ctrl
is TGUILabel
then
210 r_GUI_GetSize_Label(ctrl
as TGUILabel
, w
, h
)
211 else if ctrl
is TGUIScroll
then
212 w
:= 16 + ((ctrl
as TGUIScroll
).Max
+ 1) * 8 // ??? but h = 0
213 else if ctrl
is TGUISwitch
then
214 r_GUI_GetSize_Switch(ctrl
as TGUISwitch
, w
, h
)
215 else if ctrl
is TGUIEdit
then
216 w
:= 16 + (ctrl
as TGUIEdit
).Width
* 16 // ??? but h = 0
217 else if ctrl
is TGUIKeyRead
then
218 r_GUI_GetSize_KeyRead(ctrl
as TGUIKeyRead
, w
, h
)
219 else if ctrl
is TGUIKeyRead2
then
220 w
:= (ctrl
as TGUIKeyRead2
).MaxKeyNameWdt
* 2 + 8 + 8 + 16 // ??? but h = 0
221 else if ctrl
is TGUIListBox
then
223 w
:= 8 + ((ctrl
as TGUIListBox
).Width
+ 1) * 16; // recheck w & h
224 h
:= 8 + (ctrl
as TGUIListBox
).Height
* 16;
226 else if ctrl
is TGUIMemo
then
228 w
:= 8 + ((ctrl
as TGUIMemo
).Width
+ 1) * 16;
229 h
:= 8 + (ctrl
as TGUIMemo
).Height
* 16;
233 w
:= ctrl
.GetWidth();
234 h
:= ctrl
.GetHeight();
238 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
); forward;
240 procedure r_GUI_Draw_TextButton (ctrl
: TGUITextButton
);
242 ctrl
.Font
.Draw(ctrl
.X
, ctrl
.Y
, ctrl
.Caption
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
)
245 procedure r_GUI_Draw_Label (ctrl
: TGUILabel
);
248 if ctrl
.RightAlign
then
250 ctrl
.Font
.GetTextSize(ctrl
.Text, w
, h
);
251 ctrl
.Font
.Draw(ctrl
.X
+ ctrl
.CMaxWidth
- w
, ctrl
.Y
, ctrl
.Text, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
);
254 ctrl
.Font
.Draw(ctrl
.X
, ctrl
.Y
, ctrl
.Text, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
);
257 procedure r_GUI_Draw_Scroll (ctrl
: TGUIScroll
);
260 e_Draw(ScrollLeft
, ctrl
.X
, ctrl
.Y
, 0, True, False);
261 e_Draw(ScrollRight
, ctrl
.X
+ 8 + (ctrl
.Max
+ 1) * 8, ctrl
.Y
, 0, True, False);
262 for a
:= 0 to ctrl
.Max
do
263 e_Draw(ScrollMiddle
, ctrl
.X
+ 8 + a
* 8, ctrl
.Y
, 0, True, False);
264 e_Draw(ScrollMarker
, ctrl
.X
+ 8 + ctrl
.Value
* 8, ctrl
.Y
, 0, True, False);
267 procedure r_GUI_Draw_Switch (ctrl
: TGUISwitch
);
269 ctrl
.Font
.Draw(ctrl
.X
, ctrl
.Y
, ctrl
.Items
[ctrl
.ItemIndex
], ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
);
272 procedure r_GUI_Draw_Edit (ctrl
: TGUIEdit
);
273 var c
, w
, h
: Word; r
, g
, b
: Byte;
275 e_Draw(EditLeft
, ctrl
.X
, ctrl
.Y
, 0, True, False);
276 e_Draw(EditRight
, ctrl
.X
+ 8 + ctrl
.Width
* 16, ctrl
.Y
, 0, True, False);
277 for c
:= 0 to ctrl
.Width
- 1 do
278 e_Draw(EditMiddle
, ctrl
.X
+ 8 + c
* 16, ctrl
.Y
, 0, True, False);
282 if ctrl
.Invalid
and (ctrl
.Window
.ActiveControl
<> ctrl
) then
288 ctrl
.Font
.Draw(ctrl
.X
+ 8, ctrl
.Y
, ctrl
.Text, r
, g
, b
);
289 if ctrl
.Window
.ActiveControl
= ctrl
then
291 ctrl
.Font
.GetTextSize(Copy(ctrl
.Text, 1, ctrl
.CaretPos
), w
, h
);
292 h
:= e_CharFont_GetMaxHeight(ctrl
.Font
.ID
);
293 e_DrawLine(2, ctrl
.X
+ 8 + w
, ctrl
.Y
+ h
- 3, ctrl
.X
+ 8 + w
+ EDIT_CURSORLEN
, ctrl
.Y
+ h
- 3, EDIT_CURSORCOLOR
.R
, EDIT_CURSORCOLOR
.G
, EDIT_CURSORCOLOR
.B
);
297 procedure r_GUI_Draw_KeyRead (ctrl
: TGUIKeyRead
);
302 else if ctrl
.Key
<> 0 then
303 k
:= e_KeyNames
[ctrl
.Key
]
306 ctrl
.Font
.Draw(ctrl
.X
, ctrl
.Y
, k
, ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
);
309 procedure r_GUI_Draw_KeyRead2 (ctrl
: TGUIKeyRead2
);
311 procedure drawText (idx
: Integer);
312 var x
, y
: Integer; r
, g
, b
: Byte; kk
: DWORD
; str
: AnsiString;
314 if idx
= 0 then kk
:= ctrl
.Key0
else kk
:= ctrl
.Key1
;
316 if idx
= 0 then x
:= ctrl
.X
+ 8 else x
:= ctrl
.X
+ 8 + ctrl
.MaxKeyNameWdt
+ 16;
320 if ctrl
.KeyIdx
= idx
then
322 r
:= 255; g
:= 255; b
:= 255;
324 if ctrl
.IsQuery
and (ctrl
.KeyIdx
= idx
) then
326 ctrl
.Font
.Draw(x
, y
, KEYREAD_QUERY
, r
, g
, b
)
331 str
:= e_KeyNames
[kk
]
333 str
:= KEYREAD_CLEAR
;
334 ctrl
.Font
.Draw(x
, y
, str
, r
, g
, b
);
343 procedure DrawBox(X
, Y
: Integer; Width
, Height
: Word);
345 e_Draw(Box
[0], X
, Y
, 0, False, False);
346 e_DrawFill(Box
[1], X
+ 4, Y
, Width
* 4, 1, 0, False, False);
347 e_Draw(Box
[2], X
+ 4 + Width
* 16, Y
, 0, False, False);
348 e_DrawFill(Box
[3], X
, Y
+ 4, 1, Height
* 4, 0, False, False);
349 e_DrawFill(Box
[4], X
+ 4, Y
+ 4, Width
, Height
, 0, False, False);
350 e_DrawFill(Box
[5], X
+ 4 + Width
* 16, Y
+ 4, 1, Height
* 4, 0, False, False);
351 e_Draw(Box
[6], X
, Y
+ 4 + Height
* 16, 0, False, False);
352 e_DrawFill(Box
[7], X
+ 4, Y
+ 4 + Height
* 16, Width
* 4, 1, 0, False, False);
353 e_Draw(Box
[8], X
+ 4 + Width
* 16, Y
+ 4 + Height
* 16, 0, False, False);
356 procedure r_GUI_Draw_ModelView (ctrl
: TGUIModelView
);
358 DrawBox(ctrl
.X
, ctrl
.Y
, 4, 4);
359 if ctrl
.Model
<> nil then
360 r_PlayerModel_Draw(ctrl
.Model
, ctrl
.X
+ 4, ctrl
.Y
+ 4);
363 procedure r_GUI_Draw_MapPreview (ctrl
: TGUIMapPreview
);
364 var a
: Integer; r
, g
, b
: Byte;
366 DrawBox(ctrl
.X
, ctrl
.Y
, MAPPREVIEW_WIDTH
, MAPPREVIEW_HEIGHT
);
367 if (ctrl
.MapSize
.X
<= 0) or (ctrl
.MapSize
.Y
<= 0) then
369 e_DrawFillQuad(ctrl
.X
+ 4, ctrl
.Y
+ 4, ctrl
.X
+ 4 + Trunc(ctrl
.MapSize
.X
/ ctrl
.Scale
) - 1, ctrl
.Y
+ 4 + Trunc(ctrl
.MapSize
.Y
/ ctrl
.Scale
) - 1, 32, 32, 32, 0);
370 if ctrl
.MapData
<> nil then
371 for a
:= 0 to High(ctrl
.MapData
) do
372 with ctrl
.MapData
[a
] do
374 if X1
> MAPPREVIEW_WIDTH
* 16 then Continue
;
375 if Y1
> MAPPREVIEW_HEIGHT
* 16 then Continue
;
376 if X2
< 0 then Continue
;
377 if Y2
< 0 then Continue
;
378 if X2
> MAPPREVIEW_WIDTH
* 16 then X2
:= MAPPREVIEW_WIDTH
* 16;
379 if Y2
> MAPPREVIEW_HEIGHT
* 16 then Y2
:= MAPPREVIEW_HEIGHT
* 16;
380 if X1
< 0 then X1
:= 0;
381 if Y1
< 0 then Y1
:= 0;
385 r
:= 255; g
:= 255; b
:= 255;
389 r
:= 255; g
:= 255; b
:= 0;
393 r
:= 0; g
:= 0; b
:= 192;
397 r
:= 0; g
:= 176; b
:= 0;
401 r
:= 176; g
:= 0; b
:= 0;
404 r
:= 128; g
:= 128; b
:= 128;
406 if ((X2
- X1
) > 0) and ((Y2
- Y1
) > 0) then
407 e_DrawFillQuad(ctrl
.X
+ 4 + X1
, ctrl
.Y
+ 4 + Y1
, ctrl
.X
+ 4 + X2
- 1, ctrl
.Y
+ 4 + Y2
- 1, r
, g
, b
, 0);
411 procedure r_GUI_Draw_Image (ctrl
: TGUIImage
);
414 if ctrl
.ImageRes
= '' then
416 if g_Texture_Get(ctrl
.DefaultRes
, ID
) then
417 e_Draw(ID
, ctrl
.X
, ctrl
.Y
, 0, True, False);
421 if g_Texture_Get(ctrl
.ImageRes
, ID
) then
422 e_Draw(ID
, ctrl
.X
, ctrl
.Y
, 0, True, False);
426 procedure DrawScroll(X
, Y
: Integer; Height
: Word; Up
, Down
: Boolean);
432 g_Texture_Get(BSCROLL_UPA
, ID
)
434 g_Texture_Get(BSCROLL_UPU
, ID
);
435 e_Draw(ID
, X
, Y
, 0, False, False);
437 g_Texture_Get(BSCROLL_DOWNA
, ID
)
439 g_Texture_Get(BSCROLL_DOWNU
, ID
);
440 e_Draw(ID
, X
, Y
+ (Height
- 1) * 16, 0, False, False);
441 g_Texture_Get(BSCROLL_MIDDLE
, ID
);
442 e_DrawFill(ID
, X
, Y
+ 16, 1, Height
- 2, 0, False, False);
445 procedure r_GUI_Draw_ListBox (ctrl
: TGUIListBox
); // + TGUIFileListBox
446 var w2
, h2
: Word; a
: Integer; s
: string;
448 if ctrl
.DrawBack
then
449 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
450 if ctrl
.DrawScrollBar
then
451 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));
452 if ctrl
.Items
<> nil then
454 for a
:= ctrl
.StartLine
to Min(High(ctrl
.Items
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
457 ctrl
.Font
.GetTextSize(s
, w2
, h2
);
458 while (Length(s
) > 0) and (w2
> ctrl
.Width
* 16) do
460 SetLength(s
, Length(s
) - 1);
461 ctrl
.Font
.GetTextSize(s
, w2
, h2
);
463 if a
= ctrl
.ItemIndex
then
464 ctrl
.Font
.Draw(ctrl
.X
+ 4, ctrl
.Y
+ 4 + (a
- ctrl
.StartLine
) * 16, s
, ctrl
.ActiveColor
.R
, ctrl
.ActiveColor
.G
, ctrl
.ActiveColor
.B
)
466 ctrl
.Font
.Draw(ctrl
.X
+ 4, ctrl
.Y
+ 4 + (a
- ctrl
.StartLine
) * 16, s
, ctrl
.UnActiveColor
.R
, ctrl
.UnActiveColor
.G
, ctrl
.UnActiveColor
.B
);
471 procedure r_GUI_Draw_Memo (ctrl
: TGUIMemo
);
474 if ctrl
.DrawBack
then
475 DrawBox(ctrl
.X
, ctrl
.Y
, ctrl
.Width
+ 1, ctrl
.Height
);
476 if ctrl
.DrawScrollBar
then
477 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));
478 if ctrl
.Lines
<> nil then
479 for a
:= ctrl
.StartLine
to Min(High(ctrl
.Lines
), ctrl
.StartLine
+ ctrl
.Height
- 1) do
480 ctrl
.Font
.Draw(ctrl
.X
+ 4, ctrl
.Y
+ 4 + (a
- ctrl
.StartLine
) * 16, ctrl
.Lines
[a
], ctrl
.Color
.R
, ctrl
.Color
.G
, ctrl
.Color
.B
);
483 procedure r_GUI_Draw_MainMenu (ctrl
: TGUIMainMenu
);
484 var a
: Integer; w
, h
: Word; ID
: DWORD
;
486 if ctrl
.Header
<> nil then
488 r_GUI_Draw_Label(ctrl
.Header
)
490 else if LogoTex
<> 0 then
492 e_GetTextureSize(LogoTex
, @w
, @h
);
493 e_Draw(LogoTex
, ((gScreenWidth
div 2) - (w
div 2)), ctrl
.Buttons
[0].Y
- ctrl
.Buttons
[0].GetHeight
- h
, 0, True, False);
495 if ctrl
.Buttons
<> nil then
497 for a
:= 0 to High(ctrl
.Buttons
) do
498 if ctrl
.Buttons
[a
] <> nil then
499 r_GUI_Draw_TextButton(ctrl
.Buttons
[a
]);
500 if ctrl
.Index
<> -1 then
502 ID
:= MarkerID
[ctrl
.Counter
DIV MAINMENU_MARKERDELAY
MOD 2 <> 0];
503 e_Draw(ID
, ctrl
.Buttons
[ctrl
.Index
].X
- 48, ctrl
.Buttons
[ctrl
.Index
].Y
, 0, True, False);
508 procedure r_GUI_Draw_Menu (ctrl
: TGUIMenu
);
509 var a
, locx
, locy
: Integer;
511 if ctrl
.Header
<> nil then
512 r_GUI_Draw_Label(ctrl
.Header
);
513 if ctrl
.Items
<> nil then
515 for a
:= 0 to High(ctrl
.Items
) do
517 if ctrl
.Items
[a
].Text <> nil then
518 r_GUI_Draw_Control(ctrl
.Items
[a
].Text);
519 if ctrl
.Items
[a
].Control
<> nil then
520 r_GUI_Draw_Control(ctrl
.Items
[a
].Control
);
523 if (ctrl
.Index
<> -1) and (ctrl
.Counter
> MENU_MARKERDELAY
div 2) then
527 if ctrl
.Items
[ctrl
.Index
].Text <> nil then
529 locx
:= ctrl
.Items
[ctrl
.Index
].Text.X
;
530 locy
:= ctrl
.Items
[ctrl
.Index
].Text.Y
;
532 if ctrl
.Items
[ctrl
.Index
].Text.RightAlign
then
534 locx
:= locx
+ ctrl
.Items
[ctrl
.Index
].Text.CMaxWidth
- ctrl
.Items
[ctrl
.Index
].Text.GetWidth
;
537 else if ctrl
.Items
[ctrl
.Index
].Control
<> nil then
539 locx
:= ctrl
.Items
[ctrl
.Index
].Control
.X
;
540 locy
:= ctrl
.Items
[ctrl
.Index
].Control
.Y
;
542 locx
:= locx
- e_CharFont_GetMaxWidth(ctrl
.FontID
);
543 e_CharFont_PrintEx(ctrl
.FontID
, locx
, locy
, #16, _RGB(255, 0, 0));
547 procedure r_GUI_Draw_Control (ctrl
: TGUIControl
);
549 if ctrl
is TGUITextButton
then
550 r_GUI_Draw_TextButton(TGUITextButton(ctrl
))
551 else if ctrl
is TGUILabel
then
552 r_GUI_Draw_Label(TGUILabel(ctrl
))
553 else if ctrl
is TGUIScroll
then
554 r_GUI_Draw_Scroll(TGUIScroll(ctrl
))
555 else if ctrl
is TGUISwitch
then
556 r_GUI_Draw_Switch(TGUISwitch(ctrl
))
557 else if ctrl
is TGUIEdit
then
558 r_GUI_Draw_Edit(TGUIEdit(ctrl
))
559 else if ctrl
is TGUIKeyRead
then
560 r_GUI_Draw_KeyRead(TGUIKeyRead(ctrl
))
561 else if ctrl
is TGUIKeyRead2
then
562 r_GUI_Draw_KeyRead2(TGUIKeyRead2(ctrl
))
563 else if ctrl
is TGUIModelView
then
564 r_GUI_Draw_ModelView(TGUIModelView(ctrl
))
565 else if ctrl
is TGUIMapPreview
then
566 r_GUI_Draw_MapPreview(TGUIMapPreview(ctrl
))
567 else if ctrl
is TGUIImage
then
568 r_GUI_Draw_Image(TGUIImage(ctrl
))
569 else if ctrl
is TGUIListBox
then
570 r_GUI_Draw_ListBox(TGUIListBox(ctrl
)) // + TGUIFileListBox
571 else if ctrl
is TGUIMemo
then
572 r_GUI_Draw_Memo(TGUIMemo(ctrl
))
573 else if ctrl
is TGUIMainMenu
then
574 r_GUI_Draw_MainMenu(TGUIMainMenu(ctrl
))
575 else if ctrl
is TGUIMenu
then
576 r_GUI_Draw_Menu(TGUIMenu(ctrl
))
581 procedure r_GUI_Draw_Window (win
: TGUIWindow
);
582 var i
: Integer; ID
: DWORD
; tw
, th
: Word;
584 // Here goes code duplication from g_game.pas:DrawMenuBackground()
585 if win
.BackTexture
<> '' then
586 if g_Texture_Get(win
.BackTexture
, ID
) then
589 e_GetTextureSize(ID
, @tw
, @th
);
591 tw
:= round(tw
* 1.333 * (gScreenHeight
/ th
))
593 tw
:= trunc(tw
* (gScreenHeight
/ th
));
594 e_DrawSize(ID
, (gScreenWidth
- tw
) div 2, 0, 0, False, False, tw
, gScreenHeight
);
597 e_Clear(0.5, 0.5, 0.5);
600 if win
.Name
= 'AuthorsMenu' then
601 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
602 for i
:= 0 to High(win
.Childs
) do
603 if win
.Childs
[i
] <> nil then
604 r_GUI_Draw_Control(win
.Childs
[i
]);