diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index c7d8551f80..dddbb9e9b7 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -113,7 +113,6 @@ - diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index df0d79d224..328a098d0b 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -430,6 +430,7 @@ + diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SpawnSelectorTooltipLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SpawnSelectorTooltipLogic.cs similarity index 79% rename from OpenRA.Mods.Cnc/Widgets/Logic/SpawnSelectorTooltipLogic.cs rename to OpenRA.Mods.RA/Widgets/Logic/SpawnSelectorTooltipLogic.cs index 6ad7f65538..3745ae98e4 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SpawnSelectorTooltipLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SpawnSelectorTooltipLogic.cs @@ -14,7 +14,7 @@ using System.Linq; using OpenRA.Widgets; using OpenRA.Network; -namespace OpenRA.Mods.Cnc.Widgets.Logic +namespace OpenRA.Mods.RA.Widgets.Logic { public class SpawnSelectorTooltipLogic { @@ -25,9 +25,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var label = widget.Get("LABEL"); var flag = widget.Get("FLAG"); var team = widget.Get("TEAM"); - + var singleHeight = widget.Get("SINGLE_HEIGHT").Bounds.Height; + var doubleHeight = widget.Get("DOUBLE_HEIGHT").Bounds.Height; var ownerFont = Game.Renderer.Fonts[label.Font]; var teamFont = Game.Renderer.Fonts[team.Font]; + + // Width specified in YAML is used as the margin between flag / label and label / border + var labelMargin = widget.Bounds.Width; + var cachedWidth = 0; var labelText = ""; string playerCountry = null; @@ -43,18 +48,18 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic labelText = "Available spawn"; playerCountry = null; playerTeam = 0; - widget.Bounds.Height = 25; + widget.Bounds.Height = singleHeight; } else { labelText = client.Name; playerCountry = client.Country; playerTeam = client.Team; - widget.Bounds.Height = playerTeam > 0 ? 40 : 25; + widget.Bounds.Height = playerTeam > 0 ? doubleHeight : singleHeight; teamWidth = teamFont.Measure(team.GetText()).X; } - label.Bounds.X = playerCountry != null ? flag.Bounds.Right + 5 : 5; + label.Bounds.X = playerCountry != null ? flag.Bounds.Right + labelMargin : labelMargin; var textWidth = ownerFont.Measure(labelText).X; if (textWidth != cachedWidth) @@ -63,7 +68,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic widget.Bounds.Width = 2*label.Bounds.X + textWidth; } - widget.Bounds.Width = Math.Max(teamWidth + 10, label.Bounds.Right + 5); + widget.Bounds.Width = Math.Max(teamWidth + 2*labelMargin, label.Bounds.Right + labelMargin); team.Bounds.Width = widget.Bounds.Width; }; diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index b5f325c6e0..28907a96df 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -480,7 +480,6 @@ Container@SERVER_LOBBY: Height:25 Align:Right Text:Chat: - TooltipContainer@TOOLTIP_CONTAINER: Button@DISCONNECT_BUTTON: X:0 Y:499 @@ -505,3 +504,4 @@ Container@SERVER_LOBBY: Width:140 Height:35 Text:Start Game + TooltipContainer@TOOLTIP_CONTAINER: \ No newline at end of file diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index ed35e8ddb3..49644b4746 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -103,8 +103,12 @@ Background@SUPPORT_POWER_TOOLTIP: Background@SPAWN_TOOLTIP: Logic:SpawnSelectorTooltipLogic Background:panel-black - Width:141 + Width:5 Children: + Container@SINGLE_HEIGHT: + Height:26 + Container@DOUBLE_HEIGHT: + Height:40 Label@LABEL: X:5 Height:23 @@ -118,4 +122,4 @@ Background@SPAWN_TOOLTIP: Y:21 Height:15 Font:TinyBold - Align:center \ No newline at end of file + Align:center diff --git a/mods/d2k/chrome/lobby.yaml b/mods/d2k/chrome/lobby.yaml index e000aadfec..6abb365c69 100644 --- a/mods/d2k/chrome/lobby.yaml +++ b/mods/d2k/chrome/lobby.yaml @@ -34,6 +34,7 @@ Background@SERVER_LOBBY: Y:4 Width:244 Height:244 + TooltipContainer:TOOLTIP_CONTAINER ScrollPanel@PLAYERS: X:20 Y:67 @@ -493,4 +494,5 @@ Background@SERVER_LOBBY: Width:120 Height:25 Text:Start Game - Font:Bold \ No newline at end of file + Font:Bold + TooltipContainer@TOOLTIP_CONTAINER: \ No newline at end of file diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml new file mode 100644 index 0000000000..c8b88119c5 --- /dev/null +++ b/mods/d2k/chrome/tooltips.yaml @@ -0,0 +1,23 @@ +Background@SPAWN_TOOLTIP: + Logic:SpawnSelectorTooltipLogic + Background:dialog3 + Width:7 + Children: + Container@SINGLE_HEIGHT: + Height:31 + Container@DOUBLE_HEIGHT: + Height:47 + Label@LABEL: + Y:3 + Height:23 + Font:Bold + Image@FLAG: + X:5 + Y:5 + Width:23 + Height:23 + Label@TEAM: + Y:28 + Height:15 + Font:TinyBold + Align:center \ No newline at end of file diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 477dd592b6..0999f09c7c 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -60,6 +60,7 @@ ChromeLayout: mods/ra/chrome/dropdowns.yaml mods/ra/chrome/modchooser.yaml mods/ra/chrome/cheats.yaml + mods/d2k/chrome/tooltips.yaml Weapons: mods/d2k/weapons/defaults.yaml diff --git a/mods/ra/chrome/lobby.yaml b/mods/ra/chrome/lobby.yaml index 39de30bbac..d087512504 100644 --- a/mods/ra/chrome/lobby.yaml +++ b/mods/ra/chrome/lobby.yaml @@ -34,6 +34,7 @@ Background@SERVER_LOBBY: Y:4 Width:244 Height:244 + TooltipContainer:TOOLTIP_CONTAINER ScrollPanel@PLAYERS: X:20 Y:67 @@ -499,4 +500,5 @@ Background@SERVER_LOBBY: Width:120 Height:25 Text:Start Game - Font:Bold \ No newline at end of file + Font:Bold + TooltipContainer@TOOLTIP_CONTAINER: \ No newline at end of file diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml new file mode 100644 index 0000000000..03904d5d69 --- /dev/null +++ b/mods/ra/chrome/tooltips.yaml @@ -0,0 +1,23 @@ +Background@SPAWN_TOOLTIP: + Logic:SpawnSelectorTooltipLogic + Background:dialog4 + Width:7 + Children: + Container@SINGLE_HEIGHT: + Height:29 + Container@DOUBLE_HEIGHT: + Height:44 + Label@LABEL: + Y:2 + Height:23 + Font:Bold + Image@FLAG: + X:7 + Y:7 + Width:32 + Height:16 + Label@TEAM: + Y:23 + Height:15 + Font:TinyBold + Align:center \ No newline at end of file diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index ae392c4e35..d5f84e3c1b 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -70,6 +70,7 @@ ChromeLayout: mods/ra/chrome/modchooser.yaml mods/ra/chrome/cheats.yaml mods/ra/chrome/objectives.yaml + mods/ra/chrome/tooltips.yaml Weapons: mods/ra/weapons.yaml