2020-07-20 04:12:48 +00:00
|
|
|
using System;
|
2020-06-19 08:01:46 +00:00
|
|
|
using ConformalDecals.Text;
|
2020-07-13 03:27:19 +00:00
|
|
|
using ConformalDecals.UI;
|
2020-06-15 22:39:05 +00:00
|
|
|
using ConformalDecals.Util;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace ConformalDecals {
|
2020-07-20 04:12:48 +00:00
|
|
|
public class ModuleConformalText : ModuleConformalDecal {
|
2020-06-15 22:39:05 +00:00
|
|
|
[KSPField(isPersistant = true)] public string text = "Hello World!";
|
2020-07-20 04:12:48 +00:00
|
|
|
[KSPField(isPersistant = true)] public string font = "Calibri SDF";
|
|
|
|
[KSPField(isPersistant = true)] public int style;
|
|
|
|
[KSPField(isPersistant = true)] public bool vertical;
|
|
|
|
[KSPField(isPersistant = true)] public Color color = Color.black;
|
|
|
|
[KSPField(isPersistant = true)] public Color outlineColor = Color.white;
|
|
|
|
[KSPField(isPersistant = true)] public float outlineWidth;
|
2020-06-15 22:39:05 +00:00
|
|
|
|
2020-07-20 04:12:48 +00:00
|
|
|
private DecalText _text;
|
|
|
|
|
|
|
|
private TextEntryController _textEntryController;
|
2020-07-13 03:27:19 +00:00
|
|
|
|
2020-06-15 22:39:05 +00:00
|
|
|
public override void OnLoad(ConfigNode node) {
|
|
|
|
base.OnLoad(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnStart(StartState state) {
|
|
|
|
base.OnStart(state);
|
|
|
|
|
2020-07-20 04:12:48 +00:00
|
|
|
var decalFont = DecalConfig.GetFont(font);
|
|
|
|
|
|
|
|
_text = new DecalText {
|
|
|
|
text = text,
|
|
|
|
font = decalFont,
|
|
|
|
style = (FontStyles) style,
|
|
|
|
vertical = vertical,
|
|
|
|
color = color,
|
|
|
|
outlineColor = outlineColor,
|
|
|
|
outlineWidth = outlineWidth
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnTextUpdate(DecalText newText) {
|
|
|
|
_text = newText;
|
2020-06-15 22:39:05 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 03:27:19 +00:00
|
|
|
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")]
|
2020-07-20 04:12:48 +00:00
|
|
|
public void SetText() {
|
|
|
|
if (_textEntryController == null) {
|
|
|
|
_textEntryController = TextEntryController.Create(_text, OnTextUpdate);
|
2020-06-15 22:39:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|