From b89f9329969f7659e94e87660576d702012e4046 Mon Sep 17 00:00:00 2001 From: iobyte Date: Sun, 11 Sep 2022 21:29:10 +0000 Subject: [PATCH] trackeditor: check for duplicate object colors git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8490 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f1fe6ed4078f7757bbe43d902702efc3db8002af Former-commit-id: 9f0ae30e0cb4cd659a7a8deb93106f42c9b85e59 --- src/tools/trackeditor/gui/CheckDialog.java | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/tools/trackeditor/gui/CheckDialog.java b/src/tools/trackeditor/gui/CheckDialog.java index 601aa9054..e4624c166 100644 --- a/src/tools/trackeditor/gui/CheckDialog.java +++ b/src/tools/trackeditor/gui/CheckDialog.java @@ -234,7 +234,7 @@ public class CheckDialog extends JDialog { if (name.equals(trackData.getObjects().get(j).getName())) { - textArea.append("Track object " + (i + 1) + " " + name + " has same name as Track object " + (j + 1) + " " + trackData.getObjects().get(i).getName() + "\n"); + textArea.append("Track object " + (i + 1) + " " + name + " has same name as Track object " + (j + 1) + " " + trackData.getObjects().get(j).getName() + "\n"); } } @@ -242,7 +242,37 @@ public class CheckDialog extends JDialog { if (name.equals(defaultObjects.get(j).getName())) { - textArea.append("Track object " + (i + 1) + " " + name + " has same name as Default object " + (j + 1) + " " + defaultObjects.get(i).getName() + "\n"); + textArea.append("Track object " + (i + 1) + " " + name + " has same name as Default object " + (j + 1) + " " + defaultObjects.get(j).getName() + "\n"); + } + } + } + } + + // check for duplicate colors + for (int i = 0; i < trackData.getObjects().size(); i++) + { + String name = trackData.getObjects().get(i).getName(); + int color = trackData.getObjects().get(i).getColor(); + + if (color == Integer.MAX_VALUE) + { + textArea.append("Track object " + (i + 1) + " missing color\n"); + } + else + { + for (int j = i + 1; j < trackData.getObjects().size(); j++) + { + if (color == trackData.getObjects().get(j).getColor()) + { + textArea.append("Track object " + (i + 1) + " " + name + " has same color as Track object " + (j + 1) + " " + trackData.getObjects().get(j).getName() + "\n"); + } + } + + for (int j = 0; j < defaultObjects.size(); j++) + { + if (color == defaultObjects.get(j).getColor()) + { + textArea.append("Track object " + (i + 1) + " " + name + " has same color as Default object " + (j + 1) + " " + defaultObjects.get(j).getName() + "\n"); } } }