DEADSOFTWARE

Added BPP switching
[d2df-sdl.git] / src / game / g_menu.pas
index 629c38c69adc30a0a8feccfefddf376c6f462480..d720619bed89ae2a073e34c8481e968ed1a6e871 100644 (file)
@@ -42,11 +42,7 @@ var
 implementation
 
 uses
-{$IFDEF USE_NANOGL}
-  nanoGL,
-{$ELSE}
-  GL, GLExt,
-{$ENDIF}
+  {$INCLUDE ../nogl/noGLuses.inc}
   g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
   g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
   e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
@@ -115,10 +111,14 @@ var
 begin
   menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
 
-  if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
-    gBPP := 16
-  else
-    gBPP := 32;
+  case TGUISwitch(menu.GetControl('swBPP')).ItemIndex of
+    0: gBPP := 8;
+    1: gBPP := 15;
+    2: gBPP := 16;
+    3: gBPP := 24;
+    4: gBPP := 32;
+  else gBPP := 32
+  end;
 
   ovs := gVSync;
   gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
@@ -164,6 +164,7 @@ begin
   gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
   gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
   gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
+  gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex = 0;
   g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
 
   menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
@@ -258,9 +259,10 @@ begin
     end;
   end;
 
-  if SDL_GetNumTouchDevices() > 0 then
+  if g_touch_enabled then
   begin
     menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
+    g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
     g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
     g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
     g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
@@ -289,8 +291,8 @@ begin
     gPlayer2Settings.Color := Model.Color;
   end;
 
-  if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := 'Player1';
-  if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := 'Player2';
+  if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
+  if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
 
   if g_Game_IsServer then
   begin
@@ -332,10 +334,14 @@ begin
   menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
 
   with TGUISwitch(menu.GetControl('swBPP')) do
-    if gBPP = 16 then
-      ItemIndex := 0
-    else
-      ItemIndex := 1;
+    case gBPP of
+      8: ItemIndex := 0;
+      15: ItemIndex := 1;
+      16: ItemIndex := 2;
+      24: ItemIndex := 3;
+      32: ItemIndex := 4;
+    else ItemIndex := 4
+    end;
 
   with TGUISwitch(menu.GetControl('swTextureFilter')) do
     if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
@@ -454,9 +460,11 @@ begin
     end;
   end;
 
-  if SDL_GetNumTouchDevices() > 0 then
+  if g_touch_enabled then
   begin
     menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
+    with TGUISwitch(menu.GetControl('swTouchAlt')) do
+      if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
     TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
     with TGUISwitch(menu.GetControl('swTouchFire')) do
       if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
@@ -513,6 +521,9 @@ begin
   with TGUISwitch(menu.GetControl('swChatBubble')) do
     ItemIndex := gChatBubble;
 
+  with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
+    if gPlayerIndicator then ItemIndex := 0 else ItemIndex := 1;
+
   TGUIScroll(menu.GetControl('scScaleFactor')).Value := Round(g_dbg_scale - 1);
 
   menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
@@ -765,6 +776,7 @@ begin
   end
   else
     slWaitStr := _lc[I_NET_SLIST_ERROR];
+  g_Serverlist_GenerateTable(slCurrent, slTable);
 end;
 
 procedure ProcStartCampaign();
@@ -947,10 +959,12 @@ 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);
+    cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 1), 1), 255);
+    chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 1), 1), 255);
     spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
 
+    e_LogWritefln('LoadStdFont cwdt=%s chgt=%s spc=%s', [cwdt, chgt, spc]);
+
     if g_Texture_Get('FONT_STD', ID) then
       e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
 
@@ -1292,6 +1306,7 @@ var
   menu: TGUIMenu;
 begin
   menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
+  g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
   g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
   g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
 end;
@@ -2364,7 +2379,7 @@ begin
 
       Sort := True;
       Dirs := True;
-      FileMask := '*.wad|*.pk3|*.zip';
+      FileMask := '*.wad|*.pk3|*.zip|*.dfz';
       SetBase(MapsDir+'megawads/');
     end;
 
@@ -2419,7 +2434,7 @@ begin
 
       Sort := True;
       Dirs := True;
-      FileMask := '*.wad|*.pk3|*.zip';
+      FileMask := '*.wad|*.pk3|*.zip|*.dfz';
       SetBase(MapsDir);
     end;
     with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
@@ -2506,7 +2521,10 @@ begin
     with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
     begin
       Name := 'swBPP';
+      AddItem('8');
+      AddItem('15');
       AddItem('16');
+      AddItem('24');
       AddItem('32');
     end;
     with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
@@ -2710,6 +2728,12 @@ begin
       AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
       AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
     end;
+    with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
+    begin
+      Name := 'swPlayerIndicator';
+      AddItem(_lc[I_MENU_YES]);
+      AddItem(_lc[I_MENU_NO]);
+    end;
     with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
     begin
       Name := 'scScaleFactor';
@@ -2742,7 +2766,7 @@ begin
       AddSpace();
       AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
     end;
-    if SDL_GetNumTouchDevices() > 0 then
+    if g_touch_enabled then
     begin
       AddSpace();
       AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
@@ -2827,6 +2851,13 @@ begin
   with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
   begin
     Name := 'mOptionsControlsTouchMenu';
+    with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
+    begin
+      Name := 'swTouchAlt';
+      AddItem(_lc[I_MENU_NO]);
+      AddItem(_lc[I_MENU_YES]);
+      OnChange := ProcChangeTouchSettings;
+    end;
     with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
     begin
       Name := 'scTouchSize';