Correct root working directory for Windows, Linux and macOS

This commit is contained in:
fgnm
2020-08-23 21:29:05 +02:00
parent 147cb12226
commit 3596ea2ca5
7 changed files with 14 additions and 4 deletions
Binary file not shown.
@@ -11,6 +11,7 @@ public class SkinComposerSettings extends SettingsNodeValue<SkinComposerVO> {
private final VisCheckBox alwaysCheckUpdates;
private final H2DPluginAdapter plugin;
private boolean loaded = false;
public SkinComposerSettings(Facade facade, H2DPluginAdapter plugin) {
super("Skin Composer", facade);
@@ -25,6 +26,7 @@ public class SkinComposerSettings extends SettingsNodeValue<SkinComposerVO> {
@Override
public void translateSettingsToView() {
loaded = true;
alwaysCheckUpdates.setChecked(getSettings().alwaysCheckUpdates);
}
@@ -37,6 +39,6 @@ public class SkinComposerSettings extends SettingsNodeValue<SkinComposerVO> {
@Override
public boolean validateSettings() {
return getSettings().alwaysCheckUpdates != alwaysCheckUpdates.isChecked();
return loaded && getSettings().alwaysCheckUpdates != alwaysCheckUpdates.isChecked();
}
}
@@ -9,6 +9,7 @@ import games.rednblack.editor.Main;
import games.rednblack.editor.utils.HyperLap2DUtils;
import games.rednblack.h2d.common.vo.EditorConfigVO;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.SystemUtils;
import java.io.File;
import java.io.IOException;
@@ -44,7 +45,8 @@ public class SettingsManager extends BaseProxy {
FileUtils.forceMkdir(new File(defaultWorkspacePath));
pluginDirs = new File[] {new File(Main.getJarContainingFolder(Main.class) + File.separator + "plugins"),
new File(getRootPath() + File.separator + "plugins")};
new File(getRootPath() + File.separator + "plugins"),
new File(System.getProperty("user.dir") + File.separator + "plugins")};
cacheDir = new File(getRootPath() + File.separator + "cache");
} catch (IOException e) {
e.printStackTrace();
@@ -89,8 +91,14 @@ public class SettingsManager extends BaseProxy {
}
public String getRootPath() {
File root = new File(new File(".").getAbsolutePath()).getParentFile();
return root.getAbsolutePath() + File.separator + ".hyperlap2d";
String appRootDirectory = System.getProperty("user.home");
if (SystemUtils.IS_OS_WINDOWS) {
appRootDirectory = System.getenv("AppData");
} else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
appRootDirectory += "/Library/Application Support";
}
return appRootDirectory + File.separator + ".hyperlap2d";
}
public void setLastOpenedPath(String path) {