Implement new spawn tooltips in RA and d2k.

This commit is contained in:
Paul Chote
2013-04-25 12:07:30 +12:00
parent a309511f9b
commit ba2704291a
11 changed files with 73 additions and 12 deletions

View File

@@ -113,7 +113,6 @@
<Compile Include="WithFire.cs" />
<Compile Include="WithRoof.cs" />
<Compile Include="Widgets\ResourceBarWidget.cs" />
<Compile Include="Widgets\Logic\SpawnSelectorTooltipLogic.cs" />
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
</ItemGroup>

View File

@@ -430,6 +430,7 @@
<Compile Include="BridgeHut.cs" />
<Compile Include="Lint\CheckSequences.cs" />
<Compile Include="ServerTraits\PlayerPinger.cs" />
<Compile Include="Widgets\Logic\SpawnSelectorTooltipLogic.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -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<LabelWidget>("LABEL");
var flag = widget.Get<ImageWidget>("FLAG");
var team = widget.Get<LabelWidget>("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;
};

View File

@@ -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:

View File

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

View File

@@ -34,6 +34,7 @@ Background@SERVER_LOBBY:
Y:4
Width:244
Height:244
TooltipContainer:TOOLTIP_CONTAINER
ScrollPanel@PLAYERS:
X:20
Y:67
@@ -494,3 +495,4 @@ Background@SERVER_LOBBY:
Height:25
Text:Start Game
Font:Bold
TooltipContainer@TOOLTIP_CONTAINER:

View File

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

View File

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

View File

@@ -34,6 +34,7 @@ Background@SERVER_LOBBY:
Y:4
Width:244
Height:244
TooltipContainer:TOOLTIP_CONTAINER
ScrollPanel@PLAYERS:
X:20
Y:67
@@ -500,3 +501,4 @@ Background@SERVER_LOBBY:
Height:25
Text:Start Game
Font:Bold
TooltipContainer@TOOLTIP_CONTAINER:

View File

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

View File

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