mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
rename needsToBeLinked to linkCheck and continue dedupe
This commit is contained in:
@@ -40,12 +40,12 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
|
||||
public String id = null;
|
||||
|
||||
protected boolean needsToBeLinked(){
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
protected boolean linkCheck(){
|
||||
if (checkNotRelatedToParseOrLink()) {
|
||||
//This type of state is unrelated to parsing/linking.
|
||||
return false;
|
||||
}
|
||||
if (this.state == State.init) {
|
||||
else if (this.state == State.init) {
|
||||
//Not parsed yet.
|
||||
this.parse();
|
||||
} else if (this.state == State.linked) {
|
||||
@@ -55,7 +55,14 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected boolean checkNotRelatedToParseOrLink() {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//This type of state is unrelated to parsing/linking.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public Enumeration<ProjectTreeNode> children() {
|
||||
return null;
|
||||
|
||||
@@ -224,7 +224,7 @@ public class ActorCondition extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
if (this.icon_id != null) {
|
||||
String spritesheetId = this.icon_id.split(":")[0];
|
||||
if (getProject().getSpritesheet(spritesheetId) == null) {
|
||||
|
||||
@@ -206,7 +206,7 @@ public class Dialogue extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking dialogue "+id+". No parent project found.");
|
||||
|
||||
@@ -129,7 +129,7 @@ public class Droplist extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking droplist "+id+". No parent project found.");
|
||||
|
||||
@@ -206,7 +206,7 @@ public class Item extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking item "+id+". No parent project found.");
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ItemCategory extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
|
||||
//Nothing to link to :D
|
||||
this.state = State.linked;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class NPC extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking item "+id+". No parent project found.");
|
||||
|
||||
@@ -113,7 +113,7 @@ public class Quest extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
|
||||
for (QuestStage stage : stages) {
|
||||
stage.link();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class QuestStage extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
|
||||
//Nothing to link to :D
|
||||
this.state = State.linked;
|
||||
|
||||
@@ -153,7 +153,7 @@ public class Requirement extends JSONElement {
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (!this.needsToBeLinked()) return;
|
||||
if (!this.linkCheck()) return;
|
||||
Project proj = getProject();
|
||||
if (proj == null) {
|
||||
Notification.addError("Error linking requirement "+getDesc()+". No parent project found.");
|
||||
|
||||
@@ -489,10 +489,7 @@ public class WriterModeData extends GameDataElement {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void parse() {
|
||||
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
|
||||
//This type of state is unrelated to parsing/linking.
|
||||
return;
|
||||
}
|
||||
if (checkNotRelatedToParseOrLink()) return;
|
||||
JSONParser parser = new JSONParser();
|
||||
FileReader reader = null;
|
||||
try {
|
||||
@@ -526,7 +523,7 @@ public class WriterModeData extends GameDataElement {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void parse(Map json) {
|
||||
this.id = (String) json.get("id");
|
||||
|
||||
Reference in New Issue
Block a user