Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TagSet and editor support (#129) #132

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.lang.reflect.Modifier;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class PropertiesMenu extends Table {
public ArrayMap<String, Array<Field>> arrayMap = new ArrayMap<String, Array<Field>>();
Expand Down Expand Up @@ -162,6 +165,15 @@ else if(field.getType() == String.class) {

fieldMap.put(field, tf);
}
else if (field.getType() == TagSet.class) {
TextField tf = new TextField(v, skin);
tf.setTextFieldListener(getTextFieldListener(field));

add(label).align(Align.left);
add(tf).align(Align.left).fill();

fieldMap.put(field, tf);
}
else if(field.getType() == Material.class) {
Material val = (Material)value;

Expand Down Expand Up @@ -637,6 +649,13 @@ else if(currentField.getType() == String.class) {
currentField.set(entity, val);
}
}
else if(currentField.getType() == TagSet.class) {
for(Entity entity : selectedEntities) {
TagSet tags = new TagSet();
tags.addAll(Stream.of(val.split(",")).map((v) -> v.trim()).toArray(String[]::new));
currentField.set(entity, tags);
}
}
}
else if(actor instanceof TextButton) {
String val = ((TextButton)actor).getText().toString();
Expand Down Expand Up @@ -714,7 +733,7 @@ else if(currentField.getType() == Color.class) {
}
}
catch(Exception ex) {
Gdx.app.error("DelvEdit", ex.getMessage());
Gdx.app.error("DelvEdit: Property Change", ex.getMessage());
}
}

Expand Down
8 changes: 8 additions & 0 deletions Dungeoneer/src/com/badlogic/gdx/utils/TagSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.badlogic.gdx.utils;

public class TagSet extends ObjectSet<String> {
@Override
public String toString() {
return String.join(", ", this);
}
}
4 changes: 4 additions & 0 deletions Dungeoneer/src/com/interrupt/dungeoneer/entities/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TagSet;
import com.interrupt.dungeoneer.Audio;
import com.interrupt.dungeoneer.annotations.EditorProperty;
import com.interrupt.dungeoneer.collision.Collision;
Expand Down Expand Up @@ -30,6 +31,9 @@ public class Entity {
@EditorProperty( group = "Visual" )
public Drawable drawable;

@EditorProperty
public TagSet tags = new TagSet();

/** Position x-component. */
public float x;

Expand Down