X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_options.pas;h=d05ed835f86d43d5edd808f7db4a0ff6d17f217f;hb=ee093c74b7f323b8589dc39ca7c39e89bc6e7e63;hp=2ad3e6e497fd99f58d1b45c16d61a0b93dd83c9f;hpb=c60af5eda7f59dd43a46577bf27497a8e74f04fd;p=d2df-sdl.git diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 2ad3e6e..d05ed83 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -1,4 +1,4 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *) -{$MODE DELPHI} +{$INCLUDE ../shared/a_modes.inc} unit g_options; interface uses - g_language; + g_language, g_weapons; type TPlayerControl = record @@ -33,6 +33,7 @@ type KeyPrevWeapon: Word; KeyOpen: Word; KeyStrafe: Word; + KeyWeapon: array [WP_FIRST..WP_LAST] of Word; KeyRight2: Word; KeyLeft2: Word; @@ -44,6 +45,7 @@ type KeyPrevWeapon2: Word; KeyOpen2: Word; KeyStrafe2: Word; + KeyWeapon2: array [WP_FIRST..WP_LAST] of Word; end; TGameControls = record @@ -69,6 +71,8 @@ procedure g_Options_Write_Gameplay_Net(FileName: String); procedure g_Options_Write_Net_Server(FileName: String); procedure g_Options_Write_Net_Client(FileName: String); +const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01'; + var gGameControls: TControls; gScreenWidth: Word = 800; @@ -124,13 +128,20 @@ var gsSDLBufferSize: Integer = 2048; gSFSDebug: Boolean = False; gSFSFastMode: Boolean = False; + gDefaultMegawadStart: AnsiString = DF_Default_Megawad_Start; + gBerserkAutoswitch: Boolean = True; implementation uses +{$IFDEF USE_NANOGL} + nanoGL, +{$ELSE} + GL, GLExt, +{$ENDIF} e_log, e_input, g_window, g_sound, g_gfx, g_player, Math, - g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_textures, - g_items, GL, GLExt, wadreader, e_graphics; + g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture, + g_items, wadreader, e_graphics; procedure g_Options_SetDefault(); var @@ -141,6 +152,7 @@ begin gMuteWhenInactive := False; gAnnouncer := ANNOUNCE_MEPLUS; gSoundEffectsDF := True; + gUseChatSounds := True; g_GFX_SetMax(2000); g_Gibs_SetMax(150); g_Corpses_SetMax(20); @@ -178,6 +190,8 @@ begin KeyPrevWeapon := 71; KeyOpen := 54; KeyStrafe := 0; + for i := 0 to High(KeyWeapon) do + KeyWeapon[i] := 0; KeyRight2 := 0; KeyLeft2 := 0; @@ -189,6 +203,8 @@ begin KeyPrevWeapon2 := 0; KeyOpen2 := 0; KeyStrafe2 := 0; + for i := 0 to High(KeyWeapon2) do + KeyWeapon2[i] := 0; end; with gGameControls.P2Control do @@ -203,6 +219,8 @@ begin KeyPrevWeapon := 17; KeyOpen := 58; KeyStrafe := 0; + for i := 0 to High(KeyWeapon) do + KeyWeapon[i] := 0; KeyRight2 := 0; KeyLeft2 := 0; @@ -214,6 +232,8 @@ begin KeyPrevWeapon2 := 0; KeyOpen2 := 0; KeyStrafe2 := 0; + for i := 0 to High(KeyWeapon2) do + KeyWeapon2[i] := 0; end; with gPlayer1Settings do @@ -237,6 +257,7 @@ begin end; NetUseMaster := True; + NetForwardPorts := False; g_Net_Slist_Set('mpms.doom2d.org', 25665); end; @@ -247,11 +268,11 @@ var i: Integer; begin gAskLanguage := True; - e_WriteLog('Reading config', MSG_NOTIFY); + e_WriteLog('Reading config', TMsgType.Notify); if not FileExists(FileName) then begin - e_WriteLog('Config file '+FileName+' not found', MSG_WARNING); + e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning); g_Options_SetDefault(); // Default video options: @@ -277,12 +298,12 @@ begin gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600); if gScreenHeight < 480 then gScreenHeight := 480; - gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0); + gWinRealPosX := config.ReadInt('Video', 'WinPosX', 60); if gWinRealPosX < 0 then - gWinRealPosX := 0; - gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0); + gWinRealPosX := 60; + gWinRealPosY := config.ReadInt('Video', 'WinPosY', 60); if gWinRealPosY < 0 then - gWinRealPosY := 0; + gWinRealPosY := 60; gFullScreen := config.ReadBool('Video', 'Fullscreen', False); gWinMaximized := config.ReadBool('Video', 'Maximized', False); gBPP := config.ReadInt('Video', 'BPP', 32); @@ -298,6 +319,7 @@ begin gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False); gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL); gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True); + gUseChatSounds := config.ReadBool('Sound', 'ChatSounds', True); gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000); gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384); @@ -321,6 +343,8 @@ begin KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17); KeyOpen := ReadInt('Player1', 'KeyOpen', 58); KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0); + for i := 0 to High(KeyWeapon) do + KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0); KeyRight2 := ReadInt('Player1', 'KeyRight2', 0); KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0); @@ -332,6 +356,8 @@ begin KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0); KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0); KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0); + for i := 0 to High(KeyWeapon2) do + KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0); end; with gPlayer1Settings, config do @@ -358,6 +384,8 @@ begin KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71); KeyOpen := ReadInt('Player2', 'KeyOpen', 54); KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0); + for i := 0 to High(KeyWeapon) do + KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0); KeyRight2 := ReadInt('Player2', 'KeyRight2', 0); KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0); @@ -369,6 +397,8 @@ begin KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0); KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0); KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0); + for i := 0 to High(KeyWeapon2) do + KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0); end; with gPlayer2Settings, config do @@ -414,6 +444,8 @@ begin gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False); wadoptFast := gSFSFastMode; e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True); + gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', DF_Default_Megawad_Start); + gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True); // Ãåéìïëåé â ñâîåé èãðå gcMap := config.ReadStr('GameplayCustom', 'Map', ''); @@ -484,6 +516,7 @@ begin NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0)); NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18)); NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000)); + NetForwardPorts := config.ReadBool('Server', 'ForwardPorts', False); // Êëèåíò NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2)); @@ -505,10 +538,7 @@ begin config.Free(); - if gTextureFilter then - TEXTUREFILTER := GL_LINEAR - else - TEXTUREFILTER := GL_NEAREST; + //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST; end; procedure g_Options_Write(FileName: String); @@ -516,7 +546,7 @@ var config: TConfig; i: Integer; begin - e_WriteLog('Writing config', MSG_NOTIFY); + e_WriteLog('Writing config', TMsgType.Notify); config := TConfig.CreateFile(FileName); @@ -538,6 +568,7 @@ begin config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive); config.WriteInt('Sound', 'Announcer', gAnnouncer); config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF); + config.WriteBool('Sound', 'ChatSounds', gUseChatSounds); config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate); config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize); @@ -561,6 +592,8 @@ begin WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon); WriteInt('Player1', 'KeyOpen', KeyOpen); WriteInt('Player1', 'KeyStrafe', KeyStrafe); + for i := 0 to High(KeyWeapon) do + WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]); WriteInt('Player1', 'KeyRight2', KeyRight2); WriteInt('Player1', 'KeyLeft2', KeyLeft2); @@ -572,6 +605,8 @@ begin WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2); WriteInt('Player1', 'KeyOpen2', KeyOpen2); WriteInt('Player1', 'KeyStrafe2', KeyStrafe2); + for i := 0 to High(KeyWeapon2) do + WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]); WriteStr('Player1', 'Name', Name); WriteStr('Player1', 'model', Model); @@ -593,6 +628,8 @@ begin WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon); WriteInt('Player2', 'KeyOpen', KeyOpen); WriteInt('Player2', 'KeyStrafe', KeyStrafe); + for i := 0 to High(KeyWeapon) do + WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]); WriteInt('Player2', 'KeyRight2', KeyRight2); WriteInt('Player2', 'KeyLeft2', KeyLeft2); @@ -604,6 +641,8 @@ begin WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2); WriteInt('Player2', 'KeyOpen2', KeyOpen2); WriteInt('Player2', 'KeyStrafe2', KeyStrafe2); + for i := 0 to High(KeyWeapon2) do + WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]); WriteStr('Player2', 'Name', Name); WriteStr('Player2', 'model', Model); @@ -642,6 +681,8 @@ begin config.WriteBool('Game', 'SFSDebug', gSFSDebug); config.WriteBool('Game', 'SFSFastMode', gSFSFastMode); config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots); + config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart); + config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch); config.WriteStr ('GameplayCustom', 'Map', gcMap); config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode); @@ -677,6 +718,7 @@ begin config.WriteBool('Server', 'RCON', NetAllowRCON); config.WriteStr ('Server', 'RCONPassword', NetRCONPassword); config.WriteBool('Server', 'SyncWithMaster', NetUseMaster); + config.WriteBool('Server', 'ForwardPorts', NetForwardPorts); config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate); config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate); config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate); @@ -695,7 +737,7 @@ procedure g_Options_Write_Language(FileName: String); var config: TConfig; begin - e_WriteLog('Writing language config', MSG_NOTIFY); + e_WriteLog('Writing language config', TMsgType.Notify); config := TConfig.CreateFile(FileName); config.WriteStr('Game', 'Language', gLanguage); @@ -708,7 +750,7 @@ var config: TConfig; sW, sH: Integer; begin - e_WriteLog('Writing resolution to config', MSG_NOTIFY); + e_WriteLog('Writing resolution to config', TMsgType.Notify); config := TConfig.CreateFile(FileName); @@ -722,6 +764,7 @@ begin sW := gScreenWidth; sH := gScreenHeight; end; + e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]); config.WriteInt('Video', 'ScreenWidth', sW); config.WriteInt('Video', 'ScreenHeight', sH); @@ -738,7 +781,7 @@ procedure g_Options_Write_Gameplay_Custom(FileName: String); var config: TConfig; begin - e_WriteLog('Writing custom gameplay config', MSG_NOTIFY); + e_WriteLog('Writing custom gameplay config', TMsgType.Notify); config := TConfig.CreateFile(FileName); @@ -762,7 +805,7 @@ procedure g_Options_Write_Gameplay_Net(FileName: String); var config: TConfig; begin - e_WriteLog('Writing network gameplay config', MSG_NOTIFY); + e_WriteLog('Writing network gameplay config', TMsgType.Notify); config := TConfig.CreateFile(FileName); @@ -786,7 +829,7 @@ procedure g_Options_Write_Net_Server(FileName: String); var config: TConfig; begin - e_WriteLog('Writing server config', MSG_NOTIFY); + e_WriteLog('Writing server config', TMsgType.Notify); config := TConfig.CreateFile(FileName); @@ -795,6 +838,7 @@ begin config.WriteInt ('Server', 'Port', NetPort); config.WriteInt ('Server', 'MaxClients', NetMaxClients); config.WriteBool('Server', 'SyncWithMaster', NetUseMaster); + config.WriteBool('Server', 'ForwardPorts', NetForwardPorts); config.SaveFile(FileName); config.Free(); @@ -804,7 +848,7 @@ procedure g_Options_Write_Net_Client(FileName: String); var config: TConfig; begin - e_WriteLog('Writing client config', MSG_NOTIFY); + e_WriteLog('Writing client config', TMsgType.Notify); config := TConfig.CreateFile(FileName);