Skip to content

Commit

Permalink
Backups are now created when game files are manually changed or when …
Browse files Browse the repository at this point in the history
…the import all summary is displayed. Theme file backups are no longer written to text area when theme is added manually.
  • Loading branch information
LMH01 committed Apr 30, 2021
1 parent fc5bfb8 commit 3c5e4fd
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/AntiCheatMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.managed.AbstractAdvancedSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
Expand Down Expand Up @@ -185,6 +186,7 @@ public void menuActionAddMod() {
antiCheatMap.put("PRICE", spinnerCost.getValue().toString());
antiCheatMap.put("DEV COSTS", spinnerDevelopmentCost.getValue().toString());
if(JOptionPane.showConfirmDialog(null, getBaseSharer().getOptionPaneMessage(antiCheatMap), I18n.INSTANCE.get("frame.title.isThisCorrect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
Backup.createBackup(getFile());
getBaseEditor().addMod(antiCheatMap);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.antiCheat.upperCase") + " - " + antiCheatMap.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.antiCheat.upperCase") + ": [" + antiCheatMap.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + getType(), JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/CopyProtectMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.managed.AbstractAdvancedSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
Expand Down Expand Up @@ -185,6 +186,7 @@ public void menuActionAddMod() {
copyProtectMap.put("PRICE", spinnerCost.getValue().toString());
copyProtectMap.put("DEV COSTS", spinnerDevelopmentCost.getValue().toString());
if(JOptionPane.showConfirmDialog(null, getBaseSharer().getOptionPaneMessage(copyProtectMap), I18n.INSTANCE.get("frame.title.isThisCorrect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
Backup.createBackup(getFile());
getBaseEditor().addMod(copyProtectMap);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.copyProtect.upperCase") + " - " + copyProtectMap.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.copyProtect.upperCase") + ": [" + copyProtectMap.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + getType(), JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public void menuActionAddMod() {
newEngineFeature.put("TECH", spinnerTech.getValue().toString());
boolean addFeature = Summaries.showSummary(ModManager.engineFeatureMod.getSharer().getOptionPaneMessage(newEngineFeature), I18n.INSTANCE.get("mod.engineFeature.addMod.title"));
if (addFeature) {
Backup.createBackup(getFile());
ModManager.engineFeatureMod.getEditor().addMod(newEngineFeature);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.engineFeature.upperCase") + " - " + newEngineFeature.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.engineFeature.upperCase") + ": [" + newEngineFeature.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + getType(), JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ public void menuActionAddMod() {
}
boolean addFeature = Summaries.showSummary(ModManager.gameplayFeatureMod.getSharer().getOptionPaneMessage(newGameplayFeature), I18n.INSTANCE.get("mod.gameplayFeature.addMod.title"));
if(addFeature) {
Backup.createBackup(getFile());
ModManager.gameplayFeatureMod.getEditor().addMod(newGameplayFeature);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.gameplayFeature.upperCase") + " - " + newGameplayFeature.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.gameplayFeature.upperCase") + ": [" + newGameplayFeature.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + getType(), JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/GenreMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.GenreSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Utils;
Expand Down Expand Up @@ -294,6 +295,7 @@ public void addRandomizedGenre(){
List<HashSet<Integer>> gameplayFeatures = getRandomGameplayFeatureIds();
setGameplayFeatureCompatibility(map, gameplayFeatures.get(0), gameplayFeatures.get(1));
File iconFile = new File(iconPath.toString());
Backup.createBackup(getFile());
if(GenreManager.addGenre(map, map, compatibleThemeIds, gameplayFeatures.get(0), gameplayFeatures.get(1), screenshotFiles.get(),true, iconFile, checkBoxShowSummary.isSelected())){
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.genre") + " - " + genreName);
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.genre") + " [" + genreName + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("commonText.genre") + " " + I18n.INSTANCE.get("commonText.added"), JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/LicenceMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.LicenceSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractSimpleMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -143,6 +144,7 @@ public void menuActionAddMod() {
.append("Type: ").append(comboBoxType.getSelectedItem());
if(JOptionPane.showConfirmDialog(null, stringBuilder.toString(), "Add this licence?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
try {
Backup.createBackup(getFile());
ModManager.licenceMod.getEditor().addMod(newLicence.toString());
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.licence") + " - " + textFieldName.getText());
JOptionPane.showMessageDialog(null, "Licence [" + textFieldName.getText() + "] has been added successfully!");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/NpcEngineMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.NpcEngineSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.helper.ProgressBarHelper;
Expand Down Expand Up @@ -200,6 +201,7 @@ public void menuActionAddMod() {
if(JOptionPane.showConfirmDialog(null, I18n.INSTANCE.get("mod.npcEngine.addMod.optionPaneMessage.multipleGenres") + "<br><br>" + getBaseSharer().getOptionPaneMessage(npcEngine) + "<br><br>" + I18n.INSTANCE.get("commonText.isThisCorrect"), I18n.INSTANCE.get("frame.title.isThisCorrect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
npcEngine.remove("NAME EN");
npcEngine.remove("GENRE");
Backup.createBackup(getFile());
ProgressBarHelper.initializeProgressBar(0, listAvailableGenres.getSelectedValuesList().size(), I18n.INSTANCE.get(""));
for(String string : listAvailableGenres.getSelectedValuesList()){
getBaseAnalyzer().analyzeFile();
Expand Down Expand Up @@ -237,6 +239,7 @@ public void menuActionAddMod() {
npcEngine.put("GENRE", Integer.toString(ModManager.genreMod.getAnalyzer().getContentIdByName(listAvailableGenres.getSelectedValue())));
sendLogMessage("Only a single genre has been selected. Displaying single engine dialog");
if(JOptionPane.showConfirmDialog(null, getBaseSharer().getOptionPaneMessage(npcEngine), I18n.INSTANCE.get("frame.title.isThisCorrect"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
Backup.createBackup(getFile());
getBaseEditor().addMod(npcEngine);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.npcEngine.upperCase") + " - " + npcEngine.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.npcEngine.upperCase") + ": [" + npcEngine.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.npcEngine.upperCase"), JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/NpcGamesMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.NpcGamesSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractSimpleMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void menuActionAddMod() {
}
if(JOptionPane.showConfirmDialog(null, getBaseSharer().getOptionPaneMessage(newModLine.toString()), I18n.INSTANCE.get("commonText.add.upperCase") + ": " + getType(), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
try {
Backup.createBackup(getFile());
ModManager.npcGamesMod.getBaseEditor().addMod(newModLine.toString());
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + getType() + " - " + newModName);
JOptionPane.showMessageDialog(null, getType() + " [" + newModName + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"));
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/github/lmh01/mgt2mt/mod/PlatformMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.PlatformSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Summaries;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.*;
import com.github.lmh01.mgt2mt.util.handler.ThreadHandler;
import com.github.lmh01.mgt2mt.util.helper.OperationHelper;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
Expand Down Expand Up @@ -508,6 +505,7 @@ public void mouseClicked(MouseEvent e) {
}
platformMap.put("TYP", Integer.toString(getPlatformTypeIdByString(comboBoxFeatureType.getSelectedItem().toString())));
if(JOptionPane.showConfirmDialog(null, getBaseSharer().getOptionPaneMessage(platformMap), I18n.INSTANCE.get(""), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
Backup.createBackup(getFile());
getEditor().addMod(platformMap, finalPictureMap);
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.platform.upperCase") + " - " + platformMap.get("NAME EN"));
JOptionPane.showMessageDialog(null, I18n.INSTANCE.get("commonText.platform.upperCase") + ": [" + platformMap.get("NAME EN") + "] " + I18n.INSTANCE.get("commonText.successfullyAdded"), I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("commonText.platform.upperCase"), JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/github/lmh01/mgt2mt/mod/PublisherMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.github.lmh01.mgt2mt.data_stream.sharer.PublisherSharer;
import com.github.lmh01.mgt2mt.mod.managed.AbstractAdvancedMod;
import com.github.lmh01.mgt2mt.mod.managed.ModManager;
import com.github.lmh01.mgt2mt.util.Backup;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Utils;
Expand Down Expand Up @@ -283,6 +284,7 @@ public void menuActionAddMod() {
hashMap.put("MARKET", spinnerMarketShare.getValue().toString());
hashMap.put("SHARE", spinnerShare.getValue().toString());
hashMap.put("GENRE", genreID.toString());
Backup.createBackup(getFile());
ModManager.publisherMod.getEditor().addMod(hashMap, publisherImageFilePath.toString());
TextAreaHelper.appendText(I18n.INSTANCE.get("textArea.added") + " " + I18n.INSTANCE.get("window.main.share.export.publisher") + " - " + hashMap.get("NAME EN"));
JOptionPane.showMessageDialog(null, "Publisher " + hashMap.get("NAME EN") + " has been added successfully", "Publisher added", JOptionPane.INFORMATION_MESSAGE);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/lmh01/mgt2mt/mod/ThemeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void menuActionAddMod() {
}
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, true);
Backup.createThemeFilesBackup(false, false);
ModManager.themeMod.getEditor().addMod(themeTranslations, arrayListCompatibleGenreIds, Integer.parseInt(comboBoxViolenceLevel.getSelectedItem().toString()));
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!");
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.*;
import com.github.lmh01.mgt2mt.data_stream.sharer.*;
import com.github.lmh01.mgt2mt.mod.managed.*;
import com.github.lmh01.mgt2mt.util.I18n;
import com.github.lmh01.mgt2mt.util.Settings;
import com.github.lmh01.mgt2mt.util.Uninstaller;
import com.github.lmh01.mgt2mt.util.Utils;
import com.github.lmh01.mgt2mt.util.*;
import com.github.lmh01.mgt2mt.util.handler.ThreadHandler;
import com.github.lmh01.mgt2mt.util.helper.ProgressBarHelper;
import com.github.lmh01.mgt2mt.util.helper.TextAreaHelper;
Expand Down Expand Up @@ -348,6 +345,7 @@ public static void importAll(boolean importFromRestorePoint, String folderPath){
}
}
}
Backup.createFullBackup();
} catch (IOException e) {
errorWhileScanning = true;
TextAreaHelper.appendText(I18n.INSTANCE.get("dialog.sharingManager.importAll.error.general").replace("<html>", "").replace("<br>", " ") + " " + I18n.INSTANCE.get("commonBodies.exception") + " " + e.getMessage());
Expand Down

0 comments on commit 3c5e4fd

Please sign in to comment.