diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index 5fb8a8e7c5..5846e46fd2 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -69,6 +69,19 @@ namespace OpenRA.Graphics } } + public void DrawTextWithContrast(string text, float2 location, Color fg, Color bg, int offset) + { + if (offset > 0) + { + DrawText(text, location + new float2(-offset, 0), bg); + DrawText(text, location + new float2(offset, 0), bg); + DrawText(text, location + new float2(0, -offset), bg); + DrawText(text, location + new float2(0, offset), bg); + } + + DrawText(text, location, fg); + } + public int2 Measure(string text) { return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size); diff --git a/OpenRA.Game/Widgets/ChatDisplayWidget.cs b/OpenRA.Game/Widgets/ChatDisplayWidget.cs index edf9fe0c0d..5e982a851e 100644 --- a/OpenRA.Game/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Game/Widgets/ChatDisplayWidget.cs @@ -18,6 +18,7 @@ namespace OpenRA.Widgets public class ChatDisplayWidget : Widget { public readonly int RemoveTime = 0; + public readonly bool UseContrast = false; const int logLength = 9; public string Notification = ""; @@ -52,10 +53,13 @@ namespace OpenRA.Widgets { var owner = line.Owner + ":"; inset = Game.Renderer.RegularFont.Measure(owner).X + 10; - Game.Renderer.RegularFont.DrawText(owner, chatpos, line.Color); + + Game.Renderer.RegularFont.DrawTextWithContrast(owner, chatpos, + line.Color, Color.Black, UseContrast ? 1 : 0); } - Game.Renderer.RegularFont.DrawText(line.Text, chatpos + new int2(inset, 0), Color.White); + Game.Renderer.RegularFont.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0), + Color.White, Color.Black, UseContrast ? 1 : 0); } Game.Renderer.DisableScissor(); diff --git a/OpenRA.Game/Widgets/ChatEntryWidget.cs b/OpenRA.Game/Widgets/ChatEntryWidget.cs index 3a347b11e7..8371c433db 100755 --- a/OpenRA.Game/Widgets/ChatEntryWidget.cs +++ b/OpenRA.Game/Widgets/ChatEntryWidget.cs @@ -25,6 +25,7 @@ namespace OpenRA.Widgets string content = ""; bool composing = false; bool teamChat = false; + public readonly bool UseContrast = false; readonly OrderManager orderManager; [ObjectCreator.UseCtor] @@ -40,8 +41,8 @@ namespace OpenRA.Widgets var text = teamChat ? "Chat (Team): " : "Chat (All): "; var w = Game.Renderer.BoldFont.Measure(text).X; - Game.Renderer.BoldFont.DrawText(text, RenderOrigin + new float2(3, 7), Color.White); - Game.Renderer.RegularFont.DrawText(content, RenderOrigin + new float2(3 + w, 7), Color.White); + Game.Renderer.BoldFont.DrawTextWithContrast(text, RenderOrigin + new float2(3, 7), Color.White, Color.Black, UseContrast ? 1 : 0); + Game.Renderer.RegularFont.DrawTextWithContrast(content, RenderOrigin + new float2(3 + w, 7), Color.White, Color.Black, UseContrast ? 1 : 0); } } diff --git a/OpenRA.Game/Widgets/TimerWidget.cs b/OpenRA.Game/Widgets/TimerWidget.cs index a56c8c090a..5204b0663f 100644 --- a/OpenRA.Game/Widgets/TimerWidget.cs +++ b/OpenRA.Game/Widgets/TimerWidget.cs @@ -26,8 +26,10 @@ namespace OpenRA.Widgets public override void DrawInner( WorldRenderer wr ) { var s = WidgetUtils.FormatTime(Game.LocalTick); - var size = Game.Renderer.TitleFont.Measure(s); - Game.Renderer.TitleFont.DrawText(s, new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20), Color.White); + var size = Game.Renderer.TitleFont.Measure(s); + var pos = new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20); + + Game.Renderer.TitleFont.DrawTextWithContrast(s, pos, Color.White, Color.Black, 1); } } } diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 02d25356c0..8b8cb36968 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -206,12 +206,14 @@ Container@INGAME_ROOT: Height: 200 DrawBackground: False RemoveTime:250 + UseContrast: yes ChatEntry@CHAT_ENTRY: Id:CHAT_ENTRY X:250 Y:WINDOW_BOTTOM - HEIGHT Width: 760 Height: 30 + UseContrast: yes Background@DEVELOPERMODE_BG: Id:DEVELOPERMODE_BG Delegate:DeveloperModeDelegate diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 1e00e6349b..177b72bdb2 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -213,12 +213,14 @@ Container@INGAME_ROOT: Height: 200 DrawBackground: False RemoveTime:250 + UseContrast: yes ChatEntry@CHAT_ENTRY: Id:CHAT_ENTRY X:250 Y:WINDOW_BOTTOM - HEIGHT Width: 760 Height: 30 + UseContrast: yes Background@DEVELOPERMODE_BG: Id:DEVELOPERMODE_BG Delegate:DeveloperModeDelegate