Skip to content

Commit

Permalink
Merge pull request #13247 from pchote/widget-evaluator-expressions
Browse files Browse the repository at this point in the history
Replaced legacy Evaluator with IntegerExpressions.
  • Loading branch information
atlimit8 committed May 9, 2017
2 parents 4a80c37 + cd08982 commit 55de4a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 120 deletions.
1 change: 0 additions & 1 deletion OpenRA.Game/OpenRA.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
<Compile Include="Primitives\TypeDictionary.cs" />
<Compile Include="Map\ActorInitializer.cs" />
<Compile Include="Map\ActorReference.cs" />
<Compile Include="Support\Evaluator.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Graphics\PlayerColorRemap.cs" />
<Compile Include="Graphics\Palette.cs" />
Expand Down
109 changes: 0 additions & 109 deletions OpenRA.Game/Support/Evaluator.cs

This file was deleted.

21 changes: 11 additions & 10 deletions OpenRA.Game/Widgets/Widget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ public abstract class Widget

// Info defined in YAML
public string Id = null;
public string X = "0";
public string Y = "0";
public string Width = "0";
public string Height = "0";
public IntegerExpression X;
public IntegerExpression Y;
public IntegerExpression Width;
public IntegerExpression Height;
public string[] Logic = { };
public ChromeLogic[] LogicObjects { get; private set; }
public bool Visible = true;
Expand Down Expand Up @@ -275,16 +275,17 @@ public virtual void Initialize(WidgetArgs args)
substitutions.Add("PARENT_LEFT", parentBounds.Left);
substitutions.Add("PARENT_TOP", parentBounds.Top);
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
var width = Evaluator.Evaluate(Width, substitutions);
var height = Evaluator.Evaluate(Height, substitutions);

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

substitutions.Add("WIDTH", width);
substitutions.Add("HEIGHT", height);

Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions),
Evaluator.Evaluate(Y, substitutions),
width,
height);
var x = X != null ? X.Evaluate(readOnlySubstitutions) : 0;
var y = Y != null ? Y.Evaluate(readOnlySubstitutions) : 0;
Bounds = new Rectangle(x, y, width, height);
}

public void PostInit(WidgetArgs args)
Expand Down

0 comments on commit 55de4a5

Please sign in to comment.