diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index dc7305f9baecaa97b32195ce45391184986f8d38..2e268a0c3e69317b51a1a76bf05b607082479889 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
P2Control: TPlayerControl;
end;
+function GenPlayerName (n: Integer): String;
+
procedure g_Options_SetDefault();
procedure g_Options_Read(FileName: String);
procedure g_Options_Write(FileName: String);
implementation
uses
-{$IFDEF USE_NANOGL}
- nanoGL,
-{$ELSE}
- GL, GLExt,
-{$ENDIF}
+ {$INCLUDE ../nogl/noGLuses.inc}
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_texture,
- g_items, wadreader, e_graphics, g_touch, SDL2;
+ g_items, wadreader, e_graphics, g_touch, SDL2, envvars;
+
+ var
+ machine: Integer;
+
+ function GenPlayerName (n: Integer): String;
+ begin
+ ASSERT(n >= 1);
+ Result := GetUserName;
+ if Result = '' then
+ Result := 'Player' + IntToStr(machine MOD 10000);
+ if n = 1 then
+ Result := Copy(Result, 1, 12) + ' '
+ else
+ Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
+ end;
procedure g_Options_SetDefaultVideo;
-{$IF DEFINED(ANDROID)}
var
- display: PSDL_DisplayMode;
-{$ENDIF}
+ target, closest, display: TSDL_DisplayMode;
+ percentage: Integer;
begin
+ (* Display 0 = Primary display *)
+ SDL_GetDesktopDisplayMode(0, @display);
{$IF DEFINED(ANDROID)}
- (* On android set max screen size *)
- SDL_GetCurrentDisplayMode(0, display);
gScreenWidth := display.w;
gScreenHeight := display.h;
- gWinRealPosX := 0;
- gWinRealPosY := 0;
- gWinMaximized := False;
- gFullScreen := False; (* if True then rotation not allowed *)
+ //gBPP := SDL_BITSPERPIXEL(dispaly.format);
gBPP := 32;
- gVSync := True;
- gTextureFilter := True;
- glLegacyNPOT := False;
+ gFullScreen := True; (* rotation not allowed? *)
{$ELSE}
- (* On other systems use default 800x600 *)
- gScreenWidth := 800;
- gScreenHeight := 600;
- gWinRealPosX := 0;
- gWinRealPosY := 0;
- gWinMaximized := False;
- gFullScreen := False;
+ (* Window must be smaller than display *)
+ closest.w := display.w;
+ closest.h := display.h;
+ percentage := 75;
+ while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
+ begin
+ if percentage < 25 then
+ begin
+ closest.w := display.w * 75 div 100;
+ closest.h := display.h * 75 div 100;
+ break;
+ end;
+ target.w := display.w * percentage div 100;
+ target.h := display.h * percentage div 100;
+ target.format := 0; (* didn't care *)
+ target.refresh_rate := 0; (* didn't care *)
+ target.driverdata := nil; (* init *)
+ SDL_GetClosestDisplayMode(0, @target, @closest);
+ Dec(percentage);
+ end;
+ gScreenWidth := closest.w;
+ gScreenHeight := closest.h;
+ //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
gBPP := 32;
- gVSync := True;
- gTextureFilter := True;
- glLegacyNPOT := False;
+ gFullScreen := False;
{$ENDIF}
+ (* Must be positioned on primary display *)
+ gWinRealPosX := SDL_WINDOWPOS_CENTERED;
+ gWinRealPosY := SDL_WINDOWPOS_CENTERED;
+ gWinMaximized := False;
+ gVSync := True;
+ gTextureFilter := True;
+ glLegacyNPOT := False;
+ e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
end;
procedure g_Options_SetDefault();
with gGameControls.GameControls do
begin
TakeScreenshot := SDL_SCANCODE_F12;
- Stat := SDL_SCANCODE_L;
+ Stat := SDL_SCANCODE_TAB;
Chat := SDL_SCANCODE_T;
TeamChat := SDL_SCANCODE_Y;
end;
KeyDown := SDL_SCANCODE_KP_5;
KeyFire := SDL_SCANCODE_SLASH;
KeyJump := SDL_SCANCODE_RCTRL;
- KeyNextWeapon := SDL_SCANCODE_KP_7;
- KeyPrevWeapon := SDL_SCANCODE_KP_9;
+ KeyNextWeapon := SDL_SCANCODE_KP_9;
+ KeyPrevWeapon := SDL_SCANCODE_KP_7;
KeyOpen := SDL_SCANCODE_RSHIFT;
KeyStrafe := SDL_SCANCODE_PERIOD;
with gPlayer1Settings do
begin
- Name := 'Player1';
+ Name := GenPlayerName(1);
Model := STD_PLAYER_MODEL;
Color.R := PLAYER1_DEF_COLOR.R;
Color.G := PLAYER1_DEF_COLOR.G;
with gPlayer2Settings do
begin
- Name := 'Player2';
+ Name := GenPlayerName(2);
Model := STD_PLAYER_MODEL;
Color.R := PLAYER2_DEF_COLOR.R;
Color.G := PLAYER2_DEF_COLOR.G;
gShowMessages := True;
gRevertPlayers := False;
gChatBubble := 4;
+ gPlayerIndicator := True;
gSFSDebug := False;
gSFSFastMode := False;
e_FastScreenshots := True;
v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
end;
- procedure ReadInteger (VAR v: Single; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer)); overload;
- begin
- v := Max(Min(config.ReadInt(section, param, Integer(v)), maxv), minv)
- end;
-
procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
begin
v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
end;
section := 'Touch';
- ReadInteger(g_touch_size, 'Size', 0); g_touch_size := g_touch_size / 10;
+ i := Trunc(g_touch_size * 10); ReadInteger(i, 'Size', 0); g_touch_size := i / 10;
ReadBoolean(g_touch_fire, 'Fire');
- ReadInteger(g_touch_offset, 'Offset', 0, 100);
+ i := Round(g_touch_offset); ReadInteger(i, 'Offset', 0, 100); g_touch_offset := i;
ReadBoolean(g_touch_alt, 'Alt');
section := 'Game';
- ReadInteger(i, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i);
- ReadInteger(i, 'MaxShells', 300, 600); g_Shells_SetMax(i);
- ReadInteger(i, 'MaxGibs', 150, 500); g_Gibs_SetMax(i);
- ReadInteger(i, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i);
+ ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
+ ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
+ ReadInteger(i, 'MaxGibs', 0, 500); g_Gibs_SetMax(i);
+ ReadInteger(i, 'MaxCorpses', 0, 100); g_Corpses_SetMax(i);
ReadInteger(i, 'GibsCount');
case i of
0: gGibsCount := 0;
3: gGibsCount := 32;
else gGibsCount := 48;
end;
- ReadInteger(ITEM_RESPAWNTIME, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := ITEM_RESPAWNTIME * 36;
+ i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
ReadInteger(gBloodCount, 'BloodCount', 0, 4);
ReadBoolean(gAdvBlood, 'AdvancesBlood');
ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
ReadBoolean(gShowMessages, 'Messages');
ReadBoolean(gRevertPlayers, 'RevertPlayers');
ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
+ ReadBoolean(gPlayerIndicator, 'PlayerIndicator');
ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
ReadBoolean(e_FastScreenshots, 'FastScreenshots');
ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
- ReadInteger(g_dbg_scale, 'Scale', 1); g_dbg_scale := g_dbg_scale / 100;
+ 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
config.WriteBool('Game', 'Messages', gShowMessages);
config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
config.WriteInt('Game', 'ChatBubble', gChatBubble);
+ config.WriteBool('Game', 'PlayerIndicator', gPlayerIndicator);
config.WriteBool('Game', 'SFSDebug', gSFSDebug);
config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
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;
config.Free();
end;
+initialization
+ Randomize;
+ machine := Random(10000)
end.