com.blastedstudios.gdxworld.plugin.mode.chain.ChainWindow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of GDXWorld Show documentation
Show all versions of GDXWorld Show documentation
Uploads all artifacts belonging to configuration ':archives'
The newest version!
package com.blastedstudios.gdxworld.plugin.mode.chain;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.blastedstudios.gdxworld.plugin.mode.circle.CircleTable;
import com.blastedstudios.gdxworld.ui.AbstractWindow;
import com.blastedstudios.gdxworld.ui.leveleditor.VertexTable;
import com.blastedstudios.gdxworld.util.Log;
import com.blastedstudios.gdxworld.util.Properties;
import com.blastedstudios.gdxworld.world.GDXLevel;
import com.blastedstudios.gdxworld.world.joint.RevoluteJoint;
import com.blastedstudios.gdxworld.world.shape.GDXCircle;
import com.blastedstudios.gdxworld.world.shape.GDXPolygon;
import com.blastedstudios.gdxworld.world.shape.GDXShape;
public class ChainWindow extends AbstractWindow {
private static int chainCount = 0;
private final VertexTable startTable, endTable;
private final TextField distanceField, nameField;
private final CircleTable circleTable;
private final RectangleTable rectangleTable;
private final Table shapeTable;
private final CheckBox circleBox, rectangleBox;
public ChainWindow(final Skin skin, final GDXLevel level) {
super("Chain Editor", skin);
startTable = new VertexTable(new Vector2(), skin);
endTable = new VertexTable(new Vector2(), skin);
nameField = new TextField("Chain-" + chainCount++, skin);
nameField.setMessageText("");
distanceField = new TextField(Properties.get("level.chain.distance", "1"), skin);
distanceField.setMessageText(" shapes = new ArrayList<>();
Vector2 dir = endTable.getVertex().cpy().sub(startTable.getVertex()).nor();
for(float i=0; i