Add a UI indicator for bot players.
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 406 KiB After Width: | Height: | Size: 415 KiB |
|
Before Width: | Height: | Size: 1019 KiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 170 KiB |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 163 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |