diff --git a/Distribution/GameData/ConformalDecals/Parts/Semiotic/decal-semiotic.cfg b/Distribution/GameData/ConformalDecals/Parts/Semiotic/decal-semiotic.cfg
index c5e5cb8..2447650 100644
--- a/Distribution/GameData/ConformalDecals/Parts/Semiotic/decal-semiotic.cfg
+++ b/Distribution/GameData/ConformalDecals/Parts/Semiotic/decal-semiotic.cfg
@@ -58,9 +58,10 @@ PART
tileSize = 64, 64
tileIndex = 0
- scale = 0.1
- opacity = 0.8
- cutoff = 0
+ defaultScale = 0.1
+ defaultDepth = 0.1
+ defaultOpacity = 0.8
+ defaultCutoff = 0
scaleRange = 0.05, 0.5
cutoffAdjustable = false
diff --git a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll
index a7c987f..47720eb 100644
--- a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll
+++ b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:b32038269ed7187380230e93fd9a806edd50c169ad318117b6bf36bba593681b
+oid sha256:65795d6785bc2a83fd9bf3c37d31aa010b21ac3e05e4522533d3fad2e1b8c8df
size 34304
diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs
index f9fb4e7..38a1b65 100644
--- a/Source/ConformalDecals/ModuleConformalDecal.cs
+++ b/Source/ConformalDecals/ModuleConformalDecal.cs
@@ -8,34 +8,6 @@ namespace ConformalDecals {
public class ModuleConformalDecal : PartModule {
// CONFIGURABLE VALUES
- ///
- /// Decal scale factor, in meters.
- ///
- [KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
- UI_FloatRange(stepIncrement = 0.05f)]
- public float scale = 1.0f;
-
- ///
- /// Projection depth value for the decal projector, in meters.
- ///
- [KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
- UI_FloatRange(stepIncrement = 0.02f)]
- public float depth = 0.2f;
-
- ///
- /// Opacity value for the decal shader.
- ///
- [KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
- UI_FloatRange(stepIncrement = 0.05f)]
- public float opacity = 1.0f;
-
- ///
- /// Alpha cutoff value for the decal shader.
- ///
- [KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
- UI_FloatRange(stepIncrement = 0.05f)]
- public float cutoff = 0.5f;
-
///
/// Shader name. Should be one that supports decal projection.
///
@@ -67,83 +39,67 @@ namespace ConformalDecals {
///
[KSPField] public string decalProjector = string.Empty;
- ///
- /// Should the scale be adjustable in the editor? Default true.
- ///
- [KSPField] public bool scaleAdjustable = true;
+ // Parameters
- ///
- /// Should the depth be adjustable in the editor? Default true.
- ///
- [KSPField] public bool depthAdjustable = true;
+ [KSPField] public bool scaleAdjustable = true;
+ [KSPField] public float defaultScale = 1;
+ [KSPField] public Vector2 scaleRange = new Vector2(0, 4);
- ///
- /// Should the opacity be adjustable in the editor? Default true.
- ///
- [KSPField] public bool opacityAdjustable = true;
+ [KSPField] public bool depthAdjustable = true;
+ [KSPField] public float defaultDepth = 0.1f;
+ [KSPField] public Vector2 depthRange = new Vector2(0, 2);
- ///
- /// Should the alpha cutoff be adjustable in the editor? Default true.
- ///
- [KSPField] public bool cutoffAdjustable = true;
+ [KSPField] public bool opacityAdjustable = true;
+ [KSPField] public float defaultOpacity = 1;
+ [KSPField] public Vector2 opacityRange = new Vector2(0, 1);
- ///
- /// Available scale range in the editor, in meters. Comma seperated min, max
- ///
- [KSPField] public Vector2 scaleRange = new Vector2(0, 4);
+ [KSPField] public bool cutoffAdjustable = true;
+ [KSPField] public float defaultCutoff = 0;
+ [KSPField] public Vector2 cutoffRange = new Vector2(0, 1);
- ///
- /// Available depth range in the editor, in meters. Comma seperated min, max
- ///
- [KSPField] public Vector2 depthRange = new Vector2(0, 2);
+ [KSPField] public Rect tileRect = new Rect(-1, -1, 0, 0);
+ [KSPField] public Vector2 tileSize;
+ [KSPField] public int tileIndex = -1;
///
- /// Available opacity range in the editor. Comma seperated min, max
+ /// Should the back material scale be updated automatically?
///
- [KSPField] public Vector2 opacityRange = new Vector2(0, 1);
+ [KSPField] public bool updateBackScale = true;
///
- /// Available alpha cutoff range in the editor. Comma seperated min, max
+ /// Should the shader use the normal map of the part its projecting onto? Use only with "paint" shaders.
///
- [KSPField] public Vector2 cutoffRange = new Vector2(0, 1);
+ [KSPField] public bool useBaseNormal = true;
- ///
- /// Rectangle mask to use for any autotile textures, in pixels.
- ///
- ///
- /// Overrides and if specified. Comma seperated x, y, width, height
- ///
- [KSPField] public Rect tileRect = new Rect(-1, -1, 0, 0);
+ // INTERNAL VALUES
///
- /// Tile size for texture atlases, in pixels.
+ /// Decal scale factor, in meters.
///
- ///
- /// Overrided by , Comma seperated width, height
- ///
- ///
- [KSPField] public Vector2 tileSize;
+ [KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
+ UI_FloatRange(stepIncrement = 0.05f)]
+ public float scale = 1.0f;
///
- /// Tile index for texture atlases, 0-indexed.
+ /// Projection depth value for the decal projector, in meters.
///
- ///
- /// Overrided by , must be a positive integer. Starts with 0 in the upper left corner.
- ///
- ///
- [KSPField] public int tileIndex = -1;
+ [KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
+ UI_FloatRange(stepIncrement = 0.02f)]
+ public float depth = 0.2f;
///
- /// Should the back material scale be updated automatically?
+ /// Opacity value for the decal shader.
///
- [KSPField] public bool updateBackScale = true;
+ [KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
+ UI_FloatRange(stepIncrement = 0.05f)]
+ public float opacity = 1.0f;
///
- /// Should the shader use the normal map of the part its projecting onto? Use only with "paint" shaders.
+ /// Alpha cutoff value for the decal shader.
///
- [KSPField] public bool useBaseNormal = true;
-
- // INTERNAL VALUES
+ [KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
+ UI_FloatRange(stepIncrement = 0.05f)]
+ public float cutoff = 0.5f;
[KSPField] public MaterialPropertyCollection materialProperties;
@@ -163,7 +119,6 @@ namespace ConformalDecals {
private bool _isAttached;
private Matrix4x4 _orthoMatrix;
- private Bounds _decalBounds;
private Material _decalMaterial;
private Material _previewMaterial;
@@ -297,6 +252,12 @@ namespace ConformalDecals {
if (HighLogic.LoadedSceneIsGame) {
UpdateScale();
}
+ else {
+ scale = defaultScale;
+ depth = defaultDepth;
+ opacity = defaultOpacity;
+ cutoff = defaultCutoff;
+ }
}
///
@@ -500,21 +461,28 @@ namespace ConformalDecals {
opacityField.guiActiveEditor = opacityAdjustable;
cutoffField.guiActiveEditor = cutoffAdjustable;
+ var steps = 20;
+
if (scaleAdjustable) {
var minValue = Mathf.Max(Mathf.Epsilon, scaleRange.x);
var maxValue = Mathf.Max(minValue, scaleRange.y);
- ((UI_FloatRange) scaleField.uiControlEditor).minValue = minValue;
- ((UI_FloatRange) scaleField.uiControlEditor).maxValue = maxValue;
- scaleField.uiControlEditor.onFieldChanged = OnSizeTweakEvent;
+ var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor;
+ scaleEditor.minValue = minValue;
+ scaleEditor.maxValue = maxValue;
+ scaleEditor.stepIncrement = (maxValue - minValue) / steps;
+ scaleEditor.onFieldChanged = OnSizeTweakEvent;
}
if (depthAdjustable) {
var minValue = Mathf.Max(Mathf.Epsilon, depthRange.x);
var maxValue = Mathf.Max(minValue, depthRange.y);
- ((UI_FloatRange) depthField.uiControlEditor).minValue = minValue;
- ((UI_FloatRange) depthField.uiControlEditor).maxValue = maxValue;
- depthField.uiControlEditor.onFieldChanged = OnSizeTweakEvent;
+
+ var depthEditor = (UI_FloatRange) depthField.uiControlEditor;
+ depthEditor.minValue = minValue;
+ depthEditor.maxValue = maxValue;
+ depthEditor.stepIncrement = (maxValue - minValue) / steps;
+ depthEditor.onFieldChanged = OnSizeTweakEvent;
}
if (opacityAdjustable) {
@@ -522,9 +490,11 @@ namespace ConformalDecals {
var maxValue = Mathf.Max(minValue, opacityRange.y);
maxValue = Mathf.Min(1, maxValue);
- ((UI_FloatRange) opacityField.uiControlEditor).minValue = minValue;
- ((UI_FloatRange) opacityField.uiControlEditor).maxValue = maxValue;
- opacityField.uiControlEditor.onFieldChanged = OnMaterialTweakEvent;
+ var opacityEditor = (UI_FloatRange) opacityField.uiControlEditor;
+ opacityEditor.minValue = minValue;
+ opacityEditor.maxValue = maxValue;
+ opacityEditor.stepIncrement = (maxValue - minValue) / steps;
+ opacityEditor.onFieldChanged = OnMaterialTweakEvent;
}
if (cutoffAdjustable) {
@@ -532,9 +502,11 @@ namespace ConformalDecals {
var maxValue = Mathf.Max(minValue, cutoffRange.y);
maxValue = Mathf.Min(1, maxValue);
- ((UI_FloatRange) cutoffField.uiControlEditor).minValue = minValue;
- ((UI_FloatRange) cutoffField.uiControlEditor).maxValue = maxValue;
- cutoffField.uiControlEditor.onFieldChanged = OnMaterialTweakEvent;
+ var cutoffEditor = (UI_FloatRange) cutoffField.uiControlEditor;
+ cutoffEditor.minValue = minValue;
+ cutoffEditor.maxValue = maxValue;
+ cutoffEditor.stepIncrement = (maxValue - minValue) / steps;
+ cutoffEditor.onFieldChanged = OnMaterialTweakEvent;
}
}