fixed play is enabled when updating or file checking

This commit is contained in:
Niklas 2020-04-01 02:44:12 +02:00
parent 21b86d6808
commit 0b2f64fc9a
3 changed files with 26 additions and 8 deletions

View File

@ -371,7 +371,7 @@ public class LauncherGUI implements Observer {
Object elementAt = model1.getElementAt(presetList.getSelectedIndex()); Object elementAt = model1.getElementAt(presetList.getSelectedIndex());
Modset selectedModset = (Modset) elementAt; Modset selectedModset = (Modset) elementAt;
if(selectedModset.getType() == Modset.Type.PLACEHOLDER) return; if (selectedModset.getType() == Modset.Type.PLACEHOLDER) return;
ArmaUtils.start(selectedModset); ArmaUtils.start(selectedModset);
} }
@ -416,6 +416,8 @@ public class LauncherGUI implements Observer {
syncIntensiveCheckButton.setEnabled(false); syncIntensiveCheckButton.setEnabled(false);
syncFastCheckButton.setEnabled(false); syncFastCheckButton.setEnabled(false);
refreshRepoButton.setEnabled(false); refreshRepoButton.setEnabled(false);
playButton.setEnabled(false);
playPresetButton.setEnabled(false);
new Thread(() -> syncer.sync(lastSynclist.clone())).start(); new Thread(() -> syncer.sync(lastSynclist.clone())).start();
}); });
@ -672,7 +674,7 @@ public class LauncherGUI implements Observer {
syncFastCheckButton.setToolTipText(LangUtils.getInstance().getString("arma_running")); syncFastCheckButton.setToolTipText(LangUtils.getInstance().getString("arma_running"));
} else { } else {
if (SteamTimer.steam_running) { if (SteamTimer.steam_running) {
if (pathSet) { if (pathSet && !syncer.isRunning() && !fileChecker.isRunning()) {
if (serverTable.getSelectedRow() != -1) { if (serverTable.getSelectedRow() != -1) {
playButton.setEnabled(true); playButton.setEnabled(true);
playButton.setToolTipText(null); playButton.setToolTipText(null);
@ -1161,11 +1163,11 @@ public class LauncherGUI implements Observer {
syncDownloadButton.setEnabled(true); syncDownloadButton.setEnabled(true);
syncPauseButton.setEnabled(false); syncPauseButton.setEnabled(false);
refreshRepoButton.setEnabled(true);
syncChangedFileSizeLabel.setText(Humanize.binaryPrefix(fileChecker.getSize())); syncChangedFileSizeLabel.setText(Humanize.binaryPrefix(fileChecker.getSize()));
lastSynclist = null; lastSynclist = null;
techCheck();
} else if (s.equals("fileCheckerStopped")) { } else if (s.equals("fileCheckerStopped")) {
syncIntensiveCheckButton.setEnabled(true); syncIntensiveCheckButton.setEnabled(true);
syncFastCheckButton.setEnabled(true); syncFastCheckButton.setEnabled(true);
@ -1179,7 +1181,6 @@ public class LauncherGUI implements Observer {
syncPauseButton.setEnabled(false); syncPauseButton.setEnabled(false);
repoTree.setCheckboxesChecked(false); repoTree.setCheckboxesChecked(false);
refreshRepoButton.setEnabled(true);
syncAddedFilesLabel.setText("" + 0); syncAddedFilesLabel.setText("" + 0);
syncChangedFilesLabel.setText("" + 0); syncChangedFilesLabel.setText("" + 0);
@ -1188,6 +1189,7 @@ public class LauncherGUI implements Observer {
syncChangedFileSizeLabel.setText("0.0 B"); syncChangedFileSizeLabel.setText("0.0 B");
lastSynclist = null; lastSynclist = null;
techCheck();
} else if (s.equals("syncStopped")) { } else if (s.equals("syncStopped")) {
final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter(); final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter();
fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue())); fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()));
@ -1200,6 +1202,7 @@ public class LauncherGUI implements Observer {
TaskBarUtils.getInstance().setValue(0); TaskBarUtils.getInstance().setValue(0);
TaskBarUtils.getInstance().off(); TaskBarUtils.getInstance().off();
}); });
techCheck();
} else if (s.equals("syncComplete")) { } else if (s.equals("syncComplete")) {
final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter(); final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter();
fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue())); fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()));
@ -1214,6 +1217,7 @@ public class LauncherGUI implements Observer {
TaskBarUtils.getInstance().attention(); TaskBarUtils.getInstance().attention();
TaskBarUtils.getInstance().notification("Sync complete", "", TrayIcon.MessageType.INFO); TaskBarUtils.getInstance().notification("Sync complete", "", TrayIcon.MessageType.INFO);
}); });
techCheck();
} else if (s.equals("syncContinue")) { } else if (s.equals("syncContinue")) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
syncDownloadAbortButton.setEnabled(true); syncDownloadAbortButton.setEnabled(true);
@ -1266,6 +1270,9 @@ public class LauncherGUI implements Observer {
repoTree.setCheckboxesEnabled(false); repoTree.setCheckboxesEnabled(false);
repoTree.setCheckboxesChecked(false); repoTree.setCheckboxesChecked(false);
playButton.setEnabled(false);
playPresetButton.setEnabled(false);
} }
public void exit() { public void exit() {

View File

@ -29,12 +29,13 @@ public class FileChecker implements Observable {
private boolean stop = false; private boolean stop = false;
private boolean checked = false; private boolean checked = false;
private boolean running = false;
private ArrayList<Path> deleted = new ArrayList<>(); private ArrayList<Path> deleted = new ArrayList<>();
private HashMap<String, ArrayList<ModFile>> changed = new HashMap<>(); private HashMap<String, ArrayList<ModFile>> changed = new HashMap<>();
int changedCount = 0; private int changedCount = 0;
private HashMap<String, ArrayList<ModFile>> added = new HashMap<>(); private HashMap<String, ArrayList<ModFile>> added = new HashMap<>();
int addedCount = 0; private int addedCount = 0;
long size = 0; long size = 0;
@ -47,6 +48,7 @@ public class FileChecker implements Observable {
} }
public void check(boolean fastscan) { public void check(boolean fastscan) {
running = true;
deleted.clear(); deleted.clear();
changed.clear(); changed.clear();
changedCount = 0; changedCount = 0;
@ -63,6 +65,7 @@ public class FileChecker implements Observable {
for (AbstractMod abstractMod : RepositoryManger.MOD_LIST) { for (AbstractMod abstractMod : RepositoryManger.MOD_LIST) {
if (stop) { if (stop) {
stop = false; stop = false;
running = false;
notifyObservers("fileCheckerStopped"); notifyObservers("fileCheckerStopped");
return; return;
} }
@ -80,6 +83,7 @@ public class FileChecker implements Observable {
if (stop) { if (stop) {
stop = false; stop = false;
running = false;
notifyObservers("fileCheckerStopped"); notifyObservers("fileCheckerStopped");
return; return;
} }
@ -98,6 +102,7 @@ public class FileChecker implements Observable {
checkDeleted(); checkDeleted();
notifyObservers("fileChecker"); notifyObservers("fileChecker");
checked = true; checked = true;
running = false;
} }
public boolean isChecked() { public boolean isChecked() {
@ -108,6 +113,10 @@ public class FileChecker implements Observable {
stop = true; stop = true;
} }
public boolean isRunning() {
return running;
}
private void checkFile(String mod, ModFile mf, boolean fastscan) { private void checkFile(String mod, ModFile mf, boolean fastscan) {
ArrayList<ModFile> temp = new ArrayList<>(); ArrayList<ModFile> temp = new ArrayList<>();

View File

@ -145,14 +145,16 @@ public class Syncer implements Observable, SyncListener {
if (mf != null) { if (mf != null) {
final Path mfPath = mf.getLocaleFile().toPath(); final Path mfPath = mf.getLocaleFile().toPath();
final String mfModPath = mf.getModPath();
if(!workshopFiles.isEmpty()) { if(!workshopFiles.isEmpty()) {
try { try {
final String modfilePatj = mf.getModfileString().replace("/", File.separator).toLowerCase(); final String modfilePatj = mf.getModfileString().replace("/", File.separator).toLowerCase();
Map.Entry<Path, Long> workshopFile = workshopFiles.entrySet() Map.Entry<Path, Long> workshopFile = workshopFiles.entrySet()
.stream().filter(e -> e.getKey().toAbsolutePath().toString().toLowerCase().endsWith(modfilePatj)).findFirst().get(); .stream().filter(e -> e.getKey().toAbsolutePath().toString().toLowerCase().endsWith(modfilePatj)).findFirst().get();
if(workshopFile.getValue() == mf.getSize()) { if(workshopFile.getValue() == mf.getSize()) {
SwingUtilities.invokeLater(() -> gui.syncStatusLabel.setText(mfModPath + ": Found in Steam-Workshop. Copy."));
Files.copy(workshopFile.getKey(), mfPath, StandardCopyOption.REPLACE_EXISTING); Files.copy(workshopFile.getKey(), mfPath, StandardCopyOption.REPLACE_EXISTING);
Logger.getLogger(getClass().getName()).log(Level.INFO, "Found workshop file and copied: " + mfPath); SwingUtilities.invokeLater(() -> gui.syncStatusLabel.setText(mfModPath + ": Copied"));
success++; success++;
finnishCurrent(); finnishCurrent();
continue; continue;