Fix Analyzer warning V3008 variable is assigned values twice.

This commit is contained in:
Matthias Mailänder
2020-09-13 10:00:41 +02:00
committed by Paul Chote
parent 3e83346915
commit f13e6fb76d

View File

@@ -33,7 +33,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Width specified in YAML is used as the margin between flag / label and label / border // Width specified in YAML is used as the margin between flag / label and label / border
var labelMargin = widget.Bounds.Width; var labelMargin = widget.Bounds.Width;
var cachedWidth = 0;
var labelText = ""; var labelText = "";
string playerFaction = null; string playerFaction = null;
var playerTeam = -1; var playerTeam = -1;
@@ -67,13 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
} }
label.Bounds.X = playerFaction != null ? flag.Bounds.Right + labelMargin : labelMargin; label.Bounds.X = playerFaction != null ? flag.Bounds.Right + labelMargin : labelMargin;
label.Bounds.Width = ownerFont.Measure(labelText).X;
var textWidth = ownerFont.Measure(labelText).X;
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2 * label.Bounds.X + textWidth;
}
widget.Bounds.Width = Math.Max(teamWidth + 2 * labelMargin, label.Bounds.Right + labelMargin); widget.Bounds.Width = Math.Max(teamWidth + 2 * labelMargin, label.Bounds.Right + labelMargin);
team.Bounds.Width = widget.Bounds.Width; team.Bounds.Width = widget.Bounds.Width;