Add tooltips to the password icon and player count.
This commit is contained in:
@@ -635,7 +635,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
password.GetImageName = () => canJoin ? "protected" : "protected-disabled";
|
||||
}
|
||||
|
||||
var players = item.GetOrNull<LabelWidget>("PLAYERS");
|
||||
var players = item.GetOrNull<LabelWithTooltipWidget>("PLAYERS");
|
||||
if (players != null)
|
||||
{
|
||||
var label = "{0} / {1}".F(game.Players + game.Bots, game.MaxPlayers + game.Bots)
|
||||
@@ -644,6 +644,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var color = canJoin ? players.TextColor : incompatibleGameColor;
|
||||
players.GetText = () => label;
|
||||
players.GetColor = () => color;
|
||||
|
||||
if (game.Clients.Any())
|
||||
{
|
||||
var displayClients = game.Clients.Select(c => c.Name);
|
||||
if (game.Clients.Length > 10)
|
||||
displayClients = displayClients
|
||||
.Take(9)
|
||||
.Append("+ {0} other players".F(game.Clients.Length - 9));
|
||||
|
||||
var tooltip = displayClients.JoinWith("\n");
|
||||
players.GetTooltipText = () => tooltip;
|
||||
}
|
||||
else
|
||||
players.GetTooltipText = null;
|
||||
}
|
||||
|
||||
var state = item.GetOrNull<LabelWidget>("STATUS");
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class ScrollItemWidget : ButtonWidget
|
||||
{
|
||||
public readonly string BaseName = "scrollitem";
|
||||
public readonly bool EnableChildMouseOver = false;
|
||||
public string ItemKey;
|
||||
public string BaseName = "scrollitem";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ScrollItemWidget(ModData modData)
|
||||
@@ -25,7 +26,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
IsVisible = () => false;
|
||||
VisualHeight = 0;
|
||||
IgnoreChildMouseOver = true;
|
||||
}
|
||||
|
||||
protected ScrollItemWidget(ScrollItemWidget other)
|
||||
@@ -33,17 +33,31 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
IsVisible = () => false;
|
||||
VisualHeight = 0;
|
||||
IgnoreChildMouseOver = true;
|
||||
Key = other.Key;
|
||||
BaseName = other.BaseName;
|
||||
EnableChildMouseOver = other.EnableChildMouseOver;
|
||||
}
|
||||
|
||||
public override void Initialize(WidgetArgs args)
|
||||
{
|
||||
base.Initialize(args);
|
||||
|
||||
// HACK: We want to default IgnoreChildMouseOver to true in this widget
|
||||
// but still allow it to be disabled
|
||||
IgnoreChildMouseOver = !EnableChildMouseOver;
|
||||
}
|
||||
|
||||
public Func<bool> IsSelected = () => false;
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
// PERF: Only check for ourself or our direct children
|
||||
var isHover = Ui.MouseOverWidget == this;
|
||||
if (!IgnoreChildMouseOver && !isHover)
|
||||
isHover = Children.Contains(Ui.MouseOverWidget);
|
||||
|
||||
var state = IsSelected() ? BaseName + "-selected" :
|
||||
Ui.MouseOverWidget == this ? BaseName + "-hover" :
|
||||
isHover ? BaseName + "-hover" :
|
||||
null;
|
||||
|
||||
if (state != null)
|
||||
|
||||
@@ -103,6 +103,7 @@ Container@MULTIPLAYER_PANEL:
|
||||
Width: PARENT_RIGHT - 27
|
||||
Height: 25
|
||||
X: 2
|
||||
EnableChildMouseOver: True
|
||||
Children:
|
||||
Label@TITLE:
|
||||
X: 5
|
||||
@@ -114,10 +115,15 @@ Container@MULTIPLAYER_PANEL:
|
||||
Width: 8
|
||||
Height: 10
|
||||
ImageCollection: lobby-bits
|
||||
Label@PLAYERS:
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
TooltipText: Requires Password
|
||||
LabelWithTooltip@PLAYERS:
|
||||
X: 290
|
||||
Width: 85
|
||||
Height: 25
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Label@LOCATION:
|
||||
X: 380
|
||||
Width: 110
|
||||
|
||||
@@ -95,6 +95,7 @@ Background@MULTIPLAYER_PANEL:
|
||||
X: 2
|
||||
Width: PARENT_RIGHT - 27
|
||||
Height: 25
|
||||
EnableChildMouseOver: True
|
||||
Children:
|
||||
Label@TITLE:
|
||||
X: 5
|
||||
@@ -103,13 +104,18 @@ Background@MULTIPLAYER_PANEL:
|
||||
Image@PASSWORD_PROTECTED:
|
||||
X: 272
|
||||
Y: 6
|
||||
Width: 8
|
||||
Height: 10
|
||||
Width: 10
|
||||
Height: 12
|
||||
ImageCollection: lobby-bits
|
||||
Label@PLAYERS:
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
TooltipText: Requires Password
|
||||
LabelWithTooltip@PLAYERS:
|
||||
X: 290
|
||||
Width: 85
|
||||
Height: 25
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Label@LOCATION:
|
||||
X: 380
|
||||
Width: 110
|
||||
|
||||
Reference in New Issue
Block a user