Allow toggling multiprojection in editor

feature-saving
Andrew Cassidy 4 years ago
parent 596675ad8d
commit df95601416

@ -15,7 +15,7 @@ Localization
#LOC_ConformalDecals_gui-opacity = Opacity
#LOC_ConformalDecals_gui-cutoff = Cutoff
#LOC_ConformalDecals_gui-wear = Edge Wear
#LOC_ConformalDecals_gui-aspectratio = Aspect Ratio
#LOC_ConformalDecals_gui-multiproject = Project onto Multiple
#LOC_ConformalDecals_gui-select-flag = Select Flag
#LOC_ConformalDecals_gui-reset-flag = Reset Flag
#LOC_ConformalDecals_gui-set-text = Set Text

@ -79,7 +79,9 @@ namespace ConformalDecals {
UI_FloatRange()]
public float wear = 100;
[KSPField(isPersistant = true)] public bool projectMultiple = true;
[KSPField(guiName = "#LOC_ConformalDecals_gui-multiproject", guiActive = false, guiActiveEditor = true, isPersistant = true),
UI_Toggle()]
public bool projectMultiple = true;
[KSPField] public MaterialPropertyCollection materialProperties;
@ -301,7 +303,7 @@ namespace ConformalDecals {
Destroy(materialProperties);
}
protected void OnSizeTweakEvent(BaseField field, object obj) {
protected void OnProjectionTweakEvent(BaseField field, object obj) {
// scale or depth values have been changed, so update scale
// and update projection matrices if attached
UpdateProjection();
@ -521,6 +523,7 @@ namespace ConformalDecals {
var opacityField = Fields[nameof(opacity)];
var cutoffField = Fields[nameof(cutoff)];
var wearField = Fields[nameof(wear)];
var multiprojectField = Fields[nameof(projectMultiple)];
scaleField.guiActiveEditor = scaleAdjustable;
depthField.guiActiveEditor = depthAdjustable;
@ -538,7 +541,7 @@ namespace ConformalDecals {
scaleEditor.minValue = minValue;
scaleEditor.maxValue = maxValue;
scaleEditor.stepIncrement = (maxValue - minValue) / steps;
scaleEditor.onFieldChanged = OnSizeTweakEvent;
scaleEditor.onFieldChanged = OnProjectionTweakEvent;
}
if (depthAdjustable) {
@ -549,7 +552,7 @@ namespace ConformalDecals {
depthEditor.minValue = minValue;
depthEditor.maxValue = maxValue;
depthEditor.stepIncrement = (maxValue - minValue) / steps;
depthEditor.onFieldChanged = OnSizeTweakEvent;
depthEditor.onFieldChanged = OnProjectionTweakEvent;
}
if (opacityAdjustable) {
@ -586,6 +589,9 @@ namespace ConformalDecals {
wearEditor.stepIncrement = (maxValue - minValue) / steps;
wearEditor.onFieldChanged = OnMaterialTweakEvent;
}
var multiprojectEditor = (UI_Toggle) multiprojectField.uiControlEditor;
multiprojectEditor.onFieldChanged = OnProjectionTweakEvent;
}
public void Render(Camera camera) {

Loading…
Cancel
Save