예제 #1
0
        public void OnFontUpdate(DecalFont font)
        {
            if (_ignoreUpdates)
            {
                return;
            }

            _font = font;
            font.SetupSample(_fontButton.GetComponentInChildren <TextMeshProUGUI>());

            _textBoxTMP.text = _text;
            _textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
            _textBoxTMP.fontAsset = _font.FontAsset;

            UpdateStyleButtons();
            _textUpdated = true;
        }
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            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;

            if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style"))
            {
                style = (FontStyles)styleInt;
            }

            ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
            ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");

            if (HighLogic.LoadedSceneIsGame)
            {
                // For some reason, rendering doesnt work right on the first frame a scene is loaded
                // So delay any rendering until the next frame when called in OnLoad
                // This is probably a problem with Unity, not KSP
                StartCoroutine(UpdateTextLate());
            }
            else
            {
                UpdateText();
            }
        }
예제 #3
0
        public static TextEntryController Create(
            string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing,
            Vector2 lineSpacingRange, Vector2 charSpacingRange,
            TextUpdateDelegate textUpdateCallback)
        {
            var window = Instantiate(UILoader.TextEntryPrefab, MainCanvasUtil.MainCanvas.transform, true);

            window.AddComponent <DragPanel>();
            MenuNavigation.SpawnMenuNavigation(window, Navigation.Mode.Automatic, true);

            var controller = window.GetComponent <TextEntryController>();

            controller._text             = text;
            controller._font             = font;
            controller._style            = style;
            controller._vertical         = vertical;
            controller._lineSpacing      = linespacing;
            controller._charSpacing      = charspacing;
            controller._lineSpacingRange = lineSpacingRange;
            controller._charSpacingRange = charSpacingRange;
            controller._onValueChanged   = textUpdateCallback;

            return(controller);
        }
예제 #4
0
 public void OnFontSelected(DecalFont font)
 {
     _currentFont = font ?? throw new ArgumentNullException(nameof(font));
     onFontChanged.Invoke(_currentFont);
 }