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">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="JD_P_AT_EMPTY_LINES" value="false" />
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="200" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="SOFT_MARGINS" value="120" />
</codeStyleSettings>
</code_scheme>

View File

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

View File

@@ -203,18 +203,19 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
public abstract List<SaveEvent> 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();
}
}
}

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>>();
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);
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);

View File

@@ -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<ProjectTreeNode>());
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();
}

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -10,7 +10,7 @@ import java.util.Map;
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) {
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<? extends ActorConditionEffect> 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<TimedActorConditionEffect> 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<TimedActorConditionEffect> 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;
}

View File

@@ -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.");

View File

@@ -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.");

View File

@@ -220,7 +220,8 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> 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) {

View File

@@ -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);

View File

@@ -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;

View File

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

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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"));

View File

@@ -189,6 +189,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
});
return tfField;
}
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();
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 <E extends Common.ActorConditionEffect, T extends OrderedListenerListModel<?, E>> void updateConditionEffect(ActorCondition value,
GameDataElement backlink,
E selectedHitEffectTargetCondition,
T hitTargetConditionsModel) {
public <E extends Common.ActorConditionEffect, T extends OrderedListenerListModel<?, E>> void updateConditionEffect(ActorCondition value,
GameDataElement backlink,
E selectedHitEffectTargetCondition,
T hitTargetConditionsModel) {
if (selectedHitEffectTargetCondition.condition != null) {
selectedHitEffectTargetCondition.condition.removeBacklink(backlink);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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()}));
}
}

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 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);
}

View File

@@ -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);
}
}

View File

@@ -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<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)
@@ -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");

View File

@@ -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 {

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.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<ActorConditionEffect> selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value;
BasicLambdaWithReturn<ActorConditionEffect> selectedGetEquipConditions = ()->selectedEquipEffectCondition ;
BasicLambda selectedResetEquipConditions = ()->selectedEquipEffectCondition = null;
BasicLambdaWithArg<ActorConditionEffect> selectedSetEquipConditions = (value) -> selectedEquipEffectCondition = value;
BasicLambdaWithReturn<ActorConditionEffect> selectedGetEquipConditions = () -> selectedEquipEffectCondition;
BasicLambda selectedResetEquipConditions = () -> selectedEquipEffectCondition = null;
BasicLambdaWithArg<JPanel> 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()) {

View File

@@ -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;
}
}

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.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<QuestStage> selectedSet = (value)->selectedStage = value;
BasicLambdaWithReturn<QuestStage> selectedGet = ()->selectedStage ;
BasicLambda selectedReset = ()->selectedStage = null;
BasicLambdaWithArg<QuestStage> selectedSet = (value) -> selectedStage = value;
BasicLambdaWithReturn<QuestStage> selectedGet = () -> selectedStage;
BasicLambda selectedReset = () -> selectedStage = null;
BasicLambdaWithArg<JPanel> 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()) {

View File

@@ -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);
}

View File

@@ -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:

View File

@@ -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();
}

View File

@@ -17,7 +17,8 @@ public class UiUtils {
public CollapsiblePanel collapsiblePanel;
public JList<E> 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);