Nicer tooltips, part 1 (needs to "step out" to a taller section for description)

This commit is contained in:
Paul Chote
2010-04-10 18:40:50 +12:00
committed by Chris Forbes
parent ea46f413d1
commit 68e301fecd
3 changed files with 29 additions and 34 deletions

View File

@@ -107,6 +107,29 @@ namespace OpenRA.Widgets
if (sp.IsAvailable)
{
var drawPos = new float2(Bounds.X + 5, y);
var rect = new Rectangle(Bounds.X + 5, y, 64, 48);
if (rect.Contains(Game.chrome.lastMousePos.ToPoint()))
{
var pos = drawPos.ToInt2();
var tooltipBounds = new Rectangle(pos.X-3,pos.Y-3,350,54);
WidgetUtils.DrawPanel("dialog4", tooltipBounds, null);
pos += new int2(70, 5);
Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, sp.Info.Description, pos, Color.White);
var timer = "Charge Time: {0}".F(FormatTime(sp.RemainingTime));
Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, timer, drawPos.ToInt2() + new int2((int)tooltipBounds.Width - Game.chrome.renderer.BoldFont.Measure(timer).X - 10, 0), Color.White);
if (sp.Info.LongDesc != null)
{
pos += new int2(0, 25);
Game.chrome.renderer.RegularFont.DrawText(Game.chrome.rgbaRenderer, sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
}
Game.chrome.rgbaRenderer.Flush();
}
WidgetUtils.DrawSHP(image, drawPos);
clock.PlayFetchIndex("idle",
@@ -116,7 +139,6 @@ namespace OpenRA.Widgets
WidgetUtils.DrawSHP(clock.Image, drawPos);
var rect = new Rectangle(Bounds.X + 5, y, 64, 48);
if (sp.IsReady)
{
ready.Play("ready");
@@ -124,21 +146,11 @@ namespace OpenRA.Widgets
}
buttons.Add(Pair.New(rect,HandleSupportPower(sp)));
if (rect.Contains(Game.chrome.lastMousePos.ToPoint()))
{
tooltipItem = sp;
tooltipPos = drawPos.ToInt2() + new int2(72, 0);
}
y += 51;
}
}
Game.chrome.shpRenderer.Flush();
if (tooltipItem != null)
DrawSupportPowerTooltip(world, tooltipItem, tooltipPos);
base.Draw(world);
}
@@ -154,25 +166,5 @@ namespace OpenRA.Widgets
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
}
void DrawSupportPowerTooltip(World world, SupportPower sp, int2 pos)
{
var tooltipBounds = new Rectangle(pos.X,pos.Y,400,100);
WidgetUtils.DrawPanel("dialog4", tooltipBounds, null);
pos += new int2(5, 5);
Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, sp.Info.Description, pos, Color.White);
var timer = "Charge Time: {0}".F(FormatTime(sp.RemainingTime));
Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, timer, pos + new int2((int)tooltipBounds.Width - Game.chrome.renderer.BoldFont.Measure(timer).X - 10, 0), Color.White);
if (sp.Info.LongDesc != null)
{
pos += new int2(0, 25);
Game.chrome.renderer.RegularFont.DrawText(Game.chrome.rgbaRenderer, sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
}
Game.chrome.rgbaRenderer.Flush();
}
}
}

View File

@@ -14,7 +14,10 @@
id="svg2816"
version="1.1"
inkscape:version="0.47 r22583"
sodipodi:docname="dialog4.svg">
sodipodi:docname="dialog4.svg"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/ra/dialog4.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs2818">
<inkscape:perspective
@@ -68,7 +71,7 @@
id="layer1"
transform="translate(0,-988.36218)">
<rect
style="fill:#000000;fill-opacity:0.75102042;stroke:none"
style="fill:#000000;fill-opacity:0.62448978;stroke:none"
id="rect2826"
width="64"
height="64"

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 B

After

Width:  |  Height:  |  Size: 556 B