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

@@ -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;
}
}
}