mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-10 12:49:37 +07:00
Merge branch 'markers-update' of https://github.com/ApsZoldat/Mindustry into ApsZoldat-markers-update
This commit is contained in:
commit
84add050a9
@ -2326,7 +2326,7 @@ lst.setprop = Sets a property of a unit or building.
|
||||
lst.effect = Create a particle effect.
|
||||
lst.sync = Sync a variable across the network.\nLimited to 20 times a second per variable.
|
||||
lst.makemarker = Create a new logic marker in the world.\nAn ID to identify this marker must be provided.\nMarkers currently limited to 20,000 per world.
|
||||
lst.setmarker = Set a property for a marker.\nThe ID used must be the same as in the Make Marker instruction.
|
||||
lst.setmarker = Set a property for a marker.\nThe ID used must be the same as in the Make Marker instruction.\n[accent]null []values are being ignored instead of converting to 0.
|
||||
lst.localeprint = Add map locale property value to the text buffer.\nTo set map locale bundles in map editor, check [accent]Map Info > Locale Bundles[].\nIf client is a mobile device, tries to print a property ending in ".mobile" first.
|
||||
|
||||
logic.nounitbuild = [red]Unit building logic is not allowed here.
|
||||
@ -2480,3 +2480,8 @@ lenum.build = Build a structure.
|
||||
lenum.getblock = Fetch a building, floor and type at coordinates.\nUnit must be in range of position.\nSolid non-buildings will have the type [accent]@solid[].
|
||||
lenum.within = Check if unit is near a position.
|
||||
lenum.boost = Start/stop boosting.
|
||||
|
||||
lenum.flushtext = Flush print buffer's content to marker, if applicable.\nIf fetch is set to true, tries to fetch properties from map locale bundle or game's bundle.
|
||||
lenum.texture = Texture name straight from game's texture atlas (using kebab-case naming style).\nIf printFlush is set to true, consumes text buffer content as text argument.
|
||||
lenum.texturesize = Size of texture in tiles. Zero value scales marker width to original texture's size.
|
||||
lenum.autoscale = Whether to scale marker corresponding to player's zoom level.
|
||||
|
@ -372,6 +372,21 @@ public class Renderer implements ApplicationListener{
|
||||
});
|
||||
}
|
||||
|
||||
//draw objective markers
|
||||
state.rules.objectives.eachRunning(obj -> {
|
||||
for(var marker : obj.markers){
|
||||
if(!marker.minimap) marker.drawWorld();
|
||||
}
|
||||
});
|
||||
|
||||
for(var marker : state.markers.values()){
|
||||
if(marker != null){
|
||||
if(!marker.isHidden() && !marker.minimap) marker.drawWorld();
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
Draw.draw(Layer.overlayUI, overlays::drawTop);
|
||||
if(state.rules.fog) Draw.draw(Layer.fogOfWar, fog::drawFog);
|
||||
Draw.draw(Layer.space, this::drawLanding);
|
||||
|
@ -5,6 +5,8 @@ import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.Button.*;
|
||||
import arc.scene.ui.TextButton.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.scene.utils.*;
|
||||
import arc.struct.*;
|
||||
@ -23,6 +25,15 @@ import static mindustry.Vars.*;
|
||||
public class MapLocalesDialog extends BaseDialog{
|
||||
/** Width of UI property card. */
|
||||
private static final float cardWidth = 400f;
|
||||
/** Style for filter options buttons */
|
||||
private static final TextButtonStyle filterStyle = new TextButtonStyle(){{
|
||||
up = down = checked = over = Tex.whitePane;
|
||||
font = Fonts.outline;
|
||||
fontColor = Color.lightGray;
|
||||
overFontColor = Pal.accent;
|
||||
disabledFontColor = Color.gray;
|
||||
disabled = Styles.black;
|
||||
}};
|
||||
/** Icons for use in map locales dialog. */
|
||||
private static final ContentType[] contentIcons = {ContentType.item, ContentType.block, ContentType.liquid, ContentType.status, ContentType.unit};
|
||||
|
||||
@ -168,7 +179,7 @@ public class MapLocalesDialog extends BaseDialog{
|
||||
String name = loc.toString();
|
||||
|
||||
if(locales.containsKey(name)){
|
||||
p.button(loc.getDisplayName(), Styles.flatTogglet, () -> {
|
||||
p.button(loc.getDisplayName(Core.bundle.getLocale()), Styles.flatTogglet, () -> {
|
||||
if(name.equals(selectedLocale)) return;
|
||||
|
||||
selectedLocale = name;
|
||||
@ -195,8 +206,8 @@ public class MapLocalesDialog extends BaseDialog{
|
||||
|
||||
main.image().color(Pal.gray).height(3f).growX().expandY().top().row();
|
||||
main.pane(p -> {
|
||||
int cols = (Core.graphics.getWidth() - 380) / ((int)cardWidth + 10);
|
||||
if(props.size == 0 || cols == 0){
|
||||
int cols = Math.max(1, (Core.graphics.getWidth() - 630) / ((int)cardWidth + 10));
|
||||
if(props.size == 0){
|
||||
main.add("@empty").center().row();
|
||||
return;
|
||||
}
|
||||
@ -343,7 +354,7 @@ public class MapLocalesDialog extends BaseDialog{
|
||||
String name = loc.toString();
|
||||
|
||||
if(!locales.containsKey(name)){
|
||||
t.button(loc.getDisplayName(), Styles.flatTogglet, () -> {
|
||||
t.button(loc.getDisplayName(Core.bundle.getLocale()), Styles.flatTogglet, () -> {
|
||||
if(name.equals(selectedLocale)) return;
|
||||
|
||||
locales.put(name, new StringMap());
|
||||
@ -524,12 +535,12 @@ public class MapLocalesDialog extends BaseDialog{
|
||||
if(status == PropertyStatus.same && !showSame) continue;
|
||||
|
||||
if(status != PropertyStatus.missing){
|
||||
var comparsionString = (searchByValue ? locales.get(name).get(key).toLowerCase() : loc.getDisplayName().toLowerCase());
|
||||
var comparsionString = (searchByValue ? locales.get(name).get(key).toLowerCase() : loc.getDisplayName(Core.bundle.getLocale()).toLowerCase());
|
||||
if(!searchString.isEmpty() && !comparsionString.contains(searchString.toLowerCase())) continue;
|
||||
}
|
||||
|
||||
colTables[i].table(Tex.whitePane, t -> {
|
||||
t.add(loc.getDisplayName()).left().color(Pal.accent).row();
|
||||
t.add(loc.getDisplayName(Core.bundle.getLocale())).left().color(Pal.accent).row();
|
||||
t.image().color(Pal.accent).fillX().row();
|
||||
|
||||
if(status == PropertyStatus.missing){
|
||||
@ -576,26 +587,24 @@ public class MapLocalesDialog extends BaseDialog{
|
||||
}).padTop(5f);
|
||||
}).row();
|
||||
|
||||
dialog.cont.table(Tex.whitePane, t ->
|
||||
t.button("@locales.showcorrect", Icon.ok, Styles.nonet, () -> showCorrect = !showCorrect).update(b -> {
|
||||
dialog.cont.button("@locales.showcorrect", Icon.ok, filterStyle, () -> showCorrect = !showCorrect).update(b -> {
|
||||
((Image)b.getChildren().get(1)).setDrawable(showCorrect ? Icon.ok : Icon.cancel);
|
||||
b.setChecked(showCorrect);
|
||||
}).grow().pad(15f)).size(450f, 100f).color(Pal.gray).padTop(50f);
|
||||
}).size(450f, 100f).color(Pal.gray).padTop(65f);
|
||||
|
||||
dialog.cont.row();
|
||||
|
||||
dialog.cont.table(Tex.whitePane, t ->
|
||||
t.button("@locales.showmissing", Icon.ok, Styles.nonet, () -> showMissing = !showMissing).update(b -> {
|
||||
((Image)b.getChildren().get(1)).setDrawable(showMissing ? Icon.ok : Icon.cancel);
|
||||
b.setChecked(showMissing);
|
||||
}).grow().pad(15f)).size(450f, 100f).color(Pal.accent).padTop(50f);
|
||||
dialog.cont.button("@locales.showmissing", Icon.ok, filterStyle, () -> showMissing = !showMissing).update(b -> {
|
||||
((Image)b.getChildren().get(1)).setDrawable(showMissing ? Icon.ok : Icon.cancel);
|
||||
b.setChecked(showMissing);
|
||||
}).size(450f, 100f).color(Pal.accent).padTop(65f);
|
||||
|
||||
dialog.cont.row();
|
||||
dialog.cont.table(Tex.whitePane, t ->
|
||||
t.button("@locales.showsame", Icon.ok, Styles.nonet, () -> showSame = !showSame).update(b -> {
|
||||
((Image)b.getChildren().get(1)).setDrawable(showSame ? Icon.ok : Icon.cancel);
|
||||
b.setChecked(showSame);
|
||||
}).grow().pad(15f)).size(450f, 100f).color(Pal.techBlue).padTop(50f);
|
||||
|
||||
dialog.cont.button("@locales.showsame", Icon.ok, filterStyle, () -> showSame = !showSame).update(b -> {
|
||||
((Image)b.getChildren().get(1)).setDrawable(showSame ? Icon.ok : Icon.cancel);
|
||||
b.setChecked(showSame);
|
||||
}).size(450f, 100f).color(Pal.techBlue).padTop(65f);
|
||||
|
||||
dialog.buttons.button("@back", Icon.left, () -> {
|
||||
hidden.run();
|
||||
|
@ -64,7 +64,8 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
MinimapMarker::new,
|
||||
ShapeMarker::new,
|
||||
TextMarker::new,
|
||||
LineMarker::new
|
||||
LineMarker::new,
|
||||
TextureMarker::new
|
||||
);
|
||||
}
|
||||
|
||||
@ -624,30 +625,53 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
}
|
||||
}
|
||||
|
||||
/** Marker used for drawing UI to indicate something along with an objective. */
|
||||
/** Marker used for drawing various content to indicate something along with an objective. Mostly used as UI overlay. */
|
||||
public static abstract class ObjectiveMarker{
|
||||
/** Position of marker, in world coordinates */
|
||||
public @TilePos Vec2 pos = new Vec2();
|
||||
/** Makes sure markers are only added once. */
|
||||
public transient boolean wasAdded;
|
||||
//** Hides the marker, used by world processors */
|
||||
public boolean hidden = false;
|
||||
|
||||
/** Called in the overlay draw layer.*/
|
||||
public void draw(){}
|
||||
/** Whether to display marker on minimap instead of world. {@link MinimapMarker} ignores this value. */
|
||||
public boolean minimap = false;
|
||||
/** Whether to scale marker corresponding to player's zoom level. {@link MinimapMarker} ignores this value. */
|
||||
public boolean autoscale = false;
|
||||
/** Hides the marker, used by world processors. */
|
||||
protected boolean hidden = false;
|
||||
/** On which z-sorting layer is marker drawn. */
|
||||
protected float drawLayer = Layer.overlayUI;
|
||||
/** Draws the marker. Actual marker position and scale are calculated in {@link #drawWorld()} and {@link #drawMinimap(MinimapRenderer)}. */
|
||||
public void baseDraw(float x, float y, float scaleFactor){}
|
||||
/** Called in the main renderer. */
|
||||
public void drawWorld(){
|
||||
baseDraw(pos.x, pos.y, autoscale ? 4f / renderer.getDisplayScale() : 1f);
|
||||
}
|
||||
/** Called in the small and large map. */
|
||||
public void drawMinimap(MinimapRenderer minimap){}
|
||||
public void drawMinimap(MinimapRenderer minimap){
|
||||
minimap.transform(Tmp.v1.set(pos.x + 4f, pos.y + 4f));
|
||||
baseDraw(Tmp.v1.x, Tmp.v1.y, minimap.getScaleFactor(autoscale));
|
||||
}
|
||||
/** Add any UI elements necessary. */
|
||||
public void added(){}
|
||||
/** Remove any UI elements, if necessary. */
|
||||
public void removed(){}
|
||||
/** Control marker with world processor code*/
|
||||
/** Whether the marker is hidden */
|
||||
public boolean isHidden(){
|
||||
return hidden;
|
||||
}
|
||||
/** Control marker with world processor code. Ignores NaN (null) values. */
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
if(Double.isNaN(p1)) return;
|
||||
switch(type){
|
||||
case toggleVisibility -> hidden = !hidden;
|
||||
case setVisibility -> hidden = ((Math.abs(p1) < 1e-5));
|
||||
case visibility -> hidden = Mathf.equal((float)p1, 0f);
|
||||
case drawLayer -> drawLayer = (float)p1;
|
||||
case minimap -> minimap = !Mathf.equal((float)p1, 0f);
|
||||
case autoscale -> autoscale = !Mathf.equal((float)p1, 0f);
|
||||
}
|
||||
}
|
||||
public void setText(String text, boolean fetch){}
|
||||
|
||||
public void setTexture(String textureName){}
|
||||
|
||||
/** @return The localized type-name of this objective, defaulting to the class simple name without the "Marker" prefix. */
|
||||
public String typeName(){
|
||||
String className = getClass().getSimpleName().replace("Marker", "");
|
||||
@ -678,7 +702,6 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
/** Displays text above a shape. */
|
||||
public static class ShapeTextMarker extends ObjectiveMarker{
|
||||
public @Multiline String text = "frog";
|
||||
public @TilePos Vec2 pos = new Vec2();
|
||||
public float fontSize = 1f, textHeight = 7f;
|
||||
public @LabelFlag byte flags = WorldLabel.flagBackground | WorldLabel.flagOutline;
|
||||
|
||||
@ -718,16 +741,15 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
public ShapeTextMarker(){}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(hidden) return;
|
||||
|
||||
public void baseDraw(float x, float y, float scaleFactor){
|
||||
//in case some idiot decides to make 9999999 sides and freeze the game
|
||||
int sides = Math.min(this.sides, 200);
|
||||
|
||||
Lines.stroke(3f, Pal.gray);
|
||||
Lines.poly(pos.x, pos.y, sides, radius + 1f, rotation);
|
||||
Lines.stroke(1f, color);
|
||||
Lines.poly(pos.x, pos.y, sides, radius + 1f, rotation);
|
||||
Draw.z(drawLayer);
|
||||
Lines.stroke(3f * scaleFactor, Pal.gray);
|
||||
Lines.poly(x, y, sides, (radius + 1f) * scaleFactor, rotation);
|
||||
Lines.stroke(scaleFactor, color);
|
||||
Lines.poly(x, y, sides, (radius + 1f) * scaleFactor, rotation);
|
||||
Draw.reset();
|
||||
|
||||
if(fetchedText == null){
|
||||
@ -735,42 +757,45 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
}
|
||||
|
||||
// font size cannot be 0
|
||||
if(Math.abs(fontSize) < 1e-5) return;
|
||||
if(Mathf.equal(fontSize, 0f)) return;
|
||||
|
||||
WorldLabel.drawAt(fetchedText, pos.x, pos.y + radius + textHeight, Draw.z(), flags, fontSize);
|
||||
WorldLabel.drawAt(fetchedText, x, y + radius * scaleFactor + textHeight * scaleFactor, drawLayer, flags, fontSize * scaleFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
switch(type){
|
||||
case x -> pos.x = (float)p1 * tilesize;
|
||||
case y -> pos.y = (float)p1 * tilesize;
|
||||
case pos -> pos.set((float)p1 * tilesize, (float)p2 * tilesize);
|
||||
case fontSize -> fontSize = (float)p1;
|
||||
case textHeight -> textHeight = (float)p1;
|
||||
case labelBackground -> {
|
||||
if((Math.abs(p1) >= 1e-5)){
|
||||
flags |= WorldLabel.flagBackground;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagBackground;
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (float)p1 * tilesize;
|
||||
case fontSize -> fontSize = (float)p1;
|
||||
case textHeight -> textHeight = (float)p1;
|
||||
case labelFlags -> {
|
||||
if(!Mathf.equal((float)p1, 0f)){
|
||||
flags |= WorldLabel.flagBackground;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagBackground;
|
||||
}
|
||||
}
|
||||
case radius -> radius = (float)p1;
|
||||
case rotation -> rotation = (float)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
case shape -> sides = (int)p1;
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
case labelOutline -> {
|
||||
if((Math.abs(p1) >= 1e-5)){
|
||||
flags |= WorldLabel.flagOutline;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagOutline;
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
switch(type){
|
||||
case pos -> pos.y = (float)p2 * tilesize;
|
||||
case labelFlags -> {
|
||||
if(!Mathf.equal((float)p2, 0f)){
|
||||
flags |= WorldLabel.flagOutline;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagOutline;
|
||||
}
|
||||
}
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
case labelFlags -> {
|
||||
flags = ((Math.abs(p1) >= 1e-5) ? WorldLabel.flagBackground : 0);
|
||||
if((Math.abs(p2) >= 1e-5)) flags |= WorldLabel.flagOutline;
|
||||
}
|
||||
case radius -> radius = (float)p1;
|
||||
case rotation -> rotation = (float)p1;
|
||||
case shapeSides -> sides = (int)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -798,6 +823,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
public MinimapMarker(int x, int y, Color color){
|
||||
this.pos.set(x, y);
|
||||
this.color = color;
|
||||
minimap = true;
|
||||
}
|
||||
|
||||
public MinimapMarker(int x, int y, float radius, float stroke, Color color){
|
||||
@ -805,41 +831,59 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
this.stroke = stroke;
|
||||
this.radius = radius;
|
||||
this.color = color;
|
||||
minimap = true;
|
||||
}
|
||||
|
||||
public MinimapMarker(){}
|
||||
|
||||
@Override
|
||||
public void drawMinimap(MinimapRenderer minimap){
|
||||
if(hidden) return;
|
||||
|
||||
minimap.transform(Tmp.v1.set(pos.x * tilesize, pos.y * tilesize));
|
||||
|
||||
float rad = minimap.scale(radius * tilesize);
|
||||
public void baseDraw(float x, float y, float scaleFactor){
|
||||
float rad = radius * tilesize * scaleFactor;
|
||||
float fin = Interp.pow2Out.apply((Time.globalTime / 100f) % 1f);
|
||||
|
||||
Draw.z(drawLayer);
|
||||
Lines.stroke(Scl.scl((1f - fin) * stroke + 0.1f), color);
|
||||
Lines.circle(Tmp.v1.x, Tmp.v1.y, rad * fin);
|
||||
Lines.circle(x, y, rad * fin);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawWorld(){
|
||||
minimap = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawMinimap(MinimapRenderer minimap){
|
||||
minimap.transform(Tmp.v1.set(pos.x * tilesize, pos.y * tilesize));
|
||||
baseDraw(Tmp.v1.x, Tmp.v1.y, minimap.getScaleFactor(autoscale));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
switch(type){
|
||||
case x -> pos.x = (int)p1;
|
||||
case y -> pos.y = (int)p1;
|
||||
case pos -> pos.set((int)p1, (int)p2);
|
||||
case radius -> radius = (float)p1;
|
||||
case stroke -> stroke = (float)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (int)p1;
|
||||
case radius -> radius = (float)p1;
|
||||
case stroke -> stroke = (float)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
case minimap -> minimap = true;
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
if(type == LMarkerControl.pos){
|
||||
pos.y = (int)p2;
|
||||
}else{
|
||||
super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Displays a shape with an outline and color. */
|
||||
public static class ShapeMarker extends ObjectiveMarker{
|
||||
public @TilePos Vec2 pos = new Vec2();
|
||||
public float radius = 8f, rotation = 0f, stroke = 1f;
|
||||
public boolean fill = false, outline = true;
|
||||
public int sides = 4;
|
||||
@ -858,23 +902,22 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
public ShapeMarker(){}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(hidden) return;
|
||||
|
||||
public void baseDraw(float x, float y, float scaleFactor){
|
||||
//in case some idiot decides to make 9999999 sides and freeze the game
|
||||
int sides = Math.min(this.sides, 200);
|
||||
|
||||
Draw.z(drawLayer);
|
||||
if(!fill){
|
||||
if(outline){
|
||||
Lines.stroke(stroke + 2f, Pal.gray);
|
||||
Lines.poly(pos.x, pos.y, sides, radius + 1f, rotation);
|
||||
Lines.stroke((stroke + 2f) * scaleFactor, Pal.gray);
|
||||
Lines.poly(x, y, sides, (radius + 1f) * scaleFactor, rotation);
|
||||
}
|
||||
|
||||
Lines.stroke(stroke, color);
|
||||
Lines.poly(pos.x, pos.y, sides, radius + 1f, rotation);
|
||||
Lines.stroke(stroke * scaleFactor, color);
|
||||
Lines.poly(x, y, sides, (radius + 1f) * scaleFactor, rotation);
|
||||
}else{
|
||||
Draw.color(color);
|
||||
Fill.poly(pos.x, pos.y, sides, radius, rotation);
|
||||
Fill.poly(x, y, sides, radius * scaleFactor, rotation);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
@ -882,23 +925,32 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
switch(type){
|
||||
case x -> pos.x = (float)p1 * tilesize;
|
||||
case y -> pos.y = (float)p1 * tilesize;
|
||||
case pos -> pos.set((float)p1 * tilesize, (float)p2 * tilesize);
|
||||
case radius -> radius = (float)p1;
|
||||
case rotation -> rotation = (float)p1;
|
||||
case stroke -> stroke = (float)p1;
|
||||
case shapeSides -> sides = (int)p1;
|
||||
case shapeFill -> fill = (Math.abs(p1) >= 1e-5);
|
||||
case shapeOutline -> outline = (Math.abs(p1) >= 1e-5);
|
||||
case setShape -> {
|
||||
sides = (int)p1;
|
||||
fill = (Math.abs(p2) >= 1e-5);
|
||||
outline = (Math.abs(p3) >= 1e-5);
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (float)p1 * tilesize;
|
||||
case radius -> radius = (float)p1;
|
||||
case stroke -> stroke = (float)p1;
|
||||
case rotation -> rotation = (float)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
case shape -> sides = (int)p1;
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
switch(type){
|
||||
case pos -> pos.y = (float)p2 * tilesize;
|
||||
case shape -> fill = !Mathf.equal((float)p2, 0f);
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p3)){
|
||||
if(type == LMarkerControl.shape){
|
||||
outline = !Mathf.equal((float)p3, 0f);
|
||||
}else{
|
||||
super.control(type, p1, p2, p3);
|
||||
}
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -906,7 +958,6 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
/** Displays text at a location. */
|
||||
public static class TextMarker extends ObjectiveMarker{
|
||||
public @Multiline String text = "uwu";
|
||||
public @TilePos Vec2 pos = new Vec2();
|
||||
public float fontSize = 1f;
|
||||
public @LabelFlag byte flags = WorldLabel.flagBackground | WorldLabel.flagOutline;
|
||||
// Cached localized text.
|
||||
@ -927,43 +978,46 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
public TextMarker(){}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
public void baseDraw(float x, float y, float scaleFactor){
|
||||
// font size cannot be 0
|
||||
if(hidden || Math.abs(fontSize) < 1e-5) return;
|
||||
if(Mathf.equal(fontSize, 0f)) return;
|
||||
|
||||
if(fetchedText == null){
|
||||
fetchedText = fetchText(text);
|
||||
}
|
||||
|
||||
WorldLabel.drawAt(fetchedText, pos.x, pos.y, Draw.z(), flags, fontSize);
|
||||
WorldLabel.drawAt(fetchedText, x, y, drawLayer, flags, fontSize * scaleFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
switch(type){
|
||||
case x -> pos.x = (float)p1 * tilesize;
|
||||
case y -> pos.y = (float)p1 * tilesize;
|
||||
case pos -> pos.set((float)p1 * tilesize, (float)p2 * tilesize);
|
||||
case fontSize -> fontSize = (float)p1;
|
||||
case labelBackground -> {
|
||||
if((Math.abs(p1) >= 1e-5)){
|
||||
flags |= WorldLabel.flagBackground;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagBackground;
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (float)p1 * tilesize;
|
||||
case fontSize -> fontSize = (float)p1;
|
||||
case labelFlags -> {
|
||||
if(!Mathf.equal((float)p1, 0f)){
|
||||
flags |= WorldLabel.flagBackground;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagBackground;
|
||||
}
|
||||
}
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
case labelOutline -> {
|
||||
if((Math.abs(p1) >= 1e-5)){
|
||||
flags |= WorldLabel.flagOutline;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagOutline;
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
switch(type){
|
||||
case pos -> pos.y = (float)p2 * tilesize;
|
||||
case labelFlags -> {
|
||||
if(!Mathf.equal((float)p2, 0f)){
|
||||
flags |= WorldLabel.flagOutline;
|
||||
}else{
|
||||
flags &= ~WorldLabel.flagOutline;
|
||||
}
|
||||
}
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
case labelFlags -> {
|
||||
flags = ((Math.abs(p1) >= 1e-5) ? WorldLabel.flagBackground : 0);
|
||||
if((Math.abs(p2) >= 1e-5)) flags |= WorldLabel.flagOutline;
|
||||
}
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,51 +1034,136 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
||||
|
||||
/** Displays a line from pos1 to pos2. */
|
||||
public static class LineMarker extends ObjectiveMarker{
|
||||
public @TilePos Vec2 pos1 = new Vec2(), pos2 = new Vec2();
|
||||
public @TilePos Vec2 pos = new Vec2(), endPos = new Vec2();
|
||||
public float stroke = 1f;
|
||||
public boolean outline = true;
|
||||
public Color color = Color.valueOf("ffd37f");
|
||||
|
||||
public LineMarker(String text, float x1, float y1, float x2, float y2, float stroke){
|
||||
public LineMarker(float x1, float y1, float x2, float y2, float stroke){
|
||||
this.stroke = stroke;
|
||||
this.pos1.set(x1, y1);
|
||||
this.pos2.set(x2, y2);
|
||||
this.pos.set(x1, y1);
|
||||
this.endPos.set(x2, y2);
|
||||
}
|
||||
|
||||
public LineMarker(String text, float x1, float y1, float x2, float y2){
|
||||
this.pos1.set(x1, y1);
|
||||
this.pos2.set(x2, y2);
|
||||
public LineMarker(float x1, float y1, float x2, float y2){
|
||||
this.pos.set(x1, y1);
|
||||
this.endPos.set(x2, y2);
|
||||
}
|
||||
|
||||
public LineMarker(){}
|
||||
|
||||
public void baseLineDraw(float x1, float y1, float x2, float y2, float scaleFactor){
|
||||
Draw.z(drawLayer);
|
||||
if(outline){
|
||||
Lines.stroke((stroke + 2f) * scaleFactor, Pal.gray);
|
||||
Lines.line(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
Lines.stroke(stroke * scaleFactor, color);
|
||||
Lines.line(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawWorld(){
|
||||
baseLineDraw(pos.x, pos.y, endPos.x, endPos.y, autoscale ? 4f / renderer.getDisplayScale() : 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawMinimap(MinimapRenderer minimap){
|
||||
minimap.transform(Tmp.v1.set(pos.x + 4f, pos.y + 4f));
|
||||
minimap.transform(Tmp.v2.set(endPos.x + 4f, endPos.y + 4f));
|
||||
baseLineDraw(Tmp.v1.x, Tmp.v1.y, Tmp.v2.x, Tmp.v2.y, minimap.getScaleFactor(autoscale));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
switch(type){
|
||||
case x -> pos1.x = (float)p1 * tilesize;
|
||||
case y -> pos1.y = (float)p1 * tilesize;
|
||||
case pos -> pos1.set((float)p1 * tilesize, (float)p2 * tilesize);
|
||||
case endX -> pos2.x = (float)p1 * tilesize;
|
||||
case endY -> pos2.y = (float)p1 * tilesize;
|
||||
case endPos -> pos2.set((float)p1 * tilesize, (float)p2 * tilesize);
|
||||
case stroke -> stroke = (float)p1;
|
||||
case shapeOutline -> outline = ((Math.abs(p1) >= 1e-5));
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (float)p1 * tilesize;
|
||||
case endPos -> endPos.x = (float)p1 * tilesize;
|
||||
case stroke -> stroke = (float)p1;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
switch(type){
|
||||
case pos -> pos.y = (float)p2 * tilesize;
|
||||
case endPos -> endPos.y = (float)p2 * tilesize;
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Displays a texture with specified name. */
|
||||
public static class TextureMarker extends ObjectiveMarker{
|
||||
public float rotation = 0f, width = 0f, height = 0f; // Zero width/height scales marker to original texture's size
|
||||
public String textureName = "";
|
||||
public Color color = Color.white.cpy();
|
||||
|
||||
private transient TextureRegion fetchedRegion;
|
||||
|
||||
public TextureMarker(String textureName, float x, float y, float width, float height){
|
||||
this.textureName = textureName;
|
||||
this.pos.set(x, y);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public TextureMarker(String textureName, float x, float y){
|
||||
this.textureName = textureName;
|
||||
this.pos.set(x, y);
|
||||
}
|
||||
|
||||
public TextureMarker(){}
|
||||
|
||||
@Override
|
||||
public void control(LMarkerControl type, double p1, double p2, double p3){
|
||||
if(!Double.isNaN(p1)){
|
||||
switch(type){
|
||||
case pos -> pos.x = (float)p1 * tilesize;
|
||||
case rotation -> rotation = (float)p1;
|
||||
case textureSize -> width = (float)p1 * tilesize;
|
||||
case color -> color.set(Tmp.c1.fromDouble(p1));
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
if(!Double.isNaN(p2)){
|
||||
switch(type){
|
||||
case pos -> pos.y = (float)p2 * tilesize;
|
||||
case textureSize -> height = (float)p2 * tilesize;
|
||||
default -> super.control(type, p1, p2, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(hidden) return;
|
||||
public void baseDraw(float x, float y, float scaleFactor){
|
||||
if(textureName.isEmpty()) return;
|
||||
|
||||
if(outline){
|
||||
Lines.stroke(stroke + 2f, Pal.gray);
|
||||
Lines.line(pos1.x, pos1.y, pos2.x, pos2.y);
|
||||
if(fetchedRegion == null) fetchedRegion = Core.atlas.find(textureName);
|
||||
|
||||
// Zero width/height scales marker to original texture's size
|
||||
if(Mathf.equal(width, 0f)) width = fetchedRegion.width * fetchedRegion.scl() * Draw.xscl;
|
||||
if(Mathf.equal(height, 0f)) height = fetchedRegion.height * fetchedRegion.scl() * Draw.yscl;
|
||||
|
||||
Draw.z(drawLayer);
|
||||
if(fetchedRegion.found()){
|
||||
Draw.color(color);
|
||||
Draw.rect(fetchedRegion, x, y, width * scaleFactor, height * scaleFactor, rotation);
|
||||
}else{
|
||||
Draw.color(Color.white);
|
||||
Draw.rect("error", x, y, width * scaleFactor, height * scaleFactor, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
Lines.stroke(stroke, color);
|
||||
Lines.line(pos1.x, pos1.y, pos2.x, pos2.y);
|
||||
@Override
|
||||
public void setTexture(String textureName){
|
||||
this.textureName = textureName;
|
||||
fetchedRegion = Core.atlas.find(textureName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,12 +255,14 @@ public class MinimapRenderer{
|
||||
|
||||
state.rules.objectives.eachRunning(obj -> {
|
||||
for(var marker : obj.markers){
|
||||
marker.drawMinimap(this);
|
||||
if(marker.minimap) marker.drawMinimap(this);
|
||||
}
|
||||
});
|
||||
|
||||
for(var marker : state.markers.values()){
|
||||
if(marker != null) marker.drawMinimap(this);
|
||||
if(marker != null){
|
||||
if(!marker.isHidden() && marker.minimap) marker.drawMinimap(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,6 +305,14 @@ public class MinimapRenderer{
|
||||
return worldSpace ? (radius / (baseSize / 2f)) * 5f * lastScl : lastW / rect.width * radius;
|
||||
}
|
||||
|
||||
public float getScaleFactor(boolean zoomAutoScale){
|
||||
if(!zoomAutoScale){
|
||||
return worldSpace ? (1 / (baseSize / 2f)) * 5f * lastScl : lastW / rect.width;
|
||||
}else{
|
||||
return worldSpace ? (1 / (baseSize / 2f)) * 5f : lastW / 256f;
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable TextureRegion getRegion(){
|
||||
if(texture == null) return null;
|
||||
|
||||
|
@ -113,15 +113,6 @@ public class OverlayRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
//draw objective markers
|
||||
state.rules.objectives.eachRunning(obj -> {
|
||||
for(var marker : obj.markers) marker.draw();
|
||||
});
|
||||
|
||||
for(var marker : state.markers.values()){
|
||||
if(marker != null) marker.draw();
|
||||
}
|
||||
|
||||
if(player.dead()) return; //dead players don't draw
|
||||
|
||||
InputHandler input = control.input;
|
||||
|
@ -162,11 +162,23 @@ public class LExecutor{
|
||||
return v.isobj ? v.objval != null ? 1 : 0 : invalid(v.numval) ? 0 : v.numval;
|
||||
}
|
||||
|
||||
/** Get num value from variable, convert null to NaN to handle it differently in some instructions */
|
||||
public double numOrNan(int index){
|
||||
Var v = var(index);
|
||||
return v.isobj ? v.objval != null ? 1 : Double.NaN : invalid(v.numval) ? 0 : v.numval;
|
||||
}
|
||||
|
||||
public float numf(int index){
|
||||
Var v = var(index);
|
||||
return v.isobj ? v.objval != null ? 1 : 0 : invalid(v.numval) ? 0 : (float)v.numval;
|
||||
}
|
||||
|
||||
/** Get float value from variable, convert null to NaN to handle it differently in some instructions */
|
||||
public float numfOrNan(int index){
|
||||
Var v = var(index);
|
||||
return v.isobj ? v.objval != null ? 1 : Float.NaN : invalid(v.numval) ? 0 : (float)v.numval;
|
||||
}
|
||||
|
||||
public int numi(int index){
|
||||
return (int)num(index);
|
||||
}
|
||||
@ -1663,7 +1675,7 @@ public class LExecutor{
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
//set default to succes
|
||||
//set default to success
|
||||
exec.setnum(outSuccess, 1);
|
||||
if(headless && type != MessageType.mission) {
|
||||
exec.textBuffer.setLength(0);
|
||||
@ -1960,7 +1972,7 @@ public class LExecutor{
|
||||
}
|
||||
|
||||
public static class SetMarkerI implements LInstruction{
|
||||
public LMarkerControl type = LMarkerControl.x;
|
||||
public LMarkerControl type = LMarkerControl.pos;
|
||||
public int id, p1, p2, p3;
|
||||
|
||||
public SetMarkerI(LMarkerControl type, int id, int p1, int p2, int p3){
|
||||
@ -1982,13 +1994,18 @@ public class LExecutor{
|
||||
var marker = state.markers.get(exec.numi(id));
|
||||
if(marker == null) return;
|
||||
|
||||
if(type == LMarkerControl.text){
|
||||
marker.setText((exec.obj(p1) != null ? exec.obj(p1).toString() : "null"), false);
|
||||
}else if(type == LMarkerControl.flushText){
|
||||
marker.setText(exec.textBuffer.toString(), true);
|
||||
if(type == LMarkerControl.flushText){
|
||||
marker.setText(exec.textBuffer.toString(), exec.bool(p1));
|
||||
exec.textBuffer.setLength(0);
|
||||
}else if(type == LMarkerControl.texture){
|
||||
if(exec.bool(p1)){
|
||||
marker.setTexture(exec.textBuffer.toString());
|
||||
exec.textBuffer.setLength(0);
|
||||
}else{
|
||||
marker.setTexture(PrintI.toString(exec.obj(p2)));
|
||||
}
|
||||
}else{
|
||||
marker.control(type, exec.num(p1), exec.num(p2), exec.num(p3));
|
||||
marker.control(type, exec.numOrNan(p1), exec.numOrNan(p2), exec.numOrNan(p3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2041,17 +2058,23 @@ public class LExecutor{
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, variants = Variant.both, unreliable = true)
|
||||
public static void updateMarkerText(int id, LMarkerControl type, String text){
|
||||
public static void updateMarkerText(int id, LMarkerControl type, boolean fetch, String text){
|
||||
var marker = state.markers.get(id);
|
||||
if(marker != null){
|
||||
if(type == LMarkerControl.text){
|
||||
marker.setText(text, true);
|
||||
}else if(type == LMarkerControl.flushText){
|
||||
marker.setText(text, false);
|
||||
if(type == LMarkerControl.flushText){
|
||||
marker.setText(text, fetch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, variants = Variant.both, unreliable = true)
|
||||
public static void updateMarkerTexture(int id, String textureName){
|
||||
var marker = state.markers.get(id);
|
||||
if(marker != null){
|
||||
marker.setTexture(textureName);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LocalePrintI implements LInstruction{
|
||||
public int name;
|
||||
|
||||
|
@ -2,29 +2,23 @@ package mindustry.logic;
|
||||
|
||||
public enum LMarkerControl{
|
||||
remove,
|
||||
setVisibility("true/false"),
|
||||
toggleVisibility,
|
||||
text("text"),
|
||||
flushText,
|
||||
x("x"),
|
||||
y("y"),
|
||||
visibility("true/false"),
|
||||
minimap("true/false"),
|
||||
autoscale("true/false"),
|
||||
pos("x", "y"),
|
||||
endX("x"),
|
||||
endY("y"),
|
||||
endPos("x", "y"),
|
||||
fontSize("size"),
|
||||
textHeight("height"),
|
||||
labelBackground("true/false"),
|
||||
labelOutline("true/false"),
|
||||
labelFlags("background", "outline"),
|
||||
drawLayer("layer"),
|
||||
color("color"),
|
||||
radius("radius"),
|
||||
stroke("stroke"),
|
||||
rotation("rotation"),
|
||||
shapeSides("sides"),
|
||||
shapeFill("true/false"),
|
||||
shapeOutline("true/false"),
|
||||
setShape("sides", "fill", "outline"),
|
||||
color("color");
|
||||
shape("sides", "fill", "outline"),
|
||||
flushText("fetch"),
|
||||
fontSize("size"),
|
||||
textHeight("height"),
|
||||
labelFlags("background", "outline"),
|
||||
texture("printFlush", "name"),
|
||||
textureSize("width", "height");
|
||||
|
||||
public final String[] params;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package mindustry.logic;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.actions.*;
|
||||
@ -10,10 +11,12 @@ import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.LCanvas.*;
|
||||
import mindustry.logic.LExecutor.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.ui;
|
||||
import static mindustry.logic.LCanvas.*;
|
||||
|
||||
/**
|
||||
@ -120,6 +123,23 @@ public abstract class LStatement{
|
||||
return result[0];
|
||||
}
|
||||
|
||||
/** Adds color edit button */
|
||||
protected Cell<Button> col(Table table, String value, Cons<Color> setter){
|
||||
return table.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
b.clicked(() -> {
|
||||
Color current = Pal.accent.cpy();
|
||||
if(value.startsWith("%")){
|
||||
try{
|
||||
current = Color.valueOf(value.substring(1));
|
||||
}catch(Exception ignored){}
|
||||
}
|
||||
|
||||
ui.picker.show(current, setter);
|
||||
});
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-11).color(table.color);
|
||||
}
|
||||
|
||||
protected Cell<TextField> fields(Table table, String value, Cons<String> setter){
|
||||
return field(table, value, setter).width(85f);
|
||||
}
|
||||
|
@ -194,6 +194,10 @@ public class LStatements{
|
||||
}
|
||||
case col -> {
|
||||
fields(s, "color", x, v -> x = v).width(144f);
|
||||
col(s, x, res -> {
|
||||
x = "%" + res.toString().substring(0, res.a >= 1f ? 6 : 8);
|
||||
build(table);
|
||||
});
|
||||
}
|
||||
case stroke -> {
|
||||
s.add().width(4);
|
||||
@ -1603,22 +1607,10 @@ public class LStatements{
|
||||
if(entry.color){
|
||||
fields(table, "color", color, str -> color = str).width(120f);
|
||||
|
||||
table.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
b.clicked(() -> {
|
||||
Color current = Pal.accent.cpy();
|
||||
if(color.startsWith("%")){
|
||||
try{
|
||||
current = Color.valueOf(color.substring(1));
|
||||
}catch(Exception ignored){}
|
||||
}
|
||||
|
||||
ui.picker.show(current, result -> {
|
||||
color = "%" + result.toString().substring(0, result.a >= 1f ? 6 : 8);
|
||||
build(table);
|
||||
});
|
||||
});
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-11).color(table.color);
|
||||
col(table, color, res -> {
|
||||
color = "%" + res.toString().substring(0, res.a >= 1f ? 6 : 8);
|
||||
build(table);
|
||||
});
|
||||
}
|
||||
|
||||
row(table);
|
||||
@ -1974,7 +1966,7 @@ public class LStatements{
|
||||
|
||||
@RegisterStatement("setmarker")
|
||||
public static class SetMarkerStatement extends LStatement{
|
||||
public LMarkerControl type = LMarkerControl.x;
|
||||
public LMarkerControl type = LMarkerControl.pos;
|
||||
public String id = "0", p1 = "0", p2 = "0", p3 = "0";
|
||||
|
||||
@Override
|
||||
@ -1992,7 +1984,7 @@ public class LStatements{
|
||||
b.clicked(() -> showSelect(b, LMarkerControl.all, type, t -> {
|
||||
type = t;
|
||||
rebuild(table);
|
||||
}, 2, cell -> cell.size(140, 50)));
|
||||
}, 3, cell -> cell.size(140, 50)));
|
||||
}, Styles.logict, () -> {}).size(190, 40).color(table.color).left().padLeft(2);
|
||||
|
||||
row(table);
|
||||
@ -2008,6 +2000,31 @@ public class LStatements{
|
||||
t.setColor(table.color);
|
||||
|
||||
fields(t, type.params[i], i == 0 ? p1 : i == 1 ? p2 : p3, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : v -> p3 = v).width(100f);
|
||||
|
||||
if(type == LMarkerControl.color){
|
||||
col(t, p1, res -> {
|
||||
p1 = "%" + res.toString().substring(0, res.a >= 1f ? 6 : 8);
|
||||
build(table);
|
||||
});
|
||||
}else if(type == LMarkerControl.drawLayer){
|
||||
t.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
b.clicked(() -> showSelectTable(b, (o, hide) -> {
|
||||
o.row();
|
||||
o.table(s -> {
|
||||
s.left();
|
||||
for(var layer : Layer.class.getFields()){
|
||||
float value = Reflect.get(Layer.class, layer.getName());
|
||||
s.button(layer.getName() + " = " + value, Styles.logicTogglet, () -> {
|
||||
p1 = Float.toString(value);
|
||||
rebuild(table);
|
||||
hide.run();
|
||||
}).size(240f, 40f).row();
|
||||
}
|
||||
}).width(240f).left();
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-11).color(table.color);
|
||||
}
|
||||
});
|
||||
|
||||
if(i == 0) row(table);
|
||||
@ -2033,7 +2050,7 @@ public class LStatements{
|
||||
|
||||
@RegisterStatement("makemarker")
|
||||
public static class MakeMarkerStatement extends LStatement{
|
||||
public String id = "0", type = "shape", x = "0", y = "0", replace = "true";
|
||||
public String type = "shape", id = "0", x = "0", y = "0", replace = "true";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
|
@ -247,10 +247,10 @@ public class JoinDialog extends BaseDialog{
|
||||
void setupServer(Server server, Host host){
|
||||
server.lastHost = host;
|
||||
server.content.clear();
|
||||
buildServer(host, server.content, false);
|
||||
buildServer(host, server.content, false, true);
|
||||
}
|
||||
|
||||
void buildServer(Host host, Table content, boolean local){
|
||||
void buildServer(Host host, Table content, boolean local, boolean addName){
|
||||
content.top().left();
|
||||
boolean isBanned = local && Vars.steam && host.description != null && host.description.equals("[banned]");
|
||||
String versionString = getVersionString(host) + (isBanned ? "[red] [banned]" : "");
|
||||
@ -261,7 +261,7 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
Color color = Pal.gray;
|
||||
|
||||
if(local){
|
||||
if(addName){
|
||||
content.table(Tex.whiteui, t -> {
|
||||
t.left();
|
||||
t.setColor(color);
|
||||
@ -513,7 +513,7 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
button[0].row();
|
||||
|
||||
buildServer(host, button[0].table(t -> {}).grow().get(), false);
|
||||
buildServer(host, button[0].table(t -> {}).grow().get(), false, false);
|
||||
|
||||
if((container.getChildren().size) % columns() == 0){
|
||||
container.row();
|
||||
@ -544,7 +544,7 @@ public class JoinDialog extends BaseDialog{
|
||||
local.row();
|
||||
}
|
||||
|
||||
local.button(b -> buildServer(host, b, true), style, () -> {
|
||||
local.button(b -> buildServer(host, b, true, true), style, () -> {
|
||||
Events.fire(new ClientPreConnectEvent(host));
|
||||
safeConnect(host.address, host.port, host.version);
|
||||
}).width(w).top().left().growY();
|
||||
|
Loading…
Reference in New Issue
Block a user