private static Styles getStyle(UIStyle style, UIStyleState state)
        {
            Styles s = new Styles();

            if (style != null)
            {
                s.Font  = style.font;
                s.Style = style.fontStyle;
                s.Size  = style.fontSize;
            }

            if (state != null)
            {
                s.Color = state.textColor;
            }

            return(s);
        }
Beispiel #2
0
        /// <summary>
        ///     Gets a new ThemeTextStyle created from KSP UIStyle and UIStyleState objects.
        /// </summary>
        private static TextStyle GetTextStyle(UIStyle style, UIStyleState styleState)
        {
            TextStyle textStyle = new TextStyle();

            if (style != null)
            {
                textStyle.Font  = style.font;
                textStyle.Style = style.fontStyle;
                textStyle.Size  = style.fontSize;
            }

            if (styleState != null)
            {
                textStyle.Colour = styleState.textColor;
            }

            return(textStyle);
        }
        /// <summary>
        /// Convert GUI style state to UI style state
        /// </summary>
        /// <param name="guiStyleState"></param>
        /// <returns></returns>
        private static UIStyleState ConvertStyleState(GUIStyleState guiStyleState)
        {
            UIStyleState state = new UIStyleState();

            if (guiStyleState != null)
            {
                if (guiStyleState.background != null)
                {
                    state.background = Sprite.Create(guiStyleState.background,
                                                     new Rect(0, 0, guiStyleState.background.width, guiStyleState.background.height),
                                                     new Vector2(0.5f, 0.5f), 100, 1, SpriteMeshType.Tight, Vector4.one * 5);
                }

                state.textColor = guiStyleState.textColor;
            }

            return(state);
        }
Beispiel #4
0
        private static UIStyleState ConvertStyleState(GUIStyleState guiStyleState, RectOffset border)
        {
            UIStyleState state = new UIStyleState();

            if (guiStyleState != null)
            {
                if (guiStyleState.background != null)
                {
                    state.background = Sprite.Create(guiStyleState.background,
                                                     new Rect(0, 0, guiStyleState.background.width, guiStyleState.background.height),
                                                     new Vector2(0.5f, 0.5f), 100, 1, SpriteMeshType.Tight,
                                                     new Vector4(border.left, border.bottom, border.right, border.top));
                }

                state.textColor = guiStyleState.textColor;
            }

            return(state);
        }
Beispiel #5
0
        private static UIStyleState ConvertStyleState(GUIStyleState guiStyleState)
        {
            UIStyleState state = new UIStyleState();

            if (guiStyleState != null)
            {
                if (guiStyleState.background != null)
                {
                    state.background = Sprite.Create(guiStyleState.background,
                                                     new Rect(0, 0, guiStyleState.background.width, guiStyleState.background.height),
                                                     new Vector2(0.5f, 0.5f), 100, 1, SpriteMeshType.Tight, Vector4.one * 5);

                    // That border value was just a wild guess, but it works out quite nice so far.
                    // I could calculate the border automatically, but that looks messed up with DialogGUI,
                    // especially for window titles.
                }

                state.textColor = guiStyleState.textColor;
            }

            return(state);
        }
        /// <summary>
        ///     Gets a new ThemeTextStyle created from KSP UIStyle and UIStyleState objects.
        /// </summary>
        private static TextStyle GetTextStyle(UIStyle style, UIStyleState styleState)
        {
            TextStyle textStyle = new TextStyle();

            if (style != null)
            {
                textStyle.Font = style.font;
                textStyle.Style = style.fontStyle;
                textStyle.Size = style.fontSize;
            }

            if (styleState != null)
            {
                textStyle.Colour = styleState.textColor;
            }

            return textStyle;
        }
Beispiel #7
0
 private static void ProcessImage(Image image, UIStyleState state)
 {
     image.sprite = state.background;
     image.color  = Color.white;
     image.type   = Image.Type.Sliced;
 }