Skip to content

Commit

Permalink
Theme names are now allowed to contain numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH01 committed May 14, 2021
1 parent 4b7fc96 commit acf7f09
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
74 changes: 35 additions & 39 deletions src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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<String, String> map : ModManager.genreMod.getAnalyzer().getFileContent()){
for(String name : arrayListCompatibleGenreNames){
if(map.get("NAME EN").equals(name)){
arrayListCompatibleGenreIds.add(Integer.parseInt(map.get("ID")));
}
}
Map<String, String> 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<String, String> 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);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/locale/de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/locale/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit acf7f09

Please sign in to comment.