mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-06-11 05:54:07 +00:00
Fix styles updating textbox
This commit is contained in:
parent
1347457ad6
commit
9b5f87ab22
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:af4bdba4554a86d95eebfc736ff4b5ab1f1cf9af48b4b0680cd368daead9d822
|
oid sha256:b89868137e40e433c04e61d89accc0ba5b809f88b03840ac1790765115c92b73
|
||||||
size 82432
|
size 82432
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace ConformalDecals.UI {
|
||||||
private DecalTextStyle _style;
|
private DecalTextStyle _style;
|
||||||
private Vector2 _lineSpacingRange;
|
private Vector2 _lineSpacingRange;
|
||||||
private Vector2 _charSpacingRange;
|
private Vector2 _charSpacingRange;
|
||||||
|
private TMP_InputField _textBoxTMP;
|
||||||
|
|
||||||
private FontMenuController _fontMenu;
|
private FontMenuController _fontMenu;
|
||||||
|
|
||||||
|
@ -79,9 +80,9 @@ namespace ConformalDecals.UI {
|
||||||
_font = font;
|
_font = font;
|
||||||
font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||||
|
|
||||||
var textBox = ((TMP_InputField) _textBox);
|
_textBoxTMP.text = _text;
|
||||||
textBox.textComponent.fontStyle = _style.FontStyle | _font.FontStyle;
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
textBox.fontAsset = _font.FontAsset;
|
_textBoxTMP.fontAsset = _font.FontAsset;
|
||||||
|
|
||||||
UpdateStyleButtons();
|
UpdateStyleButtons();
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
|
@ -91,11 +92,11 @@ namespace ConformalDecals.UI {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.LineSpacing = Mathf.Lerp(_lineSpacingRange.x, _lineSpacingRange.y, value);
|
_style.LineSpacing = Mathf.Lerp(_lineSpacingRange.x, _lineSpacingRange.y, value);
|
||||||
|
|
||||||
UpdateLineSpacing();
|
UpdateLineSpacing();
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLineSpacingUpdate(string text) {
|
public void OnLineSpacingUpdate(string text) {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ namespace ConformalDecals.UI {
|
||||||
else {
|
else {
|
||||||
Logging.LogWarning("Line spacing value '{text}' could not be parsed.");
|
Logging.LogWarning("Line spacing value '{text}' could not be parsed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLineSpacing();
|
UpdateLineSpacing();
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
@ -114,11 +115,11 @@ namespace ConformalDecals.UI {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.CharSpacing = Mathf.Lerp(_charSpacingRange.x, _charSpacingRange.y, value);
|
_style.CharSpacing = Mathf.Lerp(_charSpacingRange.x, _charSpacingRange.y, value);
|
||||||
|
|
||||||
UpdateCharSpacing();
|
UpdateCharSpacing();
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCharSpacingUpdate(string text) {
|
public void OnCharSpacingUpdate(string text) {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ namespace ConformalDecals.UI {
|
||||||
else {
|
else {
|
||||||
Logging.LogWarning("Char spacing value '{text}' could not be parsed.");
|
Logging.LogWarning("Char spacing value '{text}' could not be parsed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateCharSpacing();
|
UpdateCharSpacing();
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
@ -137,6 +138,7 @@ namespace ConformalDecals.UI {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.Bold = state;
|
_style.Bold = state;
|
||||||
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +146,7 @@ namespace ConformalDecals.UI {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.Italic = state;
|
_style.Italic = state;
|
||||||
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,26 +154,31 @@ namespace ConformalDecals.UI {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.Underline = state;
|
_style.Underline = state;
|
||||||
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSmallCapsUpdate(bool state) {
|
public void OnSmallCapsUpdate(bool state) {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.SmallCaps = state;
|
_style.SmallCaps = state;
|
||||||
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnVerticalUpdate(bool state) {
|
public void OnVerticalUpdate(bool state) {
|
||||||
if (_ignoreUpdates) return;
|
if (_ignoreUpdates) return;
|
||||||
|
|
||||||
_style.Vertical = state;
|
_style.Vertical = state;
|
||||||
OnValueChanged();
|
OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Start() {
|
private void Start() {
|
||||||
((TMP_InputField) _textBox).text = _text;
|
_textBoxTMP = ((TMP_InputField) _textBox);
|
||||||
|
_textBoxTMP.text = _text;
|
||||||
|
_textBoxTMP.textComponent.fontStyle = _style.FontStyle | _font.FontStyle & ~_font.FontStyleMask;
|
||||||
|
_textBoxTMP.fontAsset = _font.FontAsset;
|
||||||
|
|
||||||
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||||
|
|
||||||
|
@ -245,19 +253,19 @@ namespace ConformalDecals.UI {
|
||||||
|
|
||||||
private void UpdateLineSpacing() {
|
private void UpdateLineSpacing() {
|
||||||
_ignoreUpdates = true;
|
_ignoreUpdates = true;
|
||||||
|
|
||||||
_lineSpacingSlider.value = Mathf.InverseLerp(_lineSpacingRange.x, _lineSpacingRange.y, _style.LineSpacing);
|
_lineSpacingSlider.value = Mathf.InverseLerp(_lineSpacingRange.x, _lineSpacingRange.y, _style.LineSpacing);
|
||||||
((TMP_InputField) _lineSpacingTextBox).text = $"{_style.LineSpacing:F1}";
|
((TMP_InputField) _lineSpacingTextBox).text = $"{_style.LineSpacing:F1}";
|
||||||
|
|
||||||
_ignoreUpdates = false;
|
_ignoreUpdates = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCharSpacing() {
|
private void UpdateCharSpacing() {
|
||||||
_ignoreUpdates = true;
|
_ignoreUpdates = true;
|
||||||
|
|
||||||
_charSpacingSlider.value = Mathf.InverseLerp(_charSpacingRange.x, _charSpacingRange.y, _style.CharSpacing);
|
_charSpacingSlider.value = Mathf.InverseLerp(_charSpacingRange.x, _charSpacingRange.y, _style.CharSpacing);
|
||||||
((TMP_InputField) _charSpacingTextBox).text = $"{_style.CharSpacing:F1}";
|
((TMP_InputField) _charSpacingTextBox).text = $"{_style.CharSpacing:F1}";
|
||||||
|
|
||||||
_ignoreUpdates = false;
|
_ignoreUpdates = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user