Loadscreen progress bar

This commit is contained in:
Paul Chote
2011-05-21 11:58:30 +12:00
parent 126e489a10
commit bafd12b88e
3 changed files with 93 additions and 62 deletions

View File

@@ -20,10 +20,12 @@ namespace OpenRA.Mods.Cnc
public class CncLoadScreen : ILoadScreen
{
Dictionary<string,string> Info;
Stopwatch lastLoadScreen = new Stopwatch();
Stopwatch loadTimer = new Stopwatch();
Sprite[] ss;
float2 nodPos, gdiPos, evaPos;
Sprite nodLogo, gdiLogo, evaLogo;
string text;
int loadTick;
float2 nodPos, gdiPos, evaPos, textPos;
Sprite nodLogo, gdiLogo, evaLogo, brightBlock, dimBlock;
Rectangle Bounds;
Renderer r;
NullInputHandler nih = new NullInputHandler();
@@ -55,27 +57,39 @@ namespace OpenRA.Mods.Cnc
nodPos = new float2(Renderer.Resolution.Width/3 - 256, Renderer.Resolution.Height/2 - 128);
gdiPos = new float2(Renderer.Resolution.Width*2/3, Renderer.Resolution.Height/2 - 128);
evaPos = new float2(Renderer.Resolution.Width-43-128, 43);
brightBlock = new Sprite(s, new Rectangle(320,0,16,35), TextureChannel.Alpha);
dimBlock = new Sprite(s, new Rectangle(336,0,16,35), TextureChannel.Alpha);
}
public void Display()
{
if (r == null)
if (r == null || loadTimer.ElapsedTime() < 0.25)
return;
loadTimer.Reset();
// Update text at most every 0.5 seconds
if (lastLoadScreen.ElapsedTime() < 0.5)
return;
var font = r.Fonts["BigBold"];
var text = "Connecting to EVA...";
lastLoadScreen.Reset();
var textSize = font.Measure(text);
loadTick = ++loadTick % 8;
r.BeginFrame(float2.Zero);
r.RgbaSpriteRenderer.DrawSprite(gdiLogo, gdiPos);
r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);
DrawBorder();
font.DrawText(text, new float2((Renderer.Resolution.Width - textSize.X) / 2, (Renderer.Resolution.Height - textSize.Y) / 2), Color.White);
var barY = Renderer.Resolution.Height-78;
text = "Loading";
var textSize = r.Fonts["BigBold"].Measure(text);
textPos = new float2((Renderer.Resolution.Width - textSize.X) / 2, barY);
r.Fonts["BigBold"].DrawText(text, textPos, Color.DarkRed);
for (var i = 0; i <= 8; i++)
{
var block = loadTick == i ? brightBlock : dimBlock;
r.RgbaSpriteRenderer.DrawSprite(block,
new float2(Renderer.Resolution.Width/2 - 114 - i*32, barY));
r.RgbaSpriteRenderer.DrawSprite(block,
new float2(Renderer.Resolution.Width/2 + 114 + i*32-16, barY));
}
r.EndFrame( nih );
}

View File

@@ -54,9 +54,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="280.3593"
inkscape:cy="454.1963"
inkscape:zoom="4"
inkscape:cx="293.08008"
inkscape:cy="512.48057"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
@@ -101,51 +101,46 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-540.3622)">
<g
transform="translate(0,-255.99998)"
id="layer1-3"
inkscape:label="Layer 1">
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
y="988.86218"
x="0.5"
height="63"
width="63"
id="rect3776-3"
style="fill:#2b0000;fill-opacity:0.87843137;stroke:#800000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none" />
<rect
style="fill:#560000;fill-opacity:0.87843137;stroke:#c00000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3759"
width="63"
height="63"
x="0.5"
y="924.86218"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<rect
style="fill:#2b2b2b;fill-opacity:0.87843137;stroke:#800000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect2984-3"
width="63"
height="63"
x="64.5"
y="924.86218"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<rect
style="fill:#0f0000;fill-opacity:0.87843137;stroke:#c00000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3753"
width="63"
height="63"
x="64.5"
y="988.86218"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
<rect
style="fill:#2b0000;fill-opacity:0.87843137;stroke:#800000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none"
id="rect3776-3"
width="63"
height="63"
x="0.5"
y="732.86218"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
y="668.86218"
x="0.5"
height="63"
width="63"
id="rect3759"
style="fill:#560000;fill-opacity:0.87843137;stroke:#c00000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
y="668.86218"
x="64.5"
height="63"
width="63"
id="rect2984-3"
style="fill:#2b2b2b;fill-opacity:0.87843137;stroke:#800000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
y="732.86218"
x="64.5"
height="63"
width="63"
id="rect3753"
style="fill:#0f0000;fill-opacity:0.87843137;stroke:#c00000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
style="fill:#2b0000;fill-opacity:0.87843137;stroke:#800000;stroke-width:1;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none"
id="rect3776"
@@ -499,7 +494,7 @@
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccsccccccccccccccccccccccscsssscs" />
<g
transform="translate(128,-372.30568)"
transform="translate(128,-382.30568)"
id="layer1-36"
inkscape:label="Layer 1">
<path
@@ -658,5 +653,27 @@
sodipodi:start="0.00014815468"
sodipodi:end="6.2831853"
sodipodi:open="true" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
y="540.86218"
x="336.5"
height="34"
width="15"
id="rect3999"
style="fill:#0f0000;fill-opacity:0.87843138;stroke:#800000;stroke-width:0.99999987999999995;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none" />
<rect
style="fill:#560000;fill-opacity:0.87843137;stroke:#c00000;stroke-width:0.99999988;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect4001"
width="15"
height="34"
x="320.5"
y="540.86218"
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
inkscape:transform-center-x="1.4142136"
inkscape:transform-center-y="40.134013" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB