Skip to content

Commit

Permalink
Added/fixed #124
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH01 committed Feb 28, 2023
1 parent 379ab81 commit 6802264
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `PIC` entry is no longer added to export toml file as this was redundant and could caused confusion
- Added new update channel: Beta
- The dependencies section is no longer required when contents are imported, this cleans up .toml files immensely and makes it easier to modify and replace content
- Dependency replacement now contains content that is currently being imported (fr #124)

### Bug fixes
- Fixed NullPointException when no `requires_pictures` key was set in any mod map inside the `.toml` file when mods where imported
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog_dev.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [v4.9.0-beta3]

### Other
- Dependency replacement now contains content that is currently being imported (fr #124)

## [v4.9.0-beta2]

### Other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class MadGamesTycoon2ModTool {
public static final OSType OS_TYPE;
private static final Logger LOGGER = LoggerFactory.getLogger(MadGamesTycoon2ModTool.class);
public static final String VERSION = "4.9.0-beta2";//Version numbers that include "dev" are not checked for updates / tool will notify if update is available
public static final String VERSION = "4.9.0-dev";//Version numbers that include "dev" are not checked for updates / tool will notify if update is available
public static final String CURRENT_RELEASE_VERSION = "4.8.0";//When this version number has been detected as the newest release version the update available message is held back

static {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/lmh01/mgt2mt/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public static void open(Path path) {
* @param arrayList The array list that should be converted
* @return Returns a string array
*/
public static String[] convertArrayListToArray(ArrayList<String> arrayList) {
public static String[] convertArrayListToArray(List<String> arrayList) {
String[] strings = new String[arrayList.size()];
strings = arrayList.toArray(strings);
return strings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ private static boolean checkAssetsFolders(Set<Map<String, Object>> mods) {
@SuppressWarnings("unchecked")
private static Set<Map<String, Object>> checkDependencies(Set<Map<String, Object>> mods) throws ModProcessingException {
ContentAdministrator.analyzeContents();
Map<BaseContentManager, List<String>> contentNames = getContentNames(mods);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.importAll.checkingDependencies"));
ProgressBarHelper.initializeProgressBar(0, mods.size(), I18n.INSTANCE.get("textArea.importAll.checkingDependencies"));
Map<BaseContentManager, Map<String, String>> alreadyReplacedDependencies = new HashMap<>();
Expand Down Expand Up @@ -785,7 +786,7 @@ private static Set<Map<String, Object>> checkDependencies(Set<Map<String, Object
}
// Ask the user with which content the missing dependency should be replaced
JLabel label1 = new JLabel("<html>" + I18n.INSTANCE.get("textArea.importAll.dependencyCheck.optionPane.part1") + ":<br><br>" + child.getTypeUpperCase() + " - " + childName + "<br><br>" + I18n.INSTANCE.get("textArea.importAll.dependencyCheck.optionPane.part2"));
JList<String> list = WindowHelper.getList(child.getContentByAlphabet(), false);
JList<String> list = WindowHelper.getList(Utils.convertArrayListToArray(contentNames.get(child)), false);
JScrollPane scrollPane = WindowHelper.getScrollPane(list);
JLabel label2 = new JLabel("<html>" + I18n.INSTANCE.get("textArea.importAll.dependencyCheck.optionPane.part3"));
JCheckBox checkBox = new JCheckBox(I18n.INSTANCE.get("textArea.importAll.dependencyCheck.optionPane.checkBox"));
Expand Down Expand Up @@ -925,6 +926,26 @@ private static void replaceDependencyInDependencyMap(Map<String, Object> parentM
}
}

/**
* @param mods All maps for the new contents.
* @return Map that contains all content names for the specific content. Includes new content as well as already added content.
*/
private static Map<BaseContentManager, List<String>> getContentNames(Set<Map<String, Object>> mods) throws ModProcessingException {
Map<BaseContentManager, List<String>> contentNames = new HashMap<>();
for (BaseContentManager contentManager : ContentAdministrator.contentManagers) {
List<String> names = new ArrayList<>();
for (Map<String, Object> map : mods) {
if (map.get("mod_type").equals(contentManager.getId())) {
names.add((String)map.get("NAME EN"));
}
}
names.addAll(Arrays.asList(contentManager.getContentByAlphabet()));
names.sort(String::compareTo);
contentNames.put(contentManager, names);
}
return contentNames;
}

/**
* Checks if the import map contains the mod name under the mod_type
*
Expand Down

0 comments on commit 6802264

Please sign in to comment.