made tiles configurable

This commit is contained in:
Stephan Richter
2020-09-14 19:27:08 +02:00
parent 10837473ce
commit 9ac2801522
4 changed files with 44 additions and 7 deletions

View File

@@ -3,6 +3,8 @@ package de.srsoftware.web4rail.tiles;
import java.util.HashMap;
import java.util.Map.Entry;
import org.json.JSONObject;
import de.srsoftware.tools.Tag;
import de.srsoftware.web4rail.Window;
import de.srsoftware.web4rail.tags.Form;
@@ -11,6 +13,19 @@ public abstract class StretchableTile extends Tile {
private static final String LENGTH = "length";
public int length = 1;
@Override
public JSONObject config() {
JSONObject config = super.config();
if (length != 1) config.put(LENGTH, length);
return config;
}
@Override
public void configure(JSONObject config) {
super.configure(config);
if (config.has(LENGTH)) setLength(config.getInt(LENGTH));
}
public Tag propMenu() {
Window menu = new Window("tile-properties",t("Properties of {} @ ({},{})",getClass().getSimpleName(),x,y));
Form form = new Form();

View File

@@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,6 +27,12 @@ public abstract class Tile {
classes.add(getClass().getSimpleName());
}
public JSONObject config() {
return new JSONObject();
}
public void configure(JSONObject config) {}
public int height() {
return 1;
}