mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
Merge branch 'v0.6.19'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="ATContentStudio/ATCS_v0.6.18.jar"/>
|
||||
<jar path="ATContentStudio/ATCS_v0.6.19.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATContentStudio/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
|
||||
@@ -1 +1 @@
|
||||
v0.6.18
|
||||
v0.6.19
|
||||
@@ -1,8 +1,8 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
!define VERSION "0.6.18"
|
||||
!define VERSION "0.6.19"
|
||||
!define TRAINER_VERSION "0.1.5"
|
||||
!define JAVA_BIN "javaw"
|
||||
!define JAVA_BIN "java"
|
||||
|
||||
Name "Andor's Trail Content Studio v${VERSION}"
|
||||
OutFile "ATCS_v${VERSION}_Setup.exe"
|
||||
@@ -88,7 +88,7 @@ Section install
|
||||
file "C:\AT\ATCS_source\lib\AndorsTrainer_v${TRAINER_VERSION}.jar"
|
||||
file "C:\AT\ATCS_source\lib\junit-4.10.jar"
|
||||
file "C:\AT\ATCS_source\lib\json_simple-1.1.jar"
|
||||
file "C:\AT\temp\ATCS_v0.6.18\ATCS_v${VERSION}.jar"
|
||||
file "C:\AT\temp\ATCS_v0.6.19\ATCS_v${VERSION}.jar"
|
||||
file "C:\AT\ATCS_source\lib\rsyntaxtextarea.jar"
|
||||
file "C:\AT\ATCS_source\lib\prefuse.jar"
|
||||
file "C:\AT\ATCS_source\lib\bsh-2.0b4.jar"
|
||||
@@ -172,4 +172,4 @@ Function GetJRE
|
||||
JreFound:
|
||||
Pop $R1
|
||||
Exch $R0
|
||||
FunctionEnd
|
||||
FunctionEnd
|
||||
|
||||
@@ -30,7 +30,9 @@ atcs.spritesheet.items_misc_4.category=item
|
||||
atcs.spritesheet.items_misc_5.category=item
|
||||
atcs.spritesheet.items_misc_6.category=item
|
||||
atcs.spritesheet.items_necklaces_1.category=item
|
||||
atcs.spritesheet.items_omgeeky.category=item
|
||||
atcs.spritesheet.items_omi2.category=item
|
||||
atcs.spritesheet.items_phoenix01.category=item
|
||||
atcs.spritesheet.items_reterski_1.category=item
|
||||
atcs.spritesheet.items_rijackson_1.category=item
|
||||
atcs.spritesheet.items_rings_1.category=item
|
||||
@@ -42,16 +44,19 @@ atcs.spritesheet.items_weapons_2.category=item
|
||||
atcs.spritesheet.items_weapons_3.category=item
|
||||
|
||||
atcs.spritesheet.monsters_armor1.category=monster
|
||||
atcs.spritesheet.monsters_arulirs.category=monster
|
||||
|
||||
atcs.spritesheet.monsters_dogs.category=monster
|
||||
atcs.spritesheet.monsters_eye1.category=monster
|
||||
atcs.spritesheet.monsters_eye2.category=monster
|
||||
atcs.spritesheet.monsters_eye3.category=monster
|
||||
atcs.spritesheet.monsters_eye4.category=monster
|
||||
|
||||
atcs.spritesheet.monsters_fatboy73.category=monster
|
||||
atcs.spritesheet.monsters_ghost1.category=monster
|
||||
|
||||
atcs.spritesheet.monsters_gisons.category=monster
|
||||
atcs.spritesheet.monsters_guynmart.category=monster
|
||||
|
||||
atcs.spritesheet.monsters_insects.category=monster
|
||||
atcs.spritesheet.monsters_karvis1.category=monster
|
||||
atcs.spritesheet.monsters_karvis2.category=monster
|
||||
@@ -68,6 +73,7 @@ atcs.spritesheet.monsters_misc.category=monster
|
||||
atcs.spritesheet.monsters_omi1.category=monster
|
||||
atcs.spritesheet.monsters_omi1_b.category=monster
|
||||
atcs.spritesheet.monsters_omi2.category=monster
|
||||
atcs.spritesheet.monsters_phoenix01.category=monster
|
||||
atcs.spritesheet.monsters_rats.category=monster
|
||||
atcs.spritesheet.monsters_redshrike1.category=monster
|
||||
atcs.spritesheet.monsters_rltiles1.category=monster
|
||||
@@ -79,7 +85,6 @@ atcs.spritesheet.monsters_skeleton1.category=monster
|
||||
atcs.spritesheet.monsters_skeleton2.category=monster
|
||||
atcs.spritesheet.monsters_snakes.category=monster
|
||||
atcs.spritesheet.monsters_tometik1.category=monster
|
||||
atcs.spritesheet.monsters_tometik10.category=monster
|
||||
atcs.spritesheet.monsters_tometik2.category=monster
|
||||
atcs.spritesheet.monsters_tometik3.category=monster
|
||||
atcs.spritesheet.monsters_tometik4.category=monster
|
||||
@@ -88,6 +93,7 @@ atcs.spritesheet.monsters_tometik6.category=monster
|
||||
atcs.spritesheet.monsters_tometik7.category=monster
|
||||
atcs.spritesheet.monsters_tometik8.category=monster
|
||||
atcs.spritesheet.monsters_tometik9.category=monster
|
||||
atcs.spritesheet.monsters_tometik10.category=monster
|
||||
atcs.spritesheet.monsters_warrior1.category=monster
|
||||
atcs.spritesheet.monsters_unknown.category=monster
|
||||
atcs.spritesheet.monsters_wraiths.category=monster
|
||||
|
||||
@@ -1,227 +1,227 @@
|
||||
package com.gpl.rpg.atcontentstudio;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
|
||||
import prefuse.data.expression.parser.ExpressionParser;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||
|
||||
|
||||
public class ATContentStudio {
|
||||
|
||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||
public static final String APP_VERSION = "v0.6.18";
|
||||
|
||||
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 FONT_SCALE_ENV_VAR_NAME = "FONT_SCALE";
|
||||
|
||||
public static boolean STARTED = false;
|
||||
public static float SCALING=1.0f;
|
||||
public static StudioFrame frame = null;
|
||||
|
||||
//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>();
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
||||
Float fontScale = null;
|
||||
if (fontScaling != null) {
|
||||
try {
|
||||
fontScale = Float.parseFloat(fontScaling);
|
||||
SCALING=fontScale;
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Failed to parse font scaling parameter. Using default.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigCache.init();
|
||||
|
||||
try {
|
||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||
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);
|
||||
|
||||
final WorkspaceSelector wsSelect = new WorkspaceSelector();
|
||||
wsSelect.pack();
|
||||
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Dimension wdim = wsSelect.getSize();
|
||||
wsSelect.setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2);
|
||||
wsSelect.setVisible(true);
|
||||
|
||||
wsSelect.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public synchronized void windowClosed(WindowEvent e) {
|
||||
if (wsSelect.selected != null && !STARTED) {
|
||||
ATContentStudio.STARTED = 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);
|
||||
};
|
||||
});
|
||||
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() {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
URL url = new URL(CHECK_UPDATE_URL);
|
||||
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
|
||||
String inputLine, lastLine = null;
|
||||
while ((inputLine = in.readLine()) != null) {lastLine = inputLine;}
|
||||
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
||||
|
||||
// for copying style
|
||||
JLabel label = new JLabel();
|
||||
Font font = label.getFont();
|
||||
Color color = label.getBackground();
|
||||
|
||||
// create some css from the label's font
|
||||
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", "<html><body style=\"" + style + "\">"
|
||||
+ "You are not running the latest ATCS version.<br/>"
|
||||
+ "You can get the latest version ("+lastLine+") by clicking the link below.<br/>"
|
||||
+ "<a href=\""+DOWNLOAD_URL+"\">"+DOWNLOAD_URL+"</a><br/>"
|
||||
+ "<br/>"
|
||||
+ "</body></html>");
|
||||
|
||||
ep.setEditable(false);
|
||||
ep.setBorder(null);
|
||||
|
||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
try {
|
||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (URISyntaxException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gpl.rpg.atcontentstudio;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
|
||||
import prefuse.data.expression.parser.ExpressionParser;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||
|
||||
|
||||
public class ATContentStudio {
|
||||
|
||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||
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 DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806";
|
||||
|
||||
public static final String FONT_SCALE_ENV_VAR_NAME = "FONT_SCALE";
|
||||
|
||||
public static boolean STARTED = false;
|
||||
public static float SCALING=1.0f;
|
||||
public static StudioFrame frame = null;
|
||||
|
||||
//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>();
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String fontScaling = System.getProperty(FONT_SCALE_ENV_VAR_NAME);
|
||||
Float fontScale = null;
|
||||
if (fontScaling != null) {
|
||||
try {
|
||||
fontScale = Float.parseFloat(fontScaling);
|
||||
SCALING=fontScale;
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Failed to parse font scaling parameter. Using default.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigCache.init();
|
||||
|
||||
try {
|
||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||
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);
|
||||
|
||||
final WorkspaceSelector wsSelect = new WorkspaceSelector();
|
||||
wsSelect.pack();
|
||||
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Dimension wdim = wsSelect.getSize();
|
||||
wsSelect.setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2);
|
||||
wsSelect.setVisible(true);
|
||||
|
||||
wsSelect.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public synchronized void windowClosed(WindowEvent e) {
|
||||
if (wsSelect.selected != null && !STARTED) {
|
||||
ATContentStudio.STARTED = 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);
|
||||
};
|
||||
});
|
||||
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() {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
URL url = new URL(CHECK_UPDATE_URL);
|
||||
in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
|
||||
String inputLine, lastLine = null;
|
||||
while ((inputLine = in.readLine()) != null) {lastLine = inputLine;}
|
||||
if (lastLine != null && !lastLine.equals(APP_VERSION)) {
|
||||
|
||||
// for copying style
|
||||
JLabel label = new JLabel();
|
||||
Font font = label.getFont();
|
||||
Color color = label.getBackground();
|
||||
|
||||
// create some css from the label's font
|
||||
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", "<html><body style=\"" + style + "\">"
|
||||
+ "You are not running the latest ATCS version.<br/>"
|
||||
+ "You can get the latest version ("+lastLine+") by clicking the link below.<br/>"
|
||||
+ "<a href=\""+DOWNLOAD_URL+"\">"+DOWNLOAD_URL+"</a><br/>"
|
||||
+ "<br/>"
|
||||
+ "</body></html>");
|
||||
|
||||
ep.setEditable(false);
|
||||
ep.setBorder(null);
|
||||
|
||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
try {
|
||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (URISyntaxException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JOptionPane.showMessageDialog(null, ep, "Update available", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
public class SpawnArea extends MapObject {
|
||||
|
||||
public int quantity = 1;
|
||||
public int spawnchance = 10;
|
||||
public int respawnSpeed = 10;
|
||||
public boolean active = true;
|
||||
public boolean ignoreAreas = false;
|
||||
public String spawngroup_id;
|
||||
@@ -21,8 +21,8 @@ public class SpawnArea extends MapObject {
|
||||
if (obj.getProperties().getProperty("quantity") != null) {
|
||||
this.quantity = Integer.parseInt(obj.getProperties().getProperty("quantity"));
|
||||
}
|
||||
if (obj.getProperties().getProperty("spawnchance") != null) {
|
||||
this.spawnchance = Integer.parseInt(obj.getProperties().getProperty("spawnchance"));
|
||||
if (obj.getProperties().getProperty("respawnspeed") != null) {
|
||||
this.respawnSpeed = Integer.parseInt(obj.getProperties().getProperty("respawnspeed"));
|
||||
}
|
||||
if (obj.getProperties().getProperty("active") != null) {
|
||||
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
||||
@@ -82,8 +82,8 @@ public class SpawnArea extends MapObject {
|
||||
if (quantity != 1) {
|
||||
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
||||
}
|
||||
if (spawnchance != 10) {
|
||||
tmxObject.getProperties().setProperty("spawnchance", Integer.toString(spawnchance));
|
||||
if (respawnSpeed != 10) {
|
||||
tmxObject.getProperties().setProperty("respawnspeed", Integer.toString(respawnSpeed));
|
||||
}
|
||||
if (!this.active) {
|
||||
tmxObject.getProperties().setProperty("active", Boolean.toString(active));
|
||||
@@ -92,5 +92,4 @@ public class SpawnArea extends MapObject {
|
||||
tmxObject.getProperties().setProperty("ignoreAreas", Boolean.toString(ignoreAreas));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,34 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui.sprites;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet.Category;
|
||||
import com.gpl.rpg.atcontentstudio.utils.SpriteUtils;
|
||||
|
||||
|
||||
public class SpriteChooser extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -6018113265015159521L;
|
||||
|
||||
|
||||
private static final int STD_WIDTH = 32;
|
||||
private static final int STD_HEIGHT = 32;
|
||||
private static final int MAX_PER_ROW = 10;
|
||||
|
||||
public static Map<Project, Map<Spritesheet.Category, SpriteChooser>> cache = new LinkedHashMap<Project, Map<Spritesheet.Category,SpriteChooser>>();
|
||||
public static Map<Project, Map<Spritesheet.Category, List<Spritesheet>>> cacheValidator = new LinkedHashMap<Project, Map<Category,List<Spritesheet>>>();
|
||||
|
||||
|
||||
|
||||
public static Map<Project, Map<Spritesheet.Category, SpriteChooser>> cache = new LinkedHashMap<Project, Map<Spritesheet.Category, SpriteChooser>>();
|
||||
public static Map<Project, Map<Spritesheet.Category, List<Spritesheet>>> cacheValidator = new LinkedHashMap<Project, Map<Category, List<Spritesheet>>>();
|
||||
|
||||
|
||||
public static SpriteChooser getChooser(Project proj, Spritesheet.Category category) {
|
||||
if (cache.get(proj) == null) {
|
||||
cache.put(proj, new LinkedHashMap<Spritesheet.Category, SpriteChooser>());
|
||||
@@ -46,13 +37,13 @@ public class SpriteChooser extends JDialog {
|
||||
cache.get(proj).put(category, new SpriteChooser(proj, category));
|
||||
} else {
|
||||
List<Spritesheet> spritesheets = new ArrayList<Spritesheet>();
|
||||
for (int i=0; i<proj.getSpritesheetCount(); i++) {
|
||||
for (int i = 0; i < proj.getSpritesheetCount(); i++) {
|
||||
Spritesheet sheet = proj.getSpritesheet(i);
|
||||
if (sheet.category == category) {
|
||||
spritesheets.add(sheet);
|
||||
}
|
||||
}
|
||||
if ( !spritesheets.equals(cacheValidator.get(proj).get(category)) ) {
|
||||
if (!spritesheets.equals(cacheValidator.get(proj).get(category))) {
|
||||
cache.get(proj).put(category, new SpriteChooser(proj, category));
|
||||
}
|
||||
}
|
||||
@@ -65,20 +56,20 @@ public class SpriteChooser extends JDialog {
|
||||
wanted.pack();
|
||||
return wanted;
|
||||
}
|
||||
|
||||
|
||||
private ButtonGroup group;
|
||||
// private IconButton selectedOne = null;
|
||||
// private JButton ok;
|
||||
// private JButton cancel;
|
||||
|
||||
|
||||
public String selectedIconId = null;
|
||||
|
||||
|
||||
public SpriteChooser(Project proj, Category category) {
|
||||
super(ATContentStudio.frame);
|
||||
setTitle("Select a sprite");
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
List<Spritesheet> spritesheets = new ArrayList<Spritesheet>();
|
||||
for (int i=0; i<proj.getSpritesheetCount(); i++) {
|
||||
for (int i = 0; i < proj.getSpritesheetCount(); i++) {
|
||||
Spritesheet sheet = proj.getSpritesheet(i);
|
||||
if (sheet.category == category) {
|
||||
spritesheets.add(sheet);
|
||||
@@ -88,8 +79,8 @@ public class SpriteChooser extends JDialog {
|
||||
cacheValidator.put(proj, new LinkedHashMap<Spritesheet.Category, List<Spritesheet>>());
|
||||
}
|
||||
cacheValidator.get(proj).put(category, spritesheets);
|
||||
|
||||
|
||||
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new GridBagLayout());
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
@@ -101,16 +92,20 @@ public class SpriteChooser extends JDialog {
|
||||
c.gridheight = 1;
|
||||
c.anchor = GridBagConstraints.NORTHWEST;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
|
||||
|
||||
List<Point> reservedSlots = new ArrayList<Point>();
|
||||
Point nextFreeSlot = new Point(0, 0);
|
||||
|
||||
|
||||
int i;
|
||||
Image img;
|
||||
BufferedImage img;
|
||||
group = new ButtonGroup();
|
||||
//For every sprite find a free space in panel:
|
||||
for (Spritesheet sheet : spritesheets) {
|
||||
i = 0;
|
||||
while ((img = sheet.getImage(i)) != null) {
|
||||
i = -1;
|
||||
while ((img = sheet.getImage(++i)) != null) {
|
||||
if (SpriteUtils.checkIsImageEmpty(img)) {
|
||||
continue;
|
||||
}
|
||||
IconButton button = new IconButton(img, sheet.id, i);
|
||||
group.add(button);
|
||||
if (sheet.spriteWidth == STD_WIDTH && sheet.spriteHeight == STD_HEIGHT) {
|
||||
@@ -120,7 +115,7 @@ public class SpriteChooser extends JDialog {
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
}
|
||||
nextFreeSlot.setLocation(c.gridx, c.gridy);
|
||||
nextFreeSlot.setLocation(c.gridx, c.gridy);
|
||||
} else {
|
||||
c.gridwidth = (sheet.spriteWidth / STD_WIDTH) + (sheet.spriteWidth % STD_WIDTH == 0 ? 0 : 1);
|
||||
c.gridheight = (sheet.spriteHeight / STD_HEIGHT) + (sheet.spriteHeight % STD_HEIGHT == 0 ? 0 : 1);
|
||||
@@ -131,14 +126,20 @@ public class SpriteChooser extends JDialog {
|
||||
for (int y = c.gridy; y < c.gridy + c.gridwidth; y++) {
|
||||
if (reservedSlots.contains(new Point(x, y))) {
|
||||
slotOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!slotOk) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slotOk && c.gridx + c.gridwidth > MAX_PER_ROW) {
|
||||
if (c.gridx + c.gridwidth > MAX_PER_ROW) {
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
slotOk = false;
|
||||
}
|
||||
} else if (!slotOk) {
|
||||
c.gridx++;
|
||||
}
|
||||
}
|
||||
pane.add(button, c);
|
||||
for (int x = c.gridx; x < c.gridx + c.gridwidth; x++) {
|
||||
@@ -157,15 +158,14 @@ public class SpriteChooser extends JDialog {
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
}
|
||||
nextFreeSlot.setLocation(c.gridx, c.gridy);
|
||||
nextFreeSlot.setLocation(c.gridx, c.gridy);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ok = new JButton("Ok");
|
||||
// cancel = new JButton("Cancel");
|
||||
|
||||
|
||||
c.gridx = 0;
|
||||
boolean emptyLine = false;
|
||||
while (!emptyLine) {
|
||||
@@ -178,7 +178,7 @@ public class SpriteChooser extends JDialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// JPanel buttonPane = new JPanel();
|
||||
// buttonPane.add(cancel, BorderLayout.WEST);
|
||||
// buttonPane.add(ok, BorderLayout.EAST);
|
||||
@@ -190,7 +190,7 @@ public class SpriteChooser extends JDialog {
|
||||
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
wrapper.add(scroller, BorderLayout.CENTER);
|
||||
// wrapper.add(buttonPane, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
// ok.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
@@ -200,7 +200,7 @@ public class SpriteChooser extends JDialog {
|
||||
// if (listener != null) listener.iconSelected(selectedIconId);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// cancel.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
@@ -210,21 +210,21 @@ public class SpriteChooser extends JDialog {
|
||||
// if (listener != null) listener.iconSelected(null);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
setContentPane(wrapper);
|
||||
}
|
||||
|
||||
|
||||
private SpriteChooser.SelectionListener listener = null;
|
||||
|
||||
|
||||
public void setSelectionListener(SpriteChooser.SelectionListener l) {
|
||||
listener = l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class IconButton extends JToggleButton {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 7559407153561178455L;
|
||||
|
||||
|
||||
public String sheetId;
|
||||
public int spriteIndex;
|
||||
|
||||
@@ -232,12 +232,12 @@ public class SpriteChooser extends JDialog {
|
||||
super(new ImageIcon(img));
|
||||
this.sheetId = sheetId;
|
||||
this.spriteIndex = spriteIndex;
|
||||
setToolTipText(sheetId+":"+spriteIndex);
|
||||
setToolTipText(sheetId + ":" + spriteIndex);
|
||||
addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (IconButton.this.isSelected()) {
|
||||
selectedIconId = IconButton.this.sheetId+":"+IconButton.this.spriteIndex;
|
||||
selectedIconId = IconButton.this.sheetId + ":" + IconButton.this.spriteIndex;
|
||||
SpriteChooser.this.setVisible(false);
|
||||
SpriteChooser.this.dispose();
|
||||
if (listener != null) listener.iconSelected(selectedIconId);
|
||||
@@ -246,9 +246,9 @@ public class SpriteChooser extends JDialog {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static interface SelectionListener {
|
||||
public void iconSelected(String selected);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
34
src/com/gpl/rpg/atcontentstudio/utils/SpriteUtils.java
Normal file
34
src/com/gpl/rpg/atcontentstudio/utils/SpriteUtils.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.gpl.rpg.atcontentstudio.utils;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
public final class SpriteUtils {
|
||||
|
||||
/**
|
||||
* Check if the image is empty (transparent )
|
||||
*
|
||||
* @param img The image to check
|
||||
* @return true if the image is empty
|
||||
*/
|
||||
public static boolean checkIsImageEmpty(BufferedImage img) {
|
||||
int width = img.getWidth(null);
|
||||
int height = img.getHeight(null);
|
||||
WritableRaster raster = img.getAlphaRaster();
|
||||
if (raster == null) {
|
||||
return false;
|
||||
}
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
//get pixel alpha value
|
||||
int alpha = raster.getSample(x, y, 0);
|
||||
//if alpha is not 0 then the pixel is not transparent
|
||||
if (alpha != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//no non-transparent pixel found
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user