mirror of
https://github.com/OMGeeky/ATCS.git
synced 2026-02-15 22:04:29 +01:00
Compare commits
8 Commits
package-on
...
v0.6.21-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc3333bd0e | ||
|
|
e6d9d8fbda | ||
|
|
861c4c3bb1 | ||
|
|
c18fcfc667 | ||
|
|
9b1ac0d3e1 | ||
|
|
eb6377a983 | ||
|
|
2fb16c9213 | ||
|
|
6741100a4f |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" default="true" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -98,7 +98,11 @@ public class TileSet implements Iterable<Tile>
|
|||||||
|
|
||||||
File f = new File(imgFilename);
|
File f = new File(imgFilename);
|
||||||
|
|
||||||
BufferedImage image = ImageIO.read(f.getCanonicalFile());
|
BufferedImage image;
|
||||||
|
try {
|
||||||
|
image = ImageIO.read(f.getCanonicalFile());
|
||||||
|
} catch (IOException e) { throw new IOException("Failed to load " + imgFilename);
|
||||||
|
}
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
throw new IOException("Failed to load " + imgFilename);
|
throw new IOException("Failed to load " + imgFilename);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
lib/jide-oss.jar
BIN
lib/jide-oss.jar
Binary file not shown.
@@ -37,202 +37,219 @@ import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
|||||||
|
|
||||||
public class ATContentStudio {
|
public class ATContentStudio {
|
||||||
|
|
||||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||||
public static final String APP_VERSION = readVersionFromFile();
|
public static final String APP_VERSION = readVersionFromFile();
|
||||||
public static final String CHECK_UPDATE_URL = "https://andorstrail.com/static/ATCS_latest";
|
public static final String CHECK_UPDATE_URL = "https://andorstrail.com/static/ATCS_latest";
|
||||||
public static final String DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806";
|
public static final String DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806";
|
||||||
|
|
||||||
public static final String FONT_SCALE_ENV_VAR_NAME = "FONT_SCALE";
|
public static final String FONT_SCALE_ENV_VAR_NAME = "FONT_SCALE";
|
||||||
|
|
||||||
public static boolean STARTED = false;
|
public static boolean STARTED = false;
|
||||||
public static float SCALING = 1.0f;
|
public static float SCALING = 1.0f;
|
||||||
public static StudioFrame frame = null;
|
public static StudioFrame frame = null;
|
||||||
|
|
||||||
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
||||||
// reset these loggers.
|
// reset these loggers.
|
||||||
public static final List<Logger> configuredLoggers = new LinkedList<Logger>();
|
public static final List<Logger> configuredLoggers = new LinkedList<Logger>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
||||||
Float fontScale = null;
|
Float fontScale = null;
|
||||||
if (fontScaling != null) {
|
if (fontScaling != null) {
|
||||||
try {
|
try {
|
||||||
fontScale = Float.parseFloat(fontScaling);
|
fontScale = Float.parseFloat(fontScaling);
|
||||||
SCALING = fontScale;
|
SCALING = fontScale;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
System.err.println("Failed to parse font scaling parameter. Using default.");
|
System.err.println("Failed to parse font scaling parameter. Using default.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigCache.init();
|
ConfigCache.init();
|
||||||
|
|
||||||
try {
|
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
setLookAndFeel(laf);
|
||||||
if (laf == null)
|
|
||||||
laf = UIManager.getSystemLookAndFeelClassName();
|
|
||||||
UIManager.setLookAndFeel(laf);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (UnsupportedLookAndFeelException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleUIFont();
|
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
||||||
|
// reset this setting.
|
||||||
|
Logger l = Logger.getLogger(ExpressionParser.class.getName());
|
||||||
|
l.setLevel(Level.OFF);
|
||||||
|
configuredLoggers.add(l);
|
||||||
|
|
||||||
// Need to keep a strong reference to it, to avoid garbage collection that'll
|
final WorkspaceSelector wsSelect = new WorkspaceSelector();
|
||||||
// reset this setting.
|
wsSelect.pack();
|
||||||
Logger l = Logger.getLogger(ExpressionParser.class.getName());
|
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
l.setLevel(Level.OFF);
|
Dimension wdim = wsSelect.getSize();
|
||||||
configuredLoggers.add(l);
|
wsSelect.setLocation((sdim.width - wdim.width) / 2, (sdim.height - wdim.height) / 2);
|
||||||
|
wsSelect.setVisible(true);
|
||||||
|
|
||||||
final WorkspaceSelector wsSelect = new WorkspaceSelector();
|
wsSelect.addWindowListener(new WindowAdapter() {
|
||||||
wsSelect.pack();
|
@Override
|
||||||
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
|
public synchronized void windowClosed(WindowEvent e) {
|
||||||
Dimension wdim = wsSelect.getSize();
|
if (wsSelect.selected != null && !STARTED) {
|
||||||
wsSelect.setLocation((sdim.width - wdim.width) / 2, (sdim.height - wdim.height) / 2);
|
ATContentStudio.STARTED = true;
|
||||||
wsSelect.setVisible(true);
|
final File workspaceRoot = new File(wsSelect.selected);
|
||||||
|
WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Workspace.setActive(workspaceRoot);
|
||||||
|
if (Workspace.activeWorkspace.settings.useInternet.getCurrentValue()
|
||||||
|
&& Workspace.activeWorkspace.settings.checkUpdates.getCurrentValue()) {
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
checkUpdate();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
frame = new StudioFrame(APP_NAME + " " + APP_VERSION);
|
||||||
|
frame.setVisible(true);
|
||||||
|
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
wsSelect.addWindowListener(new WindowAdapter() {
|
;
|
||||||
@Override
|
});
|
||||||
public synchronized void windowClosed(WindowEvent e) {
|
for (File f : ConfigCache.getKnownWorkspaces()) {
|
||||||
if (wsSelect.selected != null && !STARTED) {
|
if (workspaceRoot.equals(f)) {
|
||||||
ATContentStudio.STARTED = true;
|
if (!workspaceRoot.equals(ConfigCache.getLatestWorkspace())) {
|
||||||
final File workspaceRoot = new File(wsSelect.selected);
|
ConfigCache.setLatestWorkspace(f);
|
||||||
WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable() {
|
}
|
||||||
public void run() {
|
return;
|
||||||
Workspace.setActive(workspaceRoot);
|
}
|
||||||
if (Workspace.activeWorkspace.settings.useInternet.getCurrentValue()
|
}
|
||||||
&& Workspace.activeWorkspace.settings.checkUpdates.getCurrentValue()) {
|
ConfigCache.addWorkspace(workspaceRoot);
|
||||||
new Thread() {
|
ConfigCache.setLatestWorkspace(workspaceRoot);
|
||||||
public void run() {
|
|
||||||
checkUpdate();
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
frame = new StudioFrame(APP_NAME + " " + APP_VERSION);
|
|
||||||
frame.setVisible(true);
|
|
||||||
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
for (File f : ConfigCache.getKnownWorkspaces()) {
|
|
||||||
if (workspaceRoot.equals(f)) {
|
|
||||||
if (!workspaceRoot.equals(ConfigCache.getLatestWorkspace())) {
|
|
||||||
ConfigCache.setLatestWorkspace(f);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConfigCache.addWorkspace(workspaceRoot);
|
|
||||||
ConfigCache.setLatestWorkspace(workspaceRoot);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkUpdate() {
|
public static void setLookAndFeel(String laf) {
|
||||||
BufferedReader in = null;
|
if (laf == null)
|
||||||
try {
|
{
|
||||||
URL url = new URL(CHECK_UPDATE_URL);
|
System.out.println("No look and feel specified, using system default.");
|
||||||
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
laf = UIManager.getSystemLookAndFeelClassName();
|
||||||
|
}
|
||||||
|
System.out.println("Info: Setting look and feel to: " + laf);
|
||||||
|
|
||||||
String inputLine, lastLine = null;
|
try {
|
||||||
while ((inputLine = in.readLine()) != null) {
|
UIManager.setLookAndFeel(laf);
|
||||||
lastLine = inputLine;
|
} catch (ClassNotFoundException e) {
|
||||||
}
|
System.err.println("Failed to load system look and feel. ");
|
||||||
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
System.err.println("Installed look and feel classes: ");
|
||||||
|
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
|
||||||
|
System.err.println(" " + info.getName() + " (" + info.getClassName() + ")");
|
||||||
|
}
|
||||||
|
System.err.println("Tried to load: " + laf + " but got this error:");
|
||||||
|
|
||||||
// for copying style
|
e.printStackTrace();
|
||||||
JLabel label = new JLabel();
|
} catch (InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) {
|
||||||
Font font = label.getFont();
|
e.printStackTrace();
|
||||||
Color color = label.getBackground();
|
}
|
||||||
|
var newLaF = UIManager.getLookAndFeel();
|
||||||
|
System.out.println("Using look and feel: " + newLaF.getName() + " (" + newLaF.getClass().getName() + ")");
|
||||||
|
|
||||||
// create some css from the label's font
|
scaleUIFont();
|
||||||
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
|
}
|
||||||
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
|
|
||||||
style.append("font-size:" + font.getSize() + "pt;");
|
|
||||||
style.append("background-color: rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
|
||||||
+ ");");
|
|
||||||
|
|
||||||
JEditorPane ep = new JEditorPane("text/html",
|
private static void checkUpdate() {
|
||||||
"<html><body style=\"" + style + "\">" + "You are not running the latest ATCS version.<br/>"
|
BufferedReader in = null;
|
||||||
+ "You can get the latest version (" + lastLine + ") by clicking the link below.<br/>"
|
try {
|
||||||
+ "<a href=\"" + DOWNLOAD_URL + "\">" + DOWNLOAD_URL + "</a><br/>" + "<br/>"
|
URL url = new URL(CHECK_UPDATE_URL);
|
||||||
+ "</body></html>");
|
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
|
|
||||||
ep.setEditable(false);
|
String inputLine, lastLine = null;
|
||||||
ep.setBorder(null);
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
lastLine = inputLine;
|
||||||
|
}
|
||||||
|
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
||||||
|
|
||||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
// for copying style
|
||||||
|
JLabel label = new JLabel();
|
||||||
|
Font font = label.getFont();
|
||||||
|
Color color = label.getBackground();
|
||||||
|
|
||||||
@Override
|
// create some css from the label's font
|
||||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
|
||||||
try {
|
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
|
||||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
style.append("font-size:" + font.getSize() + "pt;");
|
||||||
Desktop.getDesktop().browse(e.getURL().toURI());
|
style.append("background-color: rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||||
}
|
+ ");");
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (URISyntaxException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
|
JEditorPane ep = new JEditorPane("text/html",
|
||||||
}
|
"<html><body style=\"" + style + "\">" + "You are not running the latest ATCS version.<br/>"
|
||||||
} catch (MalformedURLException e) {
|
+ "You can get the latest version (" + lastLine + ") by clicking the link below.<br/>"
|
||||||
e.printStackTrace();
|
+ "<a href=\"" + DOWNLOAD_URL + "\">" + DOWNLOAD_URL + "</a><br/>" + "<br/>"
|
||||||
} catch (IOException e) {
|
+ "</body></html>");
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (in != null)
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void scaleUIFont() {
|
ep.setEditable(false);
|
||||||
if (SCALING != 1.0f) {
|
ep.setBorder(null);
|
||||||
System.out.println("Scaling fonts to " + SCALING);
|
|
||||||
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
|
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||||
Map<Object, Object> newDefaults = new HashMap<Object, Object>();
|
|
||||||
for (Enumeration<Object> e = defaults.keys(); e.hasMoreElements();) {
|
@Override
|
||||||
Object key = e.nextElement();
|
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||||
Object value = defaults.get(key);
|
try {
|
||||||
if (value instanceof Font) {
|
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||||
Font font = (Font) value;
|
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||||
int newSize = (int) (font.getSize() * SCALING);
|
}
|
||||||
if (value instanceof FontUIResource) {
|
} catch (IOException e1) {
|
||||||
newDefaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize));
|
e1.printStackTrace();
|
||||||
} else {
|
} catch (URISyntaxException e1) {
|
||||||
newDefaults.put(key, new Font(font.getName(), font.getStyle(), newSize));
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
for (Object key : newDefaults.keySet()) {
|
|
||||||
defaults.put(key, newDefaults.get(key));
|
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
} catch (MalformedURLException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
private static String readVersionFromFile() {
|
} catch (IOException e) {
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (in != null)
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void scaleUIFont() {
|
||||||
|
if (SCALING != 1.0f) {
|
||||||
|
System.out.println("Scaling fonts to " + SCALING);
|
||||||
|
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
|
||||||
|
Map<Object, Object> newDefaults = new HashMap<Object, Object>();
|
||||||
|
for (Enumeration<Object> e = defaults.keys(); e.hasMoreElements(); ) {
|
||||||
|
Object key = e.nextElement();
|
||||||
|
Object value = defaults.get(key);
|
||||||
|
if (value instanceof Font) {
|
||||||
|
Font font = (Font) value;
|
||||||
|
int newSize = (int) (font.getSize() * SCALING);
|
||||||
|
if (value instanceof FontUIResource) {
|
||||||
|
newDefaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize));
|
||||||
|
} else {
|
||||||
|
newDefaults.put(key, new Font(font.getName(), font.getStyle(), newSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Object key : newDefaults.keySet()) {
|
||||||
|
defaults.put(key, newDefaults.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readVersionFromFile() {
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||||
Objects.requireNonNull(ATContentStudio.class.getResourceAsStream("/ATCS_latest"))))) {
|
Objects.requireNonNull(ATContentStudio.class.getResourceAsStream("/ATCS_latest"))))) {
|
||||||
return reader.readLine();
|
return reader.readLine();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,6 +333,10 @@ public class NPC extends JSONElement {
|
|||||||
}
|
}
|
||||||
if (this.icon_id != null) {
|
if (this.icon_id != null) {
|
||||||
String spritesheetId = this.icon_id.split(":")[0];
|
String spritesheetId = this.icon_id.split(":")[0];
|
||||||
|
if (proj.getSpritesheet(spritesheetId) == null) {
|
||||||
|
Notification.addError("Error Spritesheet "+id+". has no backlink.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
proj.getSpritesheet(spritesheetId).addBacklink(this);
|
proj.getSpritesheet(spritesheetId).addBacklink(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,21 +162,12 @@ public class StudioFrame extends JFrame {
|
|||||||
changeLaF.add(lafItem);
|
changeLaF.add(lafItem);
|
||||||
lafItem.addActionListener(new ActionListener() {
|
lafItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e1) {
|
||||||
try {
|
String lookAndFeel = i.getClassName();
|
||||||
UIManager.setLookAndFeel(i.getClassName());
|
ATContentStudio.setLookAndFeel(lookAndFeel);
|
||||||
ATContentStudio.scaleUIFont();
|
SwingUtilities.updateComponentTreeUI(ATContentStudio.frame);
|
||||||
SwingUtilities.updateComponentTreeUI(ATContentStudio.frame);
|
ConfigCache.setFavoriteLaFClassName(lookAndFeel);
|
||||||
ConfigCache.setFavoriteLaFClassName(i.getClassName());
|
|
||||||
} catch (ClassNotFoundException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (InstantiationException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (UnsupportedLookAndFeelException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user