diff --git a/docs/changelog_dev.md b/docs/changelog_dev.md index e17da54f..a4218f7b 100644 --- a/docs/changelog_dev.md +++ b/docs/changelog_dev.md @@ -4,8 +4,10 @@ ### Other - Updated tech level spinner max value to 9 (fr #137) -- New fields (T, ST, TG, ARA, ROM) in `NpcGame.txt` are now recognized, even though they can't be set by gui yet (fr #140) +- New fields (T, ST, TG, ARA, ROM) are now recognized in `NpcGame.txt`, even though they can't be set by gui yet (fr #140) - License quality in `Licences.txt` is now recognized, even tough it can't be set by gui yet (fr #142) +- New fields (ARA and ROM) are now recognized in `NpcIPs.txt`, even though they can't be set by gui yet (fr #143) +- Predecessors and successors are now recognized in `Platforms.txt`, even though they can't be set by gui yet (fr #144) ### Game compatibility - Fixed theme handling, the place where genres that match themes are saved was changed (fr #141) diff --git a/src/main/java/com/github/lmh01/mgt2mt/content/instances/Platform.java b/src/main/java/com/github/lmh01/mgt2mt/content/instances/Platform.java index 861ea193..a20dc411 100644 --- a/src/main/java/com/github/lmh01/mgt2mt/content/instances/Platform.java +++ b/src/main/java/com/github/lmh01/mgt2mt/content/instances/Platform.java @@ -1,6 +1,19 @@ package com.github.lmh01.mgt2mt.content.instances; -import com.github.lmh01.mgt2mt.content.managed.*; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import com.github.lmh01.mgt2mt.content.managed.AbstractAdvancedContent; +import com.github.lmh01.mgt2mt.content.managed.DependentContent; +import com.github.lmh01.mgt2mt.content.managed.Image; +import com.github.lmh01.mgt2mt.content.managed.ModProcessingException; +import com.github.lmh01.mgt2mt.content.managed.PlatformImage; +import com.github.lmh01.mgt2mt.content.managed.RequiresPictures; import com.github.lmh01.mgt2mt.content.managed.types.PlatformType; import com.github.lmh01.mgt2mt.content.manager.GameplayFeatureManager; import com.github.lmh01.mgt2mt.content.manager.PlatformManager; @@ -10,12 +23,6 @@ import com.github.lmh01.mgt2mt.util.Utils; import com.github.lmh01.mgt2mt.util.manager.TranslationManager; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; - public class Platform extends AbstractAdvancedContent implements DependentContent, RequiresPictures { final String manufacturer; @@ -35,6 +42,8 @@ public class Platform extends AbstractAdvancedContent implements DependentConten final Integer gamepassGames; final Integer publisher; // The publisher that released this console final ArrayList backwardsCompatiblePlatforms; // Contains the ids of platforms that this platform is backwards compatible to + final Integer predecessorId; + final Integer successorId; public Platform(String name, Integer id, @@ -55,7 +64,9 @@ public Platform(String name, boolean startPlatform, Integer gamepassGames, Integer publisher, - ArrayList backwardsCompatiblePlatforms) throws ModProcessingException { + ArrayList backwardsCompatiblePlatforms, + Integer predecessorId, + Integer successorId) throws ModProcessingException { super(PlatformManager.INSTANCE, name, id, translationManager); this.manufacturer = manufacturer; this.manufacturerTranslations = manufacturerTranslations; @@ -74,6 +85,8 @@ public Platform(String name, this.gamepassGames = gamepassGames; this.publisher = publisher; this.backwardsCompatiblePlatforms = backwardsCompatiblePlatforms; + this.predecessorId = predecessorId; + this.successorId = successorId; // Check if platform images are valid ArrayList assignedIds = new ArrayList<>(); @@ -146,6 +159,16 @@ public Map getMap() { backwardsCompNumber += 1; } } + if (predecessorId != null) { + map.put("PRE", predecessorId.toString()); + } else { + map.put("PRE", "-1"); + } + if (successorId != null) { + map.put("SUC", successorId.toString()); + } else { + map.put("SUC", "-1"); + } return map; } @@ -231,6 +254,12 @@ public void changeExportMap(Map map) throws ModProcessingExcepti if (map.containsKey("PUB")) { changedValues.put("PUB", PublisherManager.INSTANCE.getContentNameById(Integer.parseInt(map.get("PUB")))); } + if (map.containsKey("PRE") && !map.get("PRE").equals("-1")) { + changedValues.put("PRE", PlatformManager.INSTANCE.getContentNameById(Integer.parseInt(map.get("PRE")))); + } + if (map.containsKey("SUC") && !map.get("PRE").equals("-1")) { + changedValues.put("SUC", PlatformManager.INSTANCE.getContentNameById(Integer.parseInt(map.get("SUC")))); + } Utils.replaceMapEntries(map, changedValues); } diff --git a/src/main/java/com/github/lmh01/mgt2mt/content/manager/PlatformManager.java b/src/main/java/com/github/lmh01/mgt2mt/content/manager/PlatformManager.java index 13be87d3..7fc9e81b 100644 --- a/src/main/java/com/github/lmh01/mgt2mt/content/manager/PlatformManager.java +++ b/src/main/java/com/github/lmh01/mgt2mt/content/manager/PlatformManager.java @@ -142,7 +142,9 @@ protected void printValues(Map map, BufferedWriter bw) throws IO } EditHelper.printLine("GAMEPASS", map, bw); EditHelper.printLine("PUB", map, bw); - EditHelper.printLine("END", map, bw); + EditHelper.printLine("PRE", map, bw); + EditHelper.printLine("SUC", map, bw); + bw.write("[END]\n"); } @Override @@ -196,6 +198,14 @@ public AbstractBaseContent constructContentFromMap(Map map) thro if (map.containsKey("PUB")) { publisher = Integer.parseInt(map.get("PUB")); } + Integer predecessorId = null; + if (map.containsKey("PRE")) { + predecessorId = Integer.parseInt(map.get("PRE")); + } + Integer successorId = null; + if (map.containsKey("SUC")) { + successorId = Integer.parseInt(map.get("SUC")); + } return new Platform( map.get("NAME EN"), getIdFromMap(map), @@ -216,7 +226,9 @@ public AbstractBaseContent constructContentFromMap(Map map) thro map.containsKey("STARTPLATFORM"), gamepassGames, publisher, - platformIds + platformIds, + predecessorId, + successorId ); } @@ -232,6 +244,8 @@ protected List getDataLines() { line.add(new DataLine("COMPLEX", true, DataType.INT)); line.add(new DataLine("TYP", true, DataType.INT)); line.add(new DataLine("PUB", false, DataType.INT)); + line.add(new DataLine("PRE", true, DataType.INT)); + line.add(new DataLine("SUC", true, DataType.INT)); line.add(new DataLine("END", false, DataType.UNCHECKED)); return line; } @@ -318,6 +332,14 @@ public AbstractBaseContent constructContentFromImportMap(Map map if (transformedMap.containsKey("PUB")) { publisher = PublisherManager.INSTANCE.getImportHelperMap().getContentIdByName(transformedMap.get("PUB")); } + Integer predecessorId = null; + if (transformedMap.containsKey("PRE") && !transformedMap.get("PRE").equals("-1")) { + predecessorId = PlatformManager.INSTANCE.getImportHelperMap().getContentIdByName(transformedMap.get("PRE")); + } + Integer successorId = null; + if (transformedMap.containsKey("SUC") && !transformedMap.get("PRE").equals("-1")) { + successorId = PlatformManager.INSTANCE.getImportHelperMap().getContentIdByName(transformedMap.get("SUC")); + } return new Platform( transformedMap.get("NAME EN"), getIdFromMap(transformedMap), @@ -338,7 +360,9 @@ public AbstractBaseContent constructContentFromImportMap(Map map transformedMap.containsKey("STARTPLATFORM") && !transformedMap.get("STARTPLATFORM").equals("false"), gamepassGames, publisher, - platformIds + platformIds, + predecessorId, + successorId ); } @@ -661,7 +685,9 @@ public void mouseClicked(MouseEvent e) { checkBoxStartplatform.isSelected(), gpg, pid, - platformIds.get() + platformIds.get(), + null, + null ); if (JOptionPane.showConfirmDialog(null, platform.getOptionPaneMessage(), I18n.INSTANCE.get("commonText.add.upperCase") + ": " + getType(), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { addContent(platform); @@ -692,6 +718,12 @@ public void replaceMissingDependency(Map map, String missingDepe if (entry.getKey().contains("BACKCOMP")) { replaceMapEntry(map, missingDependency, replacement, entry.getKey()); } + if (entry.getKey().contains("PRE")) { + replaceMapEntry(map, missingDependency, replacement, entry.getKey()); + } + if (entry.getKey().contains("SUC")) { + replaceMapEntry(map, missingDependency, replacement, entry.getKey()); + } } replaceMapEntry(map, missingDependency, replacement, "PUB"); } @@ -718,6 +750,12 @@ public Map getDependencyMapFromImport(Map import platforms.add((String)entry.getValue()); } } + if (importMap.containsKey("PRE") && !importMap.get("PRE").equals("-1")) { + platforms.add((String)importMap.get("PRE")); + } + if (importMap.containsKey("SUC") && !importMap.get("PRE").equals("-1")) { + platforms.add((String)importMap.get("SUC")); + } map.put(GameplayFeatureManager.INSTANCE.getId(), gameplayFeatures); map.put(PlatformManager.INSTANCE.getId(), platforms); Set publishers = new HashSet<>();