diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs
index 0a3cbe7ed2..cd6d0119ba 100644
--- a/OpenRA.Game/Graphics/Renderer.cs
+++ b/OpenRA.Game/Graphics/Renderer.cs
@@ -47,7 +47,7 @@ namespace OpenRA.Graphics
public ITexture PaletteTexture;
- public readonly SpriteFont RegularFont, BoldFont;
+ public readonly SpriteFont RegularFont, BoldFont, TitleFont;
public Size Resolution { get { return device.WindowSize; } }
@@ -64,11 +64,9 @@ namespace OpenRA.Graphics
RgbaSpriteRenderer = new SpriteRenderer( this, RgbaSpriteShader );
WorldSpriteRenderer = new SpriteRenderer( this, WorldSpriteShader );
-// RegularFont = device.CreateFont( "FreeSans.ttf" );
-// BoldFont = device.CreateFont( "FreeSansBold.ttf" );
-
RegularFont = new SpriteFont(this, "FreeSans.ttf", 14);
BoldFont = new SpriteFont(this, "FreeSansBold.ttf", 14);
+ TitleFont = new SpriteFont(this, "titles.ttf", 48);
}
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index fbe5be43b1..6e750f90b5 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -82,6 +82,7 @@
+
@@ -90,6 +91,7 @@
+
diff --git a/OpenRA.Game/Traits/Player/VictoryConditions.cs b/OpenRA.Game/Traits/Player/VictoryConditions.cs
new file mode 100644
index 0000000000..f38c6b4fee
--- /dev/null
+++ b/OpenRA.Game/Traits/Player/VictoryConditions.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OpenRA.Traits
+{
+ class VictoryConditionsInfo : ITraitInfo
+ {
+ public readonly string[] ShortGameUnits = { "mcv" };
+ public object Create(Actor self) { return new VictoryConditions( self ); }
+ }
+
+ interface IVictoryConditions { bool HasLost { get; } bool HasWon { get; } }
+
+ class VictoryConditions : ITick, IVictoryConditions
+ {
+ public bool HasLost { get; private set; }
+ public bool HasWon { get; private set; }
+
+ public VictoryConditions(Actor self)
+ {
+ }
+
+ public void Tick(Actor self)
+ {
+ var info = self.Info.Traits.Get();
+ var hasAnyBuildings = self.World.Queries.OwnedBy[self.Owner]
+ .WithTrait().Any();
+ var hasAnyShortGameUnits = self.World.Queries.OwnedBy[self.Owner]
+ .Any(a => info.ShortGameUnits.Contains(a.Info.Name));
+
+ var hasLost = !(hasAnyBuildings || hasAnyShortGameUnits);
+ if (hasLost && !HasLost)
+ Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
+
+ HasLost = hasLost;
+ }
+ }
+}
diff --git a/OpenRA.Game/Widgets/PostGameWidget.cs b/OpenRA.Game/Widgets/PostGameWidget.cs
new file mode 100644
index 0000000000..3e997df497
--- /dev/null
+++ b/OpenRA.Game/Widgets/PostGameWidget.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using OpenRA.Traits;
+using System.Drawing;
+
+namespace OpenRA.Widgets
+{
+ class PostGameWidget : Widget
+ {
+ string text;
+
+ public override void Draw(World world)
+ {
+ base.Draw(world);
+
+ if (world.LocalPlayer == null) text = null;
+
+ else if (world.players.Count > 2) /* more than just us + neutral */
+ {
+ var conds = world.Queries.WithTrait()
+ .Where(c => c.Actor.Owner != world.NeutralPlayer);
+
+ if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost))
+ text = "YOU ARE DEFEATED";
+ else if (conds.All(c => c.Actor.Owner == world.LocalPlayer || c.Trait.HasLost))
+ text = "YOU ARE VICTORIOUS";
+ else
+ text = null;
+ }
+ else
+ text = null;
+
+ if (text != null)
+ DrawText(text);
+ }
+
+ void DrawText(string s)
+ {
+ var size = Game.chrome.renderer.TitleFont.Measure(s);
+
+ WidgetUtils.DrawPanel("dialog4", new Rectangle(
+ (Game.viewport.Width - size.X - 40) / 2,
+ (Game.viewport.Height - size.Y - 10) / 2,
+ size.X + 40,
+ size.Y + 13), null);
+
+ Game.chrome.renderer.TitleFont.DrawText(s,
+ new float2((Game.viewport.Width - size.X) / 2,
+ (Game.viewport.Height - size.Y) / 2 - .2f * size.Y), Color.White);
+
+ Game.chrome.renderer.RgbaSpriteRenderer.Flush();
+ }
+ }
+}
diff --git a/mods/ra/menus.yaml b/mods/ra/menus.yaml
index 1dc039de55..268a8a2ced 100644
--- a/mods/ra/menus.yaml
+++ b/mods/ra/menus.yaml
@@ -1,6 +1,14 @@
Container:
ClickThrough:true
Children:
+ PostGame@POSTGAME_TEXT:
+ Id:POSTGAME_TEXT
+ X:0
+ Y:0
+ Width: WINDOW_RIGHT
+ Height: WINDOW_BOTTOM
+ ClickThrough: true
+ Visible: true
Background@MAINMENU_BG:
Id:MAINMENU_BG
X:(WINDOW_RIGHT - WIDTH)/2
diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml
index 65b0b5fec9..704c0ce04e 100644
--- a/mods/ra/system.yaml
+++ b/mods/ra/system.yaml
@@ -76,6 +76,8 @@ Player:
OneShot: yes
UnitType: badr.bomber
SelectTargetSound: slcttgt1.aud
+ VictoryConditions:
+ ShortGameUnits: mcv
World:
diff --git a/titles.ttf b/titles.ttf
new file mode 100644
index 0000000000..8b28063957
Binary files /dev/null and b/titles.ttf differ