summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1581de2)
raw | patch | inline | side by side (parent: 1581de2)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 8 Nov 2019 14:14:55 +0000 (17:14 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 8 Nov 2019 14:14:55 +0000 (17:14 +0300) |
diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas
index afe112e157ecda9cd1a0e00b6ea25e640c9b2216..7df493fe4f248a8fe57ac8fb11da55c9713227b4 100644 (file)
--- a/src/game/g_basic.pas
+++ b/src/game/g_basic.pas
begin
result := nil; lines := 0;
j := 1; i := 1; len := Length(Text);
- e_LogWritefln('GetLines @%s len=%s [%s]', [MaxWidth, len, Text]);
+ // e_LogWritefln('GetLines @%s len=%s [%s]', [MaxWidth, len, Text]);
while j <= len do
begin
(* --- Get longest possible sequence --- *)
(* --- Add line --- *)
SetLength(result, lines + 1);
result[lines] := GetLine(j, i);
- e_LogWritefln(' -> (%s:%s::%s) [%s]', [j, i, GetWidth(j, i), result[lines]]);
+ // e_LogWritefln(' -> (%s:%s::%s) [%s]', [j, i, GetWidth(j, i), result[lines]]);
Inc(lines);
(* --- Skip spaces --- *)
while (i <= len) and (text[i] = ' ') do Inc(i);
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 288eb547acfd7194a764d4e424e2917540bad514..35530016786688639acf4254fd6435302c00bf47 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
AddCommand('segfault', segfault, 'make segfault');
+ AddCommand('r_reset', g_Options_Commands);
+ AddCommand('g_language', g_Options_Commands);
+
AddCommand('bind', BindCommands);
AddCommand('bindlist', BindCommands);
AddCommand('unbind', BindCommands);
end
end
end;
+ if gAskLanguage then
+ WriteLn(f, 'g_language ask')
+ else
+ WriteLn(f, 'g_language ', gLanguage);
+ WriteLn(f, 'r_reset');
CloseFile(f)
end;
end
end;
-initialization
+procedure Init;
+ var i: Integer;
+begin
conRegVar('chat_at_top', @ChatTop, 'draw chat at top border', 'draw chat at top border');
conRegVar('console_height', @ConsoleHeight, 0.0, 1.0, 'set console size', 'set console size');
conRegVar('console_trans', @ConsoleTrans, 0.0, 1.0, 'set console transparency', 'set console transparency');
conRegVar('console_step', @ConsoleStep, 0.0, 1.0, 'set console animation speed', 'set console animation speed');
- conRegVar('d_eres', @debug_e_res, '', '');
{$IFDEF ANDROID}
ChatTop := True;
ConsoleHeight := 0.35;
{$ENDIF}
ConsoleTrans := 0.1;
ConsoleStep := 0.07;
+ conRegVar('d_eres', @debug_e_res, '', '');
+ for i := 1 to e_MaxJoys do
+ conRegVar('joy' + IntToStr(i) + '_deadzone', @e_JoystickDeadzones[i - 1], '', '')
+end;
+
+initialization
+ Init
end.
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 8366787a04365305daa80afd9c8d47e574458427..27dcb909f4f11dd463aad1ce0aae631fbc1233a9 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure g_Game_RestartLevel();
procedure g_Game_RestartRound(NoMapRestart: Boolean = False);
function g_Game_ClientWAD (NewWAD: String; const WHash: TMD5Digest): AnsiString;
-procedure g_Game_SaveOptions();
function g_Game_StartMap(asMegawad: Boolean; Map: String; Force: Boolean = False; const oldMapPath: AnsiString=''): Boolean;
procedure g_Game_ChangeMap(const MapPath: String);
procedure g_Game_ExitLevel(const Map: AnsiString);
gHearPoint1, gHearPoint2: THearPoint;
gSoundEffectsDF: Boolean = False;
gSoundTriggerTime: Word = 0;
- gAnnouncer: Byte = ANNOUNCE_NONE;
+ gAnnouncer: Integer = ANNOUNCE_NONE;
goodsnd: array[0..3] of TPlayableSound;
killsnd: array[0..3] of TPlayableSound;
hahasnd: array[0..2] of TPlayableSound;
gMapToDelete: String;
gTempDelete: Boolean = False;
gLastMap: Boolean = False;
- gWinPosX, gWinPosY: Integer;
gWinSizeX, gWinSizeY: Integer;
gWinFrameX, gWinFrameY, gWinCaption: Integer;
gWinActive: Boolean = True; // by default window is active, lol
gResolutionChange: Boolean = False;
- gRC_Width, gRC_Height: Word;
+ gRC_Width, gRC_Height: Integer;
gRC_FullScreen, gRC_Maximized: Boolean;
gLanguageChange: Boolean = False;
gDebugMode: Boolean = False;
begin
g_Game_StopAllSounds(True);
gMusic.Free();
- g_Game_SaveOptions();
g_Game_FreeData();
g_PlayerModel_FreeData();
g_Texture_DeleteAll();
e_WriteLog('NET: Connection successful.', TMsgType.Notify);
end;
-procedure g_Game_SaveOptions;
- var s: AnsiString;
-begin
- s := e_GetWriteableDir(ConfigDirs);
- if s <> '' then
- g_Options_Write_Video(s + '/' + CONFIG_FILENAME)
- else
- e_LogWritefln('unable to find or create directory for configs', []);
-end;
-
var
lastAsMegaWad: Boolean = false;
cmd := LowerCase(P[0]);
if cmd = 'd_window' then
begin
- g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX, gWinPosY]));
- g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX, gWinRealPosY]));
g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth, gScreenHeight]));
g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX, gWinSizeY]));
g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX, gWinFrameY, gWinCaption]));
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 8142dd83c30f7c1fd14b4a28fe650aec0769415a..def9f2914d20b342539c8021c605dc93e39c353f 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
e_InitInput;
sys_Init;
+ g_Options_SetDefault;
+ g_Options_SetDefaultVideo;
s := CONFIG_FILENAME;
if e_FindResource(ConfigDirs, s) = true then
- begin
- g_Options_Read(s)
- end
- else
- begin
- g_Options_SetDefault;
- g_Options_SetDefaultVideo
- end;
+ g_Options_Read(s);
+ g_Console_SysInit;
if sys_SetDisplayMode(gScreenWidth, gScreenHeight, gBPP, gFullScreen) = False then
raise Exception.Create('Failed to set videomode on startup.');
- g_Console_SysInit;
e_WriteLog(gLanguage, TMsgType.Notify);
g_Language_Set(gLanguage);
if assigned(oglDeinitCB) then oglDeinitCB;
{$ENDIF}
+ g_Console_WriteGameConfig;
sys_Final;
end;
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index 11dd664dd078e80d4103dc8bed63e66d190ade31..cdf0f13604090c4ba58716ec568d6cdbc43c660d 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
end;
procedure ProcSetRussianLanguage;
- var s: AnsiString;
begin
if gLanguage <> LANGUAGE_RUSSIAN then
begin
gLanguage := LANGUAGE_RUSSIAN;
gLanguageChange := True;
gAskLanguage := False;
-
- s := e_GetWriteableDir(ConfigDirs);
- if s <> '' then
- g_Options_Write_Language(s + '/' + CONFIG_FILENAME);
-
- // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
ProcApplyOptions();
end;
end;
procedure ProcSetEnglishLanguage;
- var s: AnsiString;
begin
if gLanguage <> LANGUAGE_ENGLISH then
begin
gLanguage := LANGUAGE_ENGLISH;
gLanguageChange := True;
gAskLanguage := False;
-
- s := e_GetWriteableDir(ConfigDirs);
- if s <> '' then
- g_Options_Write_Language(s + '/' + CONFIG_FILENAME);
-
- // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
ProcApplyOptions();
end;
end;
end;
procedure ProcSetFirstRussianLanguage;
- var s: AnsiString;
begin
gLanguage := LANGUAGE_RUSSIAN;
gLanguageChange := True;
gAskLanguage := False;
-
- s := e_GetWriteableDir(ConfigDirs);
- if s <> '' then
- g_Options_Write_Language(s + '/' + CONFIG_FILENAME)
end;
procedure ProcSetFirstEnglishLanguage;
- var s: AnsiString;
begin
gLanguage := LANGUAGE_ENGLISH;
gLanguageChange := True;
gAskLanguage := False;
-
- s := e_GetWriteableDir(ConfigDirs);
- if s <> '' then
- g_Options_Write_Language(s + '/' + CONFIG_FILENAME)
end;
procedure ProcRecallAddress();
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index 7aea70fc0a5f9add839ce28ab3bfe334a975fc9f..41f0e69ffa8633d35f53b3540e61bce94b167838 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
interface
uses
- g_language, g_weapons;
+ g_language, g_weapons, utils;
function GenPlayerName (n: Integer): String;
procedure g_Options_SetDefaultVideo;
procedure g_Options_Read(FileName: String);
procedure g_Options_Write(FileName: String);
-procedure g_Options_Write_Language(FileName: String);
-procedure g_Options_Write_Video(FileName: String);
procedure g_Options_Write_Gameplay_Custom(FileName: String);
procedure g_Options_Write_Gameplay_Net(FileName: String);
procedure g_Options_Write_Net_Server(FileName: String);
procedure g_Options_Write_Net_Client(FileName: String);
+procedure g_Options_Commands (p: SSArray);
const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
var
-// gGameControls: TControls;
gScreenWidth: Word;
gScreenHeight: Word;
- gWinRealPosX: Integer;
- gWinRealPosY: Integer;
- gBPP: Byte;
+ gBPP: Integer;
gFreq: Byte;
gFullscreen: Boolean;
gWinMaximized: Boolean;
glLegacyNPOT: Boolean;
gTextureFilter: Boolean;
gNoSound: Boolean;
- gSoundLevel: Byte;
- gMusicLevel: Byte;
- gMaxSimSounds: Byte;
+ gSoundLevel: Integer;
+ gMusicLevel: Integer;
+ gMaxSimSounds: Integer;
gMuteWhenInactive: Boolean;
gAdvCorpses: Boolean;
gAdvBlood: Boolean;
{$ENDIF}
e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
- g_items, wadreader, e_graphics, g_touch, envvars;
+ g_items, wadreader, e_graphics, g_touch, envvars, g_system;
var
machine: Integer;
e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
end;
(* Must be positioned on primary display *)
- gWinRealPosX := SDL_WINDOWPOS_CENTERED;
- gWinRealPosY := SDL_WINDOWPOS_CENTERED;
gWinMaximized := False;
gVSync := True;
gTextureFilter := True;
gScreenHeight := 480;
gBPP := 32;
gFullScreen := False;
- gWinRealPosX := 0;
- gWinRealPosY := 0;
gWinMaximized := False;
gVSync := True;
gTextureFilter := True;
config := TConfig.CreateFile(FileName);
- section := 'Video';
- ReadInteger(gScreenWidth, 'ScreenWidth', 0);
- ReadInteger(gScreenHeight, 'ScreenHeight', 0);
- ReadInteger(gWinRealPosX, 'WinPosX', 60);
- ReadInteger(gWinRealPosY, 'WinPosY', 60);
- ReadBoolean(gFullScreen, 'Fullscreen');
- ReadBoolean(gWinMaximized, 'Maximized');
- ReadInteger(gBPP, 'BPP', 0);
- ReadInteger(gFreq, 'Freq', 0);
- ReadBoolean(gVSync, 'VSync');
- ReadBoolean(gTextureFilter, 'TextureFilter');
- ReadBoolean(glNPOTOverride, 'LegacyCompatibleForce');
-
- section := 'Sound';
- ReadBoolean(gNoSound, 'NoSound');
- ReadInteger(gSoundLevel, 'SoundLevel', 0, 255);
- ReadInteger(gMusicLevel, 'MusicLevel', 0, 255);
- ReadInteger(gMaxSimSounds, 'MaxSimSounds', 2, 66);
- ReadBoolean(gMuteWhenInactive, 'MuteInactive');
- ReadInteger(gAnnouncer, 'Announcer', ANNOUNCE_NONE, ANNOUNCE_ALL);
- ReadBoolean(gSoundEffectsDF, 'SoundEffectsDF');
- ReadBoolean(gUseChatSounds, 'ChatSounds');
- ReadInteger(gsSDLSampleRate, 'SDLSampleRate', 11025, 96000);
- ReadInteger(gsSDLBufferSize, 'SDLBufferSize', 64, 16384);
-
section := 'Player1';
with gPlayer1Settings do
begin
Team := TEAM_RED;
end;
- section := 'Joysticks';
- for i := 0 to e_MaxJoys - 1 do
- begin
- ReadInteger(e_JoystickDeadzones[i], 'Deadzone' + IntToStr(i))
- end;
-
section := 'Game';
ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
- ReadString(gLanguage, 'Language');
- if (gLanguage = LANGUAGE_RUSSIAN) or (gLanguage = LANGUAGE_ENGLISH) then
- gAskLanguage := False
- else
- gLanguage := LANGUAGE_ENGLISH;
section := 'GameplayCustom';
ReadString(gcMap, 'Map');
end;
procedure g_Options_Write(FileName: String);
-var
- config: TConfig;
- i: Integer;
+ var config: TConfig;
begin
e_WriteLog('Writing config', TMsgType.Notify);
config := TConfig.CreateFile(FileName);
- config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
- config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
- config.WriteInt('Video', 'WinPosX', gWinRealPosX);
- config.WriteInt('Video', 'WinPosY', gWinRealPosY);
- config.WriteBool('Video', 'Fullscreen', gFullScreen);
- config.WriteBool('Video', 'Maximized', gWinMaximized);
- config.WriteInt('Video', 'BPP', gBPP);
- config.WriteBool('Video', 'VSync', gVSync);
- config.WriteBool('Video', 'TextureFilter', gTextureFilter);
- config.WriteBool('Video', 'LegacyCompatibleForce', glNPOTOverride);
-
- config.WriteBool('Sound', 'NoSound', gNoSound);
- config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
- config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
- config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
- 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);
-
with config, gPlayer1Settings do
begin
WriteStr('Player1', 'Name', Name);
WriteInt('Player2', 'team', Team);
end;
- for i := 0 to e_MaxJoys-1 do
- config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
-
with config do
case gGibsCount of
0: config.WriteInt('Game', 'GibsCount', 0);
config.Free();
end;
-procedure g_Options_Write_Language(FileName: String);
-var
- config: TConfig;
-begin
- e_WriteLog('Writing language config', TMsgType.Notify);
-
- config := TConfig.CreateFile(FileName);
- config.WriteStr('Game', 'Language', gLanguage);
- config.SaveFile(FileName);
- config.Free();
-end;
-
-procedure g_Options_Write_Video(FileName: String);
-var
- config: TConfig;
- sW, sH: Integer;
-begin
- e_WriteLog('Writing resolution to config', TMsgType.Notify);
-
- config := TConfig.CreateFile(FileName);
-
- if gWinMaximized and (not gFullscreen) then
- begin
- sW := gWinSizeX;
- sH := gWinSizeY;
- end
- else
- 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);
- config.WriteInt('Video', 'WinPosX', gWinRealPosX);
- config.WriteInt('Video', 'WinPosY', gWinRealPosY);
- config.WriteBool('Video', 'Fullscreen', gFullscreen);
- config.WriteBool('Video', 'Maximized', gWinMaximized);
-
- config.WriteStr('Player1', 'Name', gPlayer1Settings.Name);
- config.WriteStr('Player2', 'Name', gPlayer2Settings.Name);
-
- config.SaveFile(FileName);
- config.Free();
-end;
-
procedure g_Options_Write_Gameplay_Custom(FileName: String);
var
config: TConfig;
config.Free();
end;
+procedure g_Options_Commands (p: SSArray);
+ var cmd: AnsiString;
+begin
+ cmd := LowerCase(p[0]);
+ case cmd of
+ 'r_reset':
+ begin
+ sys_EnableVSync(gVSync);
+ gRC_Width := Max(1, gRC_Width);
+ gRC_Height := Max(1, gRC_Height);
+ gBPP := Max(1, gBPP);
+ if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen) = True then
+ e_LogWriteln('resolution changed')
+ else
+ e_LogWriteln('resolution not changed')
+ end;
+ 'g_language':
+ begin
+ if Length(p) = 2 then
+ begin
+ gAskLanguage := true;
+ gLanguage := LANGUAGE_ENGLISH;
+ case LowerCase(p[1]) of
+ 'english':
+ begin
+ gAskLanguage := false;
+ gLanguage := LANGUAGE_ENGLISH;
+ end;
+ 'russian':
+ begin
+ gAskLanguage := false;
+ gLanguage := LANGUAGE_RUSSIAN;
+ end;
+ 'ask':
+ begin
+ gAskLanguage := true;
+ gLanguage := LANGUAGE_ENGLISH;
+ end;
+ end;
+ g_Language_Set(gLanguage)
+ end
+ end
+ end;
+end;
+
initialization
Randomize;
- machine := Random(10000)
+ machine := Random(10000);
+
+ (* Video *)
+ conRegVar('r_width', @gRC_Width, '', '');
+ conRegVar('r_height', @gRC_Height, '', '');
+ conRegVar('r_fullscreen', @gRC_FullScreen, '', '');
+ conRegVar('r_maximized', @gRC_Maximized, '', '');
+ conRegVar('r_bpp', @gBPP, '', '');
+ conRegVar('r_vsync', @gVSync, '', '');
+ conRegVar('r_texfilter', @gTextureFilter, '', '');
+ conRegVar('r_npot', @glNPOTOverride, '', '');
+
+ (* Sound *)
+ conRegVar('s_nosound', @gNoSound, '', '');
+ conRegVar('s_soundvolume', @gSoundLevel, '', '');
+ conRegVar('s_musicvolume', @gMusicLevel, '', '');
+ conRegVar('s_maxsim', @gMaxSimSounds, '', ''); // e_sound_fmod/sdl?
+ conRegVar('s_muteinactive', @gMuteWhenInactive, '', '');
+ conRegVar('s_announcer', @gAnnouncer, '', '');
+ conRegVar('s_sfx', @gSoundEffectsDF, '', '');
+ conRegVar('s_chatsounds', @gUseChatSounds, '', '');
+ {$IFDEF USE_SDLMIXER}
+ conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate, '', '');
+ conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize, '', '');
+ {$ENDIF}
end.
index bdb4addacd31ae280b01274772671f61683ab014..01467205ceaf1285f382cbf7ef4be336f6f68289 100644 (file)
begin
gWinSizeX := w;
gWinSizeY := h;
- gWinRealPosX := 0;
- gWinRealPosY := 0;
gScreenWidth := w;
gScreenHeight := h;
{$IFDEF ENABLE_HOLMES}
index 6750d68e6364570a0485647bc8c61d7e1bf832d4..7899e9cfac8e602b427f5c21049bcdf72e845e1b 100644 (file)
begin
gWinSizeX := w;
gWinSizeY := h;
- gWinRealPosX := 0;
- gWinRealPosY := 0;
gScreenWidth := w;
gScreenHeight := h;
{$IFDEF ENABLE_HOLMES}
end;
function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean;
- var flags: UInt32;
+ var flags: UInt32; x, y: Integer;
begin
// note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB;
e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
{$ENDIF}
flags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE;
if fullScreen then flags := flags or SDL_WINDOW_FULLSCREEN;
- window := SDL_CreateWindow(GetTitle(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, flags);
+ x := SDL_WINDOWPOS_CENTERED;
+ y := SDL_WINDOWPOS_CENTERED;
+ window := SDL_CreateWindow(GetTitle(), x, y, w, h, flags);
if window <> nil then
begin
context := SDL_GL_CreateContext(window);