Compare commits

...

4 Commits

Author SHA1 Message Date
Zukero
ef521207de v0.6.4 released. 2017-07-28 13:15:42 +02:00
Zukero
3ef0f7e0f1 Update checker now honors the "Use internet" setting. Another setting,
"check for updates" also controls this behavior.
2017-07-28 13:11:30 +02:00
Zukero
74808cdd3a Fixed a bug improperly restoring the state of WriteModeData (Dialogue
sketches) after loading it from disk. This created a risk of data loss
upon subsequent edition of dialogue sketches.
2017-07-27 20:50:10 +02:00
Zukero
1e8d08ee3a Added online version check, to warn of availability of a new version. 2017-07-27 01:07:01 +02:00
7 changed files with 155 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?> <?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc> <jardesc>
<jar path="ATCS/ATCS_v0.6.3.jar"/> <jar path="ATCS/ATCS_v0.6.4.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATCS/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> <options buildIfNeeded="true" compress="true" descriptionLocation="/ATCS/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/> <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/> <selectedProjects/>

View File

@@ -1,6 +1,6 @@
!include MUI2.nsh !include MUI2.nsh
!define VERSION "0.6.3" !define VERSION "0.6.4"
!define TRAINER_VERSION "0.1.4" !define TRAINER_VERSION "0.1.4"
!define JAVA_BIN "javaw" !define JAVA_BIN "javaw"

View File

@@ -1,30 +1,47 @@
package com.gpl.rpg.atcontentstudio; package com.gpl.rpg.atcontentstudio;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
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.File; 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.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
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.JLabel;
import javax.swing.JOptionPane;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.HyperlinkEvent;
import prefuse.data.expression.parser.ExpressionParser; import javax.swing.event.HyperlinkListener;
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;
import prefuse.data.expression.parser.ExpressionParser;
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.3"; public static final String APP_VERSION = "v0.6.4";
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 boolean STARTED = false; public static boolean STARTED = false;
public static StudioFrame frame = null; public static StudioFrame frame = null;
@@ -74,6 +91,11 @@ public class ATContentStudio {
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()) {
new Thread() {
public void run() {checkUpdate();}
}.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);
@@ -95,4 +117,65 @@ public class ATContentStudio {
}); });
} }
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();
}
}
}
} }

View File

@@ -42,6 +42,8 @@ public class WorkspaceSettings {
public Setting<String> translatorLanguage = new NullDefaultPrimitiveSetting<String>("translatorLanguage"); public Setting<String> translatorLanguage = new NullDefaultPrimitiveSetting<String>("translatorLanguage");
public static Boolean DEFAULT_ALLOW_INTERNET = true; public static Boolean DEFAULT_ALLOW_INTERNET = true;
public Setting<Boolean> useInternet = new PrimitiveSetting<Boolean>("useInternet", DEFAULT_ALLOW_INTERNET); public Setting<Boolean> useInternet = new PrimitiveSetting<Boolean>("useInternet", DEFAULT_ALLOW_INTERNET);
public static Boolean DEFAULT_CHECK_UPDATE = true;
public Setting<Boolean> checkUpdates = new PrimitiveSetting<Boolean>("checkUpdates", DEFAULT_CHECK_UPDATE);
public List<Setting<? extends Object>> settings = new ArrayList<Setting<? extends Object>>(); public List<Setting<? extends Object>> settings = new ArrayList<Setting<? extends Object>>();
@@ -55,6 +57,7 @@ public class WorkspaceSettings {
settings.add(imageEditorCommand); settings.add(imageEditorCommand);
settings.add(translatorLanguage); settings.add(translatorLanguage);
settings.add(useInternet); settings.add(useInternet);
settings.add(checkUpdates);
file = new File(parent.baseFolder, FILENAME); file = new File(parent.baseFolder, FILENAME);
if (file.exists()) { if (file.exists()) {
load(file); load(file);

View File

@@ -167,6 +167,9 @@ public class WriterModeData extends GameDataElement {
this.id = (String) json.get("id"); this.id = (String) json.get("id");
this.index = ((Number)json.get("index")).intValue(); this.index = ((Number)json.get("index")).intValue();
this.id_prefix = (String) json.get("id_prefix"); this.id_prefix = (String) json.get("id_prefix");
if (threadsNextIndex.get(id_prefix) == null || threadsNextIndex.get(id_prefix) <= index) {
threadsNextIndex.put(id_prefix, index+1);
}
this.text = (String) json.get("text"); this.text = (String) json.get("text");
this.dialogue_id = (String) json.get("dialogue"); this.dialogue_id = (String) json.get("dialogue");
if (json.get("begin") != null && ((Boolean)json.get("begin"))) begin = this; if (json.get("begin") != null && ((Boolean)json.get("begin"))) begin = this;
@@ -541,6 +544,7 @@ public class WriterModeData extends GameDataElement {
nodesById.put(dialogue.getID(), dialogue); nodesById.put(dialogue.getID(), dialogue);
} }
} }
this.state = State.parsed; this.state = State.parsed;
} }
@@ -557,6 +561,11 @@ public class WriterModeData extends GameDataElement {
this.parse(); this.parse();
} }
if (this.state == State.parsed) { if (this.state == State.parsed) {
for (String prefix : threadsNextIndex.keySet()) {
while (getProject().getDialogue(prefix+threadsNextIndex.get(prefix)) != null) {
threadsNextIndex.put(prefix, threadsNextIndex.get(prefix)+1);
}
}
for (WriterDialogue dialogue : nodesById.values()) { for (WriterDialogue dialogue : nodesById.values()) {
if (dialogue.dialogue_id != null) { if (dialogue.dialogue_id != null) {
dialogue.dialogue = getProject().getDialogue(dialogue.dialogue_id); dialogue.dialogue = getProject().getDialogue(dialogue.dialogue_id);
@@ -571,32 +580,34 @@ public class WriterModeData extends GameDataElement {
} }
} }
//TODO Seriously, this is failure-prone by design. Can't do much better though... //TODO Seriously, this is failure-prone by design. Can't do much better though...
List<Dialogue.Reply> linked = new ArrayList<Dialogue.Reply>(dialogue.dialogue.replies.size()); if (dialogue.dialogue != null) {
if (dialogue.dialogue != null && dialogue.dialogue.replies != null) { List<Dialogue.Reply> linked = new ArrayList<Dialogue.Reply>(dialogue.dialogue.replies.size());
//Try to hook to existing replies... not as easy when there's no ID. if (dialogue.dialogue != null && dialogue.dialogue.replies != null) {
Dialogue.Reply best = null; //Try to hook to existing replies... not as easy when there's no ID.
int score, maxScore = 0; Dialogue.Reply best = null;
for (Dialogue.Reply dReply : dialogue.dialogue.replies) { int score, maxScore = 0;
//Never link twice to the same... for (Dialogue.Reply dReply : dialogue.dialogue.replies) {
if (linked.contains(dReply)) continue; //Never link twice to the same...
score = 0; if (linked.contains(dReply)) continue;
//Arbitrary values... hopefully this gives good results. score = 0;
//Same target gives good hope of preserving at least the structure. //Arbitrary values... hopefully this gives good results.
if (dReply.next_phrase_id != null && dReply.next_phrase_id.equals(reply.next_dialogue_id)) score +=50; //Same target gives good hope of preserving at least the structure.
//Same text is almost as good as an ID, but there may be duplicates due to requirements system... if (dReply.next_phrase_id != null && dReply.next_phrase_id.equals(reply.next_dialogue_id)) score +=50;
if (dReply.text != null && dReply.text.equals(reply.text)) score +=40; //Same text is almost as good as an ID, but there may be duplicates due to requirements system...
//Same slot in the list. That's not so bad if all else fails, and could help sort duplicates with same text. if (dReply.text != null && dReply.text.equals(reply.text)) score +=40;
if (dialogue.dialogue.replies.indexOf(dReply) == dialogue.replies.indexOf(reply)) score +=20; //Same slot in the list. That's not so bad if all else fails, and could help sort duplicates with same text.
//Both have null text. It's not much, but it's something.... if (dialogue.dialogue.replies.indexOf(dReply) == dialogue.replies.indexOf(reply)) score +=20;
if (dReply.text == null && reply.text == null) score += 10; //Both have null text. It's not much, but it's something....
if (score > maxScore) { if (dReply.text == null && reply.text == null) score += 10;
maxScore = score; if (score > maxScore) {
best = dReply; maxScore = score;
best = dReply;
}
}
if (maxScore > 0) {
reply.reply = best;
linked.add(best);
} }
}
if (maxScore > 0) {
reply.reply = best;
linked.add(best);
} }
} }
} }

View File

@@ -31,9 +31,10 @@ public class WorkspaceSettingsEditor extends JDialog {
JRadioButton useSystemDefaultImageViewerButton, useSystemDefaultImageEditorButton, useCustomImageEditorButton; JRadioButton useSystemDefaultImageViewerButton, useSystemDefaultImageEditorButton, useCustomImageEditorButton;
JTextField imageEditorCommandField; JTextField imageEditorCommandField;
JCheckBox useInternetBox;
JCheckBox translatorModeBox; JCheckBox translatorModeBox;
JComboBox<String> translatorLanguagesBox; JComboBox<String> translatorLanguagesBox;
JCheckBox useInternetBox; JCheckBox checkUpdatesBox;
@@ -53,7 +54,7 @@ public class WorkspaceSettingsEditor extends JDialog {
pane.add(getExternalToolsPane(), JideBoxLayout.FIX); pane.add(getExternalToolsPane(), JideBoxLayout.FIX);
pane.add(getTranslatorModePane(), JideBoxLayout.FIX); pane.add(getInternetPane(), JideBoxLayout.FIX);
pane.add(new JPanel(), JideBoxLayout.VARY); pane.add(new JPanel(), JideBoxLayout.VARY);
buttonPane.add(new JPanel(), JideBoxLayout.VARY); buttonPane.add(new JPanel(), JideBoxLayout.VARY);
@@ -155,10 +156,14 @@ public class WorkspaceSettingsEditor extends JDialog {
return pane; return pane;
} }
public JPanel getTranslatorModePane() { public JPanel getInternetPane() {
CollapsiblePanel pane = new CollapsiblePanel("Translator options");
CollapsiblePanel pane = new CollapsiblePanel("Internet options");
pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS)); pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS));
useInternetBox = new JCheckBox("Allow connecting to internet to retrieve data from weblate and check for updates.");
pane.add(useInternetBox, JideBoxLayout.FIX);
translatorModeBox = new JCheckBox("Activate translator mode"); translatorModeBox = new JCheckBox("Activate translator mode");
pane.add(translatorModeBox, JideBoxLayout.FIX); pane.add(translatorModeBox, JideBoxLayout.FIX);
@@ -171,14 +176,15 @@ public class WorkspaceSettingsEditor extends JDialog {
pane.add(new JLabel("If your language isn't here, complain on the forums at https://andorstrail.com/"), JideBoxLayout.FIX); pane.add(new JLabel("If your language isn't here, complain on the forums at https://andorstrail.com/"), JideBoxLayout.FIX);
useInternetBox = new JCheckBox("Allow connecting to internet to retrieve data from weblate."); checkUpdatesBox = new JCheckBox("Check for ATCS updates at startup");
pane.add(useInternetBox, JideBoxLayout.FIX); pane.add(checkUpdatesBox, JideBoxLayout.FIX);
translatorModeBox.addActionListener(new ActionListener() { useInternetBox.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
translatorLanguagesBox.setEnabled(translatorModeBox.isSelected()); translatorLanguagesBox.setEnabled(useInternetBox.isSelected());
useInternetBox.setEnabled(translatorModeBox.isSelected()); translatorModeBox.setEnabled(useInternetBox.isSelected());
checkUpdatesBox.setEnabled(useInternetBox.isSelected());
} }
}); });
@@ -196,19 +202,20 @@ public class WorkspaceSettingsEditor extends JDialog {
useSystemDefaultImageEditorButton.setSelected(settings.useSystemDefaultImageEditor.getCurrentValue()); useSystemDefaultImageEditorButton.setSelected(settings.useSystemDefaultImageEditor.getCurrentValue());
useCustomImageEditorButton.setSelected(!(settings.useSystemDefaultImageViewer.getCurrentValue() || settings.useSystemDefaultImageEditor.getCurrentValue())); useCustomImageEditorButton.setSelected(!(settings.useSystemDefaultImageViewer.getCurrentValue() || settings.useSystemDefaultImageEditor.getCurrentValue()));
imageEditorCommandField.setText(settings.imageEditorCommand.getCurrentValue()); imageEditorCommandField.setText(settings.imageEditorCommand.getCurrentValue());
//Translator //Internet
useInternetBox.setSelected(settings.useInternet.getCurrentValue());
if (settings.translatorLanguage.getCurrentValue() != null) { if (settings.translatorLanguage.getCurrentValue() != null) {
translatorModeBox.setSelected(true); translatorModeBox.setSelected(true);
translatorLanguagesBox.setSelectedItem(settings.translatorLanguage.getCurrentValue()); translatorLanguagesBox.setSelectedItem(settings.translatorLanguage.getCurrentValue());
translatorLanguagesBox.setEnabled(true); translatorLanguagesBox.setEnabled(useInternetBox.isSelected());
useInternetBox.setEnabled(true);
} else { } else {
translatorModeBox.setSelected(false); translatorModeBox.setSelected(false);
translatorLanguagesBox.setSelectedItem(null); translatorLanguagesBox.setSelectedItem(null);
translatorLanguagesBox.setEnabled(false); translatorLanguagesBox.setEnabled(false);
useInternetBox.setEnabled(false);
} }
useInternetBox.setSelected(settings.useInternet.getCurrentValue()); translatorModeBox.setEnabled(useInternetBox.isSelected());
checkUpdatesBox.setSelected(settings.checkUpdates.getCurrentValue());
checkUpdatesBox.setEnabled(useInternetBox.isSelected());
} }
public void pushToModel() { public void pushToModel() {
@@ -219,13 +226,14 @@ public class WorkspaceSettingsEditor extends JDialog {
settings.useSystemDefaultImageViewer.setCurrentValue(useSystemDefaultImageViewerButton.isSelected()); settings.useSystemDefaultImageViewer.setCurrentValue(useSystemDefaultImageViewerButton.isSelected());
settings.useSystemDefaultImageEditor.setCurrentValue(useSystemDefaultImageEditorButton.isSelected()); settings.useSystemDefaultImageEditor.setCurrentValue(useSystemDefaultImageEditorButton.isSelected());
settings.imageEditorCommand.setCurrentValue(imageEditorCommandField.getText()); settings.imageEditorCommand.setCurrentValue(imageEditorCommandField.getText());
//Translator //Internet
settings.useInternet.setCurrentValue(useInternetBox.isSelected());
if (translatorModeBox.isSelected()) { if (translatorModeBox.isSelected()) {
settings.translatorLanguage.setCurrentValue((String)translatorLanguagesBox.getSelectedItem()); settings.translatorLanguage.setCurrentValue((String)translatorLanguagesBox.getSelectedItem());
} else { } else {
settings.translatorLanguage.resetDefault(); settings.translatorLanguage.resetDefault();
} }
settings.useInternet.setCurrentValue(useInternetBox.isSelected()); settings.checkUpdates.setCurrentValue(checkUpdatesBox.isSelected());
settings.save(); settings.save();
} }

View File

@@ -60,6 +60,9 @@ public class WeblateIntegration {
if (!Workspace.activeWorkspace.settings.useInternet.getCurrentValue()) { if (!Workspace.activeWorkspace.settings.useInternet.getCurrentValue()) {
unit.status = Status.notAllowed; unit.status = Status.notAllowed;
unit.translatedText = "Allow internet connection in the workspace settings to get translation status"; unit.translatedText = "Allow internet connection in the workspace settings to get translation status";
} else if (Workspace.activeWorkspace.settings.translatorLanguage == null) {
unit.status = Status.notAllowed;
unit.translatedText = "Select a target language in the workspace settings to get translation status";
} else { } else {
unit.status = Status.absent; unit.status = Status.absent;
unit.translatedText = "Cannot find this on weblate"; unit.translatedText = "Cannot find this on weblate";