diff --git a/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java b/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java index 5643f57..f65a961 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java +++ b/src/com/gpl/rpg/atcontentstudio/model/GameDataElement.java @@ -39,6 +39,22 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable { private Map backlinks = new ConcurrentHashMap(); public String id = null; + + protected boolean needsToBeLinked(){ + if (this.state == State.created || this.state == State.modified || this.state == State.saved) { + //This type of state is unrelated to parsing/linking. + return false; + } + if (this.state == State.init) { + //Not parsed yet. + this.parse(); + } else if (this.state == State.linked) { + //Already linked. + return false; + } + return true; + + } @Override public Enumeration children() { diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java index b171a3c..e2aa928 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java @@ -224,17 +224,7 @@ public class ActorCondition extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; if (this.icon_id != null) { String spritesheetId = this.icon_id.split(":")[0]; if (getProject().getSpritesheet(spritesheetId) == null) { @@ -250,7 +240,8 @@ public class ActorCondition extends JSONElement { this.state = State.linked; } - + + public static String getStaticDesc() { return "Actor Conditions"; diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java index d316955..2493858 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Dialogue.java @@ -206,17 +206,7 @@ public class Dialogue extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; 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 b83dea5..8f62df8 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java @@ -129,17 +129,7 @@ public class Droplist extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; 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/Item.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java index 6cad8c4..94ac347 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java @@ -206,17 +206,7 @@ public class Item extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; Project proj = getProject(); if (proj == null) { Notification.addError("Error linking item "+id+". No parent project found."); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java index 1c6622d..8a2110c 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ItemCategory.java @@ -171,17 +171,7 @@ public class ItemCategory extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; //Nothing to link to :D this.state = State.linked; diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java index 0a939d0..2a7458a 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java @@ -208,17 +208,7 @@ public class NPC extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; Project proj = getProject(); if (proj == null) { Notification.addError("Error linking item "+id+". No parent project found."); diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java index cbb993c..c7455f8 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Quest.java @@ -113,17 +113,7 @@ public class Quest extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; 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 61baa85..072c376 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/QuestStage.java @@ -59,17 +59,7 @@ public class QuestStage extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; //Nothing to link to :D this.state = State.linked; diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Requirement.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Requirement.java index 66e8af2..25e4974 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Requirement.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Requirement.java @@ -153,17 +153,7 @@ public class Requirement extends JSONElement { @Override public void link() { - if (this.state == State.created || this.state == State.modified || this.state == State.saved) { - //This type of state is unrelated to parsing/linking. - return; - } - if (this.state == State.init) { - //Not parsed yet. - this.parse(); - } else if (this.state == State.linked) { - //Already linked. - return; - } + if (!this.needsToBeLinked()) return; Project proj = getProject(); if (proj == null) { Notification.addError("Error linking requirement "+getDesc()+". No parent project found.");