Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jsvg = { group = "com.github.weisj", name = "jsvg", version = "1.4.0" }

handlebars = { group = "com.github.jknack", name = "handlebars", version.ref = "handlebars" }
handlebars-helpers = { group = "com.github.jknack", name = "handlebars-helpers", version.ref = "handlebars" }
handlebars-json = { group = "com.github.jknack", name = "handlebars-jackson2", version = "4.3.1" }

# Apache commons and other utilities
# parsing of configuration data
Expand Down Expand Up @@ -213,7 +214,7 @@ flatlaf = [
"flatlaf-extras",
"flatlaf-jide-oss",
]
handlebars = ["handlebars", "handlebars-helpers"]
handlebars = ["handlebars", "handlebars-helpers", "handlebars-json"]
junit = ["junit-api", "junit-engine", "junit-params"]
jai-imageio = ["jai-imageio-core", "jai-imageio-jpeg"]
graalvm-js = ["graalvm-js", "graalvm-js-scriptengine"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class DeveloperOptions {
new PreferenceStore(Preferences.userRoot().node(AppConstants.APP_NAME + "/dev"));

public static final class Toggle {
public static final Preference<Boolean> EnableHandlebarsDebugging =
store.defineBoolean(
"enableHandlebarsDebugging",
"Preferences.developer.enableHandlebarsDebugging.label",
"Preferences.developer.enableHandlebarsDebugging.tooltip",
false);
public static final Preference<Boolean> AutoSaveMeasuredInSeconds =
store.defineBoolean(
"autoSaveMeasuredInSeconds",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ private Object getProperties(
seg, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]));
pi.next();
}
StringBuilder stringBuilder = new StringBuilder(sd.toString());
StringBuilder stringBuilder = new StringBuilder(sd.toString(false));
stringBuilder.append("segments=").append(String.join(",", segments)).append(";");

if (delimiter.equalsIgnoreCase("json")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,37 @@
*/
package net.rptools.maptool.client.ui.sheet.stats;

import com.github.jknack.handlebars.*;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import javafx.application.Platform;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.DeveloperOptions;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.ui.htmlframe.HTMLContent;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.sheet.stats.StatSheetContext;
import net.rptools.maptool.model.sheet.stats.StatSheetLocation;
import net.rptools.maptool.util.HBDebugUtil;
import net.rptools.maptool.util.HandlebarsUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Class that represents a pop up stat sheet. */
public class StatSheet {

/** Object for logging messages. */
private static final Logger log = LogManager.getLogger(StatSheet.class);
private static final Logger log = LoggerFactory.getLogger(StatSheet.class);

private static final HBDebugUtil HBD;

static {
HBDebugUtil hbd = null;
if (DeveloperOptions.Toggle.EnableHandlebarsDebugging.get()) {
hbd = new HBDebugUtil();
}
HBD = hbd;
}

Comment thread
bubblobill marked this conversation as resolved.
Outdated
/**
* Sets the content for the stat sheet. The content is a HTML page that is rendered using the
Expand Down Expand Up @@ -67,6 +80,10 @@ public void setContent(Token token, String content, URL entry, StatSheetLocation
null);
}
});
if (HBD != null) {
Platform.runLater(
() -> HBD.publish(statSheetContext, token, content, entry, output.getHtmlString()));
}
} catch (IOException e) {
MapTool.showError("msg.error.renderingStatSheet", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ public int hashCode() {

@Override
public String toString() {
return toString(true);
}

public String toString(boolean localised) {
StringBuilder sb = new StringBuilder();
sb.append("name=").append(getName()).append(";");
sb.append("layer=").append(getLayer()).append(";");
if (localised) {
sb.append("layer=").append(getLayer()).append(";");
} else {
sb.append("layer=").append(getLayer().name()).append(";");
}
sb.append("id=").append(getId()).append(";");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ private Object applyAA(Graphics2D g) {

@Override
public String toString() {
StringBuilder sb = new StringBuilder(super.toString());
return toString(true);
}

public String toString(boolean localised) {
StringBuilder sb = new StringBuilder(super.toString(localised));
sb.append("antiAliasing=").append(getUseAntiAliasing()).append(";");
sb.append("shapeType=").append(getShapeTypeName()).append(";");
sb.append("bounds=\"");
Expand Down
Loading