All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blastedstudios.gdxworld.plugin.mode.polygon.ShapeTable Maven / Gradle / Ivy

The newest version!
package com.blastedstudios.gdxworld.plugin.mode.polygon;

import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.blastedstudios.gdxworld.ui.leveleditor.FilterTable;
import com.blastedstudios.gdxworld.world.shape.GDXShape;

public class ShapeTable extends Table {
	private final TextField densityField, frictionField, restitutionField, resourceField, tagField;
	private final FilterTable filterTable;

	public ShapeTable(Skin skin, GDXShape shape){
		super(skin);
		resourceField = new TextField(shape.getResource(), skin);
		resourceField.setMessageText("");
		densityField = new TextField(shape.getDensity()+"", skin);
		densityField.setMessageText("");
		frictionField = new TextField(shape.getFriction()+"", skin);
		frictionField.setMessageText("");
		restitutionField = new TextField(shape.getRestitution()+"", skin);
		restitutionField.setMessageText("");
		tagField = new TextField(shape.getTag(), skin);
		tagField.setMessageText("");
		filterTable = new FilterTable(skin, shape.getFilter());

		add("Resource: ");
		add(resourceField);
		row();
		add("Tag: ");
		add(tagField);
		row();
		add("Friction: ");
		add(frictionField);
		row();
		add("Density: ");
		add(densityField);
		row();
		add("Restitution: ");
		add(restitutionField);
		row();
		add("Filter ");
		add(filterTable);
	}
	
	public GDXShape apply(GDXShape shape){
		shape.setDensity(Float.parseFloat(densityField.getText()));
		shape.setFriction(Float.parseFloat(frictionField.getText()));
		shape.setResource(resourceField.getText());
		shape.setRestitution(Float.parseFloat(restitutionField.getText()));
		shape.setFilter(filterTable.createFilterFromUI());
		shape.setTag(tagField.getText());
		return shape;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy