From f1325e12d4995413adf45d0a206905d77f5aa967 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 12 Jan 2020 15:36:36 +0000 Subject: [PATCH] Extract text contrast radius to ChromeMetrics and reduce to 1px. --- OpenRA.Mods.Common/Widgets/ButtonWidget.cs | 4 +++- OpenRA.Mods.Common/Widgets/LabelWidget.cs | 4 +++- mods/common/metrics.yaml | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs index 23e8faeee5..633619d619 100644 --- a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs @@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets public bool Shadow = ChromeMetrics.Get("ButtonTextShadow"); public Color ContrastColorDark = ChromeMetrics.Get("ButtonTextContrastColorDark"); public Color ContrastColorLight = ChromeMetrics.Get("ButtonTextContrastColorLight"); + public int ContrastRadius = ChromeMetrics.Get("ButtonTextContrastRadius"); public string ClickSound = ChromeMetrics.Get("ClickSound"); public string ClickDisabledSound = ChromeMetrics.Get("ClickDisabledSound"); public bool Disabled = false; @@ -114,6 +115,7 @@ namespace OpenRA.Mods.Common.Widgets GetColorDisabled = other.GetColorDisabled; ContrastColorDark = other.ContrastColorDark; ContrastColorLight = other.ContrastColorLight; + ContrastRadius = other.ContrastRadius; GetContrastColorDark = other.GetContrastColorDark; GetContrastColorLight = other.GetContrastColorLight; OnMouseDown = other.OnMouseDown; @@ -251,7 +253,7 @@ namespace OpenRA.Mods.Common.Widgets DrawBackground(rb, disabled, Depressed, hover, highlighted); if (Contrast) font.DrawTextWithContrast(text, position + stateOffset, - disabled ? colordisabled : color, bgDark, bgLight, 2); + disabled ? colordisabled : color, bgDark, bgLight, ContrastRadius); else if (Shadow) font.DrawTextWithShadow(text, position, color, bgDark, bgLight, 1); else diff --git a/OpenRA.Mods.Common/Widgets/LabelWidget.cs b/OpenRA.Mods.Common/Widgets/LabelWidget.cs index 831af4f940..ef90f420e2 100644 --- a/OpenRA.Mods.Common/Widgets/LabelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LabelWidget.cs @@ -31,6 +31,7 @@ namespace OpenRA.Mods.Common.Widgets public bool Shadow = ChromeMetrics.Get("TextShadow"); public Color ContrastColorDark = ChromeMetrics.Get("TextContrastColorDark"); public Color ContrastColorLight = ChromeMetrics.Get("TextContrastColorLight"); + public int ContrastRadius = ChromeMetrics.Get("TextContrastRadius"); public bool WordWrap = false; public Func GetText; public Func GetColor; @@ -56,6 +57,7 @@ namespace OpenRA.Mods.Common.Widgets Contrast = other.Contrast; ContrastColorDark = other.ContrastColorDark; ContrastColorLight = other.ContrastColorLight; + ContrastRadius = other.ContrastRadius; Shadow = other.Shadow; WordWrap = other.WordWrap; GetText = other.GetText; @@ -100,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets var bgDark = GetContrastColorDark(); var bgLight = GetContrastColorLight(); if (Contrast) - font.DrawTextWithContrast(text, position, color, bgDark, bgLight, 2); + font.DrawTextWithContrast(text, position, color, bgDark, bgLight, ContrastRadius); else if (Shadow) font.DrawTextWithShadow(text, position, color, bgDark, bgLight, 1); else diff --git a/mods/common/metrics.yaml b/mods/common/metrics.yaml index 78ced5348b..a8473104fa 100644 --- a/mods/common/metrics.yaml +++ b/mods/common/metrics.yaml @@ -6,6 +6,7 @@ Metrics: ButtonTextContrast: false ButtonTextContrastColorDark: 000000 ButtonTextContrastColorLight: 7F7F7F + ButtonTextContrastRadius: 1 ButtonTextShadow: false CheckboxPressedState: false GameStartedColor: FFA500 @@ -31,6 +32,7 @@ Metrics: TextContrast: false TextContrastColorDark: 000000 TextContrastColorLight: 7F7F7F + TextContrastRadius: 1 TextFont: Regular TextShadow: false TextfieldColor: FFFFFF