Beispiel #1
0
 public UILabelParamProps()
 {
     Margins       = new Vector2(8, 4);
     TextColor     = new Color32(186, 186, 186, 255);
     TextAlignment = UIHorizontalAlignment.Center;
     TextScale     = 0.85f;
 }
Beispiel #2
0
        private static void DrawTextBri(ushort refID, int boardIdx, int secIdx, Matrix4x4 propMatrix, BoardTextDescriptorGeneralXml textDescriptor,
                                        MaterialPropertyBlock materialPropertyBlock, BasicRenderInformation renderInfo, Color colorToSet, Vector3 targetPos, Vector3 targetRotation,
                                        Vector3 baseScale, bool placeClone180Y, UIHorizontalAlignment targetTextAlignment, float maxWidth, int instanceFlags, Color parentColor,
                                        PrefabInfo srcInfo, ref int defaultCallsCounter, Camera targetCamera = null)
        {
            var textMatrixes = CalculateTextMatrix(targetPos, targetRotation, baseScale, targetTextAlignment, maxWidth, textDescriptor, renderInfo, placeClone180Y);

            foreach (var textMatrixTuple in textMatrixes)
            {
                Matrix4x4 matrix = propMatrix * textMatrixTuple.First;

                materialPropertyBlock.Clear();

                Material    targetMaterial = renderInfo.m_generatedMaterial;
                PropManager instance       = CalculateIllumination(refID, boardIdx, secIdx, textDescriptor, materialPropertyBlock, ref colorToSet, instanceFlags);


                defaultCallsCounter++;
                Graphics.DrawMesh(renderInfo.m_mesh, matrix, targetMaterial, 10, targetCamera, 0, materialPropertyBlock, false);

                if (((Vector2)textDescriptor.BackgroundMeshSettings.Size).sqrMagnitude != 0)
                {
                    BasicRenderInformation bgBri = WriteTheSignsMod.Controller.AtlasesLibrary.GetFromLocalAtlases(null, KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon));
                    if (bgBri != null)
                    {
                        Matrix4x4 containerMatrix = DrawBgMesh(ref propMatrix, textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, targetTextAlignment, targetCamera, textMatrixTuple, instance, bgBri, ref defaultCallsCounter);
                        if (textDescriptor.BackgroundMeshSettings.UseFrame)
                        {
                            DrawTextFrame(textDescriptor, materialPropertyBlock, ref targetPos, ref targetRotation, ref baseScale, ref parentColor, srcInfo, targetCamera, ref containerMatrix, ref defaultCallsCounter);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private CustomUILabel AddLabel(UIHorizontalAlignment alignment)
        {
            var label = AddUIComponent <CustomUILabel>();

            label.font              = Font;
            label.autoSize          = true;
            label.textScale         = 0.65f;
            label.padding           = new RectOffset(alignment == UIHorizontalAlignment.Left ? 2 : 0, alignment == UIHorizontalAlignment.Right ? 2 : 0, 1, 2);
            label.textColor         = TextColor;
            label.textAlignment     = alignment;
            label.verticalAlignment = UIVerticalAlignment.Bottom;
            label.eventTextChanged += LabelTextChanged;
            return(label);
        }
Beispiel #4
0
        private UILabel AddData(UIPanel parent, UIPanel other, string text, UIHorizontalAlignment alignment)
        {
            var label = parent.AddUIComponent <UILabel>();

            label.autoSize          = false;
            label.autoHeight        = false;
            label.textScale         = 0.65f;
            label.height            = 0;
            label.eventTextChanged += (UIComponent component, string value) => SetSize(parent, other);
            label.padding           = new RectOffset(alignment == UIHorizontalAlignment.Left ? 2 : 0, alignment == UIHorizontalAlignment.Right ? 2 : 0, 1, 2);
            label.text              = text;
            label.textColor         = TextColor;
            label.textAlignment     = alignment;
            label.verticalAlignment = UIVerticalAlignment.Bottom;
            return(label);
        }
        public static UILabel AlignedTo(this UILabel label, UIHorizontalAlignment alignment)
        {
            label.textAlignment = alignment;

            return(label);
        }
Beispiel #6
0
 private void OnSetTextAlignmentHorizontal(UIHorizontalAlignment sel) => SafeObtain((ref BoardTextDescriptorGeneralXml desc) => desc.m_textAlign = sel);
Beispiel #7
0
        private static Matrix4x4 DrawBgMesh(ref Matrix4x4 propMatrix, BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock, ref Vector3 targetPos,
                                            ref Vector3 targetRotation, ref Vector3 baseScale, UIHorizontalAlignment targetTextAlignment, Camera targetCamera, Tuple <Matrix4x4, Tuple <Matrix4x4, Matrix4x4, Matrix4x4, Matrix4x4> > textMatrixTuple,
                                            PropManager instance, BasicRenderInformation bgBri, ref int defaultCallsCounter)
        {
            materialPropertyBlock.SetColor(WTSDynamicTextRenderingRules.SHADER_PROP_COLOR, textDescriptor.BackgroundMeshSettings.BackgroundColor * new Color(1, 1, 1, 0));
            materialPropertyBlock.SetVector(instance.ID_ObjectIndex, new Vector4());
            var bgBriMatrix = ApplyTextAdjustments(targetPos, targetRotation, bgBri, baseScale, textDescriptor.BackgroundMeshSettings.Size.Y, targetTextAlignment, textDescriptor.BackgroundMeshSettings.Size.X, false, false, false);

            var lineAdjustmentVector = new Vector3(0, (-textDescriptor.BackgroundMeshSettings.Size.Y / 2) + (32 * SCALING_FACTOR * textDescriptor.m_textScale) - (bgBri.m_YAxisOverflows.min + bgBri.m_YAxisOverflows.max) * SCALING_FACTOR * textDescriptor.m_textScale / 2, -0.001f);
            var containerMatrix      = propMatrix
                                       * Matrix4x4.Translate(targetPos)
                                       * textMatrixTuple.Second.Second
                                       * Matrix4x4.Translate(lineAdjustmentVector)
                                       * textMatrixTuple.Second.Fourth
            ;
            var bgMatrix = propMatrix
                           * Matrix4x4.Translate(targetPos)
                           * textMatrixTuple.Second.Second
                           * Matrix4x4.Translate(lineAdjustmentVector)
                           * Matrix4x4.Scale(new Vector3(textDescriptor.BackgroundMeshSettings.Size.X / bgBri.m_mesh.bounds.size.x, textDescriptor.BackgroundMeshSettings.Size.Y / bgBri.m_mesh.bounds.size.y, 1))
                           * textMatrixTuple.Second.Fourth;

            defaultCallsCounter++;
            Graphics.DrawMesh(bgBri.m_mesh, bgMatrix, bgBri.m_generatedMaterial, 10, targetCamera, 0, materialPropertyBlock, false);
            return(containerMatrix);
        }
        /// <summary>
        /// Adds a UI text label to the current panel.
        /// </summary>
        /// <param name="text">Label text</param>
        /// <param name="yPos">Relative Y position</param>
        /// <param name="scale">Text scale (default 0.8f)</param>
        /// <returns></returns>
        protected UILabel AddLabel(string text, float xPos, float yPos, float scale = 0.8f, UIHorizontalAlignment hAlign = UIHorizontalAlignment.Center)
        {
            UILabel newLabel = AddUIComponent <UILabel>();

            newLabel.autoSize         = false;
            newLabel.textAlignment    = hAlign;
            newLabel.size             = new Vector2(this.width - xPos, scale * 30f);
            newLabel.textScale        = scale;
            newLabel.text             = text;
            newLabel.relativePosition = new Vector3(xPos, yPos);

            return(newLabel);
        }
        public static UILabel CreateLabelWhite(UIComponent parent, string text, float textScale, UIHorizontalAlignment textAlignment, RectOffset padding, Vector2 size, Vector3 relativePosition)
        {
            UILabel _label = parent.AddUIComponent <UILabel>();

            _label.autoHeight = false;
            _label.autoSize   = false;

            _label.textScale         = textScale;
            _label.textAlignment     = textAlignment;
            _label.verticalAlignment = UIVerticalAlignment.Bottom;
            _label.textColor         = new Color32(255, 255, 255, 255);
            _label.disabledTextColor = new Color32(128, 128, 128, 255);
            _label.text = text;

            _label.size             = size;
            _label.padding          = padding;
            _label.relativePosition = relativePosition;

            return(_label);
        }
        /// <param name="atlas">Leave null to keep default atlas.</param>
        public static void ModifyToCustomButton(ref UIButton button, string text, float textScale, UIHorizontalAlignment textHorizontalAlignment, UIVerticalAlignment textVerticalAlignment, RectOffset textPadding, Vector2 size, Vector3 relativePosition, string spriteBgPrefix, string spriteFgPrefix, UITextureAtlas atlas)
        {
            if (atlas != null)
            {
                button.atlas = atlas;
            }

            button.normalBgSprite   = spriteBgPrefix + "";
            button.focusedBgSprite  = spriteBgPrefix + "Focused";
            button.hoveredBgSprite  = spriteBgPrefix + "Hovered";
            button.pressedBgSprite  = spriteBgPrefix + "Pressed";
            button.disabledBgSprite = spriteBgPrefix + "Disabled";

            button.normalFgSprite   = spriteFgPrefix + "";
            button.focusedFgSprite  = spriteFgPrefix + "Focused";
            button.hoveredFgSprite  = spriteFgPrefix + "Hovered";
            button.pressedFgSprite  = spriteFgPrefix + "Pressed";
            button.disabledFgSprite = spriteFgPrefix + "Disabled";

            button.text                    = text;
            button.textScale               = textScale;
            button.textPadding             = textPadding;
            button.textHorizontalAlignment = textHorizontalAlignment;
            button.textVerticalAlignment   = textVerticalAlignment;
            button.textColor               = new Color32(255, 255, 255, 255);
            button.disabledTextColor       = new Color32(255, 255, 255, 128);
            button.wordWrap                = true;

            button.playAudioEvents = true;

            button.size             = size;
            button.relativePosition = relativePosition;
        }
 public static void ModifyToBlueButton(ref UIButton button, string text, float textScale, UIHorizontalAlignment textHorizontalAlignment, UIVerticalAlignment textVerticalAlignment, RectOffset textPadding, Vector2 size, Vector3 relativePosition)
 {
     ModifyToCustomButton(ref button, text, textScale, textHorizontalAlignment, textVerticalAlignment, textPadding, size, relativePosition, "ButtonMenu", "", null);
 }
        public static UIButton CreateBlueButton(UIComponent parent, string text, float textScale, UIHorizontalAlignment textHorizontalAlignment, UIVerticalAlignment textVerticalAlignment, RectOffset textPadding, Vector2 size, Vector3 relativePosition)
        {
            UIButton _button = parent.AddUIComponent <UIButton>();

            _button.normalBgSprite   = "ButtonMenu";
            _button.focusedBgSprite  = "ButtonMenuFocused";
            _button.hoveredBgSprite  = "ButtonMenuHovered";
            _button.pressedBgSprite  = "ButtonMenuPressed";
            _button.disabledBgSprite = "ButtonMenuDisabled";

            _button.text                    = text;
            _button.textScale               = textScale;
            _button.textPadding             = textPadding;
            _button.textHorizontalAlignment = textHorizontalAlignment;
            _button.textVerticalAlignment   = textVerticalAlignment;
            _button.textColor               = new Color32(255, 255, 255, 255);
            _button.disabledTextColor       = new Color32(255, 255, 255, 128);
            _button.wordWrap                = true;

            _button.playAudioEvents = true;

            _button.size             = size;
            _button.relativePosition = relativePosition;

            return(_button);
        }