diff --git a/src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java b/src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java index ce421576..0a64e2ea 100644 --- a/src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java +++ b/src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java @@ -164,49 +164,45 @@ public void menuActionAddMod() { if(listAvailableThemes.getSelectedValuesList().size() != 0){ if(!textFieldThemeName.getText().isEmpty()){ if(!ModManager.themeMod.getAnalyzerEn().getFileContent().containsValue(textFieldThemeName.getText()) && !ModManager.themeMod.getAnalyzerGe().getFileContent().containsValue(textFieldThemeName.getText())){ - if(!textFieldThemeName.getText().matches(".*\\d.*")){ - arrayListCompatibleGenreNames.addAll(listAvailableThemes.getSelectedValuesList()); - for(Map map : ModManager.genreMod.getAnalyzer().getFileContent()){ - for(String name : arrayListCompatibleGenreNames){ - if(map.get("NAME EN").equals(name)){ - arrayListCompatibleGenreIds.add(Integer.parseInt(map.get("ID"))); - } + arrayListCompatibleGenreNames.addAll(listAvailableThemes.getSelectedValuesList()); + for(Map map : ModManager.genreMod.getAnalyzer().getFileContent()){ + for(String name : arrayListCompatibleGenreNames){ + if(map.get("NAME EN").equals(name)){ + arrayListCompatibleGenreIds.add(Integer.parseInt(map.get("ID"))); } } - Map themeTranslations = new HashMap<>(); - int currentTranslationKey = 0; - if(arrayListThemeTranslations[0].isEmpty()){ - for(String translationKey : TranslationManager.TRANSLATION_KEYS){ - themeTranslations.put("NAME " + translationKey, textFieldThemeName.getText()); - } - }else{ - for(String translation : arrayListThemeTranslations[0]){ - themeTranslations.put("NAME " + TranslationManager.TRANSLATION_KEYS[currentTranslationKey], translation); - currentTranslationKey++; - } - } - themeTranslations.put("NAME EN", textFieldThemeName.getText()); - if(JOptionPane.showConfirmDialog(null, I18n.INSTANCE.get("mod.theme.addTheme.addTheme.question") + ":\n" + textFieldThemeName.getText(), I18n.INSTANCE.get("mod.theme.addTheme.addTheme.title"), JOptionPane.YES_NO_OPTION) == 0){ - Backup.createThemeFilesBackup(false, false); - int ageNumber = 0; - if(comboBoxViolenceLevel.getSelectedItem().toString().equals("Index")){ - ageNumber = 5; - }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 18){ - ageNumber = 4; - }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 16){ - ageNumber = 3; - }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 12){ - ageNumber = 2; - }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 6){ - ageNumber = 1; - } - ModManager.themeMod.getEditor().addMod(themeTranslations, arrayListCompatibleGenreIds, ageNumber); - TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.theme") + " - " + textFieldThemeName.getText()); - JOptionPane.showMessageDialog(null, "The new theme has been added successfully!"); - breakLoop = true; + } + Map themeTranslations = new HashMap<>(); + int currentTranslationKey = 0; + if(arrayListThemeTranslations[0].isEmpty()){ + for(String translationKey : TranslationManager.TRANSLATION_KEYS){ + themeTranslations.put("NAME " + translationKey, textFieldThemeName.getText()); } }else{ - JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("mod.theme.addTheme.unableToAddTheme") + "\n" + I18n.INSTANCE.get("mod.theme.addTheme.unableToAddTheme.error4"), I18n.INSTANCE.get("frame.title.error"), JOptionPane.ERROR_MESSAGE); + for(String translation : arrayListThemeTranslations[0]){ + themeTranslations.put("NAME " + TranslationManager.TRANSLATION_KEYS[currentTranslationKey], translation); + currentTranslationKey++; + } + } + themeTranslations.put("NAME EN", textFieldThemeName.getText()); + if(JOptionPane.showConfirmDialog(null, I18n.INSTANCE.get("mod.theme.addTheme.addTheme.question") + ":\n" + textFieldThemeName.getText(), I18n.INSTANCE.get("mod.theme.addTheme.addTheme.title"), JOptionPane.YES_NO_OPTION) == 0){ + Backup.createThemeFilesBackup(false, false); + int ageNumber = 0; + if(comboBoxViolenceLevel.getSelectedItem().toString().equals("Index")){ + ageNumber = 5; + }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 18){ + ageNumber = 4; + }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 16){ + ageNumber = 3; + }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 12){ + ageNumber = 2; + }else if(Integer.parseInt(Objects.requireNonNull(comboBoxViolenceLevel.getSelectedItem().toString())) == 6){ + ageNumber = 1; + } + ModManager.themeMod.getEditor().addMod(themeTranslations, arrayListCompatibleGenreIds, ageNumber); + TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.theme") + " - " + textFieldThemeName.getText()); + JOptionPane.showMessageDialog(null, "The new theme has been added successfully!"); + breakLoop = true; } }else{ JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("mod.theme.addTheme.unableToAddTheme") + "\n" + I18n.INSTANCE.get("mod.theme.addTheme.unableToAddTheme.error3"), I18n.INSTANCE.get("frame.title.error"), JOptionPane.ERROR_MESSAGE); diff --git a/src/main/resources/locale/de.txt b/src/main/resources/locale/de.txt index e4614130..763c2481 100644 --- a/src/main/resources/locale/de.txt +++ b/src/main/resources/locale/de.txt @@ -287,7 +287,6 @@ mod.theme.addTheme.unableToAddTheme|Thema kann nicht hinzugefügt werden: mod.theme.addTheme.unableToAddTheme.error1|Bitte wähle mindestens ein genre aus. mod.theme.addTheme.unableToAddTheme.error2|Bitte gebe den Namen für das Thema ein. mod.theme.addTheme.unableToAddTheme.error3|Der eingegebene Name wird schon benutzt. -mod.theme.addTheme.unableToAddTheme.error4|Der Name des Themas darf keine Nummern enthalten! mod.theme.addTheme.addTheme.question|Möchtest du das folgende Thema hinzufügen? mod.theme.addTheme.addTheme.title|Dieses Thema hinzufügen? mod.theme.addTheme.main.title|Neues Thema hinzufügen diff --git a/src/main/resources/locale/en.txt b/src/main/resources/locale/en.txt index 82a430fa..693c1603 100644 --- a/src/main/resources/locale/en.txt +++ b/src/main/resources/locale/en.txt @@ -286,7 +286,6 @@ mod.theme.addTheme.unableToAddTheme|Unable to add theme: mod.theme.addTheme.unableToAddTheme.error1|Please select at least one genre. mod.theme.addTheme.unableToAddTheme.error2|Please enter a name for your theme. mod.theme.addTheme.unableToAddTheme.error3|The selected name is already in use. -mod.theme.addTheme.unableToAddTheme.error4|The theme name can not contain numbers! mod.theme.addTheme.addTheme.question|Do you want to add this theme? mod.theme.addTheme.addTheme.title|Add this theme? mod.theme.addTheme.main.title|Add new theme