This commit is contained in:
OMGeeky
2025-06-24 20:10:18 +02:00
parent 6c296868c0
commit 1c83eedd80
35 changed files with 270 additions and 195 deletions

View File

@@ -1,8 +1,13 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="JD_P_AT_EMPTY_LINES" value="false" />
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA"> <codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="200" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" /> <option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" /> <option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="SOFT_MARGINS" value="120" /> <option name="SOFT_MARGINS" value="120" />
</codeStyleSettings> </codeStyleSettings>
</code_scheme> </code_scheme>

View File

@@ -152,13 +152,13 @@ public class ATContentStudio {
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", JEditorPane ep = new JEditorPane("text/html",
"<html><body style=\"" + style + "\">" + "You are not running the latest ATCS version.<br/>" "<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/>" + "You can get the latest version (" + lastLine + ") by clicking the link below.<br/>"
+ "<a href=\"" + DOWNLOAD_URL + "\">" + DOWNLOAD_URL + "</a><br/>" + "<br/>" + "<a href=\"" + DOWNLOAD_URL + "\">" + DOWNLOAD_URL + "</a><br/>" + "<br/>"
+ "</body></html>"); + "</body></html>");
ep.setEditable(false); ep.setEditable(false);
ep.setBorder(null); ep.setBorder(null);

View File

@@ -203,18 +203,19 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
public abstract List<SaveEvent> attemptSave(); public abstract List<SaveEvent> attemptSave();
/** /**
* Checks if the current state indicates that parsing/linking should be skipped. * Checks if the current state indicates that parsing/linking should be skipped.
* @return true if the operation should be skipped, false otherwise *
*/ * @return true if the operation should be skipped, false otherwise
protected boolean shouldSkipParseOrLink() { */
protected boolean shouldSkipParseOrLink() {
if (shouldSkipParse()) return true; if (shouldSkipParse()) return true;
if (this.state == State.linked) { if (this.state == State.linked) {
//Already linked. //Already linked.
return true; return true;
} }
return false; return false;
} }
protected boolean shouldSkipParse() { protected boolean shouldSkipParse() {
if (this.state == State.created || this.state == State.modified || this.state == State.saved) { if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
@@ -225,12 +226,12 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
} }
/** /**
* Ensures the element is parsed if needed based on its current state. * Ensures the element is parsed if needed based on its current state.
*/ */
protected void ensureParseIfNeeded() { protected void ensureParseIfNeeded() {
if (this.state == State.init) { if (this.state == State.init) {
//Not parsed yet. //Not parsed yet.
this.parse(); this.parse();
} }
} }
} }

View File

@@ -1105,13 +1105,15 @@ public class Project implements ProjectTreeNode, Serializable {
// } // }
Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType = new LinkedHashMap<Class<? extends GameDataElement>, List<String>>(); Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType = new LinkedHashMap<Class<? extends GameDataElement>, List<String>>();
List<String> writtenFiles; List<String> writtenFiles;
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class, tmpJsonDataDir); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class,
tmpJsonDataDir);
writtenFilesPerDataType.put(ActorCondition.class, writtenFiles); writtenFilesPerDataType.put(ActorCondition.class, writtenFiles);
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir);
writtenFilesPerDataType.put(Dialogue.class, writtenFiles); writtenFilesPerDataType.put(Dialogue.class, writtenFiles);
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.droplists, alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.droplists, alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir);
writtenFilesPerDataType.put(Droplist.class, writtenFiles); writtenFilesPerDataType.put(Droplist.class, writtenFiles);
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.itemCategories, alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class, tmpJsonDataDir); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.itemCategories, alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class,
tmpJsonDataDir);
writtenFilesPerDataType.put(ItemCategory.class, writtenFiles); writtenFilesPerDataType.put(ItemCategory.class, writtenFiles);
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.items, alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.items, alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir);
writtenFilesPerDataType.put(Item.class, writtenFiles); writtenFilesPerDataType.put(Item.class, writtenFiles);

View File

@@ -44,7 +44,7 @@ public class Workspace implements ProjectTreeNode, Serializable {
workspaceRoot.mkdir(); workspaceRoot.mkdir();
} catch (SecurityException e) { } catch (SecurityException e) {
Notification.addError("Error creating workspace directory: " Notification.addError("Error creating workspace directory: "
+ e.getMessage()); + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -55,12 +55,12 @@ public class Workspace implements ProjectTreeNode, Serializable {
settingsFile.createNewFile(); settingsFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
Notification.addError("Error creating workspace datafile: " Notification.addError("Error creating workspace datafile: "
+ e.getMessage()); + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
Notification.addSuccess("New workspace created: " Notification.addSuccess("New workspace created: "
+ workspaceRoot.getAbsolutePath()); + workspaceRoot.getAbsolutePath());
save(); save();
} }
@@ -169,26 +169,26 @@ public class Workspace implements ProjectTreeNode, Serializable {
public static void createProject(final String projectName, public static void createProject(final String projectName,
final File gameSourceFolder, final Project.ResourceSet sourceSet) { final File gameSourceFolder, final Project.ResourceSet sourceSet) {
WorkerDialog.showTaskMessage("Creating project " + projectName + "...", WorkerDialog.showTaskMessage("Creating project " + projectName + "...",
ATContentStudio.frame, new Runnable() { ATContentStudio.frame, new Runnable() {
@Override @Override
public void run() { public void run() {
if (activeWorkspace.projectsName.contains(projectName)) { if (activeWorkspace.projectsName.contains(projectName)) {
Notification.addError("A project named " Notification.addError("A project named "
+ projectName + projectName
+ " already exists in this workspace."); + " already exists in this workspace.");
return; return;
} }
Project p = new Project(activeWorkspace, projectName, Project p = new Project(activeWorkspace, projectName,
gameSourceFolder, sourceSet); gameSourceFolder, sourceSet);
activeWorkspace.projects.add(p); activeWorkspace.projects.add(p);
activeWorkspace.projectsName.add(projectName); activeWorkspace.projectsName.add(projectName);
activeWorkspace.projectsOpenByName.put(projectName, activeWorkspace.projectsOpenByName.put(projectName,
p.open); p.open);
activeWorkspace.knownMapSourcesFolders activeWorkspace.knownMapSourcesFolders
.add(gameSourceFolder); .add(gameSourceFolder);
p.notifyCreated(); p.notifyCreated();
Notification.addSuccess("Project " + projectName Notification.addSuccess("Project " + projectName
+ " successfully created"); + " successfully created");
saveActive(); saveActive();
} }
}); });
@@ -210,19 +210,19 @@ public class Workspace implements ProjectTreeNode, Serializable {
public static void openProject(final ClosedProject cp) { public static void openProject(final ClosedProject cp) {
WorkerDialog.showTaskMessage("Opening project " + cp.name + "...", WorkerDialog.showTaskMessage("Opening project " + cp.name + "...",
ATContentStudio.frame, new Runnable() { ATContentStudio.frame, new Runnable() {
@Override @Override
public void run() { public void run() {
int index = activeWorkspace.projects.indexOf(cp); int index = activeWorkspace.projects.indexOf(cp);
if (index < 0) { if (index < 0) {
Notification Notification
.addError("Cannot open unknown project " .addError("Cannot open unknown project "
+ cp.name); + cp.name);
return; return;
} }
cp.childrenRemoved(new ArrayList<ProjectTreeNode>()); cp.childrenRemoved(new ArrayList<ProjectTreeNode>());
Project p = Project.fromFolder(activeWorkspace, Project p = Project.fromFolder(activeWorkspace,
new File(activeWorkspace.baseFolder, cp.name)); new File(activeWorkspace.baseFolder, cp.name));
p.open(); p.open();
activeWorkspace.projects.set(index, p); activeWorkspace.projects.set(index, p);
activeWorkspace.projectsOpenByName.put(p.name, true); activeWorkspace.projectsOpenByName.put(p.name, true);
@@ -246,14 +246,14 @@ public class Workspace implements ProjectTreeNode, Serializable {
} else { } else {
Notification Notification
.addError("Failed to open project " .addError("Failed to open project "
+ projectName + projectName
+ ". Removing it from workspace (not from filesystem though)."); + ". Removing it from workspace (not from filesystem though).");
projectsFailed.add(projectName); projectsFailed.add(projectName);
} }
} else { } else {
Notification.addError("Unable to find project " Notification.addError("Unable to find project "
+ projectName + projectName
+ "'s root folder. Removing it from workspace"); + "'s root folder. Removing it from workspace");
projectsFailed.add(projectName); projectsFailed.add(projectName);
} }
} else { } else {
@@ -299,10 +299,10 @@ public class Workspace implements ProjectTreeNode, Serializable {
activeWorkspace.projectsName.remove(cp.name); activeWorkspace.projectsName.remove(cp.name);
if (delete(new File(activeWorkspace.baseFolder, cp.name))) { if (delete(new File(activeWorkspace.baseFolder, cp.name))) {
Notification.addSuccess("Closed project " + cp.name Notification.addSuccess("Closed project " + cp.name
+ " successfully deleted."); + " successfully deleted.");
} else { } else {
Notification.addError("Error while deleting closed project " Notification.addError("Error while deleting closed project "
+ cp.name + ". Files may remain in the workspace."); + cp.name + ". Files may remain in the workspace.");
} }
saveActive(); saveActive();
} }
@@ -314,10 +314,10 @@ public class Workspace implements ProjectTreeNode, Serializable {
activeWorkspace.projectsName.remove(p.name); activeWorkspace.projectsName.remove(p.name);
if (delete(p.baseFolder)) { if (delete(p.baseFolder)) {
Notification.addSuccess("Project " + p.name Notification.addSuccess("Project " + p.name
+ " successfully deleted."); + " successfully deleted.");
} else { } else {
Notification.addError("Error while deleting project " + p.name Notification.addError("Error while deleting project " + p.name
+ ". Files may remain in the workspace."); + ". Files may remain in the workspace.");
} }
saveActive(); saveActive();
} }

View File

@@ -91,7 +91,13 @@ public class BookmarkEntry implements BookmarkNode {
if (text.length() > 60) { if (text.length() > 60) {
text = text.substring(0, 57) + "..."; text = text.substring(0, 57) + "...";
} }
return ((GameDataElement) bookmarkedElement).getDataType().toString() + "/" + ((Quest) ((QuestStage) bookmarkedElement).parent).id + "#" + ((QuestStage) bookmarkedElement).progress + ":" + text; return ((GameDataElement) bookmarkedElement).getDataType().toString() +
"/" +
((Quest) ((QuestStage) bookmarkedElement).parent).id +
"#" +
((QuestStage) bookmarkedElement).progress +
":" +
text;
} else { } else {
return ((GameDataElement) bookmarkedElement).getDataType().toString() + "/" + ((GameDataElement) bookmarkedElement).getDesc(); return ((GameDataElement) bookmarkedElement).getDataType().toString() + "/" + ((GameDataElement) bookmarkedElement).getDesc();
} }

View File

@@ -222,10 +222,10 @@ public class ActorCondition extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
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 (getProject().getSpritesheet(spritesheetId) == null) { if (getProject().getSpritesheet(spritesheetId) == null) {

View File

@@ -10,7 +10,7 @@ import java.util.Map;
public final class Common { public final class Common {
public static <T extends ActorConditionEffect> void actorConditionElementChanged(List<T> list, GameDataElement oldOne, GameDataElement newOne,GameDataElement backlink){ public static <T extends ActorConditionEffect> void actorConditionElementChanged(List<T> list, GameDataElement oldOne, GameDataElement newOne, GameDataElement backlink) {
if (list != null) { if (list != null) {
for (T c : list) { for (T c : list) {
if (c.condition == oldOne) { if (c.condition == oldOne) {
@@ -22,6 +22,7 @@ public final class Common {
} }
} }
//region link common stuff //region link common stuff
public static void linkConditions(List<? extends ActorConditionEffect> conditions, Project proj, GameDataElement backlink) { public static void linkConditions(List<? extends ActorConditionEffect> conditions, Project proj, GameDataElement backlink) {
if (conditions != null) { if (conditions != null) {
@@ -31,19 +32,20 @@ public final class Common {
} }
} }
} }
public static void linkEffects(HitEffect effect, Project proj, GameDataElement backlink){
public static void linkEffects(HitEffect effect, Project proj, GameDataElement backlink) {
linkEffects((DeathEffect) effect, proj, backlink); linkEffects((DeathEffect) effect, proj, backlink);
if (effect != null) if (effect != null) {
{
linkConditions(effect.conditions_target, proj, backlink); linkConditions(effect.conditions_target, proj, backlink);
} }
} }
public static void linkEffects(DeathEffect effect, Project proj, GameDataElement backlink){
if (effect != null) public static void linkEffects(DeathEffect effect, Project proj, GameDataElement backlink) {
{ if (effect != null) {
linkConditions(effect.conditions_source, proj, backlink); linkConditions(effect.conditions_source, proj, backlink);
} }
} }
public static void linkIcon(Project proj, String iconId, GameDataElement backlink) { public static void linkIcon(Project proj, String iconId, GameDataElement backlink) {
if (iconId != null) { if (iconId != null) {
String spritesheetId = iconId.split(":")[0]; String spritesheetId = iconId.split(":")[0];
@@ -63,6 +65,7 @@ public final class Common {
else parent.put("max", defaultValue); else parent.put("max", defaultValue);
} }
} }
public static void writeMinMaxToMap(Map parent, String key, Integer min, Integer max, int defaultValue) { public static void writeMinMaxToMap(Map parent, String key, Integer min, Integer max, int defaultValue) {
if (min != null || max != null) { if (min != null || max != null) {
Map minMaxMap = new LinkedHashMap(); Map minMaxMap = new LinkedHashMap();
@@ -70,6 +73,7 @@ public final class Common {
writeMinMaxToMap(minMaxMap, min, max, defaultValue); writeMinMaxToMap(minMaxMap, min, max, defaultValue);
} }
} }
public static void writeDescriptionToMap(Map parent, String description) { public static void writeDescriptionToMap(Map parent, String description) {
if (description != null) parent.put("description", description); if (description != null) parent.put("description", description);
} }
@@ -77,12 +81,14 @@ public final class Common {
public static void writeIconToMap(Map parent, String icon_id) { public static void writeIconToMap(Map parent, String icon_id) {
if (icon_id != null) parent.put("iconID", icon_id); if (icon_id != null) parent.put("iconID", icon_id);
} }
public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect) { public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect) {
if(effect != null){ if (effect != null) {
writeHitEffectToMap(parent, effect); writeHitEffectToMap(parent, effect);
writeBasicEffectObjectToMap(effect.target, parent, "increaseAttackerCurrentHP", "increaseAttackerCurrentAP"); writeBasicEffectObjectToMap(effect.target, parent, "increaseAttackerCurrentHP", "increaseAttackerCurrentAP");
} }
} }
public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect, String key) { public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect, String key) {
if (effect != null) { if (effect != null) {
Map effectJson = new LinkedHashMap(); Map effectJson = new LinkedHashMap();
@@ -90,12 +96,14 @@ public final class Common {
writeHitReceivedEffectToMap(effectJson, effect); writeHitReceivedEffectToMap(effectJson, effect);
} }
} }
public static void writeHitEffectToMap(Map parent, HitEffect effect) { public static void writeHitEffectToMap(Map parent, HitEffect effect) {
if(effect != null){ if (effect != null) {
writeDeathEffectToMap(parent, effect); writeDeathEffectToMap(parent, effect);
writeTimedActorConditionEffectObjectToMap(effect.conditions_target, parent, "conditionsTarget"); writeTimedActorConditionEffectObjectToMap(effect.conditions_target, parent, "conditionsTarget");
} }
} }
public static void writeHitEffectToMap(Map parent, HitEffect effect, String key) { public static void writeHitEffectToMap(Map parent, HitEffect effect, String key) {
if (effect != null) { if (effect != null) {
Map effectJson = new LinkedHashMap(); Map effectJson = new LinkedHashMap();
@@ -103,10 +111,12 @@ public final class Common {
writeHitEffectToMap(effectJson, effect); writeHitEffectToMap(effectJson, effect);
} }
} }
public static void writeDeathEffectToMap(Map parent, DeathEffect effect) { public static void writeDeathEffectToMap(Map parent, DeathEffect effect) {
writeBasicEffectObjectToMap(effect, parent, "increaseCurrentHP", "increaseCurrentAP"); writeBasicEffectObjectToMap(effect, parent, "increaseCurrentHP", "increaseCurrentAP");
writeTimedActorConditionEffectObjectToMap(effect.conditions_source, parent, "conditionsSource"); writeTimedActorConditionEffectObjectToMap(effect.conditions_source, parent, "conditionsSource");
} }
public static void writeDeathEffectToMap(Map parent, DeathEffect effect, String key) { public static void writeDeathEffectToMap(Map parent, DeathEffect effect, String key) {
if (effect != null) { if (effect != null) {
Map effectJson = new LinkedHashMap(); Map effectJson = new LinkedHashMap();
@@ -154,6 +164,7 @@ public final class Common {
parent.put("chance", JSONElement.printJsonChance(condition.chance)); parent.put("chance", JSONElement.printJsonChance(condition.chance));
} }
} }
//endregion //endregion
public static class TimedActorConditionEffect extends ActorConditionEffect { public static class TimedActorConditionEffect extends ActorConditionEffect {
//Available from parsed state //Available from parsed state
@@ -169,12 +180,15 @@ public final class Common {
cclone.duration = this.duration; cclone.duration = this.duration;
return cclone; return cclone;
} }
public boolean isInfinite(){
public boolean isInfinite() {
return duration != null && duration.equals(ActorCondition.DURATION_FOREVER); return duration != null && duration.equals(ActorCondition.DURATION_FOREVER);
} }
public boolean isImmunity(){
public boolean isImmunity() {
return (super.isClear()) && (duration != null && duration > ActorCondition.DURATION_NONE); return (super.isClear()) && (duration != null && duration > ActorCondition.DURATION_NONE);
} }
@Override @Override
public boolean isClear() { public boolean isClear() {
return (super.isClear()) && (duration == null || duration.equals(ActorCondition.DURATION_NONE)); return (super.isClear()) && (duration == null || duration.equals(ActorCondition.DURATION_NONE));
@@ -188,7 +202,8 @@ public final class Common {
//Available from linked state //Available from linked state
public ActorCondition condition = null; public ActorCondition condition = null;
public boolean isClear(){
public boolean isClear() {
return magnitude == null || magnitude.equals(ActorCondition.MAGNITUDE_CLEAR); return magnitude == null || magnitude.equals(ActorCondition.MAGNITUDE_CLEAR);
} }
} }
@@ -287,9 +302,10 @@ public final class Common {
public static class DeathEffect extends BasicEffect { public static class DeathEffect extends BasicEffect {
//Available from parsed state //Available from parsed state
public List<TimedActorConditionEffect> conditions_source = null; public List<TimedActorConditionEffect> conditions_source = null;
@Override @Override
public boolean isNull(){ public boolean isNull() {
if(!super.isNull()) return false; if (!super.isNull()) return false;
if (conditions_source != null) return false; if (conditions_source != null) return false;
return true; return true;
} }
@@ -298,9 +314,10 @@ public final class Common {
public static class HitEffect extends DeathEffect { public static class HitEffect extends DeathEffect {
//Available from parsed state //Available from parsed state
public List<TimedActorConditionEffect> conditions_target = null; public List<TimedActorConditionEffect> conditions_target = null;
@Override @Override
public boolean isNull(){ public boolean isNull() {
if(!super.isNull()) return false; if (!super.isNull()) return false;
if (conditions_target != null) return false; if (conditions_target != null) return false;
return true; return true;
} }
@@ -309,9 +326,10 @@ public final class Common {
public static class HitReceivedEffect extends Common.HitEffect { public static class HitReceivedEffect extends Common.HitEffect {
//Available from parsed state //Available from parsed state
public BasicEffect target = new BasicEffect(); public BasicEffect target = new BasicEffect();
@Override @Override
public boolean isNull(){ public boolean isNull() {
if(!super.isNull()) return false; if (!super.isNull()) return false;
if (!target.isNull()) return false; if (!target.isNull()) return false;
return true; return true;
} }

View File

@@ -205,10 +205,10 @@ public class Dialogue extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
Project proj = getProject(); Project proj = getProject();
if (proj == null) { if (proj == null) {
Notification.addError("Error linking dialogue " + id + ". No parent project found."); Notification.addError("Error linking dialogue " + id + ". No parent project found.");

View File

@@ -128,10 +128,10 @@ public class Droplist extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
Project proj = getProject(); Project proj = getProject();
if (proj == null) { if (proj == null) {
Notification.addError("Error linking droplist " + id + ". No parent project found."); Notification.addError("Error linking droplist " + id + ". No parent project found.");

View File

@@ -220,7 +220,8 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
break; break;
} }
} }
events.add(new SaveEvent(SaveEvent.Type.alsoSave, node, true, "There are " + containedIds.get(node.id) + " elements with this ID in this category. Change the conflicting IDs before saving.")); events.add(new SaveEvent(SaveEvent.Type.alsoSave, node, true,
"There are " + containedIds.get(node.id) + " elements with this ID in this category. Change the conflicting IDs before saving."));
} }
} }
if (checkImpactedCategory && impactedCategory != null) { if (checkImpactedCategory && impactedCategory != null) {

View File

@@ -206,10 +206,10 @@ public class Item extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
Project proj = getProject(); Project proj = getProject();
if (proj == null) { if (proj == null) {
Notification.addError("Error linking item " + id + ". No parent project found."); Notification.addError("Error linking item " + id + ". No parent project found.");
@@ -381,7 +381,7 @@ public class Item extends JSONElement {
} }
writeHitEffectToMap(itemJson, this.hit_effect, "hitEffect"); writeHitEffectToMap(itemJson, this.hit_effect, "hitEffect");
writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect"); writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect");
String key; String key;
if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) { if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) {
key = "killEffect"; key = "killEffect";
@@ -438,7 +438,8 @@ public class Item extends JSONElement {
public int calculateEquipCost(boolean isWeapon) { public int calculateEquipCost(boolean isWeapon) {
final int costBC = (int) (3 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_block_chance)), 2.5) + 28 * zeroForNull(equip_effect.increase_block_chance)); final int costBC = (int) (3 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_block_chance)), 2.5) + 28 * zeroForNull(equip_effect.increase_block_chance));
final int costAC = (int) (0.4 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_attack_chance)), 2.5) - 6 * Math.pow(Math.abs(Math.min(0, zeroForNull(equip_effect.increase_attack_chance))), 2.7)); final int costAC = (int) (0.4 * Math.pow(Math.max(0, zeroForNull(equip_effect.increase_attack_chance)), 2.5) - 6 * Math.pow(
Math.abs(Math.min(0, zeroForNull(equip_effect.increase_attack_chance))), 2.7));
final int costAP = isWeapon ? final int costAP = isWeapon ?
(int) (0.2 * Math.pow(10.0f / zeroForNull(equip_effect.increase_attack_cost), 8) - 25 * zeroForNull(equip_effect.increase_attack_cost)) (int) (0.2 * Math.pow(10.0f / zeroForNull(equip_effect.increase_attack_cost), 8) - 25 * zeroForNull(equip_effect.increase_attack_cost))
: -3125 * zeroForNull(equip_effect.increase_attack_cost); : -3125 * zeroForNull(equip_effect.increase_attack_cost);

View File

@@ -171,10 +171,10 @@ public class ItemCategory extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
//Nothing to link to :D //Nothing to link to :D
this.state = State.linked; this.state = State.linked;

View File

@@ -21,7 +21,7 @@ public abstract class JSONElement extends GameDataElement {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void parse() { public void parse() {
if (shouldSkipParse()) { if (shouldSkipParse()) {
return; return;
} }
JSONParser parser = new JSONParser(); JSONParser parser = new JSONParser();

View File

@@ -12,7 +12,6 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -187,10 +186,10 @@ public class NPC extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
Project proj = getProject(); Project proj = getProject();
if (proj == null) { if (proj == null) {
Notification.addError("Error linking item " + id + ". No parent project found."); Notification.addError("Error linking item " + id + ". No parent project found.");
@@ -345,7 +344,8 @@ public class NPC extends JSONElement {
avgCrit = (double) (critical_skill / 100.0) * critical_multiplier; avgCrit = (double) (critical_skill / 100.0) * critical_multiplier;
} }
double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit); double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit);
double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double) (block_chance != null ? block_chance : 0) / 100.0))) + (EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0)); double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double) (block_chance != null ? block_chance : 0) / 100.0))) +
(EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0));
double attackConditionBonus = 0; double attackConditionBonus = 0;
if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) { if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) {
attackConditionBonus = 50; attackConditionBonus = 50;

View File

@@ -112,10 +112,10 @@ public class Quest extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
for (QuestStage stage : stages) { for (QuestStage stage : stages) {
stage.link(); stage.link();

View File

@@ -59,10 +59,10 @@ public class QuestStage extends JSONElement {
@Override @Override
public void link() { public void link() {
if (shouldSkipParseOrLink()) { if (shouldSkipParseOrLink()) {
return; return;
} }
ensureParseIfNeeded(); ensureParseIfNeeded();
//Nothing to link to :D //Nothing to link to :D
this.state = State.linked; this.state = State.linked;

View File

@@ -101,7 +101,8 @@ public class KeyArea extends MapObject {
public void updateNameFromRequirementChange() { public void updateNameFromRequirementChange() {
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) { if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value)); name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(
requirement.required_value));
} else if (oldSchoolRequirement) { } else if (oldSchoolRequirement) {
int i = 0; int i = 0;
String futureName = requirement.type.toString() + "#" + Integer.toString(i); String futureName = requirement.type.toString() + "#" + Integer.toString(i);

View File

@@ -102,7 +102,8 @@ public class ReplaceArea extends MapObject {
//Don't use yet ! //Don't use yet !
public void updateNameFromRequirementChange() { public void updateNameFromRequirementChange() {
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) { if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value)); name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id + ":" + ((requirement.required_value == null) ? "" : Integer.toString(
requirement.required_value));
} else if (oldSchoolRequirement) { } else if (oldSchoolRequirement) {
int i = 0; int i = 0;
String futureName = requirement.type.toString() + "#" + Integer.toString(i); String futureName = requirement.type.toString() + "#" + Integer.toString(i);

View File

@@ -152,12 +152,14 @@ public class AboutEditor extends Editor {
editorTabsHolder.add("Welcome", getInfoPane(WELCOME_STRING, "text/html")); editorTabsHolder.add("Welcome", getInfoPane(WELCOME_STRING, "text/html"));
editorTabsHolder.add("JSON.simple License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JSON.simple.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("JSON.simple License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JSON.simple.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("RSyntaxTextArea License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/RSyntaxTextArea.License.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("RSyntaxTextArea License",
getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/RSyntaxTextArea.License.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("JIDE Common Layer License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JIDE.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("JIDE Common Layer License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.JIDE.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("libtiled-java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.libtiled.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("libtiled-java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.libtiled.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("prefuse License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/license-prefuse.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("prefuse License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/license-prefuse.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("BeanShell License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.LGPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("BeanShell License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.LGPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("SipHash for Java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.siphash-zackehh.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("SipHash for Java License",
getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.siphash-zackehh.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("jsoup License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.jsoup.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("jsoup License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.jsoup.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("General PO Parser License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.GPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("General PO Parser License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.GPLv3.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));
editorTabsHolder.add("Minify.java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.minify.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text")); editorTabsHolder.add("Minify.java License", getInfoPane(new Scanner(ATContentStudio.class.getResourceAsStream("/LICENSE.minify.txt"), "UTF-8").useDelimiter("\\A").next(), "text/text"));

View File

@@ -189,6 +189,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
}); });
return tfField; return tfField;
} }
public static <T extends JTextComponent> T addTextComponent(JPanel pane, String label, boolean editable, final FieldUpdateListener listener, T tfField, boolean specialNewLinesHandling, boolean scrollable) { public static <T extends JTextComponent> T addTextComponent(JPanel pane, String label, boolean editable, final FieldUpdateListener listener, T tfField, boolean specialNewLinesHandling, boolean scrollable) {
JPanel tfPane = new JPanel(); JPanel tfPane = new JPanel();
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6)); tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
@@ -196,9 +197,9 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
tfPane.add(tfLabel, JideBoxLayout.FIX); tfPane.add(tfLabel, JideBoxLayout.FIX);
tfField.setEditable(editable); tfField.setEditable(editable);
JComponent component; JComponent component;
if (scrollable){ if (scrollable) {
component = new JScrollPane(tfField); component = new JScrollPane(tfField);
}else{ } else {
component = tfField; component = tfField;
} }
tfPane.add(component, JideBoxLayout.VARY); tfPane.add(component, JideBoxLayout.VARY);
@@ -218,21 +219,21 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
String text = tfField.getText(); String text = tfField.getText();
if(specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n")); if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
listener.valueChanged(tfField, text); listener.valueChanged(tfField, text);
} }
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
String text = tfField.getText(); String text = tfField.getText();
if(specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n")); if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
listener.valueChanged(tfField, text); listener.valueChanged(tfField, text);
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
String text = tfField.getText(); String text = tfField.getText();
if(specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n")); if (specialNewLinesHandling) text = text.replaceAll("\n", Matcher.quoteReplacement("\n"));
listener.valueChanged(tfField, text); listener.valueChanged(tfField, text);
} }
}); });
@@ -291,11 +292,12 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
}); });
return spinner; return spinner;
} }
public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, Integer defaultValue, boolean allowNegatives, boolean editable, final FieldUpdateListener listener) { public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, Integer defaultValue, boolean allowNegatives, boolean editable, final FieldUpdateListener listener) {
int value = initialValue != null ? initialValue : defaultValue; int value = initialValue != null ? initialValue : defaultValue;
int minimum = allowNegatives ? Integer.MIN_VALUE : 0; int minimum = allowNegatives ? Integer.MIN_VALUE : 0;
int maximum = Integer.MAX_VALUE; int maximum = Integer.MAX_VALUE;
return addNumberField(pane, label, editable, listener, minimum, maximum, 1, value, defaultValue); return addNumberField(pane, label, editable, listener, minimum, maximum, 1, value, defaultValue);
} }
@@ -361,7 +363,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
entryTypeBox.setEnabled(editable); entryTypeBox.setEnabled(editable);
tfPane.add(entryTypeBox, JideBoxLayout.FIX); tfPane.add(entryTypeBox, JideBoxLayout.FIX);
/////////////////////////////////////////////////////////////////////////////////////////////////// make sure "chance" is between 1 and 100. If lower than 1 get 1. If higher than 100, get chance/maxChance * 100... Then do the same with defaultChance, in case no value exist. /////////////////////////////////////////////////////////////////////////////////////////////////// make sure "chance" is between 1 and 100. If lower than 1 get 1. If higher than 100, get chance/maxChance * 100... Then do the same with defaultChance, in case no value exist.
final SpinnerNumberModel percentModel = new SpinnerNumberModel(initialValue != null ? ((chance > 1 ? chance : 1) < 100 ? chance : (chance * 100 / maxChance)) : ((defaultChance > 1 ? defaultChance : 1) < 100 ? defaultChance : (defaultChance * 100 / defaultMaxChance)), 1, 100, 1); final SpinnerNumberModel percentModel = new SpinnerNumberModel(
initialValue != null ? ((chance > 1 ? chance : 1) < 100 ? chance : (chance * 100 / maxChance)) : ((defaultChance > 1 ? defaultChance : 1) < 100 ? defaultChance : (defaultChance * 100 /
defaultMaxChance)),
1, 100, 1);
final SpinnerNumberModel ratioChanceModel = new SpinnerNumberModel(initialValue != null ? chance : defaultChance, 1, Integer.MAX_VALUE, 1); final SpinnerNumberModel ratioChanceModel = new SpinnerNumberModel(initialValue != null ? chance : defaultChance, 1, Integer.MAX_VALUE, 1);
final JSpinner chanceSpinner = new JSpinner(currentFormIsRatio ? ratioChanceModel : percentModel); final JSpinner chanceSpinner = new JSpinner(currentFormIsRatio ? ratioChanceModel : percentModel);
@@ -1105,10 +1110,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
} }
public <E extends Common.ActorConditionEffect, T extends OrderedListenerListModel<?, E>> void updateConditionEffect(ActorCondition value, public <E extends Common.ActorConditionEffect, T extends OrderedListenerListModel<?, E>> void updateConditionEffect(ActorCondition value,
GameDataElement backlink, GameDataElement backlink,
E selectedHitEffectTargetCondition, E selectedHitEffectTargetCondition,
T hitTargetConditionsModel) { T hitTargetConditionsModel) {
if (selectedHitEffectTargetCondition.condition != null) { if (selectedHitEffectTargetCondition.condition != null) {
selectedHitEffectTargetCondition.condition.removeBacklink(backlink); selectedHitEffectTargetCondition.condition.removeBacklink(backlink);
} }

View File

@@ -5,7 +5,6 @@ import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.NotificationListener; import com.gpl.rpg.atcontentstudio.NotificationListener;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import java.awt.*; import java.awt.*;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@@ -1,6 +1,5 @@
package com.gpl.rpg.atcontentstudio.ui; package com.gpl.rpg.atcontentstudio.ui;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@@ -624,19 +624,25 @@ public class ProjectsTree extends JPanel {
public void insertNode(TreePath node) { public void insertNode(TreePath node) {
for (TreeModelListener l : listeners) { for (TreeModelListener l : listeners) {
l.treeNodesInserted(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath().getPath(), new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()})); l.treeNodesInserted(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath().getPath(),
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
new Object[]{node.getLastPathComponent()}));
} }
} }
public void changeNode(TreePath node) { public void changeNode(TreePath node) {
for (TreeModelListener l : listeners) { for (TreeModelListener l : listeners) {
l.treeNodesChanged(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(), new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()})); l.treeNodesChanged(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(),
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
new Object[]{node.getLastPathComponent()}));
} }
} }
public void removeNode(TreePath node) { public void removeNode(TreePath node) {
for (TreeModelListener l : listeners) { for (TreeModelListener l : listeners) {
l.treeNodesRemoved(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(), new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())}, new Object[]{node.getLastPathComponent()})); l.treeNodesRemoved(new TreeModelEvent(node.getLastPathComponent(), node.getParentPath(),
new int[]{((ProjectTreeNode) node.getParentPath().getLastPathComponent()).getIndex((ProjectTreeNode) node.getLastPathComponent())},
new Object[]{node.getLastPathComponent()}));
} }
} }

View File

@@ -65,11 +65,13 @@ public class WorkspaceActions {
public ATCSAction deleteProject = new ATCSAction("Delete project", "Deletes the project, and all created/altered data, from disk") { public ATCSAction deleteProject = new ATCSAction("Delete project", "Deletes the project, and all created/altered data, from disk") {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (selectedNode instanceof Project) { if (selectedNode instanceof Project) {
if (JOptionPane.showConfirmDialog(ATContentStudio.frame, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { if (JOptionPane.showConfirmDialog(ATContentStudio.frame, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?",
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Workspace.deleteProject((Project) selectedNode); Workspace.deleteProject((Project) selectedNode);
} }
} else if (selectedNode instanceof ClosedProject) { } else if (selectedNode instanceof ClosedProject) {
if (JOptionPane.showConfirmDialog(ATContentStudio.frame, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { if (JOptionPane.showConfirmDialog(ATContentStudio.frame, "Are you sure you wish to delete this project ?\nAll files created for it will be deleted too...", "Delete this project ?",
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
Workspace.deleteProject((ClosedProject) selectedNode); Workspace.deleteProject((ClosedProject) selectedNode);
} }
} }
@@ -380,7 +382,8 @@ public class WorkspaceActions {
public ATCSAction exitATCS = new ATCSAction("Exit", "Closes the program") { public ATCSAction exitATCS = new ATCSAction("Exit", "Closes the program") {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (Workspace.activeWorkspace.needsSaving()) { if (Workspace.activeWorkspace.needsSaving()) {
int answer = JOptionPane.showConfirmDialog(ATContentStudio.frame, "There are unsaved changes in your workspace.\nExiting ATCS will discard these changes.\nDo you really want to exit?", "Unsaved changes. Confirm exit.", JOptionPane.YES_NO_OPTION); int answer = JOptionPane.showConfirmDialog(ATContentStudio.frame, "There are unsaved changes in your workspace.\nExiting ATCS will discard these changes.\nDo you really want to exit?",
"Unsaved changes. Confirm exit.", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) { if (answer == JOptionPane.YES_OPTION) {
System.exit(0); System.exit(0);
} }

View File

@@ -89,7 +89,7 @@ public class ActorConditionEditor extends JSONElementEditor {
} else { } else {
roundEffect = new ActorCondition.RoundEffect(); roundEffect = new ActorCondition.RoundEffect();
} }
roundVisualField = addEnumValueBox(roundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), roundEffect.visual_effect, ac.writable, listener);//addTextField(roundEffectPane, "Visual effect ID: ", roundEffect.visual_effect, ac.writable, listener); roundVisualField = addEnumValueBox(roundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), roundEffect.visual_effect, ac.writable, listener);
roundHpMinField = addIntegerField(roundEffectPane, "HP Bonus Min: ", roundEffect.hp_boost_min, true, ac.writable, listener); roundHpMinField = addIntegerField(roundEffectPane, "HP Bonus Min: ", roundEffect.hp_boost_min, true, ac.writable, listener);
roundHpMaxField = addIntegerField(roundEffectPane, "HP Bonus Max: ", roundEffect.hp_boost_max, true, ac.writable, listener); roundHpMaxField = addIntegerField(roundEffectPane, "HP Bonus Max: ", roundEffect.hp_boost_max, true, ac.writable, listener);
roundApMinField = addIntegerField(roundEffectPane, "AP Bonus Min: ", roundEffect.ap_boost_min, true, ac.writable, listener); roundApMinField = addIntegerField(roundEffectPane, "AP Bonus Min: ", roundEffect.ap_boost_min, true, ac.writable, listener);
@@ -106,7 +106,7 @@ public class ActorConditionEditor extends JSONElementEditor {
} else { } else {
fullRoundEffect = new ActorCondition.RoundEffect(); fullRoundEffect = new ActorCondition.RoundEffect();
} }
fullRoundVisualField = addEnumValueBox(fullRoundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), fullRoundEffect.visual_effect, ac.writable, listener);//addTextField(fullRoundEffectPane, "Visual effect ID: ", fullRoundEffect.visual_effect, ac.writable, listener); fullRoundVisualField = addEnumValueBox(fullRoundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), fullRoundEffect.visual_effect, ac.writable, listener);
fullRoundHpMinField = addIntegerField(fullRoundEffectPane, "HP Bonus min: ", fullRoundEffect.hp_boost_min, true, ac.writable, listener); fullRoundHpMinField = addIntegerField(fullRoundEffectPane, "HP Bonus min: ", fullRoundEffect.hp_boost_min, true, ac.writable, listener);
fullRoundHpMaxField = addIntegerField(fullRoundEffectPane, "HP Bonus max: ", fullRoundEffect.hp_boost_max, true, ac.writable, listener); fullRoundHpMaxField = addIntegerField(fullRoundEffectPane, "HP Bonus max: ", fullRoundEffect.hp_boost_max, true, ac.writable, listener);
fullRoundApMinField = addIntegerField(fullRoundEffectPane, "AP Bonus min: ", fullRoundEffect.ap_boost_min, true, ac.writable, listener); fullRoundApMinField = addIntegerField(fullRoundEffectPane, "AP Bonus min: ", fullRoundEffect.ap_boost_min, true, ac.writable, listener);
@@ -505,18 +505,17 @@ public class ActorConditionEditor extends JSONElementEditor {
} }
private boolean isEmpty(ActorCondition.RoundEffect round_effect) { private boolean isEmpty(ActorCondition.RoundEffect round_effect) {
return round_effect == null || ( return round_effect == null ||
round_effect.visual_effect == null && (round_effect.visual_effect == null &&
round_effect.hp_boost_min == null && round_effect.hp_boost_min == null &&
round_effect.hp_boost_max == null && round_effect.hp_boost_max == null &&
round_effect.ap_boost_min == null && round_effect.ap_boost_min == null &&
round_effect.ap_boost_max == null round_effect.ap_boost_max == null);
);
} }
private boolean isEmpty(ActorCondition.AbilityEffect ability_effect) { private boolean isEmpty(ActorCondition.AbilityEffect ability_effect) {
return ability_effect == null || ( return ability_effect == null ||
ability_effect.max_hp_boost == null && (ability_effect.max_hp_boost == null &&
ability_effect.max_ap_boost == null && ability_effect.max_ap_boost == null &&
ability_effect.increase_move_cost == null && ability_effect.increase_move_cost == null &&
ability_effect.increase_use_cost == null && ability_effect.increase_use_cost == null &&
@@ -527,8 +526,7 @@ public class ActorConditionEditor extends JSONElementEditor {
ability_effect.increase_damage_max == null && ability_effect.increase_damage_max == null &&
ability_effect.increase_critical_skill == null && ability_effect.increase_critical_skill == null &&
ability_effect.increase_block_chance == null && ability_effect.increase_block_chance == null &&
ability_effect.increase_damage_resistance == null ability_effect.increase_damage_resistance == null);
);
} }
} }

View File

@@ -48,7 +48,12 @@ public class CommonEditor {
} else { } else {
label.setIcon(new ImageIcon(effect.condition.getIcon())); label.setIcon(new ImageIcon(effect.condition.getIcon()));
label.setText( label.setText(
effect.chance + "% chances to give actor condition " + effect.condition.getDesc() + " x" + effect.magnitude + (forever ? " forever" : " for " + effect.duration + " rounds")); effect.chance +
"% chances to give actor condition " +
effect.condition.getDesc() +
" x" +
effect.magnitude +
(forever ? " forever" : " for " + effect.duration + " rounds"));
} }
} else { } else {
label.setText("New, undefined actor condition effect."); label.setText("New, undefined actor condition effect.");
@@ -143,7 +148,7 @@ public class CommonEditor {
protected final String applyToTargetHint; protected final String applyToTargetHint;
private JList hitTargetConditionsList; private JList hitTargetConditionsList;
private final ConditionEffectEditorPane<LIST_MODEL_SOURCE, ELEMENT, MODEL> hitTargetConditionPane ; private final ConditionEffectEditorPane<LIST_MODEL_SOURCE, ELEMENT, MODEL> hitTargetConditionPane;
/* /*
* create a new HitEffectPane with the selections (probably passed in from last time) * create a new HitEffectPane with the selections (probably passed in from last time)
@@ -193,7 +198,7 @@ public class CommonEditor {
@Override @Override
public boolean valueChanged(JComponent source, Object value, GameDataElement backlink) { public boolean valueChanged(JComponent source, Object value, GameDataElement backlink) {
boolean updateHit = false; boolean updateHit = false;
if(super.valueChanged(source, value, backlink)){ if (super.valueChanged(source, value, backlink)) {
updateHit = true; updateHit = true;
} else if (source == hitTargetConditionsList) { } else if (source == hitTargetConditionsList) {
updateHit = true; updateHit = true;
@@ -295,7 +300,7 @@ public class CommonEditor {
updateHit = true; updateHit = true;
} else if (source == sourceConditionsList) { } else if (source == sourceConditionsList) {
updateHit = true; updateHit = true;
} else if (sourceConditionPane.valueChanged(source, value, backlink)){ } else if (sourceConditionPane.valueChanged(source, value, backlink)) {
updateHit = true; updateHit = true;
} }
return updateHit; return updateHit;
@@ -360,7 +365,7 @@ public class CommonEditor {
Project proj = editor.target.getProject(); Project proj = editor.target.getProject();
conditionBox = editor.addActorConditionBox(pane, proj, "Actor Condition: ", condition.condition, writable, conditionBox = editor.addActorConditionBox(pane, proj, "Actor Condition: ", condition.condition, writable,
listener); listener);
conditionChance = Editor.addDoubleField(pane, "Chance: ", condition.chance, writable, listener); conditionChance = Editor.addDoubleField(pane, "Chance: ", condition.chance, writable, listener);
conditionClear = new JRadioButton("Clear active condition"); conditionClear = new JRadioButton("Clear active condition");

View File

@@ -234,7 +234,8 @@ public class DialogueEditor extends JSONElementEditor {
case changeMapFilter: case changeMapFilter:
rewardMap = addMapBox(pane, ((Dialogue) target).getProject(), "Map Name: ", reward.map, writable, listener); rewardMap = addMapBox(pane, ((Dialogue) target).getProject(), "Map Name: ", reward.map, writable, listener);
rewardObjId = null; rewardObjId = null;
rewardObjIdCombo = addEnumValueBox(pane, "Color Filter", TMXMap.ColorFilter.values(), reward.reward_obj_id != null ? TMXMap.ColorFilter.valueOf(reward.reward_obj_id) : TMXMap.ColorFilter.none, writable, listener); rewardObjIdCombo = addEnumValueBox(pane, "Color Filter", TMXMap.ColorFilter.values(),
reward.reward_obj_id != null ? TMXMap.ColorFilter.valueOf(reward.reward_obj_id) : TMXMap.ColorFilter.none, writable, listener);
rewardObj = null; rewardObj = null;
rewardValue = null; rewardValue = null;
break; break;
@@ -278,7 +279,8 @@ public class DialogueEditor extends JSONElementEditor {
if (!immunity) radioGroup.add(rewardConditionClear); if (!immunity) radioGroup.add(rewardConditionClear);
if (immunity) { if (immunity) {
rewardConditionTimed.setSelected(reward.reward_value == null || (!reward.reward_value.equals(ActorCondition.DURATION_FOREVER) && !reward.reward_value.equals(ActorCondition.MAGNITUDE_CLEAR))); rewardConditionTimed.setSelected(
reward.reward_value == null || (!reward.reward_value.equals(ActorCondition.DURATION_FOREVER) && !reward.reward_value.equals(ActorCondition.MAGNITUDE_CLEAR)));
rewardConditionForever.setSelected(reward.reward_value != null && !reward.reward_value.equals(ActorCondition.DURATION_FOREVER)); rewardConditionForever.setSelected(reward.reward_value != null && !reward.reward_value.equals(ActorCondition.DURATION_FOREVER));
rewardConditionClear.setSelected(reward.reward_value != null && !reward.reward_value.equals(ActorCondition.MAGNITUDE_CLEAR)); rewardConditionClear.setSelected(reward.reward_value != null && !reward.reward_value.equals(ActorCondition.MAGNITUDE_CLEAR));
} else { } else {

View File

@@ -4,9 +4,14 @@ import com.gpl.rpg.atcontentstudio.ATContentStudio;
import com.gpl.rpg.atcontentstudio.model.GameDataElement; import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.Project; import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode; import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.gamedata.*; import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
import com.gpl.rpg.atcontentstudio.model.gamedata.ItemCategory;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet; import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.ui.*; import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
import com.gpl.rpg.atcontentstudio.ui.OrderedListenerListModel;
import com.gpl.rpg.atcontentstudio.utils.BasicLambda; import com.gpl.rpg.atcontentstudio.utils.BasicLambda;
import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithArg; import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithArg;
import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithReturn; import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithReturn;
@@ -97,7 +102,8 @@ public class ItemEditor extends JSONElementEditor {
typeBox = addEnumValueBox(pane, "Type: ", Item.DisplayType.values(), item.display_type, item.writable, listener); typeBox = addEnumValueBox(pane, "Type: ", Item.DisplayType.values(), item.display_type, item.writable, listener);
manualPriceBox = addIntegerBasedCheckBox(pane, "Has manual price", item.has_manual_price, item.writable, listener); manualPriceBox = addIntegerBasedCheckBox(pane, "Has manual price", item.has_manual_price, item.writable, listener);
baseManualPrice = item.base_market_cost; baseManualPrice = item.base_market_cost;
baseCostField = addIntegerField(pane, "Base market cost: ", (item.has_manual_price != null && item.has_manual_price == 1) ? item.base_market_cost : item.computePrice(), false, item.writable, listener); baseCostField = addIntegerField(pane, "Base market cost: ", (item.has_manual_price != null && item.has_manual_price == 1) ? item.base_market_cost : item.computePrice(), false, item.writable,
listener);
if (!manualPriceBox.isSelected()) { if (!manualPriceBox.isSelected()) {
baseCostField.setEnabled(false); baseCostField.setEnabled(false);
} }
@@ -128,22 +134,23 @@ public class ItemEditor extends JSONElementEditor {
String titleEquipConditions = "Actor Conditions applied when equipped: "; String titleEquipConditions = "Actor Conditions applied when equipped: ";
equipConditionsModel = new EquipConditionsListModel(equipEffect); equipConditionsModel = new EquipConditionsListModel(equipEffect);
CommonEditor.ConditionsCellRenderer cellRendererEquipConditions = new CommonEditor.ConditionsCellRenderer(); CommonEditor.ConditionsCellRenderer cellRendererEquipConditions = new CommonEditor.ConditionsCellRenderer();
BasicLambdaWithArg<ActorConditionEffect> selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value; BasicLambdaWithArg<ActorConditionEffect> selectedSetEquipConditions = (value) -> selectedEquipEffectCondition = value;
BasicLambdaWithReturn<ActorConditionEffect> selectedGetEquipConditions = ()->selectedEquipEffectCondition ; BasicLambdaWithReturn<ActorConditionEffect> selectedGetEquipConditions = () -> selectedEquipEffectCondition;
BasicLambda selectedResetEquipConditions = ()->selectedEquipEffectCondition = null; BasicLambda selectedResetEquipConditions = () -> selectedEquipEffectCondition = null;
BasicLambdaWithArg<JPanel> updatePaneEquipConditions = (editorPane) -> updateEquipConditionEditorPane(editorPane, selectedEquipEffectCondition, listener); BasicLambdaWithArg<JPanel> updatePaneEquipConditions = (editorPane) -> updateEquipConditionEditorPane(editorPane, selectedEquipEffectCondition, listener);
var resultEquipConditions = UiUtils.getCollapsibleItemList(listener, var resultEquipConditions = UiUtils.getCollapsibleItemList(listener,
equipConditionsModel, equipConditionsModel,
selectedResetEquipConditions, selectedResetEquipConditions,
selectedSetEquipConditions, selectedSetEquipConditions,
selectedGetEquipConditions, selectedGetEquipConditions,
(x) -> {}, (x) -> {
updatePaneEquipConditions, },
item.writable, updatePaneEquipConditions,
ActorConditionEffect::new, item.writable,
cellRendererEquipConditions, ActorConditionEffect::new,
titleEquipConditions, cellRendererEquipConditions,
(x) -> null); titleEquipConditions,
(x) -> null);
equipConditionsList = resultEquipConditions.list; equipConditionsList = resultEquipConditions.list;
CollapsiblePanel equipConditionsPane = resultEquipConditions.collapsiblePanel; CollapsiblePanel equipConditionsPane = resultEquipConditions.collapsiblePanel;
if (item.equip_effect == null || item.equip_effect.conditions == null || item.equip_effect.conditions.isEmpty()) { if (item.equip_effect == null || item.equip_effect.conditions == null || item.equip_effect.conditions.isEmpty()) {

View File

@@ -3,9 +3,13 @@ package com.gpl.rpg.atcontentstudio.ui.gamedataeditors;
import com.gpl.rpg.atcontentstudio.ATContentStudio; import com.gpl.rpg.atcontentstudio.ATContentStudio;
import com.gpl.rpg.atcontentstudio.model.GameDataElement; import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode; import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.gamedata.*; import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
import com.gpl.rpg.atcontentstudio.model.gamedata.Droplist;
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet; import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.ui.*; import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree.DialogueGraphView; import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree.DialogueGraphView;
import com.gpl.rpg.atcontentstudio.utils.UiUtils; import com.gpl.rpg.atcontentstudio.utils.UiUtils;
import com.jidesoft.swing.JideBoxLayout; import com.jidesoft.swing.JideBoxLayout;
@@ -15,7 +19,6 @@ import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*; import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*;
@@ -57,7 +60,8 @@ public class NPCEditor extends JSONElementEditor {
private JSpinner dmgRes; private JSpinner dmgRes;
private CommonEditor.HitEffectPane hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", TimedActorConditionEffect::new, this, null, null); private CommonEditor.HitEffectPane hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", TimedActorConditionEffect::new, this, null, null);
private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", TimedActorConditionEffect::new, this, "NPC", "Attacker"); private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", TimedActorConditionEffect::new, this, "NPC",
"Attacker");
private CommonEditor.DeathEffectPane deathEffectPane = new CommonEditor.DeathEffectPane("Effect when killed: ", TimedActorConditionEffect::new, this, "Killer"); private CommonEditor.DeathEffectPane deathEffectPane = new CommonEditor.DeathEffectPane("Effect when killed: ", TimedActorConditionEffect::new, this, "Killer");
private JPanel dialogueGraphPane; private JPanel dialogueGraphPane;
@@ -170,7 +174,6 @@ public class NPCEditor extends JSONElementEditor {
} }
public class NPCFieldUpdater implements FieldUpdateListener { public class NPCFieldUpdater implements FieldUpdateListener {
@Override @Override
@@ -263,7 +266,7 @@ public class NPCEditor extends JSONElementEditor {
npc.block_chance = (Integer) value; npc.block_chance = (Integer) value;
} else if (source == dmgRes) { } else if (source == dmgRes) {
npc.damage_resistance = (Integer) value; npc.damage_resistance = (Integer) value;
} else if(hitEffectPane.valueChanged(source, value, npc)) { } else if (hitEffectPane.valueChanged(source, value, npc)) {
updateHit = true; updateHit = true;
} else if (hitReceivedEffectPane.valueChanged(source, value, npc)) { } else if (hitReceivedEffectPane.valueChanged(source, value, npc)) {
updateHitReceived = true; updateHitReceived = true;
@@ -289,7 +292,7 @@ public class NPCEditor extends JSONElementEditor {
if (deathEffectPane.effect.isNull()) { if (deathEffectPane.effect.isNull()) {
npc.death_effect = null; npc.death_effect = null;
} else { } else {
npc.death_effect = deathEffectPane. effect; npc.death_effect = deathEffectPane.effect;
} }
} }

View File

@@ -5,7 +5,9 @@ import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode; import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest; import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage; import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage;
import com.gpl.rpg.atcontentstudio.ui.*; import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
import com.gpl.rpg.atcontentstudio.ui.OrderedListenerListModel;
import com.gpl.rpg.atcontentstudio.utils.BasicLambda; import com.gpl.rpg.atcontentstudio.utils.BasicLambda;
import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithArg; import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithArg;
import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithReturn; import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithReturn;
@@ -13,11 +15,7 @@ import com.gpl.rpg.atcontentstudio.utils.UiUtils;
import com.jidesoft.swing.JideBoxLayout; import com.jidesoft.swing.JideBoxLayout;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -64,23 +62,24 @@ public class QuestEditor extends JSONElementEditor {
String title = "Quest stages: "; String title = "Quest stages: ";
StagesCellRenderer cellRenderer = new StagesCellRenderer(); StagesCellRenderer cellRenderer = new StagesCellRenderer();
stagesListModel = new StagesListModel(quest); stagesListModel = new StagesListModel(quest);
BasicLambdaWithArg<QuestStage> selectedSet = (value)->selectedStage = value; BasicLambdaWithArg<QuestStage> selectedSet = (value) -> selectedStage = value;
BasicLambdaWithReturn<QuestStage> selectedGet = ()->selectedStage ; BasicLambdaWithReturn<QuestStage> selectedGet = () -> selectedStage;
BasicLambda selectedReset = ()->selectedStage = null; BasicLambda selectedReset = () -> selectedStage = null;
BasicLambdaWithArg<JPanel> updatePane = (editorPane) -> updateStageEditorPane(editorPane, selectedStage, listener); BasicLambdaWithArg<JPanel> updatePane = (editorPane) -> updateStageEditorPane(editorPane, selectedStage, listener);
var result = UiUtils.getCollapsibleItemList(listener, var result = UiUtils.getCollapsibleItemList(listener,
stagesListModel, stagesListModel,
selectedReset, selectedReset,
selectedSet, selectedSet,
selectedGet, selectedGet,
(x) -> {}, (x) -> {
updatePane, },
quest.writable, updatePane,
() -> new QuestStage(quest), quest.writable,
cellRenderer, () -> new QuestStage(quest),
title, cellRenderer,
(x) -> null); title,
(x) -> null);
stagesList = result.list; stagesList = result.list;
if (quest.stages == null || quest.stages.isEmpty()) { if (quest.stages == null || quest.stages.isEmpty()) {

View File

@@ -1541,7 +1541,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (map.needsSaving()) { if (map.needsSaving()) {
int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this, "You have unsaved changes in ATCS.\nYou'd better save your changes in ATCS before opening this map with the external editor.\nDo you want to save before opening the file?", "Save before opening?", JOptionPane.YES_NO_CANCEL_OPTION); int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this,
"You have unsaved changes in ATCS.\nYou'd better save your changes in ATCS before opening this map with the external editor.\nDo you want to save before opening the file?",
"Save before opening?", JOptionPane.YES_NO_CANCEL_OPTION);
if (confirm == JOptionPane.CANCEL_OPTION) return; if (confirm == JOptionPane.CANCEL_OPTION) return;
if (confirm == JOptionPane.YES_OPTION) { if (confirm == JOptionPane.YES_OPTION) {
map.save(); map.save();
@@ -1559,7 +1561,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (map.needsSaving()) { if (map.needsSaving()) {
int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this, "You modified this map in ATCS. All ATCS-made changes will be lost if you confirm.\n On the other hand, if you save using ATCS, all external changes will be lost.\n Do you want to reload?", "Confirm reload?", JOptionPane.OK_CANCEL_OPTION); int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this,
"You modified this map in ATCS. All ATCS-made changes will be lost if you confirm.\n On the other hand, if you save using ATCS, all external changes will be lost.\n Do you want to reload?",
"Confirm reload?", JOptionPane.OK_CANCEL_OPTION);
if (confirm == JOptionPane.CANCEL_OPTION) return; if (confirm == JOptionPane.CANCEL_OPTION) return;
} }
reload.setEnabled(false); reload.setEnabled(false);
@@ -1581,11 +1585,14 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (map.state != TMXMap.State.saved) { if (map.state != TMXMap.State.saved) {
if (map.changedOnDisk) { if (map.changedOnDisk) {
int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this, "You modified this map in an external tool. All external changes will be lost if you confirm.\n On the other hand, if you reload in ATCS, all ATCS-made changes will be lost.\n Do you want to save?", "Confirm save?", JOptionPane.OK_CANCEL_OPTION); int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this,
"You modified this map in an external tool. All external changes will be lost if you confirm.\n On the other hand, if you reload in ATCS, all ATCS-made changes will be lost.\n Do you want to save?",
"Confirm save?", JOptionPane.OK_CANCEL_OPTION);
if (confirm == JOptionPane.CANCEL_OPTION) return; if (confirm == JOptionPane.CANCEL_OPTION) return;
File backup = FileUtils.backupFile(map.tmxFile); File backup = FileUtils.backupFile(map.tmxFile);
if (backup != null) { if (backup != null) {
JOptionPane.showMessageDialog(TMXMapEditor.this, "The externally-modified file was backed up as " + backup.getAbsolutePath(), "File backed up", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(TMXMapEditor.this, "The externally-modified file was backed up as " + backup.getAbsolutePath(), "File backed up",
JOptionPane.INFORMATION_MESSAGE);
} else { } else {
JOptionPane.showMessageDialog(TMXMapEditor.this, "The externally-modified file could not be backed up.", "File backup failed", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(TMXMapEditor.this, "The externally-modified file could not be backed up.", "File backup failed", JOptionPane.ERROR_MESSAGE);
} }

View File

@@ -307,7 +307,9 @@ public class ItemsTableView extends ElementTableView {
case 22: case 22:
return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.ap_boost_max : null;//"On hit recv - AP max"; return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.ap_boost_max : null;//"On hit recv - AP max";
case 23: case 23:
return (!canUse && item.hit_received_effect != null && item.hit_received_effect.conditions_source != null) ? item.hit_received_effect.conditions_source.size() : null;//"On hit recv - # conditions"; return (!canUse &&
item.hit_received_effect != null &&
item.hit_received_effect.conditions_source != null) ? item.hit_received_effect.conditions_source.size() : null;//"On hit recv - # conditions";
case 24: case 24:
return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.hp_boost_min : null;//"On hit recv - Tgt HP min"; return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.hp_boost_min : null;//"On hit recv - Tgt HP min";
case 25: case 25:

View File

@@ -147,7 +147,8 @@ public class FileUtils {
case Windows: case Windows:
System.err.println("Trying the Windows way with mklink"); System.err.println("Trying the Windows way with mklink");
try { try {
Runtime.getRuntime().exec("cmd.exe /C mklink " + (targetFile.isDirectory() ? "/J " : "") + "\"" + linkFile.getAbsolutePath() + "\" \"" + targetFile.getAbsolutePath() + "\""); Runtime.getRuntime().exec(
"cmd.exe /C mklink " + (targetFile.isDirectory() ? "/J " : "") + "\"" + linkFile.getAbsolutePath() + "\" \"" + targetFile.getAbsolutePath() + "\"");
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }

View File

@@ -17,7 +17,8 @@ public class UiUtils {
public CollapsiblePanel collapsiblePanel; public CollapsiblePanel collapsiblePanel;
public JList<E> list; public JList<E> list;
} }
public static JPanel createRefreshButtonPane(ActionListener reloadButtonEditor){
public static JPanel createRefreshButtonPane(ActionListener reloadButtonEditor) {
JPanel buttonPane = new JPanel(); JPanel buttonPane = new JPanel();
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS)); buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS));
JButton reloadButton = new JButton("Refresh graph"); JButton reloadButton = new JButton("Refresh graph");
@@ -64,8 +65,8 @@ public class UiUtils {
moveDownBtn.setEnabled(false); moveDownBtn.setEnabled(false);
} else { } else {
deleteBtn.setEnabled(true); deleteBtn.setEnabled(true);
moveUpBtn.setEnabled(list.getSelectedIndex() > 0); moveUpBtn.setEnabled(list.getSelectedIndex() > 0);
moveDownBtn.setEnabled(list.getSelectedIndex() < (listModel.getSize() - 1)); moveDownBtn.setEnabled(list.getSelectedIndex() < (listModel.getSize() - 1));
} }
updateEditorPane.doIt(editorPane); updateEditorPane.doIt(editorPane);