added auto detect arma path

This commit is contained in:
Niklas 2020-03-30 15:09:39 +02:00
parent bdab51ff18
commit 91c72f06cc
7 changed files with 225 additions and 97 deletions

View File

@ -24,11 +24,12 @@ import de.mc8051.arma3launcher.objects.Server;
import de.mc8051.arma3launcher.repo.DownloadStatus; import de.mc8051.arma3launcher.repo.DownloadStatus;
import de.mc8051.arma3launcher.repo.FileChecker; import de.mc8051.arma3launcher.repo.FileChecker;
import de.mc8051.arma3launcher.repo.RepositoryManger; import de.mc8051.arma3launcher.repo.RepositoryManger;
import de.mc8051.arma3launcher.repo.SyncList;
import de.mc8051.arma3launcher.repo.Syncer;
import de.mc8051.arma3launcher.repo.Updater; import de.mc8051.arma3launcher.repo.Updater;
import de.mc8051.arma3launcher.repo.Version; import de.mc8051.arma3launcher.repo.Version;
import de.mc8051.arma3launcher.repo.sync.SyncList;
import de.mc8051.arma3launcher.repo.sync.Syncer;
import de.mc8051.arma3launcher.steam.SteamTimer; import de.mc8051.arma3launcher.steam.SteamTimer;
import de.mc8051.arma3launcher.utils.ArmaUtils;
import de.mc8051.arma3launcher.utils.Callback; import de.mc8051.arma3launcher.utils.Callback;
import de.mc8051.arma3launcher.utils.Humanize; import de.mc8051.arma3launcher.utils.Humanize;
import de.mc8051.arma3launcher.utils.ImageUtils; import de.mc8051.arma3launcher.utils.ImageUtils;
@ -61,6 +62,8 @@ import java.lang.management.ManagementFactory;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
@ -198,6 +201,21 @@ public class LauncherGUI implements Observer {
fileChecker.addObserver(this); fileChecker.addObserver(this);
syncer.addObserver(this); syncer.addObserver(this);
if (Parameters.ARMA_PATH.toStringParameter().getConfigValue() == null || Parameters.ARMA_PATH.toStringParameter().getConfigValue().isEmpty()) {
final Path installationPath = ArmaUtils.getInstallationPath();
if (installationPath != null) {
Parameters.ARMA_PATH.toStringParameter().save(installationPath.toAbsolutePath().toString());
Parameters.MOD_PATH.toStringParameter().save(Paths.get(
installationPath.toAbsolutePath().toString(), ArmA3Launcher.config.getString("name") + " Mods"
).toAbsolutePath().toString());
techCheck();
} else {
SwingUtilities.invokeLater(() -> {
warnBox(LangUtils.getInstance().getString("arma_path_not_found_msg"), LangUtils.getInstance().getString("arma_path_not_found"));
});
}
}
new Thread(() -> { new Thread(() -> {
RepositoryManger.getInstance().refreshMeta(); RepositoryManger.getInstance().refreshMeta();
try { try {
@ -580,7 +598,7 @@ public class LauncherGUI implements Observer {
} }
public void techCheck() { public void techCheck() {
boolean pathSet = ArmA3Launcher.user_config.get("client").containsKey("armaPath") && ArmA3Launcher.user_config.get("client").containsKey("modPath"); boolean pathSet = Parameters.ARMA_PATH.toStringParameter().getConfigValue() != null && Parameters.ARMA_PATH.toStringParameter().getConfigValue() != null;
if (SteamTimer.arma_running) { if (SteamTimer.arma_running) {
playButton.setEnabled(false); playButton.setEnabled(false);
playPresetButton.setEnabled(false); playPresetButton.setEnabled(false);
@ -639,26 +657,6 @@ public class LauncherGUI implements Observer {
} }
} }
public boolean checkArmaPath(String path) {
if (settingsArmaPathText.getText().isEmpty()) return false;
File dir = new File(settingsArmaPathText.getText());
ArrayList<String> search = new ArrayList<String>(Arrays.asList("arma3.exe", "steam.dll"));
File[] listOfFiles = dir.listFiles();
try {
for (File file : listOfFiles) {
if (search.isEmpty()) return true;
if (file.isFile()) {
search.remove(file.getName().toLowerCase());
}
}
} catch (NullPointerException ex) {
return false;
}
return false;
}
public void initSettings() { public void initSettings() {
settingsBackendText.setText(ArmA3Launcher.config.getString("sync.url")); settingsBackendText.setText(ArmA3Launcher.config.getString("sync.url"));
@ -683,11 +681,11 @@ public class LauncherGUI implements Observer {
((JComboBox<String>) settingsProfileCombo).setModel(new DefaultComboBoxModel<>(readableDirectories)); ((JComboBox<String>) settingsProfileCombo).setModel(new DefaultComboBoxModel<>(readableDirectories));
initFolderChooser(settingsArmaPathText, settingsArmaPathBtn, "armaPath", Parameter.ParameterType.CLIENT, new Callback.JFileSelectCallback() { initFolderChooser(settingsArmaPathText, settingsArmaPathBtn, Parameters.ARMA_PATH.toStringParameter(), new Callback.JFileSelectCallback() {
@Override @Override
public boolean allowSelection(File path) { public boolean allowSelection(File path) {
String sPath = path.getAbsolutePath(); String sPath = path.getAbsolutePath();
if (!checkArmaPath(sPath)) { if (!ArmaUtils.checkArmaPath(path.toPath())) {
SwingUtilities.invokeLater(() -> warnBox(LangUtils.getInstance().getString("not_arma_dir_msg"), LangUtils.getInstance().getString("not_arma_dir"))); SwingUtilities.invokeLater(() -> warnBox(LangUtils.getInstance().getString("not_arma_dir_msg"), LangUtils.getInstance().getString("not_arma_dir")));
return false; return false;
} }
@ -704,7 +702,7 @@ public class LauncherGUI implements Observer {
} }
}); });
initFolderChooser(settingsModsPathText, settingsModsPathBtn, "modPath", Parameter.ParameterType.CLIENT, new Callback.JFileSelectCallback() { initFolderChooser(settingsModsPathText, settingsModsPathBtn, Parameters.MOD_PATH.toStringParameter(), new Callback.JFileSelectCallback() {
@Override @Override
public boolean allowSelection(File path) { public boolean allowSelection(File path) {
String sPath = path.getAbsolutePath(); String sPath = path.getAbsolutePath();
@ -723,39 +721,39 @@ public class LauncherGUI implements Observer {
// -------------------------------- COMBO BOXES -------------------------------- // -------------------------------- COMBO BOXES --------------------------------
initComboBox(settingsLanguageCombo, "language", Parameter.ParameterType.CLIENT, new String[]{"system", "en_US", "de_DE"}); initComboBox(settingsLanguageCombo, Parameters.LANGUAGE.toStringParameter());
initComboBox(settingsBehaviorStartCombo, "behaviourAfterStart", Parameter.ParameterType.CLIENT, new String[]{"nothing", "minimize", "exit"}); initComboBox(settingsBehaviorStartCombo, Parameters.BEHAVIOUR_AFTER_START.toStringParameter());
initComboBox(settingsProfileCombo, "Profile", Parameter.ParameterType.ARMA, directories); initComboBox(settingsProfileCombo, Parameters.PROFILE.toStringParameter(directories));
initComboBox(settingsExThreadsCombo, "ExThreads", Parameter.ParameterType.ARMA, new String[]{"", "3", "7"}); initComboBox(settingsExThreadsCombo, Parameters.EXTRA_THREADS.toStringParameter());
initComboBox(settingsMallocCombo, "Malloc", Parameter.ParameterType.ARMA, new String[]{"", "tbb4malloc_bi", "jemalloc_bi", "system"}); initComboBox(settingsMallocCombo, Parameters.MALLOC.toStringParameter());
// -------------------------------- CHECK BOXES -------------------------------- // -------------------------------- CHECK BOXES --------------------------------
initCheckBox(settingsShowParameterBox, "ShowStartParameter", Parameter.ParameterType.CLIENT); initCheckBox(settingsShowParameterBox, Parameters.SHOW_START_PARAMETER.toBooolParameter());
settingsShowParameterBox.addItemListener(e -> parameterText.setVisible(e.getStateChange() == ItemEvent.SELECTED)); settingsShowParameterBox.addItemListener(e -> parameterText.setVisible(e.getStateChange() == ItemEvent.SELECTED));
initCheckBox(settingsCheckModsBox, "CheckModset", Parameter.ParameterType.CLIENT); initCheckBox(settingsCheckModsBox, Parameters.CHECK_MODSET.toBooolParameter());
initCheckBox(settingsUseWorkshopBox, "UseWorkshop", Parameter.ParameterType.CLIENT); initCheckBox(settingsUseWorkshopBox, Parameters.USE_WORKSHOP.toBooolParameter());
settingsUseWorkshopBox.addItemListener(e -> { settingsUseWorkshopBox.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getStateChange() == ItemEvent.SELECTED) {
SwingUtilities.invokeLater(() -> warnBox(LangUtils.getInstance().getString("warning_workshop"), LangUtils.getInstance().getString("warning"))); SwingUtilities.invokeLater(() -> warnBox(LangUtils.getInstance().getString("warning_workshop"), LangUtils.getInstance().getString("warning")));
} }
}); });
initCheckBox(settingsUseSixtyFourBitBox, "Use64BitClient", Parameter.ParameterType.ARMA); initCheckBox(settingsUseSixtyFourBitBox, Parameters.USE_64_BIT_CLIENT.toBooolParameter());
initCheckBox(settingsNoSplashBox, "NoSplash", Parameter.ParameterType.ARMA); initCheckBox(settingsNoSplashBox, Parameters.NO_SPLASH.toBooolParameter());
initCheckBox(settingsSkipIntroBox, "SkipIntro", Parameter.ParameterType.ARMA); initCheckBox(settingsSkipIntroBox, Parameters.SKIP_INTRO.toBooolParameter());
initCheckBox(settingsNoCBBox, "NoCB", Parameter.ParameterType.ARMA); initCheckBox(settingsNoCBBox, Parameters.NO_CB.toBooolParameter());
initCheckBox(settingsNoLogsBox, "NoLogs", Parameter.ParameterType.ARMA); initCheckBox(settingsNoLogsBox, Parameters.NO_LOGS.toBooolParameter());
initCheckBox(settingsEnableHTBox, "EnableHT", Parameter.ParameterType.ARMA); initCheckBox(settingsEnableHTBox, Parameters.ENABLE_HT.toBooolParameter());
initCheckBox(settingsHugeoagesBox, "Hugepages", Parameter.ParameterType.ARMA); initCheckBox(settingsHugeoagesBox, Parameters.HUGEPAGES.toBooolParameter());
initCheckBox(settingsNoPauseBox, "NoPause", Parameter.ParameterType.ARMA); initCheckBox(settingsNoPauseBox, Parameters.NO_PAUSE.toBooolParameter());
initCheckBox(settingsShowScriptErrorsBox, "ShowScriptErrors", Parameter.ParameterType.ARMA); initCheckBox(settingsShowScriptErrorsBox, Parameters.SHOW_SCRIPT_ERRORS.toBooolParameter());
initCheckBox(settingsFilePatchingBox, "FilePatching", Parameter.ParameterType.ARMA); initCheckBox(settingsFilePatchingBox, Parameters.FILE_PATCHING.toBooolParameter());
initCheckBox(settingsCrashDiagBox, "CrashDiag", Parameter.ParameterType.ARMA); initCheckBox(settingsCrashDiagBox, Parameters.CRASH_DIAG.toBooolParameter());
initCheckBox(settingsWindowBox, "Window", Parameter.ParameterType.ARMA); initCheckBox(settingsWindowBox, Parameters.WINDOW.toBooolParameter());
// -------------------------------- SPINNER -------------------------------- // -------------------------------- SPINNER --------------------------------
@ -763,37 +761,32 @@ public class LauncherGUI implements Observer {
OperatingSystemMXBean mxbean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); OperatingSystemMXBean mxbean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
int memorySize = (int) (mxbean.getTotalPhysicalMemorySize() / 1024); int memorySize = (int) (mxbean.getTotalPhysicalMemorySize() / 1024);
initSpinner(settingsMaxMemSpinner, "MaxMem", Parameter.ParameterType.ARMA, -1, memorySize); initSpinner(settingsMaxMemSpinner, Parameters.MAX_MEM.toStringParameter(), -1, memorySize);
initSpinner(settingsMaxVRamSpinner, "MaxVRAM", Parameter.ParameterType.ARMA, -1, 99999); initSpinner(settingsMaxVRamSpinner, Parameters.MAX_VRAM.toStringParameter(), -1, 99999);
initSpinner(settingsCpuCountSpinner, "CpuCount", Parameter.ParameterType.ARMA, 0, Runtime.getRuntime().availableProcessors()); initSpinner(settingsCpuCountSpinner, Parameters.CPU_COUNT.toStringParameter(), 0, Runtime.getRuntime().availableProcessors());
initSpinner(settingsPosXSpinner, "PosX", Parameter.ParameterType.ARMA, -1, 99999); initSpinner(settingsPosXSpinner, Parameters.POS_X.toStringParameter(), -1, 99999);
initSpinner(settingsPosYSpinner, "PosY", Parameter.ParameterType.ARMA, -1, 99999); initSpinner(settingsPosYSpinner, Parameters.POS_Y.toStringParameter(), -1, 99999);
// -------------------------------- -------------------------------- -------------------------------- // -------------------------------- -------------------------------- --------------------------------
} }
private void initCheckBox(JCheckBox cb, String parameter, Parameter.ParameterType pType) { private void initCheckBox(JCheckBox cb, Parameter<Boolean> paraObj) {
Parameter<Boolean> paraObj = new Parameter<>(parameter, pType, Boolean.class);
cb.setSelected(paraObj.getValue()); cb.setSelected(paraObj.getValue());
cb.addItemListener(new SettingsHandler.CheckBoxListener(paraObj)); cb.addItemListener(new SettingsHandler.CheckBoxListener(paraObj));
} }
private void initComboBox(JComboBox<String> cb, String parameter, Parameter.ParameterType pType, String[] values) { private void initComboBox(JComboBox<String> cb, Parameter<String> paraObj) {
Parameter<String> paraObj = new Parameter<>(parameter, pType, String.class, values);
cb.setSelectedIndex(paraObj.getIndex()); cb.setSelectedIndex(paraObj.getIndex());
if (cb.getItemListeners().length == 1) cb.addItemListener(new SettingsHandler.ComboBoxListener(paraObj)); if (cb.getItemListeners().length == 1) cb.addItemListener(new SettingsHandler.ComboBoxListener(paraObj));
} }
private void initFolderChooser(JTextField showText, JButton actionButton, String parameter, Parameter.ParameterType pType, Callback.JFileSelectCallback check) { private void initFolderChooser(JTextField showText, JButton actionButton, Parameter<String> paraObj, Callback.JFileSelectCallback check) {
Parameter<String> paraObj = new Parameter<>(parameter, pType, String.class);
showText.setText(paraObj.getValue()); showText.setText(paraObj.getValue());
if (actionButton.getActionListeners().length == 0) if (actionButton.getActionListeners().length == 0)
actionButton.addActionListener(new SettingsHandler.Fileistener(mainPanel, paraObj, check)); actionButton.addActionListener(new SettingsHandler.Fileistener(mainPanel, paraObj, check));
} }
public void initSpinner(JSpinner spinner, String parameter, Parameter.ParameterType pType, int min, int max) { public void initSpinner(JSpinner spinner, Parameter<String> paraObj, int min, int max) {
Parameter<String> paraObj = new Parameter<>(parameter, pType, String.class);
SpinnerNumberModel RAMModel = new SpinnerNumberModel(Integer.parseInt(paraObj.getValue()), min, max, 1); SpinnerNumberModel RAMModel = new SpinnerNumberModel(Integer.parseInt(paraObj.getValue()), min, max, 1);
spinner.setModel(RAMModel); spinner.setModel(RAMModel);
JComponent comp = spinner.getEditor(); JComponent comp = spinner.getEditor();

View File

@ -13,47 +13,26 @@ import java.util.logging.Logger;
*/ */
public class Parameter<T> { public class Parameter<T> {
private static Map<String, String> PARAMETERS = new HashMap<String, String>() {{
put("profile", "name");
put("nosplash", "noSplash");
put("skipintro", "skipIntro");
put("world", "world");
put("maxmem", "maxMem");
put("maxvram", "maxVRAM");
put("nocb", "noCB");
put("cpucount", "cpuCount");
put("exthreads", "exThreads");
put("malloc", "malloc");
put("nologs", "noLogs");
put("enableht", "enableHT");
put("hugepages", "hugepages");
put("nopause", "noPause");
put("showscripterrors", "showScriptErrors");
put("filepatching", "filePatching");
put("init", "init");
put("beta", "beta");
put("crashdiag", "crashDiag");
put("window", "window");
put("posx", "posX");
put("posy", "posY");
// use64bitclient -> arma3_x64.exe
}};
private String name; private String name;
private ParameterType pType; private ParameterType pType;
private Class<T> persistentClass; private Class<T> persistentClass;
private String[] values = null; private String[] values = null;
private String startParameter = "";
public Parameter(String name, ParameterType pType, Class<T> persistentClass) { public Parameter(String name, ParameterType pType, Class<T> persistentClass) {
this(name, pType, persistentClass, null); this(name, pType, persistentClass, null, "");
} }
public Parameter(String name, ParameterType pType, Class<T> persistentClass, String[] values) { public Parameter(String name, ParameterType pType, Class<T> persistentClass, String startParameter) {
this(name, pType, persistentClass, null, startParameter);
}
public Parameter(String name, ParameterType pType, Class<T> persistentClass, String[] values, String startParameter) {
this.name = name; this.name = name;
this.pType = pType; this.pType = pType;
this.persistentClass = persistentClass; this.persistentClass = persistentClass;
this.values = values; this.values = values;
this.startParameter = startParameter;
} }
public String getName() { public String getName() {
@ -100,11 +79,11 @@ public class Parameter<T> {
} }
public String getParameter() { public String getParameter() {
if(!PARAMETERS.containsKey(name.toLowerCase())) return null; if(startParameter.isEmpty()) return null;
return PARAMETERS.get(name.toLowerCase()); return startParameter;
} }
public T getValue() { public T getConfigValue() {
// Get User Value else Default else null // Get User Value else Default else null
Ini.Section section = ArmA3Launcher.user_config.get(getUserConfigSectionName()); Ini.Section section = ArmA3Launcher.user_config.get(getUserConfigSectionName());
if (section != null) { if (section != null) {
@ -117,6 +96,12 @@ public class Parameter<T> {
} }
} }
return null;
}
public T getValue() {
final T configValue = getConfigValue();
if(configValue != null) return configValue;
return getDefault(); return getDefault();
} }
@ -137,6 +122,10 @@ public class Parameter<T> {
else return null; else return null;
} }
public String getStartParameter() {
return startParameter;
}
enum ParameterType { enum ParameterType {
ARMA, ARMA,
CLIENT CLIENT

View File

@ -0,0 +1,83 @@
package de.mc8051.arma3launcher;
/**
* Created by gurkengewuerz.de on 30.03.2020.
*/
public enum Parameters {
LANGUAGE("language", Parameter.ParameterType.CLIENT, "", new String[]{"system", "en_US", "de_DE"}),
BEHAVIOUR_AFTER_START("behaviourAfterStart", Parameter.ParameterType.CLIENT, "", new String[]{"nothing", "minimize", "exit"}),
SHOW_START_PARAMETER("ShowStartParameter", Parameter.ParameterType.CLIENT),
CHECK_MODSET("CheckModset", Parameter.ParameterType.CLIENT),
USE_WORKSHOP("UseWorkshop", Parameter.ParameterType.CLIENT),
ARMA_PATH("armaPath", Parameter.ParameterType.CLIENT),
MOD_PATH("modPath", Parameter.ParameterType.CLIENT),
PROFILE("Profile", Parameter.ParameterType.ARMA, "name"),
USE_64_BIT_CLIENT("Use64BitClient", Parameter.ParameterType.ARMA, "Use64BitClient"),
NO_SPLASH("NoSplash", Parameter.ParameterType.ARMA, "noSplash"),
SKIP_INTRO("SkipIntro", Parameter.ParameterType.ARMA, "skipIntro"),
WORLD("World", Parameter.ParameterType.ARMA, "world"),
MAX_MEM("MaxMem", Parameter.ParameterType.ARMA, "maxMem"),
MAX_VRAM("MaxVRAM", Parameter.ParameterType.ARMA, "maxVRAM"),
NO_CB("NoCB", Parameter.ParameterType.ARMA, "noCB"),
CPU_COUNT("CpuCount", Parameter.ParameterType.ARMA, "cpuCount"),
EXTRA_THREADS("ExThreads", Parameter.ParameterType.ARMA, "exThreads", new String[]{"", "3", "7"}),
MALLOC("Malloc", Parameter.ParameterType.ARMA, "malloc", new String[]{"", "tbb4malloc_bi", "jemalloc_bi", "system"}),
NO_LOGS("NoLogs", Parameter.ParameterType.ARMA, "noLogs"),
ENABLE_HT("EnableHT", Parameter.ParameterType.ARMA, "enableHT"),
HUGEPAGES("Hugepages", Parameter.ParameterType.ARMA, "hugepages"),
NO_PAUSE("NoPause", Parameter.ParameterType.ARMA, "noPause"),
SHOW_SCRIPT_ERRORS("ShowScriptErrors", Parameter.ParameterType.ARMA, "showScriptErrors"),
FILE_PATCHING("FilePatching", Parameter.ParameterType.ARMA, "filePatching"),
INIT("Init", Parameter.ParameterType.ARMA, "init"),
BETA("Beta", Parameter.ParameterType.ARMA, "beta"),
CRASH_DIAG("CrashDiag", Parameter.ParameterType.ARMA, "crashDiag"),
WINDOW("Window", Parameter.ParameterType.ARMA, "window"),
POS_X("PosX", Parameter.ParameterType.ARMA, "posX"),
POS_Y("PosY", Parameter.ParameterType.ARMA, "posY");
private String name;
private Parameter.ParameterType type;
private String[] values;
private String startParameter;
Parameters(String name, Parameter.ParameterType type) {
this(name, type, "");
}
Parameters(String name, Parameter.ParameterType type, String startParameter) {
this(name, type, startParameter, null);
}
Parameters(String name, Parameter.ParameterType type, String startParameter, String[] values) {
this.name = name;
this.type = type;
this.startParameter = startParameter;
this. values = values;
}
public Parameter<String> toStringParameter() {
return new Parameter<String>(name, type, String.class, values, startParameter);
}
public Parameter<String> toStringParameter(String... values) {
return new Parameter<String>(name, type, String.class, values, startParameter);
}
public Parameter<Boolean> toBooolParameter() {
return new Parameter<>(name, type, Boolean.class);
}
public String getName() {
return name;
}
public Parameter.ParameterType getType() {
return type;
}
public String getStartParameter() {
return startParameter;
}
}

View File

@ -1,7 +1,6 @@
package de.mc8051.arma3launcher.steam; package de.mc8051.arma3launcher.steam;
import de.mc8051.arma3launcher.LauncherGUI; import de.mc8051.arma3launcher.utils.SteamUtils;
import de.mc8051.arma3launcher.SteamUtils;
import de.mc8051.arma3launcher.interfaces.Observer; import de.mc8051.arma3launcher.interfaces.Observer;
import de.ralleytn.simple.registry.Key; import de.ralleytn.simple.registry.Key;
import de.ralleytn.simple.registry.Registry; import de.ralleytn.simple.registry.Registry;
@ -48,7 +47,10 @@ public class SteamTimer extends TimerTask {
steam_running = true; steam_running = true;
arma_running = SteamUtils.findProcess("arma3.exe") || SteamUtils.findProcess("arma3_x64.exe") || SteamUtils.findProcess("arma3launcher.exe"); arma_running = SteamUtils.findProcess("arma3.exe")
|| SteamUtils.findProcess("arma3_x64.exe")
|| SteamUtils.findProcess("arma3battleye.exe")
|| SteamUtils.findProcess("arma3launcher.exe");
if(old_steamrunning != steam_running || old_arma_running != arma_running) notifyObservers("steamtimer"); if(old_steamrunning != steam_running || old_arma_running != arma_running) notifyObservers("steamtimer");
} catch (IOException e) { } catch (IOException e) {

View File

@ -0,0 +1,57 @@
package de.mc8051.arma3launcher.utils;
import de.ralleytn.simple.registry.Key;
import de.ralleytn.simple.registry.Registry;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Created by gurkengewuerz.de on 30.03.2020.
*/
public class ArmaUtils {
public static Path getInstallationPath() {
Key regKey = null;
try {
regKey = Registry.getKey(Registry.HKEY_LOCAL_MASHINE + "\\SOFTWARE\\bohemia interactive\\arma 3");
} catch (IOException ignored) {
try {
regKey = Registry.getKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\bohemia interactive\\arma 3");
} catch (IOException e) {
Logger.getLogger(ArmaUtils.class.getName()).log(Level.INFO, "Arma patch cant be detected automatically");
}
}
if (regKey == null) return null;
final Path main = Paths.get(regKey.getValueByName("main").getRawValue());
if(!checkArmaPath(main)) return null;
return main;
}
public static boolean checkArmaPath(Path path) {
ArrayList<String> search = new ArrayList<>(Arrays.asList("arma3.exe", "steam.dll"));
final File f = path.toFile();
if (!f.exists() || !f.isDirectory()) return false;
if (f.listFiles() == null) return false;
File[] listOfFiles = f.listFiles();
try {
for (File file : listOfFiles) {
if (search.isEmpty()) return true;
if (file.isFile()) {
search.remove(file.getName().toLowerCase());
}
}
} catch (NullPointerException ex) {
return false;
}
return false;
}
}

View File

@ -112,4 +112,6 @@ clone_preset=Vorlage klonen
new_modset_name=Modsset Name new_modset_name=Modsset Name
modset_exists_msg=Bitte wähle ein anderen Namen für deine Vorlage. modset_exists_msg=Bitte wähle ein anderen Namen für deine Vorlage.
modset_exists=Preset mit diesen Namen existiert bereits modset_exists=Preset mit diesen Namen existiert bereits
update_now=Jetzt updaten! update_now=Jetzt updaten!
arma_path_not_found=ArmA 3 Pfad nicht gefunden
arma_path_not_found_msg=Der Installationsordner von ArmA 3 konnte nicht automatisch erkannt werden. Bitte gehe zuerst in die Einstellungen.

View File

@ -110,4 +110,6 @@ presets_note=Presets can only be used as preset for new user presents. You can c
clone_preset=Clone preset clone_preset=Clone preset
modset_exists_msg=Please choose another name for your preset. modset_exists_msg=Please choose another name for your preset.
modset_exists=Preset with these names already exists modset_exists=Preset with these names already exists
update_now=Update now! update_now=Update now!
arma_path_not_found=ArmA 3 path can't be detected
arma_path_not_found_msg=The installation folder of ArmA 3 could not be detected automatically. Please go to the settings first.