Skip to content

Commit

Permalink
Evaluate read only dictionaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender authored and PunkPun committed Aug 6, 2023
1 parent e49135b commit db3145e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
Expand Down Expand Up @@ -510,8 +511,9 @@ static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
{ "PARENT_BOTTOM", parentBounds.Height }
};

var width = w.Width.Evaluate(substitutions);
var height = w.Height.Evaluate(substitutions);
var readOnlySubstitutions = new ReadOnlyDictionary<string, int>(substitutions);
var width = w.Width != null ? w.Width.Evaluate(readOnlySubstitutions) : 0;
var height = w.Height != null ? w.Height.Evaluate(readOnlySubstitutions) : 0;

substitutions.Add("WIDTH", width);
substitutions.Add("HEIGHT", height);
Expand All @@ -520,8 +522,8 @@ static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
w.Bounds = new Rectangle(w.Bounds.X, w.Bounds.Y, width, w.Bounds.Height);
else
w.Bounds = new Rectangle(
w.X.Evaluate(substitutions),
w.Y.Evaluate(substitutions),
w.X != null ? w.X.Evaluate(readOnlySubstitutions) : 0,
w.Y != null ? w.Y.Evaluate(readOnlySubstitutions) : 0,
width,
height);

Expand Down

0 comments on commit db3145e

Please sign in to comment.