Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,22 @@ public static float getFloat(MdxJsxElementFields el, String name, float defaultV

public static int getInt(PageCompiler compiler, LytErrorSink errorSink, MdxJsxElementFields el, String name,
int defaultValue) {
var attrValue = getString(compiler, errorSink, el, name, null);
if (attrValue == null) {
var attribute = el.getAttribute(name);
if (attribute == null) {
return defaultValue;
}
String attrValue;
if (attribute.hasExpressionValue()) {
attrValue = attribute.getExpressionValue();
} else if (attribute.hasStringValue()) {
attrValue = attribute.getStringValue();
} else {
return defaultValue;
}
try {
return Integer.parseInt(attrValue);
return Integer.parseInt(attrValue.trim());
} catch (NumberFormatException e) {
errorSink.appendError(compiler, "Malformed integer value: '" + attrValue + "'", el);
errorSink.appendError(compiler, "Malformed integer for '" + name + "': '" + attrValue + "'", el);
return defaultValue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxEl
MdxAttrs.getString(compiler, parent, el, "handlerWhitelist", null));
List<String> handlerBlacklist = parseNameList(
MdxAttrs.getString(compiler, parent, el, "handlerBlacklist", null));
String handlerOrderStr = MdxAttrs.getString(compiler, parent, el, "handlerOrder", null);
String handlerOrderStr = el.getAttributeString("handlerOrder", null);
int handlerOrder = -1;
if (handlerOrderStr != null && !handlerOrderStr.isEmpty()) {
try {
Expand All @@ -82,7 +82,7 @@ protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxEl
return;
}
}
String recipeIndexStr = MdxAttrs.getString(compiler, parent, el, "recipeIndex", null);
String recipeIndexStr = el.getAttributeString("recipeIndex", null);
int exactRecipeIndex = -1;
if (recipeIndexStr != null && !recipeIndexStr.isEmpty()) {
try {
Expand All @@ -100,7 +100,7 @@ protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxEl
FilterExpr inputExpr = parseFilterExpr(compiler, parent, el, "input", defaultNs);
FilterExpr outputExpr = parseFilterExpr(compiler, parent, el, "output", defaultNs);

String limitStr = MdxAttrs.getString(compiler, parent, el, "limit", null);
String limitStr = el.getAttributeString("limit", null);
int limit = multi ? Integer.MAX_VALUE : 1;
if (limitStr != null && !limitStr.isEmpty()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static CornerLegendPosition parseCornerLegendPosition(String s, CornerLeg
* Parse a boxed {@link Double}; null means "auto".
*/
public static Double parseBoxedDouble(MdxJsxElementFields el, String name) {
String s = MdxAttrs.getString(el, name, null);
String s = el.getAttributeString(name, null);
if (s == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public static void applyRange(LytFunctionGraph graph, PageCompiler compiler, Lyt
} else {
String domain = MdxAttrs.getString(compiler, sink, el, "domain", null);
double[] domainRange = domain != null ? parseRange(domain) : null;
double xMin = parseDouble(MdxAttrs.getString(compiler, sink, el, "xMin", null), Double.NaN);
double xMax = parseDouble(MdxAttrs.getString(compiler, sink, el, "xMax", null), Double.NaN);
double xMin = parseDouble(el.getAttributeString("xMin", null), Double.NaN);
double xMax = parseDouble(el.getAttributeString("xMax", null), Double.NaN);
if (domainRange != null && Double.isNaN(xMin) && Double.isNaN(xMax)) {
xMin = domainRange[0];
xMax = domainRange[1];
Expand All @@ -99,17 +99,17 @@ public static void applyRange(LytFunctionGraph graph, PageCompiler compiler, Lyt
double[] r = parseRange(yRange);
graph.setExplicitYRange(r[0], r[1]);
} else {
double yMin = parseDouble(MdxAttrs.getString(compiler, sink, el, "yMin", null), Double.NaN);
double yMax = parseDouble(MdxAttrs.getString(compiler, sink, el, "yMax", null), Double.NaN);
double yMin = parseDouble(el.getAttributeString("yMin", null), Double.NaN);
double yMax = parseDouble(el.getAttributeString("yMax", null), Double.NaN);
if (!Double.isNaN(yMin) || !Double.isNaN(yMax)) {
graph.setExplicitYRange(yMin, yMax);
}
}
double xStep = parseDouble(MdxAttrs.getString(compiler, sink, el, "xStep", null), Double.NaN);
double xStep = parseDouble(el.getAttributeString("xStep", null), Double.NaN);
if (!Double.isNaN(xStep)) {
graph.setExplicitXStep(xStep);
}
double yStep = parseDouble(MdxAttrs.getString(compiler, sink, el, "yStep", null), Double.NaN);
double yStep = parseDouble(el.getAttributeString("yStep", null), Double.NaN);
if (!Double.isNaN(yStep)) {
graph.setExplicitYStep(yStep);
}
Expand All @@ -136,8 +136,8 @@ public static FunctionPlot parsePlot(PageCompiler compiler, LytErrorSink sink, M
boolean showFunction = MdxAttrs.getBoolean(compiler, sink, el, "showFunction", true);
boolean showValues = MdxAttrs.getBoolean(compiler, sink, el, "showValues", true);
AutoPointSpec autoPointSpec = parseAutoPointSpec(
MdxAttrs.getString(compiler, sink, el, "pointEveryX", null),
MdxAttrs.getString(compiler, sink, el, "pointEveryY", null),
el.getAttributeString("pointEveryX", null),
el.getAttributeString("pointEveryY", null),
MdxAttrs.getString(compiler, sink, el, "autoPointLabel", null),
MdxAttrs.getString(compiler, sink, el, "autoPointColor", null),
color);
Expand All @@ -162,16 +162,16 @@ public static MarkedPoint parsePoint(PageCompiler compiler, LytErrorSink sink, M
: ColorUtils.WHITE.getColor();
String label = MdxAttrs.getString(compiler, sink, el, "label", null);

double xValue = parseDouble(MdxAttrs.getString(compiler, sink, el, "x", null), Double.NaN);
double yValue = parseDouble(MdxAttrs.getString(compiler, sink, el, "y", null), Double.NaN);
double xValue = parseDouble(el.getAttributeString("x", null), Double.NaN);
double yValue = parseDouble(el.getAttributeString("y", null), Double.NaN);
if (!Double.isNaN(xValue) && !Double.isNaN(yValue)) {
return new MarkedPoint(MarkedPoint.MODE_EXPLICIT, -1, xValue, yValue, color, false, label);
}

int plotIndex = MdxAttrs.getInt(compiler, sink, el, "plot", -1);
if (plotIndex >= 0) {
double atX = parseDouble(MdxAttrs.getString(compiler, sink, el, "atX", null), Double.NaN);
double atY = parseDouble(MdxAttrs.getString(compiler, sink, el, "atY", null), Double.NaN);
double atX = parseDouble(el.getAttributeString("atX", null), Double.NaN);
double atY = parseDouble(el.getAttributeString("atY", null), Double.NaN);
if (!Double.isNaN(atX)) {
return new MarkedPoint(MarkedPoint.MODE_PLOT_AT_X, plotIndex, atX, 0d, color, colorInherit, label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ public void onExtensionsBuilt(ExtensionCollection extensions) {
@Override
protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxElementFields el) {
// Width and height
String rawWidth = MdxAttrs.getString(compiler, parent, el, "width", null);
String rawHeight = MdxAttrs.getString(compiler, parent, el, "height", null);
boolean explicitWidth = rawWidth != null;
boolean explicitHeight = rawHeight != null;
boolean explicitWidth = el.getAttribute("width") != null;
boolean explicitHeight = el.getAttribute("height") != null;
int w = MdxAttrs.getInt(compiler, parent, el, "width", DEFAULT_WIDTH);
int h = MdxAttrs.getInt(compiler, parent, el, "height", DEFAULT_HEIGHT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private StructureLibSceneConditionParser() {}
public static StructureLibSceneCondition parse(PageCompiler compiler, LytErrorSink errorSink,
MdxJsxElementFields element) {
String structureName = MdxAttrs.getString(compiler, errorSink, element, "showWhenStructure", null);
String tierExpression = MdxAttrs.getString(compiler, errorSink, element, "showWhenTier", null);
String tierExpression = element.getAttributeString("showWhenTier", null);
String channelExpression = MdxAttrs.getString(compiler, errorSink, element, "showWhenChannels", null);
try {
return StructureLibSceneCondition.parse(structureName, tierExpression, channelExpression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,11 @@ public void compile(GuidebookLevel level, CameraSettings camera, PageCompiler co
}
}

int offsetX = MdxAttrs.getString(compiler, errorSink, el, "offsetX", null) != null
? MdxAttrs.getInt(compiler, errorSink, el, "offsetX", 0)
int offsetX = el.getAttribute("offsetX") != null ? MdxAttrs.getInt(compiler, errorSink, el, "offsetX", 0)
: MdxAttrs.getInt(compiler, errorSink, el, "x", 0);
int offsetY = MdxAttrs.getString(compiler, errorSink, el, "offsetY", null) != null
? MdxAttrs.getInt(compiler, errorSink, el, "offsetY", 0)
int offsetY = el.getAttribute("offsetY") != null ? MdxAttrs.getInt(compiler, errorSink, el, "offsetY", 0)
: MdxAttrs.getInt(compiler, errorSink, el, "y", 0);
int offsetZ = MdxAttrs.getString(compiler, errorSink, el, "offsetZ", null) != null
? MdxAttrs.getInt(compiler, errorSink, el, "offsetZ", 0)
int offsetZ = el.getAttribute("offsetZ") != null ? MdxAttrs.getInt(compiler, errorSink, el, "offsetZ", 0)
: MdxAttrs.getInt(compiler, errorSink, el, "z", 0);
boolean formed = SceneStructureOptions.isFormed(compiler, errorSink, el);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public void compile(GuidebookLevel level, CameraSettings camera, PageCompiler co
weatherName = MdxAttrs.getString(compiler, errorSink, el, "type", "rain");
}
GuidebookSceneWeatherType weatherType = GuidebookSceneWeatherType.fromSerializedName(weatherName);
int[] xValues = GuidebookSceneWeatherSupport
.parseAxisValues(MdxAttrs.getString(compiler, errorSink, el, "x", null));
int[] zValues = GuidebookSceneWeatherSupport
.parseAxisValues(MdxAttrs.getString(compiler, errorSink, el, "z", null));
int[] xValues = GuidebookSceneWeatherSupport.parseAxisValues(el.getAttributeString("x", null));
int[] zValues = GuidebookSceneWeatherSupport.parseAxisValues(el.getAttributeString("z", null));
int density = Math.max(
1,
MdxAttrs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxEl
parent.appendError(compiler, "QuestCard id is not a valid BetterQuesting quest id: " + idAttr, el);
return;
}
boolean showDesc = !"false".equalsIgnoreCase(MdxAttrs.getString(compiler, parent, el, "show_desc", "true"));
boolean showDesc = MdxAttrs.getBoolean(compiler, parent, el, "show_desc", true);
boolean showTooltip = QuestTagSupport.resolveShowTooltip(compiler, parent, el);

QuestCardPlaceholder ph = new QuestCardPlaceholder(questId, showDesc, showTooltip);
Expand Down