use of org.terasology.logic.common.InspectionToolComponent in project Terasology by MovingBlocks.
the class InspectionScreen method updateFields.
private void updateFields(EntityRef interactionTarget) {
InspectionToolComponent inspectorComponent = interactionTarget.getComponent(InspectionToolComponent.class);
EntityRef inspectedEntity = inspectorComponent.inspectedEntity;
entityIdField.setText(Long.toString(inspectedEntity.getId()));
if (inspectedEntity.exists()) {
if (inspectedEntity.isActive()) {
fullDescriptionLabel.setText(inspectedEntity.toFullDescription());
} else {
fullDescriptionLabel.setText("not active: " + inspectedEntity.toFullDescription());
}
} else {
fullDescriptionLabel.setText("Non existing entity with id " + inspectedEntity.getId());
}
}
use of org.terasology.logic.common.InspectionToolComponent in project Terasology by MovingBlocks.
the class InspectionScreen method initialise.
@Override
public void initialise() {
fullDescriptionLabel = find("fullDescriptionLabel", UIText.class);
entityIdField = find("entityIdField", UIText.class);
setEntityIdButton = find("setEntityIdButton", UIButton.class);
setEntityIdButton.subscribe(widget -> {
String text = entityIdField.getText();
EntityRef interactionTarget = getInteractionTarget();
InspectionToolComponent inspectorComponent = interactionTarget.getComponent(InspectionToolComponent.class);
if (text.equals("this")) {
inspectorComponent.inspectedEntity = interactionTarget;
} else {
try {
int id1 = Integer.parseInt(text);
inspectorComponent.inspectedEntity = CoreRegistry.get(EntityManager.class).getEntity(id1);
} catch (NumberFormatException e) {
fullDescriptionLabel.setText("Please specify a valid number");
}
}
updateFields(interactionTarget);
});
}
Aggregations