mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Apply stash
This commit is contained in:
parent
f20119565f
commit
d714c498fb
BIN
Assets/Textures/Decal-Back.afdesign
Normal file
BIN
Assets/Textures/Decal-Back.afdesign
Normal file
Binary file not shown.
BIN
Assets/Textures/Icons Generic.afdesign
Normal file
BIN
Assets/Textures/Icons Generic.afdesign
Normal file
Binary file not shown.
BIN
Assets/Textures/Munar.afdesign
Normal file
BIN
Assets/Textures/Munar.afdesign
Normal file
Binary file not shown.
BIN
Assets/Textures/Semiotic.afdesign
Normal file
BIN
Assets/Textures/Semiotic.afdesign
Normal file
Binary file not shown.
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ConformalDecals.MaterialProperties;
|
||||
using ConformalDecals.Targets;
|
||||
using ConformalDecals.Util;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
namespace ConformalDecals.Targets {
|
||||
public interface IProjectionTarget {
|
||||
bool Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds);
|
||||
void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera);
|
@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace ConformalDecals {
|
||||
namespace ConformalDecals.Targets {
|
||||
public class ProjectionMeshTarget : IProjectionTarget {
|
||||
public const string NodeName = "MESH_TARGET";
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
namespace ConformalDecals.Targets {
|
||||
public class ProjectionPartTarget : IProjectionTarget {
|
||||
public const string NodeName = "PART_TARGET";
|
||||
|
33
Source/ConformalDecals/Tweakables/TweakableData.cs
Normal file
33
Source/ConformalDecals/Tweakables/TweakableData.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Tweakables {
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public abstract class TweakableData : System.Attribute, ISerializationCallbackReceiver {
|
||||
public string name;
|
||||
|
||||
public bool adjustable = true;
|
||||
public string adjustableKey;
|
||||
|
||||
// public string fieldChangedCallback;
|
||||
public bool useSymmetry = true;
|
||||
|
||||
protected TweakableData(string name) {
|
||||
this.name = name;
|
||||
adjustableKey = name + "Adjustable";
|
||||
}
|
||||
|
||||
public virtual void Load(ConfigNode node) {
|
||||
ParseUtil.ParseBoolIndirect(ref adjustable, node, adjustableKey);
|
||||
}
|
||||
|
||||
public virtual void Apply(BaseField baseField, PartModule module) {
|
||||
baseField.guiActiveEditor = adjustable;
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize() { }
|
||||
|
||||
public void OnAfterDeserialize() { }
|
||||
}
|
||||
}
|
30
Source/ConformalDecals/Tweakables/TweakableDataCollection.cs
Normal file
30
Source/ConformalDecals/Tweakables/TweakableDataCollection.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Tweakables {
|
||||
public class TweakableDataCollection : IEnumerable<TweakableData>, ISerializationCallbackReceiver {
|
||||
public readonly Dictionary<string, TweakableData> tweakables = new Dictionary<string, TweakableData>();
|
||||
|
||||
[SerializeField] private TweakableData[] _serializedTweakables;
|
||||
|
||||
public IEnumerator<TweakableData> GetEnumerator() {
|
||||
return tweakables.Values.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize() {
|
||||
_serializedTweakables = tweakables.Values.ToArray();
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize() {
|
||||
foreach (var tweakable in _serializedTweakables) {
|
||||
tweakables.Add(tweakable.name, tweakable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
Source/ConformalDecals/Tweakables/TweakableSlider.cs
Normal file
56
Source/ConformalDecals/Tweakables/TweakableSlider.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Tweakables {
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class TweakableSlider : TweakableData {
|
||||
// The default value for the slider
|
||||
public float defaultValue;
|
||||
public string defaultValueKey;
|
||||
|
||||
// The range of the slider as a vector of <min, max>
|
||||
public float min = 0;
|
||||
public float max = 1;
|
||||
public string rangeKey;
|
||||
|
||||
// The step size of the slider
|
||||
public float step;
|
||||
public string stepKey;
|
||||
|
||||
public TweakableSlider(string name) : base(name) {
|
||||
defaultValueKey = name + "Default";
|
||||
rangeKey = name + "Range";
|
||||
stepKey = name + "Step";
|
||||
}
|
||||
|
||||
public override void Load(ConfigNode node) {
|
||||
base.Load(node);
|
||||
|
||||
var range = new Vector2(min, max);
|
||||
ParseUtil.ParseVector2Indirect(ref range, node, rangeKey);
|
||||
min = Mathf.Max(Mathf.Epsilon, range.x);
|
||||
max = Mathf.Max(min, range.y);
|
||||
|
||||
ParseUtil.ParseFloatIndirect(ref step, node, stepKey);
|
||||
|
||||
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) {
|
||||
ParseUtil.ParseFloatIndirect(ref defaultValue, node, defaultValueKey);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(BaseField baseField, PartModule module) {
|
||||
base.Apply(baseField, module);
|
||||
var uiControlEditor = (UI_FloatRange) baseField.uiControlEditor;
|
||||
|
||||
uiControlEditor.minValue = min;
|
||||
uiControlEditor.maxValue = max;
|
||||
uiControlEditor.stepIncrement = step;
|
||||
|
||||
// Set the default value on first load
|
||||
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) {
|
||||
baseField.FieldInfo.SetValue(module, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
Source/ConformalDecals/Tweakables/TweakableToggle.cs
Normal file
34
Source/ConformalDecals/Tweakables/TweakableToggle.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using ConformalDecals.Util;
|
||||
|
||||
namespace ConformalDecals.Tweakables {
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class TweakableToggle : TweakableData {
|
||||
// The default value for the toggle
|
||||
public bool defaultValue;
|
||||
public string defaultValueKey;
|
||||
|
||||
public TweakableToggle(string name) : base(name) {
|
||||
defaultValueKey = name + "Default";
|
||||
}
|
||||
|
||||
public override void Load(ConfigNode node) {
|
||||
base.Load(node);
|
||||
|
||||
// Set the default value on first load
|
||||
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) {
|
||||
ParseUtil.ParseBoolIndirect(ref defaultValue, node, defaultValueKey);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(BaseField baseField, PartModule module) {
|
||||
base.Apply(baseField, module);
|
||||
|
||||
// Set the default value on first load
|
||||
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) {
|
||||
baseField.FieldInfo.SetValue(module, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Util {
|
||||
@ -32,7 +31,7 @@ namespace ConformalDecals.Util {
|
||||
|
||||
public static string ParseString(ConfigNode node, string valueName, bool isOptional = false, string defaultValue = "") {
|
||||
if (node.HasValue(valueName)) return node.GetValue(valueName);
|
||||
|
||||
|
||||
if (isOptional) {
|
||||
return defaultValue;
|
||||
}
|
||||
@ -121,7 +120,6 @@ namespace ConformalDecals.Util {
|
||||
|
||||
public static bool ParseMatrix4x4Indirect(ref Matrix4x4 value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseUtil.TryParseMatrix4x4);
|
||||
|
||||
}
|
||||
|
||||
public static T ParseValue<T>(ConfigNode node, string valueName, TryParseDelegate<T> tryParse, bool isOptional = false, T defaultValue = default) {
|
||||
|
Loading…
Reference in New Issue
Block a user