mirror of
https://github.com/OMGeeky/ATCS.git
synced 2026-02-23 15:38:23 +01:00
Made dialogue-tree translations loading asynchronous.
Fixed quote escaping issue in english.pot generation tool.
This commit is contained in:
@@ -56,6 +56,7 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
|||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
|
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
|
||||||
import com.gpl.rpg.atcontentstudio.utils.WeblateIntegration;
|
import com.gpl.rpg.atcontentstudio.utils.WeblateIntegration;
|
||||||
|
import com.gpl.rpg.atcontentstudio.utils.WeblateIntegration.WeblateTranslationUnit;
|
||||||
import com.jidesoft.swing.JideBoxLayout;
|
import com.jidesoft.swing.JideBoxLayout;
|
||||||
|
|
||||||
public class DialogueGraphView extends Display {
|
public class DialogueGraphView extends Display {
|
||||||
@@ -74,6 +75,10 @@ public class DialogueGraphView extends Display {
|
|||||||
public static final String HIDDEN_REPLY = "hidden_reply";
|
public static final String HIDDEN_REPLY = "hidden_reply";
|
||||||
public static final String HAS_REQS = "has_reqs";
|
public static final String HAS_REQS = "has_reqs";
|
||||||
|
|
||||||
|
private static final String TRANSLATION_LOADING="Loading translation...";
|
||||||
|
private String translationHeader="\n---[ Translation from weblate ]---\n";
|
||||||
|
|
||||||
|
|
||||||
private static final Schema DECORATOR_SCHEMA = PrefuseLib.getVisualItemSchema();
|
private static final Schema DECORATOR_SCHEMA = PrefuseLib.getVisualItemSchema();
|
||||||
|
|
||||||
private Dialogue dialogue;
|
private Dialogue dialogue;
|
||||||
@@ -92,6 +97,9 @@ public class DialogueGraphView extends Display {
|
|||||||
npcIcon = DefaultIcons.getNPCIcon();
|
npcIcon = DefaultIcons.getNPCIcon();
|
||||||
}
|
}
|
||||||
translatorMode = Workspace.activeWorkspace.settings.useInternet.getCurrentValue() && Workspace.activeWorkspace.settings.translatorLanguage.getCurrentValue() != null;
|
translatorMode = Workspace.activeWorkspace.settings.useInternet.getCurrentValue() && Workspace.activeWorkspace.settings.translatorLanguage.getCurrentValue() != null;
|
||||||
|
if (translatorMode) {
|
||||||
|
translationHeader = "\n---[ Translation in "+Workspace.activeWorkspace.settings.translatorLanguage.getCurrentValue()+" ]---\n";
|
||||||
|
}
|
||||||
loadGraph();
|
loadGraph();
|
||||||
|
|
||||||
// add visual data groups
|
// add visual data groups
|
||||||
@@ -190,9 +198,26 @@ public class DialogueGraphView extends Display {
|
|||||||
if (dialogue.switch_to_npc != null) {
|
if (dialogue.switch_to_npc != null) {
|
||||||
npcIcon = dialogue.switch_to_npc.getIcon();
|
npcIcon = dialogue.switch_to_npc.getIcon();
|
||||||
}
|
}
|
||||||
Node dNode = graph.addNode();
|
final Node dNode = graph.addNode();
|
||||||
cells.put(dialogue, dNode);
|
cells.put(dialogue, dNode);
|
||||||
dNode.setString(LABEL, dialogue.message == null ? "[Selector]" : translatorMode ? dialogue.message + "\n---\n" + WeblateIntegration.getTranslationUnit(dialogue.message).translatedText : dialogue.message);
|
String label;
|
||||||
|
Thread t = null;
|
||||||
|
if (dialogue.message == null) {
|
||||||
|
label = "[Selector]";
|
||||||
|
} else if (translatorMode) {
|
||||||
|
label = dialogue.message+translationHeader+TRANSLATION_LOADING;
|
||||||
|
final String message = dialogue.message;
|
||||||
|
t = new Thread("Get weblate translation for "+message) {
|
||||||
|
public void run() {
|
||||||
|
WeblateTranslationUnit unit = WeblateIntegration.getTranslationUnit(message);
|
||||||
|
dNode.setString(LABEL, message+translationHeader+unit.translatedText);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
label = dialogue.message;
|
||||||
|
}
|
||||||
|
dNode.setString(LABEL, label);
|
||||||
|
if (t != null) t.start();
|
||||||
dNode.set(ICON, npcIcon);
|
dNode.set(ICON, npcIcon);
|
||||||
dNode.set(TARGET, dialogue);
|
dNode.set(TARGET, dialogue);
|
||||||
if (dialogue.replies != null) {
|
if (dialogue.replies != null) {
|
||||||
@@ -210,11 +235,27 @@ public class DialogueGraphView extends Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Node addReply(Dialogue d, Dialogue.Reply r, Image npcIcon) {
|
public Node addReply(Dialogue d, Dialogue.Reply r, Image npcIcon) {
|
||||||
Node rNode;
|
final Node rNode;
|
||||||
if (r.text != null && !r.text.equals(Dialogue.Reply.GO_NEXT_TEXT)) {
|
if (r.text != null && !r.text.equals(Dialogue.Reply.GO_NEXT_TEXT)) {
|
||||||
//Normal reply...
|
//Normal reply...
|
||||||
rNode = graph.addNode();
|
rNode = graph.addNode();
|
||||||
rNode.setString(LABEL, translatorMode ? r.text + "\n---\n" + WeblateIntegration.getTranslationUnit(r.text).translatedText : r.text);
|
// rNode.setString(LABEL, translatorMode ? r.text + "\n---\n" + WeblateIntegration.getTranslationUnit(r.text).translatedText : r.text);
|
||||||
|
String label;
|
||||||
|
Thread t = null;
|
||||||
|
if (translatorMode) {
|
||||||
|
label = r.text+translationHeader+TRANSLATION_LOADING;
|
||||||
|
final String message = r.text;
|
||||||
|
t = new Thread("Get weblate translation for "+message) {
|
||||||
|
public void run() {
|
||||||
|
WeblateTranslationUnit unit = WeblateIntegration.getTranslationUnit(message);
|
||||||
|
rNode.setString(LABEL, message+translationHeader+unit.translatedText);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
label = dialogue.message;
|
||||||
|
}
|
||||||
|
rNode.setString(LABEL, label);
|
||||||
|
if (t != null) t.start();
|
||||||
rNode.set(ICON, DefaultIcons.getHeroIcon());
|
rNode.set(ICON, DefaultIcons.getHeroIcon());
|
||||||
rNode.set(TARGET, d);
|
rNode.set(TARGET, d);
|
||||||
rNode.set(REPLY, r);
|
rNode.set(REPLY, r);
|
||||||
|
|||||||
@@ -54,9 +54,11 @@ public class PotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Quest q : gsrc.gameData.quests) {
|
for (Quest q : gsrc.gameData.quests) {
|
||||||
pushString(stringsResources, resourcesStrings, q.name, getPotContextComment(q));
|
if (q.visible_in_log != null && q.visible_in_log != 0) {
|
||||||
for (QuestStage qs : q.stages) {
|
pushString(stringsResources, resourcesStrings, q.name, getPotContextComment(q));
|
||||||
pushString(stringsResources, resourcesStrings, qs.log_text, getPotContextComment(q)+":"+Integer.toString(qs.progress));
|
for (QuestStage qs : q.stages) {
|
||||||
|
pushString(stringsResources, resourcesStrings, qs.log_text, getPotContextComment(q)+":"+Integer.toString(qs.progress));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,9 @@ public class PotGenerator {
|
|||||||
private static void pushString (Map<String, List<String>> stringsResources, Map<String, String> resourcesStrings, String translatableString, String resourceIdentifier) {
|
private static void pushString (Map<String, List<String>> stringsResources, Map<String, String> resourcesStrings, String translatableString, String resourceIdentifier) {
|
||||||
if (translatableString == null) return;
|
if (translatableString == null) return;
|
||||||
if (translatableString.length() == 0) return;
|
if (translatableString.length() == 0) return;
|
||||||
|
if (translatableString.contains("\"")) {
|
||||||
|
translatableString = translatableString.replaceAll("\"", "\\\\\"");
|
||||||
|
}
|
||||||
if (translatableString.contains("\n")) {
|
if (translatableString.contains("\n")) {
|
||||||
translatableString = translatableString.replaceAll("\n", "\\\\n\"\n\"");
|
translatableString = translatableString.replaceAll("\n", "\\\\n\"\n\"");
|
||||||
translatableString = "\"\n\""+translatableString;
|
translatableString = "\"\n\""+translatableString;
|
||||||
|
|||||||
Reference in New Issue
Block a user