Add a UI indicator for bot players.

This commit is contained in:
Matthias Mailänder
2024-07-26 19:42:38 +02:00
committed by Gustas
parent 9761a68cd4
commit c24913ea24
24 changed files with 82 additions and 9 deletions

View File

@@ -354,27 +354,32 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public static void SetupProfileWidget(Widget parent, Session.Client c, OrderManager orderManager, WorldRenderer worldRenderer)
{
var visible = c != null && c.Bot == null;
var profile = parent.GetOrNull<ImageWidget>("PROFILE");
if (profile != null)
{
var imageName = (c != null && c.IsAdmin ? "admin-" : "player-")
+ (c.Fingerprint != null ? "registered" : "anonymous");
var imageName = c.IsBot ? "bot" :
c.IsAdmin ? "admin-" :
"player-";
if (!c.IsBot)
imageName += c.Fingerprint != null ? "registered" : "anonymous";
profile.GetImageName = () => imageName;
profile.IsVisible = () => visible;
profile.IsVisible = () => true;
}
var profileTooltip = parent.GetOrNull<ClientTooltipRegionWidget>("PROFILE_TOOLTIP");
if (profileTooltip != null)
{
if (c != null && c.Fingerprint != null)
if (c.Fingerprint != null)
profileTooltip.Template = "REGISTERED_PLAYER_TOOLTIP";
if (visible)
profileTooltip.Bind(orderManager, worldRenderer, c);
if (c.IsBot)
profileTooltip.Template = "BOT_TOOLTIP";
profileTooltip.IsVisible = () => visible;
profileTooltip.Bind(orderManager, worldRenderer, c);
profileTooltip.IsVisible = () => true;
}
}

View File

@@ -352,4 +352,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
}
public class BotTooltipLogic : ChromeLogic
{
[TranslationReference("name")]
const string BotManagedBy = "label-bot-managed-by-tooltip";
[ObjectCreator.UseCtor]
public BotTooltipLogic(OrderManager orderManager, Widget widget, Session.Client client)
{
var nameLabel = widget.Get<LabelWidget>("NAME");
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
var controller = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.Index == client.BotControllerClientIndex);
if (controller != null)
nameLabel.GetText = () => TranslationProvider.GetString(BotManagedBy, Translation.Arguments("name", controller.Name));
widget.Bounds.Width = nameFont.Measure(nameLabel.GetText()).X + 2 * nameLabel.Bounds.Left;
}
}
}

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Widgets
public SpawnOccupant(Session.Client client)
{
Color = client.Color;
PlayerName = client.IsBot ? TranslationProvider.GetString(client.Name) : client.Name;;
PlayerName = client.IsBot ? TranslationProvider.GetString(client.Name) : client.Name;
Team = client.Team;
Faction = client.Faction;
SpawnPoint = client.SpawnPoint;

View File

@@ -408,6 +408,7 @@ lobby-bits:
admin-anonymous: 802, 51, 16, 16
player-registered: 785, 51, 16, 16
player-anonymous: 819, 51, 16, 16
bot: 938, 51, 16, 16
reload-icon:
Inherits: ^Chrome

View File

@@ -412,6 +412,20 @@ Background@LATENCY_TOOLTIP:
Height: 23
Font: Bold
Background@BOT_TOOLTIP:
Logic: BotTooltipLogic
Background: panel-black
Height: 30
Width: 300
Children:
Label@NAME:
X: 5
Y: 2
Text: label-bot-player-tooltip-name
Width: 290
Height: 24
Font: Bold
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: panel-black

View File

@@ -696,5 +696,7 @@ button-settings-panel-reset = Reset
## tooltips.yaml
label-latency-tooltip-prefix = Latency:
label-anonymous-player-tooltip-name = Anonymous Player
label-bot-player-tooltip-name = Bot
label-bot-managed-by-tooltip = Bot managed by { $name }
label-game-admin = Game Admin

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 KiB

After

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1019 KiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 170 KiB

View File

@@ -130,6 +130,20 @@ Background@LATENCY_TOOLTIP:
Height: 26
Font: Bold
Background@BOT_TOOLTIP:
Logic: BotTooltipLogic
Background: dialog4
Height: 30
Width: 300
Children:
Label@NAME:
X: 7
Y: 2
Text: label-bot-player-tooltip-name
Width: 290
Height: 24
Font: Bold
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: dialog4

View File

@@ -522,6 +522,8 @@ button-settings-panel-reset = Reset
## tooltips.yaml
label-latency-tooltip-prefix = Latency:
label-anonymous-player-tooltip-name = Anonymous Player
label-bot-player-tooltip-name = Bot
label-bot-managed-by-tooltip = Bot managed by { $name }
label-game-admin = Game Admin
## gamesave-loading.yaml

View File

@@ -269,6 +269,7 @@ lobby-bits:
admin-anonymous: 34, 51, 16, 16
player-registered: 17, 51, 16, 16
player-anonymous: 51, 51, 16, 16
bot: 170, 51, 16, 16
reload-icon:
Inherits: ^Glyphs

View File

@@ -131,6 +131,20 @@ Background@LATENCY_TOOLTIP:
Height: 23
Font: Bold
Background@BOT_TOOLTIP:
Logic: BotTooltipLogic
Background: dialog3
Height: 30
Width: 300
Children:
Label@NAME:
X: 7
Y: 3
Text: label-bot-player-tooltip-name
Width: 290
Height: 24
Font: Bold
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: dialog3

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -345,6 +345,7 @@ lobby-bits:
spawn-unclaimed: 91, 119, 22, 22
spawn-disabled: 114, 119, 22, 22
admin: 170, 0, 6, 5
bot: 170, 51, 16, 16
colorpicker: 68, 119, 22, 22
huepicker: 136, 0, 7, 15
kick: 153, 0, 11, 11

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -489,6 +489,7 @@ lobby-bits:
admin-anonymous: 34, 51, 16, 16
player-registered: 17, 51, 16, 16
player-anonymous: 51, 51, 16, 16
bot: 170, 51, 16, 16
reload-icon:
Inherits: ^Glyphs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB