Revert "Revert "Replace legacy Evaluator with IntegerExpressions.""
This reverts commit 4f16b0d464.
This commit is contained in:
committed by
Gustas
parent
b18c2fe855
commit
94abd8a928
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Network;
|
||||
@@ -189,10 +190,10 @@ namespace OpenRA.Widgets
|
||||
|
||||
// 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 = Array.Empty<string>();
|
||||
public ChromeLogic[] LogicObjects { get; private set; }
|
||||
public bool Visible = true;
|
||||
@@ -272,16 +273,17 @@ namespace OpenRA.Widgets
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user