DEADSOFTWARE

Added textual player indicator
authorJoseph Stalin <granminigun@pm.me>
Sat, 14 Sep 2019 17:02:49 +0000 (22:02 +0500)
committerJoseph Stalin <granminigun@pm.me>
Sun, 22 Sep 2019 15:29:43 +0000 (20:29 +0500)
Menu options and localization strings included.
Also moved stuff to dfconfig.

src/game/g_game.pas
src/game/g_language.pas
src/game/g_menu.pas
src/game/g_options.pas
src/game/g_player.pas

index 3f328d493c30067afc7bf9798db2688b0ea5c514..0d5a73cdc2fc772cd49063dd7987c594d8d0c176 100644 (file)
@@ -3675,9 +3675,10 @@ begin
         for i := 0 to High(gPlayers) do
           if gPlayers[i] <> nil then
             if gPlayers[i] = p then p.DrawIndicator(_RGB(255, 255, 255))
-            else if (gPlayers[i].Team = p.Team) and (gPlayers[i].Team <> TEAM_NONE)
-            then
-              gPlayers[i].DrawIndicator(gPlayers[i].GetColor);
+            else if (gPlayers[i].Team = p.Team) and (gPlayers[i].Team <> TEAM_NONE) then
+              if gPlayerIndicatorStyle = 1 then
+                gPlayers[i].DrawIndicator(_RGB(192, 192, 192))
+              else gPlayers[i].DrawIndicator(gPlayers[i].GetColor);
     end;
 
   if p.FSpectator then
index cccffd6ec8dd8dc2db47f92b6b05cef49ec13dc9..951ba6ee829172e5ba7399b2866ffea8de15537e 100644 (file)
@@ -262,6 +262,9 @@ type
     I_MENU_GAME_INDICATOR_NONE,
     I_MENU_GAME_INDICATOR_OWN,
     I_MENU_GAME_INDICATOR_ALL,
+    I_MENU_GAME_INDICATOR_STYLE,
+    I_MENU_GAME_INDICATOR_ARROW,
+    I_MENU_GAME_INDICATOR_NAME,
     I_MENU_GAME_SCALE_FACTOR,
 
     I_MENU_VIDEO_RESOLUTION,
@@ -1100,12 +1103,18 @@ const
                                        'Òåêñòóðà'),
     ('MENU GAME PLAYER INDICATOR',     'Player indicator:',
                                        'Èíäèêàòîð èãðîêà:'),
-    ('MENU GAME INDICATOR TYPE NONE',  'None',
+    ('MENU GAME INDICATOR NONE',       'None',
                                        'Íåò'),
-    ('MENU GAME INDICATOR TYPE OWN',   'Own',
+    ('MENU GAME INDICATOR OWN',        'Own',
                                        'Ñâîé'),
-    ('MENU GAME INDICATOR TYPE ALL',   'Own + Teammates',
+    ('MENU GAME INDICATOR ALL',        'Own + Teammates',
                                        'Ñâîé + Ñîþçíèêè'),
+    ('MENU GAME INDICATOR STYLE',      'Indicator Style:',
+                                       'Âèä èíäèêàòîðà:'),
+    ('MENU GAME INDICATOR ARROW',      'Arrow',
+                                       'Ñòðåëêà'),
+    ('MENU GAME INDICATOR NAME',       'Name',
+                                       'Èìÿ'),
     ('MENU GAME SCALE FACTOR',         'Scale:',
                                        'Ìàñøòàá:'),
 
index 3a6f0e7d6efb7895642f1cd3f86bf1b5522e1354..4d2da495216be1983b5f6e38ae4454fc3f7dc6a0 100644 (file)
@@ -161,6 +161,7 @@ begin
   gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
   gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
   gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
+  gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
   if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
   begin
     TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
@@ -571,6 +572,9 @@ begin
   with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
     ItemIndex := gPlayerIndicator;
 
+  with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
+    ItemIndex := gPlayerIndicatorStyle;
+
   TempScale := Round(g_dbg_scale - 1);
   TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
 
@@ -2784,6 +2788,12 @@ begin
       AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
       AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
     end;
+    with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
+    begin
+      Name := 'swPlayerIndicatorStyle';
+      AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
+      AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
+    end;
     with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
     begin
       Name := 'scScaleFactor';
index 697656bffc0327903c8a970fdf125a55a82bf62c..979fe4510cd9d9144e8e3faff46a47a44cc6fe41 100644 (file)
@@ -226,7 +226,6 @@ begin
   gShowMessages := True;
   gRevertPlayers := False;
   gChatBubble := 4;
-  gPlayerIndicator := 1;
   gSFSDebug := False;
   gSFSFastMode := False;
   e_FastScreenshots := True;
@@ -419,7 +418,6 @@ begin
   ReadBoolean(gShowMessages, 'Messages');
   ReadBoolean(gRevertPlayers, 'RevertPlayers');
   ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
-  ReadInteger(gPlayerIndicator, 'PlayerIndicator', 0, 2);
   ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
   ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
   ReadBoolean(e_FastScreenshots, 'FastScreenshots');
@@ -593,7 +591,6 @@ begin
   config.WriteBool('Game', 'Messages', gShowMessages);
   config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
   config.WriteInt('Game', 'ChatBubble', gChatBubble);
-  config.WriteInt('Game', 'PlayerIndicator', gPlayerIndicator);
   config.WriteBool('Game', 'SFSDebug', gSFSDebug);
   config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
   config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
index d6914b1c6fd40425ca90bfcfe7e3434e514ba162..dee10aa191af47131130ed12d2b102299d1a2d60 100644 (file)
@@ -555,7 +555,8 @@ var
   gFly: Boolean = False;
   gAimLine: Boolean = False;
   gChatBubble: Byte = 0;
-  gPlayerIndicator: Byte = 1;
+  gPlayerIndicator: Integer = 1;
+  gPlayerIndicatorStyle: Integer = 0;
   gNumBots: Word = 0;
   gLMSPID1: Word = 0;
   gLMSPID2: Word = 0;
@@ -2331,24 +2332,35 @@ procedure TPlayer.DrawIndicator(Color: TRGB);
 var
   indX, indY: Integer;
   indW, indH: Word;
+  nW, nH: Byte;
   ID: DWORD;
   c: TRGB;
 begin
   if FAlive then
-  begin
-    if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
-    begin
-      e_GetTextureSize(ID, @indW, @indH);
-      indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
-      indY := FObj.Y;
-
-      c := e_Colors;
-      e_Colors := Color;
-      e_Draw(ID, indX, indY - indH, 0, True, False);
-      e_Colors := c;
+    case gPlayerIndicatorStyle of
+      0:
+        begin
+          if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
+          begin
+            e_GetTextureSize(ID, @indW, @indH);
+            indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2;
+            indY := FObj.Y - indH;
+
+            c := e_Colors;
+            e_Colors := Color;
+            e_Draw(ID, indX, indY, 0, True, False);
+            e_Colors := c;
+          end;
+        end;
+
+      1:
+        begin
+          e_TextureFontGetSize(gStdFont, nW, nH);
+          indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - Length(FName) * nW) div 2;
+          indY := FObj.Y - nH;
+          e_TextureFontPrintEx(indX, indY, FName, gStdFont, Color.R, Color.G, Color.B, 1.0, True);
+        end;
     end;
-  end;
-  //e_TextureFontPrintEx(indX, indY, FName, gStdFont, 0, 0, 255, 1.0, true); // Shows player name overhead
 end;
 
 procedure TPlayer.DrawBubble();
@@ -7898,4 +7910,6 @@ end;
 
 begin
   conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '',  true, true);
+  conRegVar('player_indicator', @gPlayerIndicator, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all');
+  conRegVar('player_indicator_style', @gPlayerIndicatorStyle, 'Visual appearance of indicator', 'Visual appearance of indicator');
 end.