From: DeaDDooMER Date: Thu, 27 Jan 2022 15:53:47 +0000 (+0300) Subject: menu: optionally disable menu in client X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=aa7e40301df69aa13c00ff2bcdb8e532b06b8053;p=d2df-sdl.git menu: optionally disable menu in client --- diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index c56af24..eee1e55 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -170,8 +170,10 @@ uses r_textures in 'opengl/r_textures.pas', r_weapons in 'opengl/r_weapons.pas', r_window in 'opengl/r_window.pas', - g_gui in 'g_gui.pas', - g_menu in 'g_menu.pas', + {$IFDEF ENABLE_MENU} + g_gui in 'g_gui.pas', + g_menu in 'g_menu.pas', + {$ENDIF} {$ENDIF} {$IFDEF USE_FMOD} @@ -931,7 +933,9 @@ end; {$ENDIF} {$IFNDEF ANDROID} (* This will fix menu reset on keyboard showing *) - g_Menu_Reset; + {$IFDEF ENABLE_MENU} + g_Menu_Reset; + {$ENDIF} {$ENDIF} //g_Game_ClearLoading; {$IFDEF ENABLE_HOLMES} @@ -975,23 +979,25 @@ end; r_Render_Load; {$ENDIF} g_Game_Init; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_Menu_Init; g_GUI_Init; {$ENDIF} g_Game_Process_Params; // TODO reload GAME textures g_Console_Init; // welcome message - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} if (not gGameOn) and gAskLanguage then g_Menu_AskLanguage; {$ENDIF} Time_Old := GetTickCount64(); while not ProcessMessage() do begin end; g_Console_WriteGameConfig; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_GUI_Destroy; g_Menu_Free; + {$ENDIF} + {$IFNDEF HEADLESS} r_Render_Free; {$ENDIF} {$IFDEF ENABLE_HOLMES} diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 91131d1..20f7c83 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -100,8 +100,11 @@ var implementation uses + {$IFDEF ENABLE_MENU} + g_gui, g_menu, + {$ENDIF} {$IFNDEF HEADLESS} - g_gui, g_menu, g_touch, + g_touch, {$ENDIF} g_textures, e_input, g_game, g_gfx, g_player, g_items, SysUtils, g_basic, g_options, Math, e_res, @@ -154,6 +157,7 @@ var rep: Boolean; down, up: SSArray; end; + menu_toggled: BOOLEAN; (* hack for menu controls *) procedure g_Console_Switch; @@ -884,7 +888,9 @@ begin else if gChatShow then g_Console_Chat_Switch else + begin KeyPress(VK_ESCAPE); + end; menu_toggled := True end; 'toggleconsole': @@ -1768,7 +1774,7 @@ function BindsAllowed (key: Integer): Boolean; var grab, active: Boolean; begin Result := False; - {$IFDEF HEADLESS} + {$IFDEF DISABLE_MENU} grab := False; active := False; {$ELSE} @@ -1811,7 +1817,7 @@ end; procedure g_Console_ProcessBindRepeat (key: Integer); var i: Integer; active: Boolean; begin - {$IFDEF HEADLESS} + {$IFDEF DISABLE_MENU} active := False; {$ELSE} active := g_ActiveWindow <> nil; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 23bf9bd..a6713a7 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -18,8 +18,11 @@ unit g_game; interface uses + {$IFDEF ENABLE_MENU} + g_gui, + {$ENDIF} {$IFNDEF HEADLESS} - g_gui, g_touch, + g_touch, {$ENDIF} SysUtils, Classes, MAPDEF, g_base, g_basic, g_player, g_res_downloader, @@ -113,9 +116,6 @@ function g_Game_GetNextMap(): String; procedure g_Game_NextLevel(); procedure g_Game_Pause(Enable: Boolean); procedure g_Game_HolmesPause(Enable: Boolean); -{$IFNDEF HEADLESS} - procedure g_Game_InGameMenu(Show: Boolean); -{$ENDIF} function g_Game_IsWatchedPlayer(UID: Word): Boolean; function g_Game_IsWatchedTeam(Team: Byte): Boolean; procedure g_Game_Message(Msg: String; Time: Word); @@ -153,11 +153,14 @@ function IsActivePlayer(p: TPlayer): Boolean; function GetActivePlayerID_Next(Skip: Integer = -1): Integer; procedure SortGameStat(var stat: TPlayerStatArray); -procedure KeyPress (K: Word); +{$IFDEF ENABLE_MENU} + procedure g_Game_InGameMenu(Show: Boolean); +{$ENDIF} {$IFNDEF HEADLESS} procedure CharPress (C: AnsiChar); {$ENDIF} + procedure KeyPress (K: Word); { procedure SetWinPause(Enable: Boolean); } @@ -445,8 +448,11 @@ uses {$IFDEF ENABLE_HOLMES} g_holmes, {$ENDIF} + {$IFDEF ENABLE_MENU} + g_menu, + {$ENDIF} {$IFNDEF HEADLESS} - r_render, g_menu, g_system, + r_render, g_system, {$ENDIF} e_res, g_window, e_input, e_log, g_console, g_items, g_map, g_panel, @@ -696,13 +702,10 @@ Cheated: end; +{$IFDEF ENABLE_MENU} procedure KeyPress (K: Word); -{$IFNDEF HEADLESS} -var - Msg: g_gui.TMessage; -{$ENDIF} + var Msg: g_gui.TMessage; begin -{$IFNDEF HEADLESS} case K of VK_ESCAPE: // : begin @@ -775,32 +778,47 @@ begin end; end; end; -{$ENDIF} end; +{$ELSE} + procedure KeyPress (K: Word); + begin + gJustChatted := False; + if gConsoleShow or gChatShow then + begin + g_Console_Control(K); + end + end; +{$ENDIF} {$IFNDEF HEADLESS} -procedure CharPress (C: AnsiChar); -var - Msg: g_gui.TMessage; - a: Integer; -begin - if gConsoleShow or gChatShow then - begin - g_Console_Char(C) - end - else if (g_ActiveWindow <> nil) then - begin - Msg.Msg := WM_CHAR; - Msg.WParam := Ord(C); - g_ActiveWindow.OnMessage(Msg); - end - else + procedure CharPress (C: AnsiChar); + {$IFDEF ENABLE_MENU} + var Msg: g_gui.TMessage; + {$ENDIF} + var a: Integer; begin - for a := 0 to 14 do charbuff[a] := charbuff[a+1]; - charbuff[15] := upcase1251(C); - Cheat(); + if gConsoleShow or gChatShow then + begin + g_Console_Char(C); + end + {$IFDEF ENABLE_MENU} + else if g_ActiveWindow <> nil then + begin + Msg.Msg := WM_CHAR; + Msg.WParam := Ord(C); + g_ActiveWindow.OnMessage(Msg); + end + {$ENDIF} + else + begin + for a := 0 to 14 do + begin + charbuff[a] := charbuff[a + 1]; + end; + charbuff[15] := upcase1251(C); + Cheat; + end; end; -end; {$ENDIF} @@ -1239,7 +1257,7 @@ begin EndingGameCounter := 0; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} g_ActiveWindow := nil; {$ENDIF} @@ -1256,29 +1274,30 @@ begin end else begin // Выход в главное меню -{$IFDEF HEADLESS} - gState := STATE_MENU; // ??? -{$ELSE} - gMusic.SetByName('MUSIC_MENU'); - gMusic.Play(); - if gState <> STATE_SLIST then - begin - g_GUI_ShowWindow('MainMenu'); - gState := STATE_MENU; - end else - begin - // Обновляем список серверов - slReturnPressed := True; - if g_Net_Slist_Fetch(slCurrent) then + {$IFDEF DISABLE_MENU} + gState := STATE_MENU; // ??? + {$ELSE} + gMusic.SetByName('MUSIC_MENU'); + gMusic.Play(); + if gState <> STATE_SLIST then begin - if slCurrent = nil then - slWaitStr := _lc[I_NET_SLIST_NOSERVERS]; + g_GUI_ShowWindow('MainMenu'); + gState := STATE_MENU; end else - slWaitStr := _lc[I_NET_SLIST_ERROR]; - g_Serverlist_GenerateTable(slCurrent, slTable); - end; -{$ENDIF} + begin + // Обновляем список серверов + slReturnPressed := True; + if g_Net_Slist_Fetch(slCurrent) then + begin + if slCurrent = nil then + slWaitStr := _lc[I_NET_SLIST_NOSERVERS]; + end + else + slWaitStr := _lc[I_NET_SLIST_ERROR]; + g_Serverlist_GenerateTable(slCurrent, slTable); + end; + {$ENDIF} g_Game_ExecuteEvent('ongameend'); end; end; @@ -1650,7 +1669,7 @@ begin end end; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} // HACK: add dynlight here if gwin_k8_enable_light_experiments then begin @@ -1689,7 +1708,7 @@ end; procedure g_Game_Update(); var - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} Msg: g_gui.TMessage; w: Word; {$ENDIF} @@ -1782,7 +1801,7 @@ begin e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK) ) and (not gJustChatted) and (not gConsoleShow) and (not gChatShow) -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} and (g_ActiveWindow = nil) {$ENDIF} ) @@ -1803,7 +1822,7 @@ begin begin // Выход в главное меню: g_Game_Free; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} g_GUI_ShowWindow('MainMenu'); gMusic.SetByName('MUSIC_MENU'); gMusic.Play(); @@ -1833,7 +1852,7 @@ begin e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK) ) and (not gJustChatted) and (not gConsoleShow) and (not gChatShow) -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} and (g_ActiveWindow = nil) {$ENDIF} ) @@ -1970,7 +1989,7 @@ begin // Обрабатываем клавиши игроков: if gPlayer1 <> nil then gPlayer1.ReleaseKeys(); if gPlayer2 <> nil then gPlayer2.ReleaseKeys(); -{$IFDEF HEADLESS} +{$IFDEF DISABLE_MENU} if (not gConsoleShow) and (not gChatShow) then {$ELSE} if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then @@ -1989,7 +2008,7 @@ begin // Наблюдатель if (gPlayer1 = nil) and (gPlayer2 = nil) and (not gConsoleShow) and (not gChatShow) -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} and (g_ActiveWindow = nil) {$ENDIF} then @@ -2236,7 +2255,7 @@ begin end; // if gameOn ... // Активно окно интерфейса - передаем клавиши ему: -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} if g_ActiveWindow <> nil then begin w := e_GetFirstKeyPressed(); @@ -2282,7 +2301,7 @@ begin begin KeyPress(IK_F10); end; -{$ENDIF} // NOT HEADLESS +{$ENDIF} Time := GetTickCount64() {div 1000}; @@ -3329,7 +3348,7 @@ begin g_Player_ResetAll(Force or gLastMap, gGameSettings.GameType = GT_SINGLE); gState := STATE_NONE; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_ActiveWindow := nil; {$ENDIF} gGameOn := True; @@ -4562,7 +4581,7 @@ begin chstr := ''; if cmd = 'pause' then begin - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} if (g_ActiveWindow = nil) then g_Game_Pause(not gPauseMain); {$ELSE} @@ -5809,7 +5828,7 @@ begin end; {$ENDIF} -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} procedure g_Game_InGameMenu(Show: Boolean); begin if (g_ActiveWindow = nil) and Show then @@ -6289,7 +6308,7 @@ begin PBarWasHere := false; end; - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_ActiveWindow := nil; {$ENDIF} diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index cb5ea3c..fe851b8 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -20,8 +20,6 @@ interface procedure g_Menu_Init(); procedure g_Menu_Free(); procedure g_Menu_Reset(); -procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD); -procedure LoadFont(txtres, fntres: string; var FontID: DWORD); procedure g_Menu_AskLanguage(); procedure g_Menu_Show_SaveMenu(); @@ -33,8 +31,6 @@ procedure g_Menu_Show_EndGameMenu(); procedure g_Menu_Show_QuitGameMenu(); var - gMenuFont: DWORD; - gMenuSmallFont: DWORD; PromptIP: string; PromptPort: Word; TempScale: Integer = -1; @@ -49,7 +45,7 @@ uses MAPDEF, Math, g_saveload, g_language, e_res, g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch, - utils, wadreader, g_system, r_render; + utils, wadreader, g_system, r_render, r_game; type TYNCallback = procedure (yes:Boolean); @@ -953,90 +949,6 @@ begin ProcChangeColor(nil); end; -procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD); -var - cwdt, chgt: Byte; - spc: ShortInt; - ID: DWORD; - wad: TWADFile; - cfgdata: Pointer; - cfglen: Integer; - config: TConfig; -begin - cfglen := 0; - - wad := TWADFile.Create; - if wad.ReadFile(GameWAD) then - wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen); - wad.Free(); - - if cfglen <> 0 then - begin - g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture); - - config := TConfig.CreateMem(cfgdata, cfglen); - cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255); - chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255); - spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127); - - if g_Texture_Get('FONT_STD', ID) then - e_TextureFontBuild(ID, FontID, cwdt, chgt, spc); - - config.Free(); - end; - - if cfglen <> 0 then FreeMem(cfgdata); -end; - -procedure LoadFont(txtres, fntres: string; var FontID: DWORD); -var - cwdt, chgt: Byte; - spc: ShortInt; - CharID: DWORD; - wad: TWADFile; - cfgdata, fntdata: Pointer; - cfglen, fntlen: Integer; - config: TConfig; - chrwidth: Integer; - a: Byte; -begin - cfglen := 0; - fntlen := 0; - - wad := TWADFile.Create; - if wad.ReadFile(GameWAD) then - begin - wad.GetResource('FONTS/'+txtres, cfgdata, cfglen); - wad.GetResource('FONTS/'+fntres, fntdata, fntlen); - end; - wad.Free(); - - if cfglen <> 0 then - begin - config := TConfig.CreateMem(cfgdata, cfglen); - cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255); - chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255); - - spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127); - FontID := e_CharFont_Create(spc); - - for a := 0 to 255 do - begin - chrwidth := config.ReadInt(IntToStr(a), 'Width', 0); - if chrwidth = 0 then Continue; - - if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16), - cwdt, chgt) then - e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth); - end; - - config.Free(); - end; - - if cfglen <> 0 then FreeMem(cfgdata); - if fntlen <> 0 then FreeMem(fntdata); -end; - procedure MenuLoadData(); begin e_WriteLog('Loading menu data...', TMsgType.Notify); diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 777453a..df1b4ac 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -521,7 +521,7 @@ var implementation uses - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_menu, {$ENDIF} e_log, g_sound, g_gfx, g_player, g_game, diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 7ae9c4c..12d926f 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -176,8 +176,11 @@ function GetTimerMS (): Int64; implementation uses + {$IFDEF ENABLE_MENU} + g_gui, g_menu, + {$ENDIF} {$IFNDEF HEADLESS} - g_gui, g_menu, r_render, g_system, + r_render, g_system, {$ENDIF} e_input, e_log, g_net, g_console, g_map, g_game, g_sound, g_options, g_language, g_basic, @@ -1758,7 +1761,7 @@ begin SL := nil; ST := nil; gState := STATE_MENU; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} g_GUI_ShowWindow('MainMenu'); g_GUI_ShowWindow('NetGameMenu'); g_GUI_ShowWindow('NetClientMenu'); @@ -1814,12 +1817,12 @@ begin Srv := GetServerFromTable(slSelection, SL, ST); if Srv.Password then begin -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} PromptIP := Srv.IP; PromptPort := Srv.Port; {$ENDIF} gState := STATE_MENU; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_MENU} g_GUI_ShowWindow('ClientPasswordMenu'); {$ENDIF} SL := nil; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 816673a..f3b0955 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -276,7 +276,7 @@ function IsValidFilePath(const S: String): Boolean; implementation uses - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_MENU} g_gui, {$ENDIF} Math, ENet, e_input, e_log, g_base, g_basic, @@ -2943,7 +2943,7 @@ begin kByte := 0; Predict := NetPredictSelf; // and (not NetGotKeys); -{$IFDEF HEADLESS} +{$IFDEF DISABLE_MENU} if (not gConsoleShow) and (not gChatShow) then {$ELSE} if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 7d25ca5..ea7cb7d 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -627,8 +627,11 @@ uses {$IFDEF ENABLE_HOLMES} g_holmes, {$ENDIF} + {$IFDEF ENABLE_MENU} + g_menu, + {$ENDIF} {$IFNDEF HEADLESS} - r_render, g_menu, + r_render, {$ENDIF} e_log, g_map, g_items, g_console, g_gfx, Math, g_options, g_triggers, g_game, g_grid, e_res, diff --git a/src/game/opengl/r_console.pas b/src/game/opengl/r_console.pas index f7ab15f..b8e8e52 100644 --- a/src/game/opengl/r_console.pas +++ b/src/game/opengl/r_console.pas @@ -24,10 +24,13 @@ interface implementation uses + {$IFDEF ENABLE_MENU} + g_menu, + {$ENDIF} SysUtils, Classes, Math, e_log, r_graphics, g_options, r_textures, r_game, conbuf, - g_base, g_console, g_game, g_menu + g_base, g_console, g_game ; (* ====== Console ====== *) diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas index 6e58786..75c3e2e 100644 --- a/src/game/opengl/r_game.pas +++ b/src/game/opengl/r_game.pas @@ -31,21 +31,26 @@ interface var gStdFont: DWORD; + gMenuFont: DWORD; + gMenuSmallFont: DWORD; implementation uses {$INCLUDE ../nogl/noGLuses.inc} -{$IFDEF ENABLE_HOLMES} - g_holmes, -{$ENDIF} + {$IFDEF ENABLE_HOLMES} + g_holmes, + {$ENDIF} + {$IFDEF ENABLE_MENU} + g_gui, g_menu, + {$ENDIF} SysUtils, Classes, Math, g_base, g_basic, r_graphics, g_system, g_touch, - MAPDEF, xprofiler, utils, wadreader, + MAPDEF, xprofiler, utils, wadreader, CONFIG, e_input, e_sound, - g_language, g_console, g_menu, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, - g_items, g_weapons, g_gfx, g_phys, g_net, g_gui, g_netmaster, + g_language, g_console, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, + g_items, g_weapons, g_gfx, g_phys, g_net, g_netmaster, g_game, r_console, r_gfx, r_items, r_map, r_monsters, r_weapons, r_netmaster, r_player, r_textures, r_playermodel ; @@ -61,6 +66,90 @@ implementation BackID: DWORD = DWORD(-1); gBackSize: TDFPoint; +procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD); +var + cwdt, chgt: Byte; + spc: ShortInt; + ID: DWORD; + wad: TWADFile; + cfgdata: Pointer; + cfglen: Integer; + config: TConfig; +begin + cfglen := 0; + + wad := TWADFile.Create; + if wad.ReadFile(GameWAD) then + wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen); + wad.Free(); + + if cfglen <> 0 then + begin + g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture); + + config := TConfig.CreateMem(cfgdata, cfglen); + cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255); + chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255); + spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127); + + if g_Texture_Get('FONT_STD', ID) then + e_TextureFontBuild(ID, FontID, cwdt, chgt, spc); + + config.Free(); + end; + + if cfglen <> 0 then FreeMem(cfgdata); +end; + +procedure LoadFont(txtres, fntres: string; var FontID: DWORD); +var + cwdt, chgt: Byte; + spc: ShortInt; + CharID: DWORD; + wad: TWADFile; + cfgdata, fntdata: Pointer; + cfglen, fntlen: Integer; + config: TConfig; + chrwidth: Integer; + a: Byte; +begin + cfglen := 0; + fntlen := 0; + + wad := TWADFile.Create; + if wad.ReadFile(GameWAD) then + begin + wad.GetResource('FONTS/'+txtres, cfgdata, cfglen); + wad.GetResource('FONTS/'+fntres, fntdata, fntlen); + end; + wad.Free(); + + if cfglen <> 0 then + begin + config := TConfig.CreateMem(cfgdata, cfglen); + cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255); + chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255); + + spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127); + FontID := e_CharFont_Create(spc); + + for a := 0 to 255 do + begin + chrwidth := config.ReadInt(IntToStr(a), 'Width', 0); + if chrwidth = 0 then Continue; + + if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16), + cwdt, chgt) then + e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth); + end; + + config.Free(); + end; + + if cfglen <> 0 then FreeMem(cfgdata); + if fntlen <> 0 then FreeMem(fntdata); +end; + procedure r_Game_Load; var wl, hl: Integer; @@ -1924,7 +2013,11 @@ begin end; end; +{$IFDEF ENABLE_MENU} if gPauseMain and gGameOn and (g_ActiveWindow = nil) then +{$ELSE} + if gPauseMain and gGameOn then +{$ENDIF} begin //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); @@ -1936,26 +2029,30 @@ begin if not gGameOn then begin - if (gState = STATE_MENU) then - begin - if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then r_Game_DrawMenuBackground('MENU_BACKGROUND'); - // F3 at menu will show game loading dialog - if e_KeyPressed(IK_F3) then g_Menu_Show_LoadMenu(true); - if (g_ActiveWindow <> nil) then + {$IFDEF ENABLE_MENU} + if (gState = STATE_MENU) then begin - //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end - else - begin - // F3 at titlepic will show game loading dialog - if e_KeyPressed(IK_F3) then + if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then r_Game_DrawMenuBackground('MENU_BACKGROUND'); + // F3 at menu will show game loading dialog + if e_KeyPressed(IK_F3) then g_Menu_Show_LoadMenu(true); + if (g_ActiveWindow <> nil) then begin - g_Menu_Show_LoadMenu(true); - if (g_ActiveWindow <> nil) then e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + end + else + begin + // F3 at titlepic will show game loading dialog + if e_KeyPressed(IK_F3) then + begin + g_Menu_Show_LoadMenu(true); + if (g_ActiveWindow <> nil) then e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + end; end; end; - end; + {$ELSE} + r_Game_DrawMenuBackground('MENU_BACKGROUND'); + {$ENDIF} if gState = STATE_FOLD then begin @@ -1977,11 +2074,13 @@ begin DrawCustomStat(); - if g_ActiveWindow <> nil then - begin - //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end; + {$IFDEF ENABLE_MENU} + if g_ActiveWindow <> nil then + begin + //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + end; + {$ENDIF} end; if gState = STATE_INTERSINGLE then @@ -1998,11 +2097,13 @@ begin DrawSingleStat(); - if g_ActiveWindow <> nil then - begin - //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end; + {$IFDEF ENABLE_MENU} + if g_ActiveWindow <> nil then + begin + //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + end; + {$ENDIF} end; end; @@ -2012,11 +2113,13 @@ begin if g_Texture_Get('TEXTURE_endpic', ID) then r_Game_DrawMenuBackground('TEXTURE_endpic') else r_Game_DrawMenuBackground(_lc[I_TEXTURE_ENDPIC]); - if g_ActiveWindow <> nil then - begin - //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end; + {$IFDEF ENABLE_MENU} + if g_ActiveWindow <> nil then + begin + //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); + end; + {$ENDIF} end; if gState = STATE_SLIST then @@ -2032,6 +2135,7 @@ begin end; end; +{$IFDEF ENABLE_MENU} if g_ActiveWindow <> nil then begin if gGameOn then @@ -2041,6 +2145,7 @@ begin end; g_ActiveWindow.Draw(); end; +{$ENDIF} {$IFNDEF HEADLESS} r_Console_Draw(); diff --git a/src/game/opengl/r_netmaster.pas b/src/game/opengl/r_netmaster.pas index 679e85a..a2545c4 100644 --- a/src/game/opengl/r_netmaster.pas +++ b/src/game/opengl/r_netmaster.pas @@ -24,9 +24,12 @@ interface implementation uses + {$IFDEF ENABLE_MENU} + g_menu, + {$ENDIF} SysUtils, Classes, Math, r_graphics, r_game, - g_basic, g_language, g_game, g_menu + g_basic, g_language, g_game ; procedure r_Serverlist_Draw (var SL: TNetServerList; var ST: TNetServerTable); diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index 2a962f7..225f852 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -41,12 +41,15 @@ interface implementation uses + {$IFDEF ENABLE_HOLMES} + g_holmes, + {$ENDIF} + {$IFDEF ENABLE_MENU} + g_menu, + {$ENDIF} SysUtils, Classes, Math, MAPDEF, utils, - g_basic, g_game, g_phys, g_map, g_menu, g_language, g_weapons, g_items, g_net, g_options, -{$IFDEF ENABLE_HOLMES} - g_holmes, -{$ENDIF} + g_basic, g_game, g_phys, g_map, g_language, g_weapons, g_items, g_net, g_options, r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game, r_map ; diff --git a/src/game/sdl2/g_touch.pas b/src/game/sdl2/g_touch.pas index da6edc8..6451760 100644 --- a/src/game/sdl2/g_touch.pas +++ b/src/game/sdl2/g_touch.pas @@ -35,8 +35,12 @@ interface implementation uses + {$IFDEF ENABLE_MENU} + g_gui, + {$ENDIF} SysUtils, - e_log, r_graphics, r_game, e_input, g_options, g_game, g_gui, g_weapons, g_console; + e_log, r_graphics, r_game, e_input, g_options, g_game, g_weapons, g_console + ; var angleFire: Boolean; @@ -219,7 +223,11 @@ implementation g_Console_ProcessBind(i, False); (* up/down + fire hack *) +{$IFDEF ENABLE_MENU} if g_touch_fire and (gGameSettings.GameType <> GT_NONE) and (g_ActiveWindow = nil) and angleFire then +{$ELSE} + if g_touch_fire and (gGameSettings.GameType <> GT_NONE) and angleFire then +{$ENDIF} begin if (i = VK_UP) or (i = VK_DOWN) then begin @@ -241,7 +249,11 @@ implementation g_Console_ProcessBind(i, True); (* up/down + fire hack *) +{$IFDEF ENABLE_MENU} if g_touch_fire and (gGameSettings.GameType <> GT_NONE) and (g_ActiveWindow = nil) then +{$ELSE} + if g_touch_fire and (gGameSettings.GameType <> GT_NONE) then +{$ENDIF} begin if i = VK_UP then begin diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc index 9b5d939..3e089bd 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -105,6 +105,22 @@ {$WARNING Holmes in headless mode has no sense. Disabled.} {$UNDEF ENABLE_HOLMES} {$ENDIF} + {$IFDEF ENABLE_MENU} + {$WARNING Menu in headless mode has no sense. Disabled.} + {$UNDEF ENABLE_MENU} + {$DEFINE DISABLE_MENU} + {$ENDIF} +{$ENDIF} + +{$IF DEFINED(ENABLE_MENU) AND DEFINED(DISABLE_MENU)} + {$ERROR Select ENABLE_MENU or DISABLE_MENU} +{$ELSEIF NOT DEFINED(ENABLE_MENU) AND NOT DEFINED(DISABLE_MENU)} + // defaut ENABLE/DISABLE menu + {$IFDEF HEADLESS} + {$DEFINE DISABLE_MENU} + {$ELSE} + {$DEFINE ENABLE_MENU} + {$ENDIF} {$ENDIF} {$IF DEFINED(USE_SYSSTUB)}