respawnspeed (originally spawnchance) renamed & added to UI

This commit is contained in:
OMGeeky
2023-08-30 14:40:50 +02:00
parent 693de98212
commit 862f4b7366
4 changed files with 2870 additions and 2865 deletions

View File

@@ -1,6 +1,6 @@
!include MUI2.nsh !include MUI2.nsh
!define VERSION "0.6.18" !define VERSION "0.6.19"
!define TRAINER_VERSION "0.1.5" !define TRAINER_VERSION "0.1.5"
!define JAVA_BIN "javaw" !define JAVA_BIN "javaw"
@@ -172,4 +172,4 @@ Function GetJRE
JreFound: JreFound:
Pop $R1 Pop $R1
Exch $R0 Exch $R0
FunctionEnd FunctionEnd

View File

@@ -1,227 +1,227 @@
package com.gpl.rpg.atcontentstudio; package com.gpl.rpg.atcontentstudio;
import java.awt.Color; import java.awt.Color;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.JEditorPane; import javax.swing.JEditorPane;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import javax.swing.plaf.FontUIResource; import javax.swing.plaf.FontUIResource;
import prefuse.data.expression.parser.ExpressionParser; import prefuse.data.expression.parser.ExpressionParser;
import com.gpl.rpg.atcontentstudio.model.Workspace; import com.gpl.rpg.atcontentstudio.model.Workspace;
import com.gpl.rpg.atcontentstudio.ui.StudioFrame; import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog; import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector; 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 = "v0.6.18"; public static final String APP_VERSION = "v0.6.19";
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 reset these loggers. //Need to keep a strong reference to it, to avoid garbage collection that'll 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 { try {
String laf = ConfigCache.getFavoriteLaFClassName(); String laf = ConfigCache.getFavoriteLaFClassName();
if (laf == null) laf = UIManager.getSystemLookAndFeelClassName(); if (laf == null) laf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(laf); UIManager.setLookAndFeel(laf);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) { } catch (UnsupportedLookAndFeelException e) {
e.printStackTrace(); e.printStackTrace();
} }
scaleUIFont(); scaleUIFont();
//Need to keep a strong reference to it, to avoid garbage collection that'll reset this setting. //Need to keep a strong reference to it, to avoid garbage collection that'll reset this setting.
Logger l = Logger.getLogger(ExpressionParser.class.getName()); Logger l = Logger.getLogger(ExpressionParser.class.getName());
l.setLevel(Level.OFF); l.setLevel(Level.OFF);
configuredLoggers.add(l); configuredLoggers.add(l);
final WorkspaceSelector wsSelect = new WorkspaceSelector(); final WorkspaceSelector wsSelect = new WorkspaceSelector();
wsSelect.pack(); wsSelect.pack();
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
Dimension wdim = wsSelect.getSize(); Dimension wdim = wsSelect.getSize();
wsSelect.setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2); wsSelect.setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2);
wsSelect.setVisible(true); wsSelect.setVisible(true);
wsSelect.addWindowListener(new WindowAdapter() { wsSelect.addWindowListener(new WindowAdapter() {
@Override @Override
public synchronized void windowClosed(WindowEvent e) { public synchronized void windowClosed(WindowEvent e) {
if (wsSelect.selected != null && !STARTED) { if (wsSelect.selected != null && !STARTED) {
ATContentStudio.STARTED = true; ATContentStudio.STARTED = true;
final File workspaceRoot = new File(wsSelect.selected); final File workspaceRoot = new File(wsSelect.selected);
WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable(){ WorkerDialog.showTaskMessage("Loading your workspace...", null, new Runnable(){
public void run() { public void run() {
Workspace.setActive(workspaceRoot); Workspace.setActive(workspaceRoot);
if (Workspace.activeWorkspace.settings.useInternet.getCurrentValue() && Workspace.activeWorkspace.settings.checkUpdates.getCurrentValue()) { if (Workspace.activeWorkspace.settings.useInternet.getCurrentValue() && Workspace.activeWorkspace.settings.checkUpdates.getCurrentValue()) {
new Thread() { new Thread() {
public void run() {checkUpdate();} public void run() {checkUpdate();}
}.start(); }.start();
} }
frame = new StudioFrame(APP_NAME+" "+APP_VERSION); frame = new StudioFrame(APP_NAME+" "+APP_VERSION);
frame.setVisible(true); frame.setVisible(true);
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE); frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
}; };
}); });
for (File f : ConfigCache.getKnownWorkspaces()) { for (File f : ConfigCache.getKnownWorkspaces()) {
if (workspaceRoot.equals(f)) { if (workspaceRoot.equals(f)) {
if (!workspaceRoot.equals(ConfigCache.getLatestWorkspace())) { if (!workspaceRoot.equals(ConfigCache.getLatestWorkspace())) {
ConfigCache.setLatestWorkspace(f); ConfigCache.setLatestWorkspace(f);
} }
return; return;
} }
} }
ConfigCache.addWorkspace(workspaceRoot); ConfigCache.addWorkspace(workspaceRoot);
ConfigCache.setLatestWorkspace(workspaceRoot); ConfigCache.setLatestWorkspace(workspaceRoot);
} }
} }
}); });
} }
private static void checkUpdate() { private static void checkUpdate() {
BufferedReader in = null; BufferedReader in = null;
try { try {
URL url = new URL(CHECK_UPDATE_URL); URL url = new URL(CHECK_UPDATE_URL);
in = new BufferedReader(new InputStreamReader(url.openStream())); in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine, lastLine = null; String inputLine, lastLine = null;
while ((inputLine = in.readLine()) != null) {lastLine = inputLine;} while ((inputLine = in.readLine()) != null) {lastLine = inputLine;}
if (lastLine != null && !lastLine.equals(APP_VERSION)) { if (lastLine != null && !lastLine.equals(APP_VERSION)) {
// for copying style // for copying style
JLabel label = new JLabel(); JLabel label = new JLabel();
Font font = label.getFont(); Font font = label.getFont();
Color color = label.getBackground(); Color color = label.getBackground();
// create some css from the label's font // create some css from the label's font
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";"); StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";"); style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
style.append("font-size:" + font.getSize() + "pt;"); style.append("font-size:" + font.getSize() + "pt;");
style.append("background-color: rgb("+color.getRed()+","+color.getGreen()+","+color.getBlue()+");"); style.append("background-color: rgb("+color.getRed()+","+color.getGreen()+","+color.getBlue()+");");
JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">"
+ "You are not running the latest ATCS version.<br/>" + "You are not running the latest ATCS version.<br/>"
+ "You can get the latest version ("+lastLine+") by clicking the link below.<br/>" + "You can get the latest version ("+lastLine+") by clicking the link below.<br/>"
+ "<a href=\""+DOWNLOAD_URL+"\">"+DOWNLOAD_URL+"</a><br/>" + "<a href=\""+DOWNLOAD_URL+"\">"+DOWNLOAD_URL+"</a><br/>"
+ "<br/>" + "<br/>"
+ "</body></html>"); + "</body></html>");
ep.setEditable(false); ep.setEditable(false);
ep.setBorder(null); ep.setBorder(null);
ep.addHyperlinkListener(new HyperlinkListener() { ep.addHyperlinkListener(new HyperlinkListener() {
@Override @Override
public void hyperlinkUpdate(HyperlinkEvent e) { public void hyperlinkUpdate(HyperlinkEvent e) {
try { try {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
Desktop.getDesktop().browse(e.getURL().toURI()); Desktop.getDesktop().browse(e.getURL().toURI());
} }
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} catch (URISyntaxException e1) { } catch (URISyntaxException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
}); });
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
} }
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (in != null) in.close(); if (in != null) in.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public static void scaleUIFont() { public static void scaleUIFont() {
if (SCALING != 1.0f) { if (SCALING != 1.0f) {
System.out.println("Scaling fonts to "+SCALING); System.out.println("Scaling fonts to "+SCALING);
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); UIDefaults defaults = UIManager.getLookAndFeelDefaults();
Map<Object, Object> newDefaults = new HashMap<Object, Object>(); Map<Object, Object> newDefaults = new HashMap<Object, Object>();
for (Enumeration<Object> e = defaults.keys(); e.hasMoreElements();) { for (Enumeration<Object> e = defaults.keys(); e.hasMoreElements();) {
Object key = e.nextElement(); Object key = e.nextElement();
Object value = defaults.get(key); Object value = defaults.get(key);
if (value instanceof Font) { if (value instanceof Font) {
Font font = (Font) value; Font font = (Font) value;
int newSize = (int)(font.getSize() * SCALING); int newSize = (int)(font.getSize() * SCALING);
if (value instanceof FontUIResource) { if (value instanceof FontUIResource) {
newDefaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize)); newDefaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize));
} else { } else {
newDefaults.put(key, new Font(font.getName(), font.getStyle(), newSize)); newDefaults.put(key, new Font(font.getName(), font.getStyle(), newSize));
} }
} }
} }
for (Object key : newDefaults.keySet()) { for (Object key : newDefaults.keySet()) {
defaults.put(key, newDefaults.get(key)); defaults.put(key, newDefaults.get(key));
} }
} }
} }
} }

View File

@@ -11,7 +11,7 @@ import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
public class SpawnArea extends MapObject { public class SpawnArea extends MapObject {
public int quantity = 1; public int quantity = 1;
public int spawnchance = 10; public int respawnSpeed = 10;
public boolean active = true; public boolean active = true;
public boolean ignoreAreas = false; public boolean ignoreAreas = false;
public String spawngroup_id; public String spawngroup_id;
@@ -21,8 +21,8 @@ public class SpawnArea extends MapObject {
if (obj.getProperties().getProperty("quantity") != null) { if (obj.getProperties().getProperty("quantity") != null) {
this.quantity = Integer.parseInt(obj.getProperties().getProperty("quantity")); this.quantity = Integer.parseInt(obj.getProperties().getProperty("quantity"));
} }
if (obj.getProperties().getProperty("spawnchance") != null) { if (obj.getProperties().getProperty("respawnspeed") != null) {
this.spawnchance = Integer.parseInt(obj.getProperties().getProperty("spawnchance")); this.respawnSpeed = Integer.parseInt(obj.getProperties().getProperty("respawnspeed"));
} }
if (obj.getProperties().getProperty("active") != null) { if (obj.getProperties().getProperty("active") != null) {
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active")); this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
@@ -82,8 +82,8 @@ public class SpawnArea extends MapObject {
if (quantity != 1) { if (quantity != 1) {
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity)); tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
} }
if (spawnchance != 10) { if (respawnSpeed != 10) {
tmxObject.getProperties().setProperty("spawnchance", Integer.toString(spawnchance)); tmxObject.getProperties().setProperty("respawnspeed", Integer.toString(respawnSpeed));
} }
if (!this.active) { if (!this.active) {
tmxObject.getProperties().setProperty("active", Boolean.toString(active)); tmxObject.getProperties().setProperty("active", Boolean.toString(active));
@@ -92,5 +92,4 @@ public class SpawnArea extends MapObject {
tmxObject.getProperties().setProperty("ignoreAreas", Boolean.toString(ignoreAreas)); tmxObject.getProperties().setProperty("ignoreAreas", Boolean.toString(ignoreAreas));
} }
} }
} }

File diff suppressed because it is too large Load Diff