mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Compare commits
7 Commits
f108341068
...
a6d58690f9
Author | SHA1 | Date | |
---|---|---|---|
a6d58690f9 | |||
a6de537e4a | |||
33b0307aa2 | |||
121428414c | |||
98f774b2ae | |||
d31576fb0b | |||
c9853049c5 |
@ -52,7 +52,7 @@ PART
|
|||||||
name = ModuleConformalText
|
name = ModuleConformalText
|
||||||
|
|
||||||
text = Text
|
text = Text
|
||||||
font = Calibri SDF
|
fontName = Calibri SDF
|
||||||
fillColor = #000000FF
|
fillColor = #000000FF
|
||||||
outlineColor = #FFFFFFFF
|
outlineColor = #FFFFFFFF
|
||||||
fillEnabled = true
|
fillEnabled = true
|
||||||
@ -62,6 +62,7 @@ PART
|
|||||||
useBaseNormal = true
|
useBaseNormal = true
|
||||||
scaleMode = MINIMUM
|
scaleMode = MINIMUM
|
||||||
|
|
||||||
|
defaultScale = 0.2
|
||||||
defaultDepth = 0.2
|
defaultDepth = 0.2
|
||||||
defaultCutoff = 0.5
|
defaultCutoff = 0.5
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -6,8 +6,8 @@
|
|||||||
{
|
{
|
||||||
"MAJOR":0,
|
"MAJOR":0,
|
||||||
"MINOR":2,
|
"MINOR":2,
|
||||||
"PATCH":3,
|
"PATCH":4,
|
||||||
"BUILD":1
|
"BUILD":0
|
||||||
},
|
},
|
||||||
"KSP_VERSION":
|
"KSP_VERSION":
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Conformal Decals v0.2.3
|
# Conformal Decals v0.2.4
|
||||||
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
|
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
|
||||||
|
|
||||||
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)
|
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)
|
||||||
|
@ -31,7 +31,7 @@ namespace ConformalDecals {
|
|||||||
|
|
||||||
[KSPField] public bool scaleAdjustable = true;
|
[KSPField] public bool scaleAdjustable = true;
|
||||||
[KSPField] public float defaultScale = 1;
|
[KSPField] public float defaultScale = 1;
|
||||||
[KSPField] public Vector2 scaleRange = new Vector2(0, 4);
|
[KSPField] public Vector2 scaleRange = new Vector2(0, 5);
|
||||||
|
|
||||||
[KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT;
|
[KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT;
|
||||||
|
|
||||||
@ -60,19 +60,19 @@ namespace ConformalDecals {
|
|||||||
|
|
||||||
// INTERNAL VALUES
|
// INTERNAL VALUES
|
||||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
[KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
||||||
UI_FloatRange(stepIncrement = 0.05f)]
|
UI_FloatRange()]
|
||||||
public float scale = 1.0f;
|
public float scale = 1.0f;
|
||||||
|
|
||||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
[KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
||||||
UI_FloatRange(stepIncrement = 0.02f)]
|
UI_FloatRange()]
|
||||||
public float depth = 0.2f;
|
public float depth = 0.2f;
|
||||||
|
|
||||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
[KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
||||||
UI_FloatRange(stepIncrement = 0.05f)]
|
UI_FloatRange()]
|
||||||
public float opacity = 1.0f;
|
public float opacity = 1.0f;
|
||||||
|
|
||||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
[KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
||||||
UI_FloatRange(stepIncrement = 0.05f)]
|
UI_FloatRange()]
|
||||||
public float cutoff = 0.5f;
|
public float cutoff = 0.5f;
|
||||||
|
|
||||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
|
[KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
|
||||||
@ -215,7 +215,7 @@ namespace ConformalDecals {
|
|||||||
foreach (var keyword in _decalMaterial.shaderKeywords) {
|
foreach (var keyword in _decalMaterial.shaderKeywords) {
|
||||||
this.Log($"keyword: {keyword}");
|
this.Log($"keyword: {keyword}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HighLogic.LoadedSceneIsEditor) {
|
if (HighLogic.LoadedSceneIsEditor) {
|
||||||
UpdateTweakables();
|
UpdateTweakables();
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ namespace ConformalDecals {
|
|||||||
cutoffField.guiActiveEditor = cutoffAdjustable;
|
cutoffField.guiActiveEditor = cutoffAdjustable;
|
||||||
wearField.guiActiveEditor = useBaseNormal;
|
wearField.guiActiveEditor = useBaseNormal;
|
||||||
|
|
||||||
var steps = 40;
|
var steps = 20;
|
||||||
|
|
||||||
if (scaleAdjustable) {
|
if (scaleAdjustable) {
|
||||||
var minValue = Mathf.Max(Mathf.Epsilon, scaleRange.x);
|
var minValue = Mathf.Max(Mathf.Epsilon, scaleRange.x);
|
||||||
@ -521,7 +521,7 @@ namespace ConformalDecals {
|
|||||||
var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor;
|
var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor;
|
||||||
scaleEditor.minValue = minValue;
|
scaleEditor.minValue = minValue;
|
||||||
scaleEditor.maxValue = maxValue;
|
scaleEditor.maxValue = maxValue;
|
||||||
scaleEditor.stepIncrement = (maxValue - minValue) / steps;
|
scaleEditor.stepIncrement = 0.01f; //1cm
|
||||||
scaleEditor.onFieldChanged = OnSizeTweakEvent;
|
scaleEditor.onFieldChanged = OnSizeTweakEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ namespace ConformalDecals {
|
|||||||
var depthEditor = (UI_FloatRange) depthField.uiControlEditor;
|
var depthEditor = (UI_FloatRange) depthField.uiControlEditor;
|
||||||
depthEditor.minValue = minValue;
|
depthEditor.minValue = minValue;
|
||||||
depthEditor.maxValue = maxValue;
|
depthEditor.maxValue = maxValue;
|
||||||
depthEditor.stepIncrement = (maxValue - minValue) / steps;
|
depthEditor.stepIncrement = 0.01f; //1cm
|
||||||
depthEditor.onFieldChanged = OnSizeTweakEvent;
|
depthEditor.onFieldChanged = OnSizeTweakEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,12 +94,25 @@ namespace ConformalDecals {
|
|||||||
|
|
||||||
public override void OnLoad(ConfigNode node) {
|
public override void OnLoad(ConfigNode node) {
|
||||||
base.OnLoad(node);
|
base.OnLoad(node);
|
||||||
text = WebUtility.UrlDecode(ParseUtil.ParseString(node, "text"));
|
|
||||||
font = DecalConfig.GetFont(ParseUtil.ParseString(node, "font", true, "Calibri SDF"));
|
string textRaw = "";
|
||||||
|
if (ParseUtil.ParseStringIndirect(ref textRaw, node, "text")) {
|
||||||
|
text = WebUtility.UrlDecode(textRaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
string fontName = "";
|
||||||
|
if (ParseUtil.ParseStringIndirect(ref fontName, node, "fontName")) {
|
||||||
|
font = DecalConfig.GetFont(fontName);
|
||||||
|
}
|
||||||
|
else if (font == null) font = DecalConfig.GetFont("Calibri SDF");
|
||||||
|
|
||||||
int styleInt = 0;
|
int styleInt = 0;
|
||||||
if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) style = (FontStyles) styleInt;
|
if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) {
|
||||||
if (!ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor")) fillColor = Color.magenta;
|
style = (FontStyles) styleInt;
|
||||||
if (!ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor")) outlineColor = Color.magenta;
|
}
|
||||||
|
|
||||||
|
ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
|
||||||
|
ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");
|
||||||
|
|
||||||
if (HighLogic.LoadedSceneIsGame) {
|
if (HighLogic.LoadedSceneIsGame) {
|
||||||
// For some reason, rendering doesnt work right on the first frame a scene is loaded
|
// For some reason, rendering doesnt work right on the first frame a scene is loaded
|
||||||
@ -210,12 +223,12 @@ namespace ConformalDecals {
|
|||||||
|
|
||||||
public override void OnDestroy() {
|
public override void OnDestroy() {
|
||||||
if (HighLogic.LoadedSceneIsGame && _currentText != null) TextRenderer.UnregisterText(_currentText);
|
if (HighLogic.LoadedSceneIsGame && _currentText != null) TextRenderer.UnregisterText(_currentText);
|
||||||
|
|
||||||
// close all UIs
|
// close all UIs
|
||||||
if (_textEntryController != null) _textEntryController.Close();
|
if (_textEntryController != null) _textEntryController.Close();
|
||||||
if (_fillColorPickerController != null) _fillColorPickerController.Close();
|
if (_fillColorPickerController != null) _fillColorPickerController.Close();
|
||||||
if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
|
if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
|
||||||
|
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ namespace ConformalDecals.Text {
|
|||||||
/// The text formatted with newlines for vertical text
|
/// The text formatted with newlines for vertical text
|
||||||
public string FormattedText {
|
public string FormattedText {
|
||||||
get {
|
get {
|
||||||
|
if (string.IsNullOrWhiteSpace(Text)) return "•";
|
||||||
if (Vertical) {
|
if (Vertical) {
|
||||||
return Regex.Replace(Text, @"(.)", "$1\n");
|
return Regex.Replace(Text, @"(.)", "$1\n");
|
||||||
}
|
}
|
||||||
|
@ -272,13 +272,14 @@ namespace ConformalDecals.Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL.PopMatrix();
|
|
||||||
|
|
||||||
// COPY TEXTURE BACK INTO RAM
|
// COPY TEXTURE BACK INTO RAM
|
||||||
RenderTexture.active = renderTex;
|
RenderTexture.active = renderTex;
|
||||||
texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, true);
|
texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, true);
|
||||||
texture.Apply();
|
texture.Apply();
|
||||||
|
|
||||||
|
GL.Clear(false, true, Color.black); //KSP doesnt clear render textures before using them so we need to clear afterwards, as well. Thanks Squad.
|
||||||
|
GL.PopMatrix();
|
||||||
|
|
||||||
// RELEASE RENDERTEX
|
// RELEASE RENDERTEX
|
||||||
RenderTexture.ReleaseTemporary(renderTex);
|
RenderTexture.ReleaseTemporary(renderTex);
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ namespace ConformalDecals.UI {
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public delegate void TextUpdateDelegate(string newText, DecalFont newFont, FontStyles style, bool vertical, float linespacing, float charspacing);
|
public delegate void TextUpdateDelegate(string newText, DecalFont newFont, FontStyles style, bool vertical, float linespacing, float charspacing);
|
||||||
|
|
||||||
|
|
||||||
[SerializeField] private Selectable _textBox;
|
[SerializeField] private Selectable _textBox;
|
||||||
[SerializeField] private Button _fontButton;
|
[SerializeField] private Button _fontButton;
|
||||||
|
|
||||||
@ -40,7 +39,10 @@ namespace ConformalDecals.UI {
|
|||||||
|
|
||||||
private FontMenuController _fontMenu;
|
private FontMenuController _fontMenu;
|
||||||
|
|
||||||
private bool _ignoreUpdates;
|
private bool _ignoreUpdates;
|
||||||
|
private bool _isLocked;
|
||||||
|
private string _lockString;
|
||||||
|
private static int _lockCounter;
|
||||||
|
|
||||||
public static TextEntryController Create(
|
public static TextEntryController Create(
|
||||||
string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing,
|
string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing,
|
||||||
@ -70,6 +72,18 @@ namespace ConformalDecals.UI {
|
|||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetControlLock(string value = null) {
|
||||||
|
if (_isLocked) return;
|
||||||
|
InputLockManager.SetControlLock(_lockString);
|
||||||
|
_isLocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveControlLock(string value = null) {
|
||||||
|
if (!_isLocked) return;
|
||||||
|
InputLockManager.RemoveControlLock(_lockString);
|
||||||
|
_isLocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnTextUpdate(string newText) {
|
public void OnTextUpdate(string newText) {
|
||||||
this._text = newText;
|
this._text = newText;
|
||||||
|
|
||||||
@ -195,12 +209,15 @@ namespace ConformalDecals.UI {
|
|||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Start() {
|
private void Start() {
|
||||||
|
_lockString = $"ConformalDecals_TextEditor_{_lockCounter++}";
|
||||||
|
|
||||||
_textBoxTMP = ((TMP_InputField) _textBox);
|
_textBoxTMP = ((TMP_InputField) _textBox);
|
||||||
_textBoxTMP.text = _text;
|
_textBoxTMP.text = _text;
|
||||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
_textBoxTMP.fontAsset = _font.FontAsset;
|
_textBoxTMP.fontAsset = _font.FontAsset;
|
||||||
|
_textBoxTMP.onSelect.AddListener(SetControlLock);
|
||||||
|
_textBoxTMP.onDeselect.AddListener(RemoveControlLock);
|
||||||
|
|
||||||
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||||
|
|
||||||
@ -209,6 +226,10 @@ namespace ConformalDecals.UI {
|
|||||||
UpdateCharSpacing();
|
UpdateCharSpacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy() {
|
||||||
|
RemoveControlLock();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnValueChanged() {
|
private void OnValueChanged() {
|
||||||
_onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing);
|
_onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
v0.2.4
|
||||||
|
------
|
||||||
|
- Fixes:
|
||||||
|
- Fixed red text appearing on planets due to KSP bug by clearing render textures afterwards.
|
||||||
|
- Fixed fonts not saving correctly.
|
||||||
|
- Changes:
|
||||||
|
- Lowered step size for decal size and depth to 1cm.
|
||||||
|
- Changed default max size to 5m.
|
||||||
|
- Changed default text decal size to 0.2m
|
||||||
|
- Text decals now show as a circle if they contain only whitespace.
|
||||||
|
|
||||||
v0.2.3
|
v0.2.3
|
||||||
------
|
------
|
||||||
- Fixes:
|
- Fixes:
|
||||||
|
Loading…
Reference in New Issue
Block a user