rename needsToBeLinked to linkCheck and continue dedupe

This commit is contained in:
OMGeeky
2025-06-01 19:16:59 +02:00
parent 8561415574
commit 8c42b498b0
11 changed files with 22 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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