Nicer tooltips, part 1 (needs to "step out" to a taller section for description)
This commit is contained in:
@@ -107,6 +107,29 @@ namespace OpenRA.Widgets
|
|||||||
if (sp.IsAvailable)
|
if (sp.IsAvailable)
|
||||||
{
|
{
|
||||||
var drawPos = new float2(Bounds.X + 5, y);
|
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);
|
WidgetUtils.DrawSHP(image, drawPos);
|
||||||
|
|
||||||
clock.PlayFetchIndex("idle",
|
clock.PlayFetchIndex("idle",
|
||||||
@@ -116,7 +139,6 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
WidgetUtils.DrawSHP(clock.Image, drawPos);
|
WidgetUtils.DrawSHP(clock.Image, drawPos);
|
||||||
|
|
||||||
var rect = new Rectangle(Bounds.X + 5, y, 64, 48);
|
|
||||||
if (sp.IsReady)
|
if (sp.IsReady)
|
||||||
{
|
{
|
||||||
ready.Play("ready");
|
ready.Play("ready");
|
||||||
@@ -125,20 +147,10 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
buttons.Add(Pair.New(rect,HandleSupportPower(sp)));
|
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;
|
y += 51;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Game.chrome.shpRenderer.Flush();
|
Game.chrome.shpRenderer.Flush();
|
||||||
|
|
||||||
if (tooltipItem != null)
|
|
||||||
DrawSupportPowerTooltip(world, tooltipItem, tooltipPos);
|
|
||||||
|
|
||||||
base.Draw(world);
|
base.Draw(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,25 +166,5 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,10 @@
|
|||||||
id="svg2816"
|
id="svg2816"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
inkscape:version="0.47 r22583"
|
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
|
<defs
|
||||||
id="defs2818">
|
id="defs2818">
|
||||||
<inkscape:perspective
|
<inkscape:perspective
|
||||||
@@ -68,7 +71,7 @@
|
|||||||
id="layer1"
|
id="layer1"
|
||||||
transform="translate(0,-988.36218)">
|
transform="translate(0,-988.36218)">
|
||||||
<rect
|
<rect
|
||||||
style="fill:#000000;fill-opacity:0.75102042;stroke:none"
|
style="fill:#000000;fill-opacity:0.62448978;stroke:none"
|
||||||
id="rect2826"
|
id="rect2826"
|
||||||
width="64"
|
width="64"
|
||||||
height="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 |
Reference in New Issue
Block a user