diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 386fbca..3e9de3b 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,8 +1,13 @@ + + + diff --git a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java index 30c787d..0afa335 100644 --- a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java +++ b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java @@ -152,13 +152,13 @@ public class ATContentStudio { 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", - "" + "You are not running the latest ATCS version.
" - + "You can get the latest version (" + lastLine + ") by clicking the link below.
" - + "" + DOWNLOAD_URL + "
" + "
" - + ""); + "" + "You are not running the latest ATCS version.
" + + "You can get the latest version (" + lastLine + ") by clicking the link below.
" + + "" + DOWNLOAD_URL + "
" + "
" + + ""); ep.setEditable(false); ep.setBorder(null); diff --git a/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java b/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java index 65f5fae..584ee1e 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java +++ b/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java @@ -203,18 +203,19 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable { public abstract List attemptSave(); - /** - * Checks if the current state indicates that parsing/linking should be skipped. - * @return true if the operation should be skipped, false otherwise - */ - protected boolean shouldSkipParseOrLink() { + /** + * Checks if the current state indicates that parsing/linking should be skipped. + * + * @return true if the operation should be skipped, false otherwise + */ + protected boolean shouldSkipParseOrLink() { if (shouldSkipParse()) return true; if (this.state == State.linked) { - //Already linked. - return true; - } - return false; - } + //Already linked. + return true; + } + return false; + } protected boolean shouldSkipParse() { 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. - */ - protected void ensureParseIfNeeded() { - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } - } + * Ensures the element is parsed if needed based on its current state. + */ + protected void ensureParseIfNeeded() { + if (this.state == State.init) { + //Not parsed yet. + this.parse(); + } + } } diff --git a/src/com/gpl/rpg/atcontentstudio/model/Project.java b/src/com/gpl/rpg/atcontentstudio/model/Project.java index baea51c..8ae3fe0 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/Project.java +++ b/src/com/gpl/rpg/atcontentstudio/model/Project.java @@ -1105,13 +1105,15 @@ public class Project implements ProjectTreeNode, Serializable { // } Map, List> writtenFilesPerDataType = new LinkedHashMap, List>(); List 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); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir); writtenFilesPerDataType.put(Dialogue.class, writtenFiles); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.droplists, alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir); 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); writtenFiles = writeDataDeltaForDataType(createdContent.gameData.items, alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir); writtenFilesPerDataType.put(Item.class, writtenFiles); diff --git a/src/com/gpl/rpg/atcontentstudio/model/Workspace.java b/src/com/gpl/rpg/atcontentstudio/model/Workspace.java index a1d485f..1dcae03 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/Workspace.java +++ b/src/com/gpl/rpg/atcontentstudio/model/Workspace.java @@ -44,7 +44,7 @@ public class Workspace implements ProjectTreeNode, Serializable { workspaceRoot.mkdir(); } catch (SecurityException e) { Notification.addError("Error creating workspace directory: " - + e.getMessage()); + + e.getMessage()); e.printStackTrace(); } } @@ -55,12 +55,12 @@ public class Workspace implements ProjectTreeNode, Serializable { settingsFile.createNewFile(); } catch (IOException e) { Notification.addError("Error creating workspace datafile: " - + e.getMessage()); + + e.getMessage()); e.printStackTrace(); } } Notification.addSuccess("New workspace created: " - + workspaceRoot.getAbsolutePath()); + + workspaceRoot.getAbsolutePath()); save(); } @@ -169,26 +169,26 @@ public class Workspace implements ProjectTreeNode, Serializable { public static void createProject(final String projectName, final File gameSourceFolder, final Project.ResourceSet sourceSet) { WorkerDialog.showTaskMessage("Creating project " + projectName + "...", - ATContentStudio.frame, new Runnable() { + ATContentStudio.frame, new Runnable() { @Override public void run() { if (activeWorkspace.projectsName.contains(projectName)) { Notification.addError("A project named " - + projectName - + " already exists in this workspace."); + + projectName + + " already exists in this workspace."); return; } Project p = new Project(activeWorkspace, projectName, - gameSourceFolder, sourceSet); + gameSourceFolder, sourceSet); activeWorkspace.projects.add(p); activeWorkspace.projectsName.add(projectName); activeWorkspace.projectsOpenByName.put(projectName, - p.open); + p.open); activeWorkspace.knownMapSourcesFolders .add(gameSourceFolder); p.notifyCreated(); Notification.addSuccess("Project " + projectName - + " successfully created"); + + " successfully created"); saveActive(); } }); @@ -210,19 +210,19 @@ public class Workspace implements ProjectTreeNode, Serializable { public static void openProject(final ClosedProject cp) { WorkerDialog.showTaskMessage("Opening project " + cp.name + "...", - ATContentStudio.frame, new Runnable() { + ATContentStudio.frame, new Runnable() { @Override public void run() { int index = activeWorkspace.projects.indexOf(cp); if (index < 0) { Notification .addError("Cannot open unknown project " - + cp.name); + + cp.name); return; } cp.childrenRemoved(new ArrayList()); Project p = Project.fromFolder(activeWorkspace, - new File(activeWorkspace.baseFolder, cp.name)); + new File(activeWorkspace.baseFolder, cp.name)); p.open(); activeWorkspace.projects.set(index, p); activeWorkspace.projectsOpenByName.put(p.name, true); @@ -246,14 +246,14 @@ public class Workspace implements ProjectTreeNode, Serializable { } else { Notification .addError("Failed to open project " - + projectName - + ". Removing it from workspace (not from filesystem though)."); + + projectName + + ". Removing it from workspace (not from filesystem though)."); projectsFailed.add(projectName); } } else { Notification.addError("Unable to find project " - + projectName - + "'s root folder. Removing it from workspace"); + + projectName + + "'s root folder. Removing it from workspace"); projectsFailed.add(projectName); } } else { @@ -299,10 +299,10 @@ public class Workspace implements ProjectTreeNode, Serializable { activeWorkspace.projectsName.remove(cp.name); if (delete(new File(activeWorkspace.baseFolder, cp.name))) { Notification.addSuccess("Closed project " + cp.name - + " successfully deleted."); + + " successfully deleted."); } else { Notification.addError("Error while deleting closed project " - + cp.name + ". Files may remain in the workspace."); + + cp.name + ". Files may remain in the workspace."); } saveActive(); } @@ -314,10 +314,10 @@ public class Workspace implements ProjectTreeNode, Serializable { activeWorkspace.projectsName.remove(p.name); if (delete(p.baseFolder)) { Notification.addSuccess("Project " + p.name - + " successfully deleted."); + + " successfully deleted."); } else { Notification.addError("Error while deleting project " + p.name - + ". Files may remain in the workspace."); + + ". Files may remain in the workspace."); } saveActive(); } diff --git a/src/com/gpl/rpg/atcontentstudio/model/bookmarks/BookmarkEntry.java b/src/com/gpl/rpg/atcontentstudio/model/bookmarks/BookmarkEntry.java index 1827e20..a18498d 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/bookmarks/BookmarkEntry.java +++ b/src/com/gpl/rpg/atcontentstudio/model/bookmarks/BookmarkEntry.java @@ -91,7 +91,13 @@ public class BookmarkEntry implements BookmarkNode { if (text.length() > 60) { 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 { return ((GameDataElement) bookmarkedElement).getDataType().toString() + "/" + ((GameDataElement) bookmarkedElement).getDesc(); } diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java index 2643a4f..9ae2ee1 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java @@ -222,10 +222,10 @@ public class ActorCondition extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); if (this.icon_id != null) { String spritesheetId = this.icon_id.split(":")[0]; if (getProject().getSpritesheet(spritesheetId) == null) { diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java index e66a172..4a967d5 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java @@ -10,7 +10,7 @@ import java.util.Map; public final class Common { - public static void actorConditionElementChanged(List list, GameDataElement oldOne, GameDataElement newOne,GameDataElement backlink){ + public static void actorConditionElementChanged(List list, GameDataElement oldOne, GameDataElement newOne, GameDataElement backlink) { if (list != null) { for (T c : list) { if (c.condition == oldOne) { @@ -22,6 +22,7 @@ public final class Common { } } + //region link common stuff public static void linkConditions(List conditions, Project proj, GameDataElement backlink) { 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); - if (effect != null) - { + if (effect != null) { 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); } } + public static void linkIcon(Project proj, String iconId, GameDataElement backlink) { if (iconId != null) { String spritesheetId = iconId.split(":")[0]; @@ -63,6 +65,7 @@ public final class Common { else parent.put("max", defaultValue); } } + public static void writeMinMaxToMap(Map parent, String key, Integer min, Integer max, int defaultValue) { if (min != null || max != null) { Map minMaxMap = new LinkedHashMap(); @@ -70,6 +73,7 @@ public final class Common { writeMinMaxToMap(minMaxMap, min, max, defaultValue); } } + public static void writeDescriptionToMap(Map parent, String 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) { if (icon_id != null) parent.put("iconID", icon_id); } + public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect) { - if(effect != null){ + if (effect != null) { writeHitEffectToMap(parent, effect); writeBasicEffectObjectToMap(effect.target, parent, "increaseAttackerCurrentHP", "increaseAttackerCurrentAP"); } } + public static void writeHitReceivedEffectToMap(Map parent, HitReceivedEffect effect, String key) { if (effect != null) { Map effectJson = new LinkedHashMap(); @@ -90,12 +96,14 @@ public final class Common { writeHitReceivedEffectToMap(effectJson, effect); } } + public static void writeHitEffectToMap(Map parent, HitEffect effect) { - if(effect != null){ + if (effect != null) { writeDeathEffectToMap(parent, effect); writeTimedActorConditionEffectObjectToMap(effect.conditions_target, parent, "conditionsTarget"); } } + public static void writeHitEffectToMap(Map parent, HitEffect effect, String key) { if (effect != null) { Map effectJson = new LinkedHashMap(); @@ -103,10 +111,12 @@ public final class Common { writeHitEffectToMap(effectJson, effect); } } + public static void writeDeathEffectToMap(Map parent, DeathEffect effect) { writeBasicEffectObjectToMap(effect, parent, "increaseCurrentHP", "increaseCurrentAP"); writeTimedActorConditionEffectObjectToMap(effect.conditions_source, parent, "conditionsSource"); } + public static void writeDeathEffectToMap(Map parent, DeathEffect effect, String key) { if (effect != null) { Map effectJson = new LinkedHashMap(); @@ -154,6 +164,7 @@ public final class Common { parent.put("chance", JSONElement.printJsonChance(condition.chance)); } } + //endregion public static class TimedActorConditionEffect extends ActorConditionEffect { //Available from parsed state @@ -169,12 +180,15 @@ public final class Common { cclone.duration = this.duration; return cclone; } - public boolean isInfinite(){ + + public boolean isInfinite() { return duration != null && duration.equals(ActorCondition.DURATION_FOREVER); } - public boolean isImmunity(){ + + public boolean isImmunity() { return (super.isClear()) && (duration != null && duration > ActorCondition.DURATION_NONE); } + @Override public boolean isClear() { return (super.isClear()) && (duration == null || duration.equals(ActorCondition.DURATION_NONE)); @@ -188,7 +202,8 @@ public final class Common { //Available from linked state public ActorCondition condition = null; - public boolean isClear(){ + + public boolean isClear() { return magnitude == null || magnitude.equals(ActorCondition.MAGNITUDE_CLEAR); } } @@ -287,9 +302,10 @@ public final class Common { public static class DeathEffect extends BasicEffect { //Available from parsed state public List conditions_source = null; + @Override - public boolean isNull(){ - if(!super.isNull()) return false; + public boolean isNull() { + if (!super.isNull()) return false; if (conditions_source != null) return false; return true; } @@ -298,9 +314,10 @@ public final class Common { public static class HitEffect extends DeathEffect { //Available from parsed state public List conditions_target = null; + @Override - public boolean isNull(){ - if(!super.isNull()) return false; + public boolean isNull() { + if (!super.isNull()) return false; if (conditions_target != null) return false; return true; } @@ -309,9 +326,10 @@ public final class Common { public static class HitReceivedEffect extends Common.HitEffect { //Available from parsed state public BasicEffect target = new BasicEffect(); + @Override - public boolean isNull(){ - if(!super.isNull()) return false; + public boolean isNull() { + if (!super.isNull()) return false; if (!target.isNull()) return false; return true; } diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java index 657217f..754f0bc 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java @@ -205,10 +205,10 @@ public class Dialogue extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); Project proj = getProject(); if (proj == null) { Notification.addError("Error linking dialogue " + id + ". No parent project found."); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java index 900b80c..fa60326 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java @@ -128,10 +128,10 @@ public class Droplist extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); Project proj = getProject(); if (proj == null) { Notification.addError("Error linking droplist " + id + ". No parent project found."); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/GameDataCategory.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/GameDataCategory.java index 3b1edd3..3b6b769 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/GameDataCategory.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/GameDataCategory.java @@ -220,7 +220,8 @@ public class GameDataCategory extends ArrayList implem 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) { diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java index 365aa65..032b91a 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java @@ -206,10 +206,10 @@ public class Item extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); Project proj = getProject(); if (proj == null) { 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"); writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect"); - + String key; if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) { key = "killEffect"; @@ -438,7 +438,8 @@ public class Item extends JSONElement { 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 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 ? (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); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java index 1b9fe82..bc8dd33 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java @@ -171,10 +171,10 @@ public class ItemCategory extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); //Nothing to link to :D this.state = State.linked; diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/JSONElement.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/JSONElement.java index fdc9502..b8b1966 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/JSONElement.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/JSONElement.java @@ -21,7 +21,7 @@ public abstract class JSONElement extends GameDataElement { @SuppressWarnings("rawtypes") public void parse() { - if (shouldSkipParse()) { + if (shouldSkipParse()) { return; } JSONParser parser = new JSONParser(); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java index 3dec0fe..632d879 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java @@ -12,7 +12,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -187,10 +186,10 @@ public class NPC extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); Project proj = getProject(); if (proj == null) { 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; } 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; if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) { attackConditionBonus = 50; diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java index 6a2a79a..77ad5b7 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java @@ -112,10 +112,10 @@ public class Quest extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); for (QuestStage stage : stages) { stage.link(); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java index f8133ca..2130bd5 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java @@ -59,10 +59,10 @@ public class QuestStage extends JSONElement { @Override public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); //Nothing to link to :D this.state = State.linked; diff --git a/src/com/gpl/rpg/atcontentstudio/model/maps/KeyArea.java b/src/com/gpl/rpg/atcontentstudio/model/maps/KeyArea.java index f19525a..c370b47 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/maps/KeyArea.java +++ b/src/com/gpl/rpg/atcontentstudio/model/maps/KeyArea.java @@ -101,7 +101,8 @@ public class KeyArea extends MapObject { public void updateNameFromRequirementChange() { 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) { int i = 0; String futureName = requirement.type.toString() + "#" + Integer.toString(i); diff --git a/src/com/gpl/rpg/atcontentstudio/model/maps/ReplaceArea.java b/src/com/gpl/rpg/atcontentstudio/model/maps/ReplaceArea.java index 4438c69..edd8cd3 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/maps/ReplaceArea.java +++ b/src/com/gpl/rpg/atcontentstudio/model/maps/ReplaceArea.java @@ -102,7 +102,8 @@ public class ReplaceArea extends MapObject { //Don't use yet ! public void updateNameFromRequirementChange() { 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) { int i = 0; String futureName = requirement.type.toString() + "#" + Integer.toString(i); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java index 6cd6637..49c5e8e 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java @@ -152,12 +152,14 @@ public class AboutEditor extends Editor { 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("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("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("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("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")); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java index 1fbd519..bbdaee6 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java @@ -189,6 +189,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener { }); return tfField; } + public static T addTextComponent(JPanel pane, String label, boolean editable, final FieldUpdateListener listener, T tfField, boolean specialNewLinesHandling, boolean scrollable) { JPanel tfPane = new JPanel(); 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); tfField.setEditable(editable); JComponent component; - if (scrollable){ + if (scrollable) { component = new JScrollPane(tfField); - }else{ + } else { component = tfField; } tfPane.add(component, JideBoxLayout.VARY); @@ -218,21 +219,21 @@ public abstract class Editor extends JPanel implements ProjectElementListener { @Override public void removeUpdate(DocumentEvent e) { 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); } @Override public void insertUpdate(DocumentEvent e) { 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); } @Override public void changedUpdate(DocumentEvent e) { 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); } }); @@ -291,11 +292,12 @@ public abstract class Editor extends JPanel implements ProjectElementListener { }); return spinner; } + 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 minimum = allowNegatives ? Integer.MIN_VALUE : 0; + int minimum = allowNegatives ? Integer.MIN_VALUE : 0; 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); 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. - 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 JSpinner chanceSpinner = new JSpinner(currentFormIsRatio ? ratioChanceModel : percentModel); @@ -1105,10 +1110,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener { } - public > void updateConditionEffect(ActorCondition value, - GameDataElement backlink, - E selectedHitEffectTargetCondition, - T hitTargetConditionsModel) { + public > void updateConditionEffect(ActorCondition value, + GameDataElement backlink, + E selectedHitEffectTargetCondition, + T hitTargetConditionsModel) { if (selectedHitEffectTargetCondition.condition != null) { selectedHitEffectTargetCondition.condition.removeBacklink(backlink); } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/NotificationsPane.java b/src/com/gpl/rpg/atcontentstudio/ui/NotificationsPane.java index 3606b76..4cd2f8b 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/NotificationsPane.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/NotificationsPane.java @@ -5,7 +5,6 @@ import com.gpl.rpg.atcontentstudio.Notification; import com.gpl.rpg.atcontentstudio.NotificationListener; import javax.swing.*; -import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import java.awt.*; import java.util.LinkedHashMap; diff --git a/src/com/gpl/rpg/atcontentstudio/ui/OrderedListenerListModel.java b/src/com/gpl/rpg/atcontentstudio/ui/OrderedListenerListModel.java index 65c8e3e..f2c2a84 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/OrderedListenerListModel.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/OrderedListenerListModel.java @@ -1,6 +1,5 @@ package com.gpl.rpg.atcontentstudio.ui; -import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import java.util.ArrayList; import java.util.Collection; diff --git a/src/com/gpl/rpg/atcontentstudio/ui/ProjectsTree.java b/src/com/gpl/rpg/atcontentstudio/ui/ProjectsTree.java index 7b2513a..ffeab2f 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/ProjectsTree.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/ProjectsTree.java @@ -624,19 +624,25 @@ public class ProjectsTree extends JPanel { public void insertNode(TreePath node) { 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) { 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) { 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()})); } } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/WorkspaceActions.java b/src/com/gpl/rpg/atcontentstudio/ui/WorkspaceActions.java index a2072f0..b797632 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/WorkspaceActions.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/WorkspaceActions.java @@ -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 void actionPerformed(ActionEvent e) { 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); } } 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); } } @@ -380,7 +382,8 @@ public class WorkspaceActions { public ATCSAction exitATCS = new ATCSAction("Exit", "Closes the program") { public void actionPerformed(ActionEvent e) { 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) { System.exit(0); } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java index 03348f0..bba83be 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java @@ -89,7 +89,7 @@ public class ActorConditionEditor extends JSONElementEditor { } else { 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); 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); @@ -106,7 +106,7 @@ public class ActorConditionEditor extends JSONElementEditor { } else { 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); 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); @@ -505,18 +505,17 @@ public class ActorConditionEditor extends JSONElementEditor { } private boolean isEmpty(ActorCondition.RoundEffect round_effect) { - return round_effect == null || ( - round_effect.visual_effect == null && + return round_effect == null || + (round_effect.visual_effect == null && round_effect.hp_boost_min == null && round_effect.hp_boost_max == 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) { - return ability_effect == null || ( - ability_effect.max_hp_boost == null && + return ability_effect == null || + (ability_effect.max_hp_boost == null && ability_effect.max_ap_boost == null && ability_effect.increase_move_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_critical_skill == null && ability_effect.increase_block_chance == null && - ability_effect.increase_damage_resistance == null - ); + ability_effect.increase_damage_resistance == null); } } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/CommonEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/CommonEditor.java index b45e718..8090851 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/CommonEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/CommonEditor.java @@ -48,7 +48,12 @@ public class CommonEditor { } else { label.setIcon(new ImageIcon(effect.condition.getIcon())); 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 { label.setText("New, undefined actor condition effect."); @@ -143,7 +148,7 @@ public class CommonEditor { protected final String applyToTargetHint; private JList hitTargetConditionsList; - private final ConditionEffectEditorPane hitTargetConditionPane ; + private final ConditionEffectEditorPane hitTargetConditionPane; /* * create a new HitEffectPane with the selections (probably passed in from last time) @@ -193,7 +198,7 @@ public class CommonEditor { @Override public boolean valueChanged(JComponent source, Object value, GameDataElement backlink) { boolean updateHit = false; - if(super.valueChanged(source, value, backlink)){ + if (super.valueChanged(source, value, backlink)) { updateHit = true; } else if (source == hitTargetConditionsList) { updateHit = true; @@ -295,7 +300,7 @@ public class CommonEditor { updateHit = true; } else if (source == sourceConditionsList) { updateHit = true; - } else if (sourceConditionPane.valueChanged(source, value, backlink)){ + } else if (sourceConditionPane.valueChanged(source, value, backlink)) { updateHit = true; } return updateHit; @@ -360,7 +365,7 @@ public class CommonEditor { Project proj = editor.target.getProject(); conditionBox = editor.addActorConditionBox(pane, proj, "Actor Condition: ", condition.condition, writable, - listener); + listener); conditionChance = Editor.addDoubleField(pane, "Chance: ", condition.chance, writable, listener); conditionClear = new JRadioButton("Clear active condition"); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java index d2e7b33..71044f0 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java @@ -234,7 +234,8 @@ public class DialogueEditor extends JSONElementEditor { case changeMapFilter: rewardMap = addMapBox(pane, ((Dialogue) target).getProject(), "Map Name: ", reward.map, writable, listener); 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; rewardValue = null; break; @@ -278,7 +279,8 @@ public class DialogueEditor extends JSONElementEditor { if (!immunity) radioGroup.add(rewardConditionClear); 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)); rewardConditionClear.setSelected(reward.reward_value != null && !reward.reward_value.equals(ActorCondition.MAGNITUDE_CLEAR)); } else { diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java index 800ca91..4a27929 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java @@ -4,9 +4,14 @@ import com.gpl.rpg.atcontentstudio.ATContentStudio; import com.gpl.rpg.atcontentstudio.model.GameDataElement; import com.gpl.rpg.atcontentstudio.model.Project; 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.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.BasicLambdaWithArg; 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); manualPriceBox = addIntegerBasedCheckBox(pane, "Has manual price", item.has_manual_price, item.writable, listener); 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()) { baseCostField.setEnabled(false); } @@ -128,22 +134,23 @@ public class ItemEditor extends JSONElementEditor { String titleEquipConditions = "Actor Conditions applied when equipped: "; equipConditionsModel = new EquipConditionsListModel(equipEffect); CommonEditor.ConditionsCellRenderer cellRendererEquipConditions = new CommonEditor.ConditionsCellRenderer(); - BasicLambdaWithArg selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value; - BasicLambdaWithReturn selectedGetEquipConditions = ()->selectedEquipEffectCondition ; - BasicLambda selectedResetEquipConditions = ()->selectedEquipEffectCondition = null; + BasicLambdaWithArg selectedSetEquipConditions = (value) -> selectedEquipEffectCondition = value; + BasicLambdaWithReturn selectedGetEquipConditions = () -> selectedEquipEffectCondition; + BasicLambda selectedResetEquipConditions = () -> selectedEquipEffectCondition = null; BasicLambdaWithArg updatePaneEquipConditions = (editorPane) -> updateEquipConditionEditorPane(editorPane, selectedEquipEffectCondition, listener); var resultEquipConditions = UiUtils.getCollapsibleItemList(listener, - equipConditionsModel, - selectedResetEquipConditions, - selectedSetEquipConditions, - selectedGetEquipConditions, - (x) -> {}, - updatePaneEquipConditions, - item.writable, - ActorConditionEffect::new, - cellRendererEquipConditions, - titleEquipConditions, - (x) -> null); + equipConditionsModel, + selectedResetEquipConditions, + selectedSetEquipConditions, + selectedGetEquipConditions, + (x) -> { + }, + updatePaneEquipConditions, + item.writable, + ActorConditionEffect::new, + cellRendererEquipConditions, + titleEquipConditions, + (x) -> null); equipConditionsList = resultEquipConditions.list; CollapsiblePanel equipConditionsPane = resultEquipConditions.collapsiblePanel; if (item.equip_effect == null || item.equip_effect.conditions == null || item.equip_effect.conditions.isEmpty()) { diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java index 724a3e1..dfda8e2 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java @@ -3,9 +3,13 @@ package com.gpl.rpg.atcontentstudio.ui.gamedataeditors; import com.gpl.rpg.atcontentstudio.ATContentStudio; import com.gpl.rpg.atcontentstudio.model.GameDataElement; 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.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.utils.UiUtils; import com.jidesoft.swing.JideBoxLayout; @@ -15,7 +19,6 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; -import java.util.List; import java.util.Objects; import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*; @@ -57,7 +60,8 @@ public class NPCEditor extends JSONElementEditor { private JSpinner dmgRes; 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 JPanel dialogueGraphPane; @@ -170,7 +174,6 @@ public class NPCEditor extends JSONElementEditor { } - public class NPCFieldUpdater implements FieldUpdateListener { @Override @@ -263,7 +266,7 @@ public class NPCEditor extends JSONElementEditor { npc.block_chance = (Integer) value; } else if (source == dmgRes) { npc.damage_resistance = (Integer) value; - } else if(hitEffectPane.valueChanged(source, value, npc)) { + } else if (hitEffectPane.valueChanged(source, value, npc)) { updateHit = true; } else if (hitReceivedEffectPane.valueChanged(source, value, npc)) { updateHitReceived = true; @@ -289,7 +292,7 @@ public class NPCEditor extends JSONElementEditor { if (deathEffectPane.effect.isNull()) { npc.death_effect = null; } else { - npc.death_effect = deathEffectPane. effect; + npc.death_effect = deathEffectPane.effect; } } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java index 9a352a0..ef9f26f 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/QuestEditor.java @@ -5,7 +5,9 @@ import com.gpl.rpg.atcontentstudio.model.GameDataElement; import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode; import com.gpl.rpg.atcontentstudio.model.gamedata.Quest; 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.BasicLambdaWithArg; import com.gpl.rpg.atcontentstudio.utils.BasicLambdaWithReturn; @@ -13,11 +15,7 @@ import com.gpl.rpg.atcontentstudio.utils.UiUtils; import com.jidesoft.swing.JideBoxLayout; import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; @@ -64,23 +62,24 @@ public class QuestEditor extends JSONElementEditor { String title = "Quest stages: "; StagesCellRenderer cellRenderer = new StagesCellRenderer(); stagesListModel = new StagesListModel(quest); - BasicLambdaWithArg selectedSet = (value)->selectedStage = value; - BasicLambdaWithReturn selectedGet = ()->selectedStage ; - BasicLambda selectedReset = ()->selectedStage = null; + BasicLambdaWithArg selectedSet = (value) -> selectedStage = value; + BasicLambdaWithReturn selectedGet = () -> selectedStage; + BasicLambda selectedReset = () -> selectedStage = null; BasicLambdaWithArg updatePane = (editorPane) -> updateStageEditorPane(editorPane, selectedStage, listener); var result = UiUtils.getCollapsibleItemList(listener, - stagesListModel, - selectedReset, - selectedSet, - selectedGet, - (x) -> {}, - updatePane, - quest.writable, - () -> new QuestStage(quest), - cellRenderer, - title, - (x) -> null); + stagesListModel, + selectedReset, + selectedSet, + selectedGet, + (x) -> { + }, + updatePane, + quest.writable, + () -> new QuestStage(quest), + cellRenderer, + title, + (x) -> null); stagesList = result.list; if (quest.stages == null || quest.stages.isEmpty()) { diff --git a/src/com/gpl/rpg/atcontentstudio/ui/map/TMXMapEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/map/TMXMapEditor.java index 825aaf6..f83dd17 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/map/TMXMapEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/map/TMXMapEditor.java @@ -1541,7 +1541,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe @Override public void actionPerformed(ActionEvent e) { 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.YES_OPTION) { map.save(); @@ -1559,7 +1561,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe @Override public void actionPerformed(ActionEvent e) { 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; } reload.setEnabled(false); @@ -1581,11 +1585,14 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe public void actionPerformed(ActionEvent e) { if (map.state != TMXMap.State.saved) { 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; File backup = FileUtils.backupFile(map.tmxFile); 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 { JOptionPane.showMessageDialog(TMXMapEditor.this, "The externally-modified file could not be backed up.", "File backup failed", JOptionPane.ERROR_MESSAGE); } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/tools/ItemsTableView.java b/src/com/gpl/rpg/atcontentstudio/ui/tools/ItemsTableView.java index 5227f89..4ac87b4 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/tools/ItemsTableView.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/tools/ItemsTableView.java @@ -307,7 +307,9 @@ public class ItemsTableView extends ElementTableView { case 22: return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.ap_boost_max : null;//"On hit recv - AP max"; 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: return (!canUse && item.hit_received_effect != null) ? item.hit_received_effect.hp_boost_min : null;//"On hit recv - Tgt HP min"; case 25: diff --git a/src/com/gpl/rpg/atcontentstudio/utils/FileUtils.java b/src/com/gpl/rpg/atcontentstudio/utils/FileUtils.java index b4ce56d..11959bd 100644 --- a/src/com/gpl/rpg/atcontentstudio/utils/FileUtils.java +++ b/src/com/gpl/rpg/atcontentstudio/utils/FileUtils.java @@ -147,7 +147,8 @@ public class FileUtils { case Windows: System.err.println("Trying the Windows way with mklink"); 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) { e1.printStackTrace(); } diff --git a/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java b/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java index bfda654..ab16767 100644 --- a/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java +++ b/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java @@ -17,7 +17,8 @@ public class UiUtils { public CollapsiblePanel collapsiblePanel; public JList list; } - public static JPanel createRefreshButtonPane(ActionListener reloadButtonEditor){ + + public static JPanel createRefreshButtonPane(ActionListener reloadButtonEditor) { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS)); JButton reloadButton = new JButton("Refresh graph"); @@ -64,8 +65,8 @@ public class UiUtils { moveDownBtn.setEnabled(false); } else { deleteBtn.setEnabled(true); - moveUpBtn.setEnabled(list.getSelectedIndex() > 0); - moveDownBtn.setEnabled(list.getSelectedIndex() < (listModel.getSize() - 1)); + moveUpBtn.setEnabled(list.getSelectedIndex() > 0); + moveDownBtn.setEnabled(list.getSelectedIndex() < (listModel.getSize() - 1)); } updateEditorPane.doIt(editorPane);