From dbcda53050faa619d592a5fb806d7ccbcc7ad4b0 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 31 Jan 2022 21:31:48 +0300 Subject: [PATCH] render: move TFont into render --- src/game/g_gui.pas | 244 +++++++++++++++----------------------- src/game/g_menu.pas | 125 ++++++++++--------- src/game/opengl/r_gui.pas | 157 ++++++++++++++++++------ 3 files changed, 277 insertions(+), 249 deletions(-) diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 832e737..a872643 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -75,22 +75,6 @@ type lParam: LongInt; end; - TFontType = (Texture, Character); - - TFont = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} - private - FID: DWORD; - FScale: Single; - FFontType: TFontType; - public - constructor Create(FontID: DWORD; FontType: TFontType); - destructor Destroy; override; - procedure Draw(X, Y: Integer; Text: string; R, G, B: Byte); - procedure GetTextSize(Text: string; var w, h: Word); - property Scale: Single read FScale write FScale; - property ID: DWORD read FID; - end; - TGUIControl = class; TGUIWindow = class; @@ -168,20 +152,20 @@ type private FText: string; FColor: TRGB; - FFont: TFont; + FBigFont: Boolean; FSound: string; FShowWindow: string; public Proc: procedure; ProcEx: procedure (sender: TGUITextButton); - constructor Create(aProc: Pointer; FontID: DWORD; Text: string); + constructor Create(aProc: Pointer; BigFont: Boolean; Text: string); destructor Destroy(); override; procedure OnMessage(var Msg: TMessage); override; procedure Update(); override; procedure Click(Silent: Boolean = False); property Caption: string read FText write FText; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property ShowWindow: string read FShowWindow write FShowWindow; end; @@ -189,17 +173,17 @@ type private FText: string; FColor: TRGB; - FFont: TFont; + FBigFont: Boolean; FFixedLen: Word; FOnClickEvent: TOnClickEvent; public - constructor Create(Text: string; FontID: DWORD); + constructor Create(Text: string; BigFont: Boolean); procedure OnMessage(var Msg: TMessage); override; property OnClick: TOnClickEvent read FOnClickEvent write FOnClickEvent; property FixedLength: Word read FFixedLen write FFixedLen; property Text: string read FText write FText; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; end; TGUIScroll = class(TGUIControl) @@ -221,27 +205,27 @@ type TGUISwitch = class(TGUIControl) private - FFont: TFont; + FBigFont: Boolean; FItems: TGUIItemsList; FIndex: Integer; FColor: TRGB; FOnChangeEvent: TOnChangeEvent; public - constructor Create(FontID: DWORD); + constructor Create(BigFont: Boolean); procedure OnMessage(var Msg: TMessage); override; procedure AddItem(Item: string); procedure Update; override; function GetText: string; property ItemIndex: Integer read FIndex write FIndex; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property OnChange: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent; property Items: TGUIItemsList read FItems; end; TGUIEdit = class(TGUIControl) private - FFont: TFont; + FBigFont: Boolean; FCaretPos: Integer; FMaxLength: Word; FWidth: Word; @@ -253,7 +237,7 @@ type FInvalid: Boolean; procedure SetText(Text: string); public - constructor Create(FontID: DWORD); + constructor Create(BigFont: Boolean); procedure OnMessage(var Msg: TMessage); override; procedure Update; override; property OnChange: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent; @@ -263,7 +247,7 @@ type property OnlyDigits: Boolean read FOnlyDigits write FOnlyDigits; property Text: string read FText write SetText; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property Invalid: Boolean read FInvalid write FInvalid; property CaretPos: Integer read FCaretPos; @@ -271,17 +255,17 @@ type TGUIKeyRead = class(TGUIControl) private - FFont: TFont; + FBigFont: Boolean; FColor: TRGB; FKey: Word; FIsQuery: Boolean; public - constructor Create(FontID: DWORD); + constructor Create(BigFont: Boolean); procedure OnMessage(var Msg: TMessage); override; function WantActivationKey (key: LongInt): Boolean; override; property Key: Word read FKey write FKey; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property IsQuery: Boolean read FIsQuery; end; @@ -289,21 +273,20 @@ type // can hold two keys TGUIKeyRead2 = class(TGUIControl) private - FFont: TFont; - FFontID: DWORD; + FBigFont: Boolean; FColor: TRGB; FKey0, FKey1: Word; // this should be an array. sorry. FKeyIdx: Integer; FIsQuery: Boolean; FMaxKeyNameWdt: Integer; public - constructor Create(FontID: DWORD); + constructor Create(BigFont: Boolean); procedure OnMessage(var Msg: TMessage); override; function WantActivationKey (key: LongInt): Boolean; override; property Key0: Word read FKey0 write FKey0; property Key1: Word read FKey1 write FKey1; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property IsQuery: Boolean read FIsQuery; property MaxKeyNameWdt: Integer read FMaxKeyNameWdt; @@ -373,7 +356,7 @@ type FItems: SSArray; FActiveColor: TRGB; FUnActiveColor: TRGB; - FFont: TFont; + FBigFont: Boolean; FStartLine: Integer; FIndex: Integer; FWidth: Word; @@ -387,7 +370,7 @@ type procedure FSetIndex(aIndex: Integer); public - constructor Create(FontID: DWORD; Width, Height: Word); + constructor Create(BigFont: Boolean; Width, Height: Word); procedure OnMessage(var Msg: TMessage); override; procedure AddItem(Item: String); function ItemExists (item: String): Boolean; @@ -403,7 +386,7 @@ type property DrawScrollBar: Boolean read FDrawScroll write FDrawScroll; property ActiveColor: TRGB read FActiveColor write FActiveColor; property UnActiveColor: TRGB read FUnActiveColor write FUnActiveColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property Width: Word read FWidth; property Height: Word read FHeight; @@ -432,7 +415,7 @@ type TGUIMemo = class(TGUIControl) private FLines: SSArray; - FFont: TFont; + FBigFont: Boolean; FStartLine: Integer; FWidth: Word; FHeight: Word; @@ -440,14 +423,14 @@ type FDrawBack: Boolean; FDrawScroll: Boolean; public - constructor Create(FontID: DWORD; Width, Height: Word); + constructor Create(BigFont: Boolean; Width, Height: Word); procedure OnMessage(var Msg: TMessage); override; procedure Clear; procedure SetText(Text: string); property DrawBack: Boolean read FDrawBack write FDrawBack; property DrawScrollBar: Boolean read FDrawScroll write FDrawScroll; property Color: TRGB read FColor write FColor; - property Font: TFont read FFont write FFont; + property BigFont: Boolean read FBigFont write FBigFont; property Width: Word read FWidth; property Height: Word read FHeight; @@ -462,10 +445,10 @@ type FButtons: TGUITextButtonList; FHeader: TGUILabel; FIndex: Integer; - FFontID: DWORD; + FBigFont: Boolean; FCounter: Byte; // !!! update it within render public - constructor Create(FontID: DWORD; Header: string); + constructor Create(BigFont: Boolean; Header: string); destructor Destroy; override; procedure OnMessage(var Msg: TMessage); override; function AddButton(fProc: Pointer; Caption: string; ShowWindow: string = ''): TGUITextButton; @@ -495,14 +478,14 @@ type FItems: TMenuItemList; FHeader: TGUILabel; FIndex: Integer; - FFontID: DWORD; + FBigFont: Boolean; FCounter: Byte; FAlign: Boolean; FLeft: Integer; FYesNo: Boolean; function NewItem(): Integer; public - constructor Create(HeaderFont, ItemsFont: DWORD; Header: string); + constructor Create(HeaderBigFont, ItemsBigFont: Boolean; Header: string); destructor Destroy; override; procedure OnMessage(var Msg: TMessage); override; procedure AddSpace(); @@ -531,7 +514,7 @@ type property Counter: Byte read FCounter; property Index: Integer read FIndex; property Items: TMenuItemList read FItems; - property FontID: DWORD read FFontID; + property BigFont: Boolean read FBigFont; end; var @@ -555,7 +538,8 @@ uses g_system, {$ENDIF} {$IFDEF ENABLE_RENDER} - r_gui, r_textures, r_graphics, + r_gui, + r_textures, (* load/free image *) {$ENDIF} g_sound, SysUtils, e_res, g_game, Math, StrUtils, g_player, g_options, @@ -565,7 +549,7 @@ uses var Saved_Windows: SSArray; -function GetLines (Text: string; FontID: DWORD; MaxWidth: Word): SSArray; +function GetLines (Text: string; BigFont: Boolean; MaxWidth: Word): SSArray; var i, j, len, lines: Integer; function GetLine (j, i: Integer): String; @@ -574,9 +558,9 @@ function GetLines (Text: string; FontID: DWORD; MaxWidth: Word): SSArray; end; function GetWidth (j, i: Integer): Integer; - var w, h: Word; + var w, h: Integer; begin - e_CharFont_GetSize(FontID, GetLine(j, i), w, h); + r_GUI_GetStringSize(BigFont, GetLine(j, i), w, h); result := w end; @@ -924,15 +908,14 @@ begin if FShowWindow <> '' then g_GUI_ShowWindow(FShowWindow); end; -constructor TGUITextButton.Create(aProc: Pointer; FontID: DWORD; Text: string); +constructor TGUITextButton.Create(aProc: Pointer; BigFont: Boolean; Text: string); begin inherited Create(); Self.Proc := aProc; ProcEx := nil; - FFont := TFont.Create(FontID, TFontType.Character); - + FBigFont := BigFont; FText := Text; end; @@ -961,43 +944,6 @@ begin inherited; end; -{ TFont } - -constructor TFont.Create(FontID: DWORD; FontType: TFontType); -begin - FID := FontID; - FScale := 1; - FFontType := FontType; -end; - -destructor TFont.Destroy; -begin - - inherited; -end; - -procedure TFont.Draw(X, Y: Integer; Text: string; R, G, B: Byte); -begin - if FFontType = TFontType.Character then e_CharFont_PrintEx(ID, X, Y, Text, _RGB(R, G, B), FScale) - else e_TextureFontPrintEx(X, Y, Text, ID, R, G, B, FScale); -end; - -procedure TFont.GetTextSize(Text: string; var w, h: Word); -var - cw, ch: Byte; -begin - if FFontType = TFontType.Character then e_CharFont_GetSize(ID, Text, w, h) - else - begin - e_TextureFontGetSize(ID, cw, ch); - w := cw*Length(Text); - h := ch; - end; - - w := Round(w*FScale); - h := Round(h*FScale); -end; - { TGUIMainMenu } function TGUIMainMenu.AddButton(fProc: Pointer; Caption: string; ShowWindow: string = ''): TGUITextButton; @@ -1010,7 +956,7 @@ begin FIndex := 0; SetLength(FButtons, Length(FButtons)+1); - FButtons[High(FButtons)] := TGUITextButton.Create(fProc, FFontID, Caption); + FButtons[High(FButtons)] := TGUITextButton.Create(fProc, FBigFont, Caption); FButtons[High(FButtons)].ShowWindow := ShowWindow; with FButtons[High(FButtons)] do begin @@ -1063,17 +1009,17 @@ begin FButtons[High(FButtons)] := nil; end; -constructor TGUIMainMenu.Create(FontID: DWORD; Header: string); +constructor TGUIMainMenu.Create(BigFont: Boolean; Header: string); begin inherited Create(); FIndex := -1; - FFontID := FontID; + FBigFont := BigFont; FCounter := MAINMENU_MARKERDELAY; if Header <> '' then begin - FHeader := TGUILabel.Create(Header, FFontID); + FHeader := TGUILabel.Create(Header, BigFont); with FHeader do begin FColor := MAINMENU_HEADER_COLOR; @@ -1183,12 +1129,11 @@ end; { TGUILabel } -constructor TGUILabel.Create(Text: string; FontID: DWORD); +constructor TGUILabel.Create(Text: string; BigFont: Boolean); begin inherited Create(); - FFont := TFont.Create(FontID, TFontType.Character); - + FBigFont := BigFont; FText := Text; FFixedLen := 0; FOnClickEvent := nil; @@ -1217,7 +1162,7 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUITextButton.Create(Proc, FFontID, fText); + Control := TGUITextButton.Create(Proc, FBigFont, fText); with Control as TGUITextButton do begin ShowWindow := _ShowWindow; @@ -1242,7 +1187,7 @@ begin i := NewItem(); with FItems[i] do begin - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1259,7 +1204,7 @@ var a, i: Integer; l: SSArray; begin - l := GetLines(fText, FFontID, MaxWidth); + l := GetLines(fText, FBigFont, MaxWidth); if l = nil then Exit; @@ -1268,7 +1213,7 @@ begin i := NewItem(); with FItems[i] do begin - Text := TGUILabel.Create(l[a], FFontID); + Text := TGUILabel.Create(l[a], FBigFont); if FYesNo then begin with Text do begin FColor := _RGB(255, 0, 0); end; @@ -1299,18 +1244,18 @@ begin ReAlign(); end; -constructor TGUIMenu.Create(HeaderFont, ItemsFont: DWORD; Header: string); +constructor TGUIMenu.Create(HeaderBigFont, ItemsBigFont: Boolean; Header: string); begin inherited Create(); FItems := nil; FIndex := -1; - FFontID := ItemsFont; + FBigFont := ItemsBigFont; FCounter := MENU_MARKERDELAY; FAlign := True; FYesNo := false; - FHeader := TGUILabel.Create(Header, HeaderFont); + FHeader := TGUILabel.Create(Header, HeaderBigFont); with FHeader do begin FX := (gScreenWidth div 2)-(GetWidth div 2); @@ -1493,7 +1438,7 @@ end; procedure TGUIMenu.ReAlign(); var - a, tx, cx, w, h: Integer; + a, tx, cx, w, h, fw, fh: Integer; cww: array of Integer; // cached widths maxcww: Integer; begin @@ -1562,7 +1507,10 @@ begin if (ControlType = TGUIListBox) or (ControlType = TGUIFileListBox) then h := h+(FItems[a].Control as TGUIListBox).GetHeight() else - h := h+e_CharFont_GetMaxHeight(FFontID); + begin + r_GUI_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh; + end; end; end; @@ -1614,7 +1562,11 @@ begin if (ControlType = TGUIListBox) or (ControlType = TGUIFileListBox) then Inc(h, (Control as TGUIListBox).GetHeight+MENU_VSPACE) else if ControlType = TGUIMemo then Inc(h, (Control as TGUIMemo).GetHeight+MENU_VSPACE) - else Inc(h, e_CharFont_GetMaxHeight(FFontID)+MENU_VSPACE); + else + begin + r_GUI_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh + MENU_VSPACE; + end; end; end; @@ -1652,7 +1604,7 @@ begin begin Control := TGUIScroll.Create(); - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1675,10 +1627,10 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUISwitch.Create(FFontID); + Control := TGUISwitch.Create(FBigFont); (Control as TGUISwitch).FColor := MENU_ITEMSCTRL_COLOR; - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1701,7 +1653,7 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIEdit.Create(FFontID); + Control := TGUIEdit.Create(FBigFont); with Control as TGUIEdit do begin FWindow := Self.FWindow; @@ -1710,7 +1662,7 @@ begin if fText = '' then Text := nil else begin - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); Text.FColor := MENU_ITEMSTEXT_COLOR; end; @@ -1745,14 +1697,14 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIKeyRead.Create(FFontID); + Control := TGUIKeyRead.Create(FBigFont); with Control as TGUIKeyRead do begin FWindow := Self.FWindow; FColor := MENU_ITEMSCTRL_COLOR; end; - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1775,14 +1727,14 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIKeyRead2.Create(FFontID); + Control := TGUIKeyRead2.Create(FBigFont); with Control as TGUIKeyRead2 do begin FWindow := Self.FWindow; FColor := MENU_ITEMSCTRL_COLOR; end; - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSCTRL_COLOR; //MENU_ITEMSTEXT_COLOR; @@ -1806,7 +1758,7 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIListBox.Create(FFontID, Width, Height); + Control := TGUIListBox.Create(FBigFont, Width, Height); with Control as TGUIListBox do begin FWindow := Self.FWindow; @@ -1814,7 +1766,7 @@ begin FUnActiveColor := MENU_ITEMSTEXT_COLOR; end; - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1837,7 +1789,7 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIFileListBox.Create(FFontID, Width, Height); + Control := TGUIFileListBox.Create(FBigFont, Width, Height); with Control as TGUIFileListBox do begin FWindow := Self.FWindow; @@ -1847,7 +1799,7 @@ begin if fText = '' then Text := nil else begin - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); Text.FColor := MENU_ITEMSTEXT_COLOR; end; @@ -1868,14 +1820,14 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUILabel.Create('', FFontID); + Control := TGUILabel.Create('', FBigFont); with Control as TGUILabel do begin FWindow := Self.FWindow; FColor := MENU_ITEMSCTRL_COLOR; end; - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); with Text do begin FColor := MENU_ITEMSTEXT_COLOR; @@ -1898,7 +1850,7 @@ begin i := NewItem(); with FItems[i] do begin - Control := TGUIMemo.Create(FFontID, Width, Height); + Control := TGUIMemo.Create(FBigFont, Width, Height); with Control as TGUIMemo do begin FWindow := Self.FWindow; @@ -1907,7 +1859,7 @@ begin if fText = '' then Text := nil else begin - Text := TGUILabel.Create(fText, FFontID); + Text := TGUILabel.Create(fText, FBigFont); Text.FColor := MENU_ITEMSTEXT_COLOR; end; @@ -2002,13 +1954,13 @@ begin if FIndex = -1 then FIndex := 0; end; -constructor TGUISwitch.Create(FontID: DWORD); +constructor TGUISwitch.Create(BigFont: Boolean); begin inherited Create(); FIndex := -1; - FFont := TFont.Create(FontID, TFontType.Character); + FBigFont := BigFont; end; function TGUISwitch.GetText: string; @@ -2068,12 +2020,11 @@ end; { TGUIEdit } -constructor TGUIEdit.Create(FontID: DWORD); +constructor TGUIEdit.Create(BigFont: Boolean); begin inherited Create(); - FFont := TFont.Create(FontID, TFontType.Character); - + FBigFont := BigFont; FMaxLength := 0; FWidth := 0; FInvalid := false; @@ -2157,13 +2108,12 @@ end; { TGUIKeyRead } -constructor TGUIKeyRead.Create(FontID: DWORD); +constructor TGUIKeyRead.Create(BigFont: Boolean); begin inherited Create(); FKey := 0; FIsQuery := false; - - FFont := TFont.Create(FontID, TFontType.Character); + FBigFont := BigFont; end; function TGUIKeyRead.WantActivationKey (key: LongInt): Boolean; @@ -2252,10 +2202,8 @@ end; { TGUIKeyRead2 } -constructor TGUIKeyRead2.Create(FontID: DWORD); -var - a: Byte; - w, h: Word; +constructor TGUIKeyRead2.Create(BigFont: Boolean); + var a: Byte; w, h: Integer; begin inherited Create(); @@ -2264,22 +2212,24 @@ begin FKeyIdx := 0; FIsQuery := False; - FFontID := FontID; - FFont := TFont.Create(FontID, TFontType.Character); + FBigFont := BigFont; FMaxKeyNameWdt := 0; + + FMaxKeyNameWdt := 0; + for a := 0 to 255 do begin - FFont.GetTextSize(e_KeyNames[a], w, h); + r_GUI_GetStringSize(BigFont, e_KeyNames[a], w, h); FMaxKeyNameWdt := Max(FMaxKeyNameWdt, w); end; FMaxKeyNameWdt := FMaxKeyNameWdt-(FMaxKeyNameWdt div 3); - FFont.GetTextSize(KEYREAD_QUERY, w, h); + r_GUI_GetStringSize(BigFont, KEYREAD_QUERY, w, h); if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; - FFont.GetTextSize(KEYREAD_CLEAR, w, h); + r_GUI_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; end; @@ -2631,12 +2581,11 @@ begin FIndex := -1; end; -constructor TGUIListBox.Create(FontID: DWORD; Width, Height: Word); +constructor TGUIListBox.Create(BigFont: Boolean; Width, Height: Word); begin inherited Create(); - FFont := TFont.Create(FontID, TFontType.Character); - + FBigFont := BigFont; FWidth := Width; FHeight := Height; FIndex := -1; @@ -2999,12 +2948,11 @@ begin FStartLine := 0; end; -constructor TGUIMemo.Create(FontID: DWORD; Width, Height: Word); +constructor TGUIMemo.Create(BigFont: Boolean; Width, Height: Word); begin inherited Create(); - FFont := TFont.Create(FontID, TFontType.Character); - + FBigFont := BigFont; FWidth := Width; FHeight := Height; FDrawBack := True; @@ -3048,7 +2996,7 @@ end; procedure TGUIMemo.SetText(Text: string); begin FStartLine := 0; - FLines := GetLines(Text, FFont.ID, FWidth*16); + FLines := GetLines(Text, FBigFont, FWidth * 16); end; { TGUIimage } diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index f80e7cb..6b68a6a 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -52,7 +52,7 @@ uses g_corpses, {$ENDIF} {$IFDEF ENABLE_RENDER} - r_render, r_game, + r_render, {$ENDIF} {$IFDEF ENABLE_SYSTEM} g_system, @@ -89,7 +89,7 @@ begin TYNCallback(ctl.UserData)(false); end; -function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow; +function CreateYNMenu (WinName, Text: String; MaxLen: Word; ActionProc: TYNCallback): TGUIWindow; var menu: TGUIMenu; begin @@ -99,7 +99,7 @@ begin begin //OnKeyDownEx := @YNKeyDownProc; //UserData := @ActionProc; - menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, ''))); + menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(False, False, ''))); with menu do begin Name := '__temp_yes_no_menu:'+WinName; @@ -1854,7 +1854,7 @@ var begin Menu := TGUIWindow.Create('FirstLanguageMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do // space to prevent show logo + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, ' '))) do // space to prevent show logo begin Name := 'mmFirstLanguageMenu'; AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', ''); @@ -1882,7 +1882,7 @@ begin a := _lc[I_MENU_PLAYER_1] else a := _lc[I_MENU_PLAYER_2]; - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, a))) do begin Name := 'mOptionsPlayers'+s+'Menu'; with AddEdit(_lc[I_MENU_PLAYER_NAME]) do @@ -1947,7 +1947,7 @@ var //list: SSArray; begin Menu := TGUIWindow.Create('MainMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do begin Name := 'mmMainMenu'; AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu'); @@ -1957,7 +1957,7 @@ begin AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu'); AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu'); end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), False))) do begin Color := _RGB(255, 255, 255); X := gScreenWidth-GetWidth-8; @@ -1968,7 +1968,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('NewGameMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_NEW_GAME]))) do begin Name := 'mmNewGameMenu'; AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]); @@ -1980,7 +1980,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('NetGameMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MULTIPLAYER]))) do begin Name := 'mmNetGameMenu'; AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu'); @@ -1990,7 +1990,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('NetServerMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_SERVER]))) do begin Name := 'mNetServerMenu'; with AddEdit(_lc[I_NET_SERVER_NAME]) do @@ -2191,7 +2191,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('NetClientMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_CLIENT]))) do begin Name := 'mNetClientMenu'; @@ -2233,7 +2233,7 @@ begin Menu := TGUIWindow.Create('LoadMenu'); Menu.OnShow := ProcLoadMenu; - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LOAD_GAME]))) do begin Name := 'mmLoadMenu'; @@ -2251,7 +2251,7 @@ begin Menu := TGUIWindow.Create('SaveMenu'); Menu.OnShow := ProcSaveMenu; - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SAVE_GAME]))) do begin Name := 'mmSaveMenu'; @@ -2268,7 +2268,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('CustomGameMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CUSTOM_GAME]))) do begin Name := 'mCustomGameMenu'; with AddLabel(_lc[I_MENU_MAP]) do @@ -2426,7 +2426,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('CampaignMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CAMPAIGN]))) do begin Name := 'mCampaignMenu'; @@ -2489,7 +2489,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('SelectMapMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SELECT_MAP]))) do begin Name := 'mSelectMapMenu'; with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do @@ -2540,7 +2540,7 @@ begin X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2; Y := GetControl('lsMapWAD').Y; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create('', False))) do begin Name := 'lbMapScale'; FixedLength := 8; @@ -2557,7 +2557,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_OPTIONS]))) do begin Name := 'mmOptionsMenu'; AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu'); @@ -2574,12 +2574,11 @@ begin Menu.DefControl := 'mmOptionsMenu'; g_GUI_AddWindow(Menu); - Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6), - gMenuSmallFont, @ProcSavedMenuKeyDown); + Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6), @ProcSavedMenuKeyDown); g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsVideoMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_VIDEO_OPTIONS]))) do begin Name := 'mOptionsVideoMenu'; AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu'); @@ -2621,7 +2620,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsVideoResMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_RESOLUTION_SELECT]))) do begin Name := 'mOptionsVideoResMenu'; with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do @@ -2656,7 +2655,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsSoundMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SOUND_OPTIONS]))) do begin Name := 'mOptionsSoundMenu'; with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do @@ -2710,7 +2709,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsGameMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_GAME_OPTIONS]))) do begin Name := 'mOptionsGameMenu'; with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do @@ -2828,7 +2827,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROLS_OPTIONS]))) do begin Name := 'mOptionsControlsMenu'; AddLine(_lc[I_MENU_CONTROL_GLOBAL]); @@ -2858,7 +2857,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsP1Menu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_KBD]))) do begin Name := 'mOptionsControlsP1Menu'; AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT]; @@ -2876,7 +2875,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_WEAPONS]))) do begin Name := 'mOptionsControlsP1MenuWeapons'; for i := WP_FIRST to WP_LAST do @@ -2887,7 +2886,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsP2Menu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_KBD]))) do begin Name := 'mOptionsControlsP2Menu'; AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT]; @@ -2905,7 +2904,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_WEAPONS]))) do begin Name := 'mOptionsControlsP2MenuWeapons'; for i := WP_FIRST to WP_LAST do @@ -2916,7 +2915,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsJoystickMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_JOYSTICKS]))) do begin Name := 'mOptionsControlsJoystickMenu'; for i := 0 to e_MaxJoys - 1 do @@ -2930,7 +2929,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsControlsTouchMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_TOUCH]))) do begin Name := 'mOptionsControlsTouchMenu'; with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do @@ -2963,7 +2962,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsPlayersMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_OPTIONS]))) do begin Name := 'mOptionsPlayersMenu'; AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu'); @@ -2976,7 +2975,7 @@ begin CreatePlayerOptionsMenu('P2'); Menu := TGUIWindow.Create('OptionsPlayersMIMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_MODEL_INFO]))) do begin Name := 'mOptionsPlayersMIMenu'; with AddLabel(_lc[I_MENU_MODEL_NAME]) do @@ -3006,7 +3005,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('OptionsLanguageMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LANGUAGE_OPTIONS]))) do begin Name := 'mOptionsLanguageMenu'; AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]); @@ -3016,8 +3015,7 @@ begin Menu.DefControl := 'mOptionsLanguageMenu'; g_GUI_AddWindow(Menu); - Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6), - gMenuSmallFont, @ProcDefaultMenuKeyDown); + Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6), @ProcDefaultMenuKeyDown); g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('AuthorsMenu'); @@ -3026,14 +3024,14 @@ begin // Çàãîëîâîê: _y := 16; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], False))) do begin Color := _RGB(255, 0, 0); X := (gScreenWidth div 2)-(GetWidth() div 2); Y := _y; _y := _y+GetHeight(); end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), False))) do begin Color := _RGB(255, 0, 0); X := (gScreenWidth div 2)-(GetWidth() div 2); @@ -3042,63 +3040,63 @@ begin end; // ×òî äåëàë: Êòî äåëàë cx := gScreenWidth div 2 - 320 + 64; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], False))) do begin Color := _RGB(255, 0, 0); X := cx; Y := _y; _y := _y+22; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+36; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], False))) do begin Color := _RGB(255, 0, 0); X := cx; Y := _y; _y := _y+22; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+22; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+36; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], False))) do begin Color := _RGB(255, 0, 0); X := cx; Y := _y; _y := _y+22; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+36; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], False))) do begin Color := _RGB(255, 0, 0); X := cx; Y := _y; _y := _y+22; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; @@ -3106,35 +3104,35 @@ begin _y := gScreenHeight - 128; end; // Çàêëþ÷åíèå: - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], False))) do begin Color := _RGB(255, 0, 0); X := cx; Y := _y; _y := _y+16; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+GetHeight(); end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := _y+GetHeight(); end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], False))) do begin Color := _RGB(255, 255, 255); X := cx+32; Y := _y; _y := gScreenHeight - 32; end; - with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], False))) do begin Color := _RGB(255, 0, 0); X := gScreenWidth div 2 - GetWidth() div 2; @@ -3142,12 +3140,11 @@ begin end; g_GUI_AddWindow(Menu); - Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6), - gMenuSmallFont, @ProcExitMenuKeyDown); + Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6), @ProcExitMenuKeyDown); g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('GameSingleMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do begin Name := 'mmGameSingleMenu'; AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu'); @@ -3163,16 +3160,14 @@ begin Menu.OnShow := ProcGMShow; g_GUI_AddWindow(Menu); - Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6), - gMenuSmallFont, @ProcEndMenuKeyDown); + Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6), @ProcEndMenuKeyDown); g_GUI_AddWindow(Menu); - Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6), - gMenuSmallFont, @ProcRestartMenuKeyDown); + Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6), @ProcRestartMenuKeyDown); g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('GameCustomMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do begin Name := 'mmGameCustomMenu'; AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu'); @@ -3190,7 +3185,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('GameServerMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do begin Name := 'mmGameServerMenu'; AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu'); @@ -3206,7 +3201,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('GameClientMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do begin Name := 'mmGameClientMenu'; AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu'); @@ -3220,7 +3215,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('ClientPasswordMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(False, False, _lc[I_MENU_ENTERPASSWORD]))) do begin Name := 'mClientPasswordMenu'; with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do @@ -3238,7 +3233,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('GameSetGameMenu'); - with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do + with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SET_GAME]))) do begin Name := 'mGameSetGameMenu'; with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do @@ -3301,7 +3296,7 @@ begin g_GUI_AddWindow(Menu); Menu := TGUIWindow.Create('TeamMenu'); - with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do + with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_CHANGE_PLAYERS]))) do begin Name := 'mmTeamMenu'; AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed'; diff --git a/src/game/opengl/r_gui.pas b/src/game/opengl/r_gui.pas index 039af75..3463a9e 100644 --- a/src/game/opengl/r_gui.pas +++ b/src/game/opengl/r_gui.pas @@ -24,6 +24,8 @@ interface procedure r_GUI_GetSize (ctrl: TGUIControl; out w, h: Integer); procedure r_GUI_GetLogoSize (out w, h: WORD); + procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + procedure r_GUI_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); procedure r_GUI_Draw_Window (win: TGUIWindow); implementation @@ -47,6 +49,23 @@ implementation BOX8 = 'BOX8'; BOX9 = 'BOX9'; + type + TFontType = (Texture, Character); + + TFont = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} + private + FID: DWORD; + FScale: Single; + FFontType: TFontType; + public + constructor Create(FontID: DWORD; FontType: TFontType); + destructor Destroy; override; + procedure Draw(X, Y: Integer; Text: string; R, G, B: Byte); + procedure GetTextSize(Text: string; var w, h: Word); + property Scale: Single read FScale write FScale; + property ID: DWORD read FID; + end; + var Box: Array [0..8] of DWORD; MarkerID: array [Boolean] of DWORD; @@ -56,6 +75,57 @@ implementation Font: array [boolean] of TFont; (* Small[FALSE] / Big[TRUE] *) LogoTex: DWORD; + constructor TFont.Create (FontID: DWORD; FontType: TFontType); + begin + FID := FontID; + FScale := 1; + FFontType := FontType; + end; + + destructor TFont.Destroy; + begin + inherited; + end; + + procedure TFont.Draw (X, Y: Integer; Text: string; R, G, B: Byte); + begin + if FFontType = TFontType.Character then + e_CharFont_PrintEx(ID, X, Y, Text, _RGB(R, G, B), FScale) + else + e_TextureFontPrintEx(X, Y, Text, ID, R, G, B, FScale) + end; + + procedure TFont.GetTextSize (Text: string; var w, h: Word); + var cw, ch: Byte; + begin + if FFontType = TFontType.Character then + e_CharFont_GetSize(ID, Text, w, h) + else + begin + e_TextureFontGetSize(ID, cw, ch); + w := cw * Length(Text); + h := ch; + end; + w := Round(w * FScale); + h := Round(h * FScale); + end; + + procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + var f: TFont; + begin + f := Font[BigFont]; + w := e_CharFont_GetMaxWidth(f.ID); + h := e_CharFont_GetMaxHeight(f.ID); + end; + + procedure r_GUI_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); + var ww, hh: WORD; + begin + e_CharFont_GetSize(Font[BigFont].ID, str, ww, hh); + w := ww; + h := hh; + end; + procedure r_GUI_GetLogoSize (out w, h: WORD); begin w := 0; @@ -150,26 +220,28 @@ implementation end; procedure r_GUI_GetSize_TextButton (ctrl: TGUITextButton; out w, h: Integer); - var ww, hh: WORD; + var ww, hh: WORD; f: TFont; begin - ctrl.Font.GetTextSize(ctrl.Caption, ww, hh); + f := Font[ctrl.BigFont]; + f.GetTextSize(ctrl.Caption, ww, hh); w := ww; h := hh; end; procedure r_GUI_GetSize_Label (ctrl: TGUILabel; out w, h: Integer); - var ww, hh: WORD; + var ww, hh: WORD; f: TFont; begin - ctrl.Font.GetTextSize(ctrl.Text, ww, hh); + f := Font[ctrl.BigFont]; + f.GetTextSize(ctrl.Text, ww, hh); h := hh; if ctrl.FixedLength = 0 then w := ww else - w := e_CharFont_GetMaxWidth(ctrl.Font.ID) * ctrl.FixedLength + w := e_CharFont_GetMaxWidth(f.ID) * ctrl.FixedLength end; procedure r_GUI_GetSize_Switch (ctrl: TGUISwitch; out w, h: Integer); - var i: Integer; ww, hh: WORD; + var i: Integer; ww, hh: WORD; f: TFont; begin w := 0; h := 0; @@ -177,7 +249,8 @@ implementation begin for i := 0 to High(ctrl.Items) do begin - ctrl.Font.GetTextSize(ctrl.Items[i], ww, hh); + f := Font[ctrl.BigFont]; + f.GetTextSize(ctrl.Items[i], ww, hh); if ww > w then w := ww; end; @@ -185,18 +258,19 @@ implementation end; procedure r_GUI_GetSize_KeyRead (ctrl: TGUIKeyRead; out w, h: Integer); - var i: Integer; ww, hh: WORD; + var i: Integer; ww, hh: WORD; f: TFont; begin w := 0; h := 0; // ??? always 0 + f := Font[ctrl.BigFont]; for i := 0 to 255 do begin - ctrl.Font.GetTextSize(e_KeyNames[i], ww, hh); + f.GetTextSize(e_KeyNames[i], ww, hh); w := MAX(w, ww); end; - ctrl.Font.GetTextSize(KEYREAD_QUERY, ww, hh); + f.GetTextSize(KEYREAD_QUERY, ww, hh); if ww > w then w := ww; - ctrl.Font.GetTextSize(KEYREAD_CLEAR, ww, hh); + f.GetTextSize(KEYREAD_CLEAR, ww, hh); if ww > w then w := ww; end; @@ -238,20 +312,23 @@ implementation procedure r_GUI_Draw_Control (ctrl: TGUIControl); forward; procedure r_GUI_Draw_TextButton (ctrl: TGUITextButton); + var f: TFont; begin - ctrl.Font.Draw(ctrl.X, ctrl.Y, ctrl.Caption, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B) + f := Font[ctrl.BigFont]; + f.Draw(ctrl.X, ctrl.Y, ctrl.Caption, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B) end; procedure r_GUI_Draw_Label (ctrl: TGUILabel); - var w, h: Word; + var w, h: Word; f: TFont; begin + f := Font[ctrl.BigFont]; if ctrl.RightAlign then begin - ctrl.Font.GetTextSize(ctrl.Text, w, h); - ctrl.Font.Draw(ctrl.X + ctrl.CMaxWidth - w, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); + f.GetTextSize(ctrl.Text, w, h); + f.Draw(ctrl.X + ctrl.CMaxWidth - w, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); end else - ctrl.Font.Draw(ctrl.X, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); + f.Draw(ctrl.X, ctrl.Y, ctrl.Text, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); end; procedure r_GUI_Draw_Scroll (ctrl: TGUIScroll); @@ -265,12 +342,14 @@ implementation end; procedure r_GUI_Draw_Switch (ctrl: TGUISwitch); + var f: TFont; begin - ctrl.Font.Draw(ctrl.X, ctrl.Y, ctrl.Items[ctrl.ItemIndex], ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); + f := Font[ctrl.BigFont]; + f.Draw(ctrl.X, ctrl.Y, ctrl.Items[ctrl.ItemIndex], ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); end; procedure r_GUI_Draw_Edit (ctrl: TGUIEdit); - var c, w, h: Word; r, g, b: Byte; + var c, w, h: Word; r, g, b: Byte; f: TFont; begin e_Draw(EditLeft, ctrl.X, ctrl.Y, 0, True, False); e_Draw(EditRight, ctrl.X + 8 + ctrl.Width * 16, ctrl.Y, 0, True, False); @@ -285,17 +364,18 @@ implementation g := 128; b := 128; end; - ctrl.Font.Draw(ctrl.X + 8, ctrl.Y, ctrl.Text, r, g, b); + f := Font[ctrl.BigFont]; + f.Draw(ctrl.X + 8, ctrl.Y, ctrl.Text, r, g, b); if ctrl.Window.ActiveControl = ctrl then begin - ctrl.Font.GetTextSize(Copy(ctrl.Text, 1, ctrl.CaretPos), w, h); - h := e_CharFont_GetMaxHeight(ctrl.Font.ID); + f.GetTextSize(Copy(ctrl.Text, 1, ctrl.CaretPos), w, h); + h := e_CharFont_GetMaxHeight(f.ID); 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); end; end; procedure r_GUI_Draw_KeyRead (ctrl: TGUIKeyRead); - var k: AnsiString; + var k: AnsiString; f: TFont; begin if ctrl.IsQuery then k := KEYREAD_QUERY @@ -303,13 +383,14 @@ implementation k := e_KeyNames[ctrl.Key] else k := KEYREAD_CLEAR; - ctrl.Font.Draw(ctrl.X, ctrl.Y, k, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); + f := Font[ctrl.BigFont]; + f.Draw(ctrl.X, ctrl.Y, k, ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); end; procedure r_GUI_Draw_KeyRead2 (ctrl: TGUIKeyRead2); procedure drawText (idx: Integer); - var x, y: Integer; r, g, b: Byte; kk: DWORD; str: AnsiString; + var x, y: Integer; r, g, b: Byte; kk: DWORD; str: AnsiString; f: TFont; begin if idx = 0 then kk := ctrl.Key0 else kk := ctrl.Key1; y := ctrl.Y; @@ -321,9 +402,10 @@ implementation begin r := 255; g := 255; b := 255; end; + f := Font[ctrl.BigFont]; if ctrl.IsQuery and (ctrl.KeyIdx = idx) then begin - ctrl.Font.Draw(x, y, KEYREAD_QUERY, r, g, b) + f.Draw(x, y, KEYREAD_QUERY, r, g, b) end else begin @@ -331,7 +413,7 @@ implementation str := e_KeyNames[kk] else str := KEYREAD_CLEAR; - ctrl.Font.Draw(x, y, str, r, g, b); + f.Draw(x, y, str, r, g, b); end end; @@ -443,7 +525,7 @@ implementation end; procedure r_GUI_Draw_ListBox (ctrl: TGUIListBox); // + TGUIFileListBox - var w2, h2: Word; a: Integer; s: string; + var w2, h2: Word; a: Integer; s: string; f: TFont; begin if ctrl.DrawBack then DrawBox(ctrl.X, ctrl.Y, ctrl.Width + 1, ctrl.Height); @@ -451,33 +533,35 @@ implementation 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)); if ctrl.Items <> nil then begin + f := Font[ctrl.BigFont]; for a := ctrl.StartLine to Min(High(ctrl.Items), ctrl.StartLine + ctrl.Height - 1) do begin s := ctrl.Items[a]; - ctrl.Font.GetTextSize(s, w2, h2); + f.GetTextSize(s, w2, h2); while (Length(s) > 0) and (w2 > ctrl.Width * 16) do begin SetLength(s, Length(s) - 1); - ctrl.Font.GetTextSize(s, w2, h2); + f.GetTextSize(s, w2, h2); end; if a = ctrl.ItemIndex then - ctrl.Font.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.ActiveColor.R, ctrl.ActiveColor.G, ctrl.ActiveColor.B) + f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.ActiveColor.R, ctrl.ActiveColor.G, ctrl.ActiveColor.B) else - ctrl.Font.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.UnActiveColor.R, ctrl.UnActiveColor.G, ctrl.UnActiveColor.B); + f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, s, ctrl.UnActiveColor.R, ctrl.UnActiveColor.G, ctrl.UnActiveColor.B); end; end; end; procedure r_GUI_Draw_Memo (ctrl: TGUIMemo); - var a: Integer; + var a: Integer; f: TFont; begin + f := Font[ctrl.BigFont]; if ctrl.DrawBack then DrawBox(ctrl.X, ctrl.Y, ctrl.Width + 1, ctrl.Height); if ctrl.DrawScrollBar then 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)); if ctrl.Lines <> nil then for a := ctrl.StartLine to Min(High(ctrl.Lines), ctrl.StartLine + ctrl.Height - 1) do - 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); + f.Draw(ctrl.X + 4, ctrl.Y + 4 + (a - ctrl.StartLine) * 16, ctrl.Lines[a], ctrl.Color.R, ctrl.Color.G, ctrl.Color.B); end; procedure r_GUI_Draw_MainMenu (ctrl: TGUIMainMenu); @@ -506,7 +590,7 @@ implementation end; procedure r_GUI_Draw_Menu (ctrl: TGUIMenu); - var a, locx, locy: Integer; + var a, locx, locy: Integer; f: TFont; begin if ctrl.Header <> nil then r_GUI_Draw_Label(ctrl.Header); @@ -539,8 +623,9 @@ implementation locx := ctrl.Items[ctrl.Index].Control.X; locy := ctrl.Items[ctrl.Index].Control.Y; end; - locx := locx - e_CharFont_GetMaxWidth(ctrl.FontID); - e_CharFont_PrintEx(ctrl.FontID, locx, locy, #16, _RGB(255, 0, 0)); + f := Font[ctrl.BigFont]; + locx := locx - e_CharFont_GetMaxWidth(f.ID); + e_CharFont_PrintEx(f.ID, locx, locy, #16, _RGB(255, 0, 0)); end; end; -- 2.29.2