Skip to content

Commit

Permalink
Fields SUC and PRE are now recognized in Platforms.txt (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH01 committed Jun 22, 2023
1 parent 24dfb55 commit 6619eb4
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 13 deletions.
4 changes: 3 additions & 1 deletion docs/changelog_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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<Integer> 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,
Expand All @@ -55,7 +64,9 @@ public Platform(String name,
boolean startPlatform,
Integer gamepassGames,
Integer publisher,
ArrayList<Integer> backwardsCompatiblePlatforms) throws ModProcessingException {
ArrayList<Integer> backwardsCompatiblePlatforms,
Integer predecessorId,
Integer successorId) throws ModProcessingException {
super(PlatformManager.INSTANCE, name, id, translationManager);
this.manufacturer = manufacturer;
this.manufacturerTranslations = manufacturerTranslations;
Expand All @@ -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<Integer> assignedIds = new ArrayList<>();
Expand Down Expand Up @@ -146,6 +159,16 @@ public Map<String, String> 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;
}

Expand Down Expand Up @@ -231,6 +254,12 @@ public void changeExportMap(Map<String, String> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ protected void printValues(Map<String, String> 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
Expand Down Expand Up @@ -196,6 +198,14 @@ public AbstractBaseContent constructContentFromMap(Map<String, String> 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),
Expand All @@ -216,7 +226,9 @@ public AbstractBaseContent constructContentFromMap(Map<String, String> map) thro
map.containsKey("STARTPLATFORM"),
gamepassGames,
publisher,
platformIds
platformIds,
predecessorId,
successorId
);
}

Expand All @@ -232,6 +244,8 @@ protected List<DataLine> 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;
}
Expand Down Expand Up @@ -318,6 +332,14 @@ public AbstractBaseContent constructContentFromImportMap(Map<String, Object> 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),
Expand All @@ -338,7 +360,9 @@ public AbstractBaseContent constructContentFromImportMap(Map<String, Object> map
transformedMap.containsKey("STARTPLATFORM") && !transformedMap.get("STARTPLATFORM").equals("false"),
gamepassGames,
publisher,
platformIds
platformIds,
predecessorId,
successorId
);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -692,6 +718,12 @@ public void replaceMissingDependency(Map<String, Object> 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");
}
Expand All @@ -718,6 +750,12 @@ public Map<String, Object> getDependencyMapFromImport(Map<String, Object> 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<String> publishers = new HashSet<>();
Expand Down

0 comments on commit 6619eb4

Please sign in to comment.