From: Joseph Stalin Date: Sat, 14 Sep 2019 17:02:49 +0000 (+0500) Subject: Added textual player indicator X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=82108dd50fb12ef54f0cd04891901782781fe442;p=d2df-sdl.git Added textual player indicator Menu options and localization strings included. Also moved stuff to dfconfig. --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 3f328d4..0d5a73c 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -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 diff --git a/src/game/g_language.pas b/src/game/g_language.pas index cccffd6..951ba6e 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -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:', 'Ìàñøòàá:'), diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 3a6f0e7..4d2da49 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -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'; diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 697656b..979fe45 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -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); diff --git a/src/game/g_player.pas b/src/game/g_player.pas index d6914b1..dee10aa 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -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.