Added visibility option for texts for usercontents
This commit is contained in:
@@ -344,7 +344,11 @@
|
|||||||
"text": "Text",
|
"text": "Text",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": -11,
|
"y": -11,
|
||||||
"color": 2039583
|
"color": 2039583,
|
||||||
|
"visible": {
|
||||||
|
"type": "js",
|
||||||
|
"function": "isVisible"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ public class ContentUsercontent extends Content
|
|||||||
{
|
{
|
||||||
for(JsonText text : this.content.getGui().getTexts())
|
for(JsonText text : this.content.getGui().getTexts())
|
||||||
{
|
{
|
||||||
container.getMinecraft().fontRenderer.drawString(TextFormatting.formatNullable(text.getText()), text.getX() + x, text.getY() + y, text.getColor());
|
if(text.getVisible() == null || text.getVisible().eval(this.engineAdapter))
|
||||||
|
{
|
||||||
|
container.getMinecraft().fontRenderer.drawString(TextFormatting.formatNullable(text.getText()), text.getX() + x, text.getY() + y, text.getColor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,16 @@ public class JsonText
|
|||||||
@SerializedName("color")
|
@SerializedName("color")
|
||||||
private int color;
|
private int color;
|
||||||
|
|
||||||
public JsonText(String text, int x, int y, int color)
|
@SerializedName("visible")
|
||||||
|
private BooleanExpression visible;
|
||||||
|
|
||||||
|
public JsonText(String text, int x, int y, int color, BooleanExpression visible)
|
||||||
{
|
{
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText()
|
public String getText()
|
||||||
@@ -67,4 +71,14 @@ public class JsonText
|
|||||||
{
|
{
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BooleanExpression getVisible()
|
||||||
|
{
|
||||||
|
return this.visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisible(BooleanExpression visible)
|
||||||
|
{
|
||||||
|
this.visible = visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user