Skip to content

Commit

Permalink
Added some more translations (fr #30). Progress bar and text area are…
Browse files Browse the repository at this point in the history
… now utilized when adding/removing things.
  • Loading branch information
LMH01 committed Apr 11, 2021
1 parent fc956a1 commit cd15536
Show file tree
Hide file tree
Showing 18 changed files with 160 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -95,6 +97,7 @@ public static boolean removeEngineFeature(String engineFeatureName) throws IOExc
}
bw.write("[EOF]");
bw.close();
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.engineFeature") + " - " + engineFeatureName);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -123,6 +125,7 @@ public static boolean removeGameplayFeature(String gameplayFeatureName) throws I
}
bw.write("[EOF]");
bw.close();
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.gameplayFeature") + " - " + gameplayFeatureName);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -88,6 +90,7 @@ public static boolean removeGenre(String genreName) throws IOException {
EditThemeFiles.editGenreAllocation(AnalyzeExistingGenres.getGenreIdByName(genreName), false, null);
EditGameplayFeaturesFile.removeGenreId(AnalyzeExistingGenres.getGenreIdByName(genreName));
ImageFileHandler.removeImageFiles(genreName);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.genre") + " - " + genreName);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -16,7 +18,9 @@ public static boolean addLicence(Map<String, String> map) throws IOException {
return editLicenceFile(true, null, map);
}
public static boolean removeLicence(String licenceName) throws IOException {
return editLicenceFile(false, licenceName, null);
boolean returnValue = editLicenceFile(false, licenceName, null);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.licence") + " - " + licenceName);
return returnValue;
}
private static boolean editLicenceFile(boolean addLicence, String licenceName, Map<String, String> newLicenceMap) throws IOException {
AnalyzeExistingLicences.analyze();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -109,6 +111,7 @@ public static boolean removePublisher(String publisherNameEN) throws IOException
LOGGER.info("Image file for publisher " + publisherNameEN + " has been removed.");
}
}
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.publisher") + " - " + publisherNameEN);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.github.lmh01.mgt2mt.data_stream;

import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,7 +29,9 @@ public static void addTheme(Map<String, String> map, ArrayList<Integer> arrayLis
* @param themeNameEn The theme name that should be removed
*/
public static boolean removeTheme(String themeNameEn) throws IOException {
return editThemeFiles(null, null, false, AnalyzeExistingThemes.getPositionOfThemeInFile(themeNameEn), 0);
boolean returnValue = editThemeFiles(null, null, false, AnalyzeExistingThemes.getPositionOfThemeInFile(themeNameEn), 0);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.removed") + " " + I18n.INSTANCE.get("window.main.share.export.theme") + " - " + themeNameEn);
return returnValue;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.helper.ProgressBarHelper;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
Expand All @@ -22,6 +24,7 @@ public static void checkForUpdates(boolean showNoUpdateAvailableDialog){
new Thread("UpdateChecker"){
public void run(){
try {
ProgressBarHelper.initializeProgressBar(0,1, I18n.INSTANCE.get("progressBar.checkForUpdates"));
LOGGER.info("Checking for updates...");
updateAvailable = false;
java.net.URL url;
Expand All @@ -36,6 +39,7 @@ public void run(){
Scanner scanner = new Scanner(url.openStream());
String currentLine = scanner.nextLine();
newestVersion = currentLine;
ProgressBarHelper.increment();
if(!newestVersion.equals(MadGamesTycoon2ModTool.VERSION)){
if(!newestVersion.equals(MadGamesTycoon2ModTool.CURRENT_RELEASE_VERSION)){
if(!MadGamesTycoon2ModTool.VERSION.contains("dev")){
Expand Down Expand Up @@ -70,6 +74,8 @@ public void run(){
} catch (IOException e) {
e.printStackTrace();
}
ProgressBarHelper.resetProgressBar();
WindowMain.lockMenuItems(false);
}

}.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public static void exportAll(boolean exportAsRestorePoint){
}
TextAreaHelper.resetAutoScroll();
WindowMain.lockMenuItems(false);
WindowMain.checkActionAvailability();
}

/**
Expand Down
38 changes: 26 additions & 12 deletions src/main/java/com/github/lmh01/mgt2mt/util/ThreadHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,26 @@
public class ThreadHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadHandler.class);

private static Runnable runnableExportLicence = () -> OperationHelper.process((string) -> SharingHandler.exportLicence(string, false), AnalyzeExistingLicences.getCustomLicenceNamesByAlphabet(), AnalyzeExistingLicences.getLicenceNamesByAlphabet(), "licence", "exported", "Export", true);
private static Runnable runnableExportEngineFeatures = () -> OperationHelper.process((string) -> SharingHandler.exportEngineFeature(string, false), AnalyzeExistingEngineFeatures.getCustomEngineFeaturesString(), AnalyzeExistingEngineFeatures.getEngineFeaturesByAlphabet(), "engine feature", "exported", "Export", true);
private static Runnable runnableExportGameplayFeatures = () -> OperationHelper.process((string) -> SharingHandler.exportGameplayFeature(string, false), AnalyzeExistingGameplayFeatures.getCustomGameplayFeaturesString(), AnalyzeExistingGameplayFeatures.getGameplayFeaturesByAlphabet(), "gameplay feature", "exported", "Export", true);
private static Runnable runnableExportThemes = () -> OperationHelper.process((string) -> SharingHandler.exportTheme(string, false), AnalyzeExistingThemes.getCustomThemesByAlphabet(), AnalyzeExistingThemes.getThemesByAlphabet(), "themes", "exported", "Export", true);
private static Runnable runnableExportPublisher = () -> OperationHelper.process((string) -> SharingHandler.exportPublisher(string, false), AnalyzeExistingPublishers.getCustomPublisherString(), AnalyzeExistingPublishers.getPublisherString(), "publisher", "exported", "Export", true);
private static Runnable runnableExportGenre = () -> OperationHelper.process((string) -> SharingHandler.exportGenre(string, false), AnalyzeExistingGenres.getCustomGenresByAlphabetWithoutId(), AnalyzeExistingGenres.getGenresByAlphabetWithoutId(), "genre", "exported", "Export", true);
private static Runnable runnableExportLicence = () -> OperationHelper.process((string) -> SharingHandler.exportLicence(string, false), AnalyzeExistingLicences.getCustomLicenceNamesByAlphabet(), AnalyzeExistingLicences.getLicenceNamesByAlphabet(), I18n.INSTANCE.get("commonText.licence"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportEngineFeatures = () -> OperationHelper.process((string) -> SharingHandler.exportEngineFeature(string, false), AnalyzeExistingEngineFeatures.getCustomEngineFeaturesString(), AnalyzeExistingEngineFeatures.getEngineFeaturesByAlphabet(), I18n.INSTANCE.get("commonText.engineFeature"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportGameplayFeatures = () -> OperationHelper.process((string) -> SharingHandler.exportGameplayFeature(string, false), AnalyzeExistingGameplayFeatures.getCustomGameplayFeaturesString(), AnalyzeExistingGameplayFeatures.getGameplayFeaturesByAlphabet(), I18n.INSTANCE.get("commonText.gameplayFeature"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportThemes = () -> OperationHelper.process((string) -> SharingHandler.exportTheme(string, false), AnalyzeExistingThemes.getCustomThemesByAlphabet(), AnalyzeExistingThemes.getThemesByAlphabet(), I18n.INSTANCE.get("commonText.theme"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportPublisher = () -> OperationHelper.process((string) -> SharingHandler.exportPublisher(string, false), AnalyzeExistingPublishers.getCustomPublisherString(), AnalyzeExistingPublishers.getPublisherString(), I18n.INSTANCE.get("commonText.publisher"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportGenre = () -> OperationHelper.process((string) -> SharingHandler.exportGenre(string, false), AnalyzeExistingGenres.getCustomGenresByAlphabetWithoutId(), AnalyzeExistingGenres.getGenresByAlphabetWithoutId(), I18n.INSTANCE.get("commonText.genre"), I18n.INSTANCE.get("commonText.exported"), I18n.INSTANCE.get("commonText.export"), I18n.INSTANCE.get("commonText.exporting"), true);
private static Runnable runnableExportAll = () -> SharingManager.exportAll(false);
private static Runnable runnableUninstall = () -> Uninstaller.uninstall();
private static Runnable runnableImportAll = () -> SharingManager.importAll();
private static Runnable runnableShowActiveMods = () -> ActiveMods.showActiveMods();
private static Runnable runnableDeleteExports = () -> Uninstaller.deleteAllExports();
private static Runnable runnableReplacePublisherWithRealPublishers = () -> PublisherHelper.realPublishers();
private static Runnable runnableImportFromURL = () -> ImportFromURLHelper.importFromURL();
private static Runnable runnableUninstall = Uninstaller::uninstall;
private static Runnable runnableImportAll = SharingManager::importAll;
private static Runnable runnableShowActiveMods = ActiveMods::showActiveMods;
private static Runnable runnableDeleteExports = Uninstaller::deleteAllExports;
private static Runnable runnableReplacePublisherWithRealPublishers = PublisherHelper::realPublishers;
private static Runnable runnableImportFromURL = ImportFromURLHelper::importFromURL;
private static Runnable runnableCheckForUpdates = () -> UpdateChecker.checkForUpdates(true);
private static Runnable runnableRemoveGenre = () -> OperationHelper.process(EditGenreFile::removeGenre, AnalyzeExistingGenres.getCustomGenresByAlphabetWithoutId(), AnalyzeExistingGenres.getGenresByAlphabetWithoutId(), I18n.INSTANCE.get("commonText.genre"), I18n.INSTANCE.get("commonText.removed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
private static Runnable runnableRemoveTheme = () -> OperationHelper.process(EditThemeFiles::removeTheme, AnalyzeExistingThemes.getCustomThemesByAlphabet(), AnalyzeExistingThemes.getThemesByAlphabet(), I18n.INSTANCE.get("commonText.theme"), I18n.INSTANCE.get("commonText.removeed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
private static Runnable runnableRemovePublisher = () -> OperationHelper.process(EditPublishersFile::removePublisher, AnalyzeExistingPublishers.getCustomPublisherString(), AnalyzeExistingPublishers.getPublisherString(), I18n.INSTANCE.get("commonText.publisher"), I18n.INSTANCE.get("commonText.removed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
private static Runnable runnableRemoveGameplayFeature = () -> OperationHelper.process(EditGameplayFeaturesFile::removeGameplayFeature, AnalyzeExistingGameplayFeatures.getCustomGameplayFeaturesString(), AnalyzeExistingGameplayFeatures.getGameplayFeaturesByAlphabet(), I18n.INSTANCE.get("commonText.gameplayFeature"), I18n.INSTANCE.get("commonText.removed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
private static Runnable runnableRemoveEngineFeature = () -> OperationHelper.process(EditEngineFeaturesFile::removeEngineFeature, AnalyzeExistingEngineFeatures.getCustomEngineFeaturesString(), AnalyzeExistingEngineFeatures.getEngineFeaturesByAlphabet(), I18n.INSTANCE.get("commonText.engineFeature"), I18n.INSTANCE.get("commonText.removed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
private static Runnable runnableRemoveLicence = () -> OperationHelper.process(EditLicenceFile::removeLicence, AnalyzeExistingLicences.getCustomLicenceNamesByAlphabet(), AnalyzeExistingLicences.getLicenceNamesByAlphabet(), I18n.INSTANCE.get("commonText.licence"), I18n.INSTANCE.get("commonText.removed"), I18n.INSTANCE.get("commonText.remove"), I18n.INSTANCE.get("commonText.removing"), false);
public static Runnable runnableDoOnShutdown = () -> {
LOGGER.info("Performing exit tasks...");
LogFile.stopLogging();
Expand Down Expand Up @@ -52,6 +59,13 @@ public static void startThread(String threadName){
case "runnableDeleteExports": thread = new Thread(runnableDeleteExports);break;
case "runnableReplacePublisherWithRealPublishers": thread = new Thread(runnableReplacePublisherWithRealPublishers);break;
case "runnableImportFromURL": thread = new Thread(runnableImportFromURL);break;
case "runnableCheckForUpdates": thread = new Thread(runnableCheckForUpdates);break;
case "runnableRemoveGenre": thread = new Thread(runnableRemoveGenre);break;
case "runnableRemoveTheme": thread = new Thread(runnableRemoveTheme);break;
case "runnableRemovePublisher": thread = new Thread(runnableRemovePublisher);break;
case "runnableRemoveGameplayFeature": thread = new Thread(runnableRemoveGameplayFeature);break;
case "runnableRemoveEngineFeature": thread = new Thread(runnableRemoveEngineFeature);break;
case "runnableRemoveLicence": thread = new Thread(runnableRemoveLicence);break;
default:
throw new IllegalStateException("This thread name is not accepted: " + threadName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public static boolean uninstallAllMods(StringBuilder uninstallFailedExplanation)
}
Backup.restoreBackup(true, false);//This is used to restore the Themes files to its original condition
ProgressBarHelper.resetProgressBar();
WindowMain.lockMenuItems(false);
return uninstallFailed;
}
public static void deleteAllExports(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public static void addEngineFeature(){
if(addFeature){
EditEngineFeaturesFile.addEngineFeature(newEngineFeature);
JOptionPane.showMessageDialog(null, "Engine feature: [" + newEngineFeature.get("NAME EN") + "] has been added successfully!", "Engine feature added", JOptionPane.INFORMATION_MESSAGE);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.engineFeature") + " - " + newEngineFeature.get("NAME EN"));
ChangeLog.addLogEntry(27, newEngineFeature.get("NAME EN"));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public static void addGameplayFeature(){
if(addFeature) {
EditGameplayFeaturesFile.addGameplayFeature(newGameplayFeature);
JOptionPane.showMessageDialog(null, "Gameplay feature: [" + newGameplayFeature.get("NAME EN") + "] has been added successfully!", "Gameplay feature added", JOptionPane.INFORMATION_MESSAGE);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.gameplayFeature") + " - " + newGameplayFeature.get("NAME EN"));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.github.lmh01.mgt2mt.data_stream.AnalyzeExistingGameplayFeatures;
import com.github.lmh01.mgt2mt.data_stream.AnalyzeExistingGenres;
import com.github.lmh01.mgt2mt.data_stream.AnalyzeExistingThemes;
import com.github.lmh01.mgt2mt.util.GenreManager;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.TranslationManager;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.*;
import com.github.lmh01.mgt2mt.windows.WindowMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -163,6 +160,7 @@ public static void addRandomizedGenre(){
File iconFile = new File(iconPath.toString());
if(GenreManager.addGenre(map, map, compatibleThemeIds, gameplayFeatures.get(0), gameplayFeatures.get(1), screenshotFiles.get(),true, iconFile, checkBoxShowSummary.isSelected())){
JOptionPane.showMessageDialog(null, "Genre [" + genreName + "] has been added successfully!", "Genre added", JOptionPane.INFORMATION_MESSAGE);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.genre") + " - " + genreName);
}
break;
}else{
Expand Down
Loading

0 comments on commit cd15536

Please sign in to comment.