New dialog type for tooltips etc

This commit is contained in:
Paul Chote
2010-04-10 18:21:58 +12:00
committed by Chris Forbes
parent 9f5c08728d
commit ea46f413d1
6 changed files with 119 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Widgets
{
class BackgroundWidget : Widget
{
public readonly string Background = "dialog";
public override void Draw(World world)
{
if (!Visible)
@@ -30,7 +31,7 @@ namespace OpenRA.Widgets
return;
}
WidgetUtils.DrawPanel("dialog", Bounds, null);
WidgetUtils.DrawPanel(Background, Bounds, null);
base.Draw(world);
}
}

View File

@@ -158,7 +158,7 @@ namespace OpenRA.Widgets
void DrawSupportPowerTooltip(World world, SupportPower sp, int2 pos)
{
var tooltipBounds = new Rectangle(pos.X,pos.Y,400,100);
WidgetUtils.DrawPanel("dialog", tooltipBounds, null);
WidgetUtils.DrawPanel("dialog4", tooltipBounds, null);
pos += new int2(5, 5);
Game.chrome.renderer.BoldFont.DrawText(Game.chrome.rgbaRenderer, sp.Info.Description, pos, Color.White);

View File

@@ -48,14 +48,18 @@ namespace OpenRA.Widgets
var r = Game.chrome.renderer;
var sr = Game.chrome.rgbaRenderer;
r.Device.EnableScissor(Bounds.Left, Bounds.Top, Bounds.Width, Bounds.Height);
var images = new[] { "border-t", "border-b", "border-l", "border-r", "corner-tl", "corner-tr", "corner-bl", "corner-br", "background" };
var ss = images.Select(i => ChromeProvider.GetImage(Game.chrome.renderer, collection, i)).ToArray();
// Don't draw the background below the bottom/right borders
r.Device.EnableScissor(Bounds.Left, Bounds.Top, Bounds.Width - (int)ss[3].size.X, Bounds.Height - (int)ss[1].size.Y);
for (var x = Bounds.Left + (int)ss[2].size.X; x < Bounds.Right - (int)ss[3].size.X; x += (int)ss[8].size.X)
for (var y = Bounds.Top + (int)ss[0].size.Y; y < Bounds.Bottom - (int)ss[1].size.Y; y += (int)ss[8].size.Y)
sr.DrawSprite(ss[8], new float2(x, y), "chrome");
sr.Flush(); // because the scissor is changing
r.Device.EnableScissor(Bounds.Left, Bounds.Top, Bounds.Width, Bounds.Height - (int)ss[1].size.Y);
//draw borders
for (var y = Bounds.Top + (int)ss[0].size.Y; y < Bounds.Bottom - (int)ss[1].size.Y; y += (int)ss[2].size.Y)
@@ -64,12 +68,18 @@ namespace OpenRA.Widgets
sr.DrawSprite(ss[3], new float2(Bounds.Right - ss[3].size.X, y), "chrome");
}
sr.Flush(); // because the scissor is changing
r.Device.EnableScissor(Bounds.Left, Bounds.Top, Bounds.Width - (int)ss[3].size.X, Bounds.Height);
for (var x = Bounds.Left + (int)ss[2].size.X; x < Bounds.Right - (int)ss[3].size.X; x += (int)ss[0].size.X)
{
sr.DrawSprite(ss[0], new float2(x, Bounds.Top), "chrome");
sr.DrawSprite(ss[1], new float2(x, Bounds.Bottom - ss[1].size.Y), "chrome");
}
sr.Flush(); // because the scissor is changing
r.Device.EnableScissor(Bounds.Left, Bounds.Top, Bounds.Width, Bounds.Height);
sr.DrawSprite(ss[4], new float2(Bounds.Left, Bounds.Top), "chrome");
sr.DrawSprite(ss[5], new float2(Bounds.Right - ss[5].size.X, Bounds.Top), "chrome");
sr.DrawSprite(ss[6], new float2(Bounds.Left, Bounds.Bottom - ss[6].size.Y), "chrome");