Nicer tooltips

This commit is contained in:
Paul Chote
2010-06-30 19:02:37 +12:00
parent 51079f0876
commit e5ce9196fa
5 changed files with 42 additions and 30 deletions

View File

@@ -75,7 +75,7 @@ namespace OpenRA
PlayerName = client.Name;
InternalName = "Multi{0}".F(client.Index);
Country = world.GetCountries()
.FirstOrDefault(c => client != null && client.Country == c.Name)
.FirstOrDefault(c => client != null && client.Country == c.Race)
?? world.GetCountries().Random(world.SharedRandom);
}

View File

@@ -145,7 +145,7 @@ namespace OpenRA.Widgets.Delegates
bool CycleRace(MouseInput mi)
{
var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Name));
var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Race));
if (mi.Button == MouseButton.Right)
countries = countries.Reverse();

View File

@@ -23,6 +23,7 @@ using System;
using System.Drawing;
using System.Linq;
using OpenRA.Traits;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
@@ -47,15 +48,17 @@ namespace OpenRA.Widgets
var text = actor.Info.Traits.Contains<ValuedInfo>()
? actor.Info.Traits.Get<ValuedInfo>().Description
: actor.Info.Name;
var text2 = (actor.Owner == world.LocalPlayer)
? "" : (actor.Owner.NonCombatant ? "{0}" : "{0} ({1})").F(actor.Owner.PlayerName, world.LocalPlayer.Stances[actor.Owner]);
var text2 = (actor.Owner.NonCombatant)
? "" : "{0}".F(actor.Owner.PlayerName);
var text3 = (actor.Owner == world.LocalPlayer || actor.Owner.NonCombatant)
? "" : " ({0})".F(world.LocalPlayer.Stances[actor.Owner]);
var renderer = Game.chrome.renderer;
var sz = renderer.BoldFont.Measure(text);
var sz2 = renderer.RegularFont.Measure(text2);
sz.X = Math.Max(sz.X, sz2.X);
var sz3 = renderer.RegularFont.Measure(text3);
sz.X = Math.Max(sz.X, sz2.X + sz3.X + 35);
if (text2 != "") sz.Y += sz2.Y + 2;
@@ -68,9 +71,18 @@ namespace OpenRA.Widgets
renderer.BoldFont.DrawText(text,
new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 30), Color.White);
renderer.RegularFont.DrawText(text2,
new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50), Color.White);
if (text2 != "")
{
renderer.RegularFont.DrawText(text2,
new float2(Game.chrome.lastMousePos.X + 65, Game.chrome.lastMousePos.Y + 50), actor.Owner.Color);
renderer.RegularFont.DrawText(text3,
new float2(Game.chrome.lastMousePos.X + 65 + sz2.X, Game.chrome.lastMousePos.Y + 50), Color.White);
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Game.chrome.renderer, "flags", actor.Owner.Country.Race), new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50));
}
renderer.RgbaSpriteRenderer.Flush();
}
}

View File

@@ -197,15 +197,15 @@
<image name="disabled" x="68" y="56" width="34" height="28" />
</collection>
<collection name="flags" src="buttons.png">
<image name="GDI" x="30" y="84" width="30" height="15" />
<image name="Nod" x="0" y="84" width="30" height="15" />
<image name="gdi" x="30" y="84" width="30" height="15" />
<image name="nod" x="0" y="84" width="30" height="15" />
<image name="Random" x="60" y="84" width="30" height="15" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />
<image name="stop" x="28" y="0" width="25" height="25" />
<image name="play" x="56" y="0" width="25" height="25" />
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />
<image name="stop" x="28" y="0" width="25" height="25" />
<image name="play" x="56" y="0" width="25" height="25" />
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
</chrome>

View File

@@ -188,17 +188,17 @@
<image name="normal" x="0" y="56" width="34" height="28" />
<image name="pressed" x="34" y="56" width="34" height="28" />
<image name="disabled" x="68" y="56" width="34" height="28" />
</collection>
<collection name="flags" src="buttons.png">
<image name="Allies" x="30" y="84" width="30" height="15" />
<image name="Soviet" x="0" y="84" width="30" height="15" />
<image name="Random" x="60" y="84" width="30" height="15" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />
<image name="stop" x="28" y="0" width="25" height="25" />
<image name="play" x="56" y="0" width="25" height="25" />
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
<collection name="flags" src="buttons.png">
<image name="allies" x="30" y="84" width="30" height="15" />
<image name="soviet" x="0" y="84" width="30" height="15" />
<image name="Random" x="60" y="84" width="30" height="15" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />
<image name="stop" x="28" y="0" width="25" height="25" />
<image name="play" x="56" y="0" width="25" height="25" />
<image name="next" x="84" y="0" width="25" height="25" />
<image name="prev" x="112" y="0" width="25" height="25" />
</collection>
</chrome>