Improvement: allow multi config file support
This commit is contained in:
@@ -40,6 +40,7 @@ public class Configuration {
|
||||
CPU_GPU, CPU, GPU
|
||||
} // accept job for ...
|
||||
|
||||
private String configFilePath;
|
||||
public File workingDirectory;
|
||||
public File storageDirectory; // for permanent storage (binary archive)
|
||||
public boolean userHasSpecifiedACacheDir;
|
||||
@@ -64,6 +65,7 @@ public class Configuration {
|
||||
private String hostname;
|
||||
|
||||
public Configuration(File cache_dir_, String login_, String password_) {
|
||||
this.configFilePath = null;
|
||||
this.login = login_;
|
||||
this.password = password_;
|
||||
this.proxy = null;
|
||||
@@ -94,6 +96,14 @@ public class Configuration {
|
||||
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
public String getConfigFilePath() {
|
||||
return this.configFilePath;
|
||||
}
|
||||
|
||||
public void setConfigPath(String val) {
|
||||
this.configFilePath = val;
|
||||
}
|
||||
|
||||
public String login() {
|
||||
return this.login;
|
||||
}
|
||||
|
||||
@@ -55,16 +55,22 @@ public class SettingsLoader {
|
||||
private String tileSize;
|
||||
private int priority;
|
||||
|
||||
public SettingsLoader() {
|
||||
public SettingsLoader(String path_) {
|
||||
if (path_ == null) {
|
||||
path = getDefaultFilePath();
|
||||
}
|
||||
|
||||
public SettingsLoader(String path_) {
|
||||
else {
|
||||
path = path_;
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsLoader(String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||
public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||
if (path_ == null) {
|
||||
path = getDefaultFilePath();
|
||||
}
|
||||
else {
|
||||
path = path_;
|
||||
}
|
||||
login = login_;
|
||||
password = password_;
|
||||
proxy = proxy_;
|
||||
|
||||
@@ -291,6 +291,7 @@ public class Worker {
|
||||
System.err.println("Aborting");
|
||||
System.exit(2);
|
||||
}
|
||||
config.setConfigPath(config_file);
|
||||
new SettingsLoader(config_file).merge(config);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class Settings implements Activity {
|
||||
@Override
|
||||
public void show() {
|
||||
Configuration config = parent.getConfiguration();
|
||||
new SettingsLoader().merge(config);
|
||||
new SettingsLoader(config.getConfigFilePath()).merge(config);
|
||||
|
||||
List<GPUDevice> gpus = GPU.listDevices(config);
|
||||
|
||||
@@ -617,14 +617,7 @@ public class Settings implements Activity {
|
||||
}
|
||||
|
||||
if (saveFile.isSelected()) {
|
||||
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
new File(new SettingsLoader().getFilePath()).delete();
|
||||
}
|
||||
catch (SecurityException e3) {
|
||||
}
|
||||
new SettingsLoader(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user