From 4f2245f370850d68a58f1cd18b2fd326042950d8 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 31 Jan 2022 22:08:03 +0300 Subject: [PATCH] menu: allow to build menu without render --- src/game/Doom2DF.lpr | 7 +++- src/game/g_gui.pas | 86 +++++++++++++++++++++++++----------------- src/game/g_menu.pas | 6 ++- src/shared/a_modes.inc | 6 --- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 0a361e6..24289f8 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -161,6 +161,11 @@ uses {$ENDIF} {$ENDIF} + {$IFDEF ENABLE_MENU} + g_gui in 'g_gui.pas', + g_menu in 'g_menu.pas', + {$ENDIF} + {$IFDEF ENABLE_RENDER} {$I ../shared/vampimg.inc} r_animations in 'opengl/r_animations.pas', @@ -185,8 +190,6 @@ uses r_touch in 'opengl/r_touch.pas', {$ENDIF} {$IFDEF ENABLE_MENU} - g_gui in 'g_gui.pas', - g_menu in 'g_menu.pas', r_gui in 'opengl/r_gui.pas', {$ENDIF} {$ENDIF} diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 988d090..734251a 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -557,10 +557,16 @@ function GetLines (Text: string; BigFont: Boolean; MaxWidth: Word): SSArray; end; function GetWidth (j, i: Integer): Integer; - var w, h: Integer; + {$IFDEF ENABLE_RENDER} + var w, h: Integer; + {$ENDIF} begin - r_GUI_GetStringSize(BigFont, GetLine(j, i), w, h); - result := w + {$IFDEF ENABLE_RENDER} + r_GUI_GetStringSize(BigFont, GetLine(j, i), w, h); + Result := w; + {$ELSE} + Result := 0; + {$ENDIF} end; begin @@ -946,11 +952,13 @@ end; { TGUIMainMenu } function TGUIMainMenu.AddButton(fProc: Pointer; Caption: string; ShowWindow: string = ''): TGUITextButton; -var - a, _x: Integer; - h, hh: Word; - lw: Word = 0; - lh: Word = 0; + var + {$IFDEF ENABLE_RENDER} + lw: Word = 0; + {$ENDIF} + a, _x: Integer; + h, hh: Word; + lh: Word = 0; begin FIndex := 0; @@ -970,8 +978,10 @@ begin if FButtons[a] <> nil then _x := Min(_x, (gScreenWidth div 2)-(FButtons[a].GetWidth div 2)); - if FHeader = nil then - r_GUI_GetLogoSize(lw, lh); + {$IFDEF ENABLE_RENDER} + if FHeader = nil then + r_GUI_GetLogoSize(lw, lh); + {$ENDIF} hh := FButtons[High(FButtons)].GetHeight; if FHeader = nil then h := lh + hh * (1 + Length(FButtons)) + MAINMENU_SPACE * (Length(FButtons) - 1) @@ -1436,10 +1446,13 @@ begin end; procedure TGUIMenu.ReAlign(); -var - a, tx, cx, w, h, fw, fh: Integer; - cww: array of Integer; // cached widths - maxcww: Integer; + var + {$IFDEF ENABLE_RENDER} + fw, fh: Integer; + {$ENDIF} + a, tx, cx, w, h: Integer; + cww: array of Integer; // cached widths + maxcww: Integer; begin if FItems = nil then Exit; @@ -1507,8 +1520,10 @@ begin h := h+(FItems[a].Control as TGUIListBox).GetHeight() else begin - r_GUI_GetMaxFontSize(FBigFont, fw, fh); - h := h + fh; + {$IFDEF ENABLE_RENDER} + r_GUI_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh; + {$ENDIF} end; end; end; @@ -1563,8 +1578,12 @@ begin else if ControlType = TGUIMemo then Inc(h, (Control as TGUIMemo).GetHeight+MENU_VSPACE) else begin - r_GUI_GetMaxFontSize(FBigFont, fw, fh); - h := h + fh + MENU_VSPACE; + {$IFDEF ENABLE_RENDER} + r_GUI_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh + MENU_VSPACE; + {$ELSE} + h := h + MENU_VSPACE; + {$ENDIF} end; end; end; @@ -2202,7 +2221,9 @@ end; { TGUIKeyRead2 } constructor TGUIKeyRead2.Create(BigFont: Boolean); - var a: Byte; w, h: Integer; + {$IFDEF ENABLE_RENDER} + var a: Byte; w, h: Integer; + {$ENDIF} begin inherited Create(); @@ -2215,21 +2236,18 @@ begin FMaxKeyNameWdt := 0; - FMaxKeyNameWdt := 0; - - for a := 0 to 255 do - begin - r_GUI_GetStringSize(BigFont, e_KeyNames[a], w, h); - FMaxKeyNameWdt := Max(FMaxKeyNameWdt, w); - end; - - FMaxKeyNameWdt := FMaxKeyNameWdt-(FMaxKeyNameWdt div 3); - - r_GUI_GetStringSize(BigFont, KEYREAD_QUERY, w, h); - if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; - - r_GUI_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); - if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + {$IFDEF ENABLE_RENDER} + for a := 0 to 255 do + begin + r_GUI_GetStringSize(BigFont, e_KeyNames[a], w, h); + FMaxKeyNameWdt := Max(FMaxKeyNameWdt, w); + end; + FMaxKeyNameWdt := FMaxKeyNameWdt-(FMaxKeyNameWdt div 3); + r_GUI_GetStringSize(BigFont, KEYREAD_QUERY, w, h); + if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + r_GUI_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); + if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + {$ENDIF} end; function TGUIKeyRead2.WantActivationKey (key: LongInt): Boolean; diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 6b68a6a..3d731a2 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -1756,7 +1756,11 @@ begin with TGUIListBox(menu.GetControl('lsResolution')) do begin - list := sys_GetDisplayModes(gBPP); + {$IFDEF ENABLE_SYSTEM} + list := sys_GetDisplayModes(gBPP); + {$ELSE} + list := nil; + {$ENDIF} if list <> nil then begin Items := list; diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc index 4ba0007..adfbc14 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -311,12 +311,6 @@ {$ENDIF} {$ENDIF} -{$IFDEF ENABLE_MENU} - {$IFDEF DISABLE_RENDER} - {$FATAL Render driver required for current menu implementation} - {$ENDIF} -{$ENDIF} - {$IFDEF ENABLE_TOUCH} {$IFDEF DISABLE_SYSTEM} {$FATAL System driver required for current touch implementation} -- 2.29.2