mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-28 04:46:31 -08:00
Properly save SkeletonConfig values
This commit is contained in:
3 files changed
+39
-22
No files matched your search
@@ -127,24 +127,34 @@ public class SkeletonConfigGUI extends EJBagNoStretch {
|
||||
}
|
||||
|
||||
private void change(SkeletonConfigValue joint, float diff) {
|
||||
// Update config value
|
||||
float current = server.humanPoseProcessor.getSkeletonConfig(joint);
|
||||
server.humanPoseProcessor.setSkeletonConfig(joint, current + diff);
|
||||
server.humanPoseProcessor.getSkeletonConfig().saveToConfig(server.config);
|
||||
server.saveConfig();
|
||||
|
||||
// Update GUI
|
||||
labels.get(joint).setText(StringUtils.prettyNumber((current + diff) * 100, 0));
|
||||
}
|
||||
|
||||
private void reset(SkeletonConfigValue joint) {
|
||||
// Update config value
|
||||
server.humanPoseProcessor.resetSkeletonConfig(joint);
|
||||
server.humanPoseProcessor.getSkeletonConfig().saveToConfig(server.config);
|
||||
server.saveConfig();
|
||||
|
||||
// Update GUI
|
||||
float current = server.humanPoseProcessor.getSkeletonConfig(joint);
|
||||
labels.get(joint).setText(StringUtils.prettyNumber((current) * 100, 0));
|
||||
}
|
||||
|
||||
private void resetAll() {
|
||||
// Update config value
|
||||
server.humanPoseProcessor.resetAllSkeletonConfigs();
|
||||
server.humanPoseProcessor.getSkeletonConfig().saveToConfig(server.config);
|
||||
server.saveConfig();
|
||||
|
||||
// Update GUI
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,29 +64,29 @@ public class SkeletonConfig {
|
||||
}
|
||||
|
||||
private void callCallbackOnAll(boolean defaultOnly) {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (SkeletonConfigValue config : SkeletonConfigValue.values) {
|
||||
if (callback != null) {
|
||||
try {
|
||||
Float val = configs.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateConfigState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.log.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
try {
|
||||
Float val = configs.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateConfigState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.log.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
|
||||
for (SkeletonConfigToggle config : SkeletonConfigToggle.values) {
|
||||
if (callback != null) {
|
||||
try {
|
||||
Boolean val = toggles.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateToggleState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.log.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
try {
|
||||
Boolean val = toggles.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateToggleState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.log.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,13 +334,14 @@ public class SkeletonConfig {
|
||||
}
|
||||
|
||||
public void saveToConfig(YamlFile config) {
|
||||
configs.forEach((key, value) -> {
|
||||
config.setProperty(key.configKey, value);
|
||||
});
|
||||
// Write all possible values, this keeps configs consistent even if defaults were changed
|
||||
for (SkeletonConfigValue value : SkeletonConfigValue.values) {
|
||||
config.setProperty(value.configKey, getConfig(value));
|
||||
}
|
||||
|
||||
toggles.forEach((key, value) -> {
|
||||
config.setProperty(key.configKey, value);
|
||||
});
|
||||
for (SkeletonConfigToggle value : SkeletonConfigToggle.values) {
|
||||
config.setProperty(value.configKey, getToggle(value));
|
||||
}
|
||||
}
|
||||
|
||||
public void resetConfigs() {
|
||||
|
||||
Reference in new issue
Block a user