mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Allow fonts to disable certain unsupported styles
Also clean up some stuff
This commit is contained in:
@ -45,10 +45,10 @@ namespace ConformalDecals.UI {
|
||||
|
||||
Toggle active = null;
|
||||
|
||||
foreach (var font in fonts.OrderBy(x => x.title)) {
|
||||
Debug.Log(font.title);
|
||||
foreach (var font in fonts.OrderBy(x => x.Title)) {
|
||||
Debug.Log(font.Title);
|
||||
var listItem = GameObject.Instantiate(_menuItem, _menuList.transform);
|
||||
listItem.name = font.title;
|
||||
listItem.name = font.Title;
|
||||
listItem.SetActive(true);
|
||||
|
||||
var fontItem = listItem.AddComponent<FontMenuItem>();
|
||||
|
@ -35,33 +35,19 @@ namespace ConformalDecals.UI {
|
||||
|
||||
var controller = window.GetComponent<TextEntryController>();
|
||||
controller._text = text;
|
||||
controller._font = font;
|
||||
controller._style = style;
|
||||
controller.onValueChanged.AddListener(textUpdateCallback);
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
((TMP_InputField) _textBox).text = _text;
|
||||
|
||||
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||
|
||||
_boldButton.isOn = _style.Bold;
|
||||
_italicButton.isOn = _style.Italic;
|
||||
_underlineButton.isOn = _style.Underline;
|
||||
_smallCapsButton.isOn = _style.SmallCaps;
|
||||
_verticalButton.isOn = _style.Vertical;
|
||||
|
||||
}
|
||||
|
||||
public void OnClose() {
|
||||
if (_fontMenu != null) _fontMenu.OnClose();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void OnValueChanged() {
|
||||
onValueChanged.Invoke(_text, _font, _style);
|
||||
}
|
||||
|
||||
public void OnTextUpdate(string newText) {
|
||||
this._text = newText;
|
||||
|
||||
@ -77,9 +63,10 @@ namespace ConformalDecals.UI {
|
||||
font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||
|
||||
var textBox = ((TMP_InputField) _textBox);
|
||||
textBox.textComponent.fontStyle = _style.FontStyle | _font.fontStyle;
|
||||
textBox.fontAsset = _font.fontAsset;
|
||||
textBox.textComponent.fontStyle = _style.FontStyle | _font.FontStyle;
|
||||
textBox.fontAsset = _font.FontAsset;
|
||||
|
||||
UpdateStyleButtons();
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
@ -111,5 +98,30 @@ namespace ConformalDecals.UI {
|
||||
_style.Vertical = state;
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
|
||||
private void Start() {
|
||||
((TMP_InputField) _textBox).text = _text;
|
||||
|
||||
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
|
||||
|
||||
_boldButton.isOn = _style.Bold;
|
||||
_italicButton.isOn = _style.Italic;
|
||||
_underlineButton.isOn = _style.Underline;
|
||||
_smallCapsButton.isOn = _style.SmallCaps;
|
||||
_verticalButton.isOn = _style.Vertical;
|
||||
UpdateStyleButtons();
|
||||
}
|
||||
|
||||
private void OnValueChanged() {
|
||||
onValueChanged.Invoke(_text, _font, _style);
|
||||
}
|
||||
|
||||
private void UpdateStyleButtons() {
|
||||
_boldButton.interactable = !_font.Bold && !_font.BoldMask;
|
||||
_italicButton.interactable = !_font.Italic && !_font.ItalicMask;
|
||||
_underlineButton.interactable = !_font.Underline && !_font.UnderlineMask;
|
||||
_smallCapsButton.interactable = !_font.SmallCaps && !_font.SmallCapsMask;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user