From 624e69e97becfefcbb6c3317ba0e08fbcd249210 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Wed, 31 Aug 2016 20:55:22 +0200 Subject: [PATCH] Replace use of Contrast with Shadow for ingame chat and support power timers --- .../Widgets/ChatDisplayWidget.cs | 21 +++++++++++++++---- .../Widgets/SupportPowerTimerWidget.cs | 2 +- mods/cnc/chrome/ingame-chat.yaml | 2 +- mods/ra/chrome/ingame-chat.yaml | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/ChatDisplayWidget.cs b/OpenRA.Mods.Common/Widgets/ChatDisplayWidget.cs index 30955d12f5..24b7064ea5 100644 --- a/OpenRA.Mods.Common/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ChatDisplayWidget.cs @@ -21,6 +21,7 @@ namespace OpenRA.Mods.Common.Widgets { public readonly int RemoveTime = 0; public readonly bool UseContrast = false; + public readonly bool UseShadow = false; public readonly Color BackgroundColorDark = ChromeMetrics.Get("TextContrastColorDark"); public readonly Color BackgroundColorLight = ChromeMetrics.Get("TextContrastColorLight"); public string Notification = ""; @@ -58,12 +59,24 @@ namespace OpenRA.Mods.Common.Widgets if (owner != null) { - font.DrawTextWithContrast(owner, chatpos, - line.Color, BackgroundColorDark, BackgroundColorLight, UseContrast ? 1 : 0); + if (UseContrast) + font.DrawTextWithContrast(owner, chatpos, + line.Color, BackgroundColorDark, BackgroundColorLight, 1); + else if (UseShadow) + font.DrawTextWithShadow(owner, chatpos, + line.Color, BackgroundColorDark, BackgroundColorLight, 1); + else + font.DrawText(owner, chatpos, line.Color); } - font.DrawTextWithContrast(text, chatpos + new int2(inset, 0), - Color.White, Color.Black, UseContrast ? 1 : 0); + if (UseContrast) + font.DrawTextWithContrast(text, chatpos + new int2(inset, 0), + Color.White, Color.Black, 1); + else if (UseShadow) + font.DrawTextWithShadow(text, chatpos + new int2(inset, 0), + Color.White, Color.Black, 1); + else + font.DrawText(text, chatpos + new int2(inset, 0), Color.White); } Game.Renderer.DisableScissor(); diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index c67e48e3d0..4eb12093be 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Widgets foreach (var t in texts) { var font = Game.Renderer.Fonts[Font]; - font.DrawTextWithContrast(t.First, new float2(Bounds.Location) + new float2(0, y), t.Second, bgDark, bgLight, 1); + font.DrawTextWithShadow(t.First, new float2(Bounds.Location) + new float2(0, y), t.Second, bgDark, bgLight, 1); y += (font.Measure(t.First).Y + 5) * (int)Order; } } diff --git a/mods/cnc/chrome/ingame-chat.yaml b/mods/cnc/chrome/ingame-chat.yaml index 5d1abe8ebe..c06fe890cf 100644 --- a/mods/cnc/chrome/ingame-chat.yaml +++ b/mods/cnc/chrome/ingame-chat.yaml @@ -14,7 +14,7 @@ Container@CHAT_PANEL: Width: PARENT_RIGHT Height: PARENT_BOTTOM RemoveTime: 250 - UseContrast: yes + UseShadow: True Container@CHAT_CHROME: Width: PARENT_RIGHT Height: PARENT_BOTTOM diff --git a/mods/ra/chrome/ingame-chat.yaml b/mods/ra/chrome/ingame-chat.yaml index 3f264faaf4..530ff7f4e2 100644 --- a/mods/ra/chrome/ingame-chat.yaml +++ b/mods/ra/chrome/ingame-chat.yaml @@ -14,7 +14,7 @@ Container@CHAT_PANEL: Width: PARENT_RIGHT Height: PARENT_BOTTOM RemoveTime: 250 - UseContrast: yes + UseShadow: True Container@CHAT_CHROME: Width: PARENT_RIGHT Height: PARENT_BOTTOM