Beispiel #1
0
        public ActionResult <CustomRichTextDto> UpdateCustomRichText([FromRoute] int customRichTextTypeID,
                                                                     [FromBody] CustomRichTextDto customRichTextUpdateDto)
        {
            var customRichTextDto = CustomRichText.GetByCustomRichTextTypeID(_dbContext, customRichTextTypeID);

            if (ThrowNotFound(customRichTextDto, "Custom Rich Text", customRichTextTypeID, out var actionResult))
            {
                return(actionResult);
            }

            var updatedCustomRichTextDto = CustomRichText.UpdateCustomRichText(_dbContext, customRichTextTypeID, customRichTextUpdateDto);

            return(Ok(updatedCustomRichTextDto));
        }
Beispiel #2
0
        public ActionResult <CustomRichTextDto> GetCustomRichText([FromRoute] int customRichTextTypeID)
        {
            var customRichTextDto = CustomRichText.GetByCustomRichTextTypeID(_dbContext, customRichTextTypeID);

            return(RequireNotNullThrowNotFound(customRichTextDto, "Custom Rich Text", customRichTextTypeID));
        }
Beispiel #3
0
    /// <summary>
    /// Sets the font material.
    /// </summary>
    void SetFontMaterial()
    {
        if (!dontOverrideMaterials)
        {
            Material customMaterial = null;
            if (_privateProperties.customDetailMaterial != null)
            {
                customMaterial = _privateProperties.customDetailMaterial;
            }
            else if (_privateProperties.fillColorStyle == FILL_COLOR_STYLE.textureGradient && _privateProperties.fillMaterial != null)
            {
                customMaterial = _privateProperties.fillMaterial;
            }

            if (customMaterial != null)
            {
                if (customMaterial.mainTexture != _privateProperties.font.material.mainTexture) //Check if the assigned font texture is OK
                {
                    customMaterial.mainTexture = _privateProperties.font.material.mainTexture;
                }
                if (_privateProperties.enableShadow || _privateProperties.enableOutline)
                {
                    textRenderer.sharedMaterials = new Material[2] {
                        MainFontMaterial, customMaterial
                    }
                }
                ;
                else
                {
                    textRenderer.sharedMaterials = new Material[1] {
                        customMaterial
                    }
                };
            }
            else
            {
                textRenderer.sharedMaterials = new Material[1] {
                    MainFontMaterial
                }
            };
        }
    }

    /// <summary>
    /// 텍스트를 파싱합니다.
    /// _updateTexureInfo 가 true이면 Font.RequestCharactersInTexture도 함께 실행합니다.
    /// Parsing Font Style, Color, Characters.
    /// <b>Bold</b>
    /// <i>Italic</i>
    /// <bi>Bold and Italic</bi>
    /// <color=#FFFFFF>Color</color>
    /// <gradient=#FF0000,#FFFF00>Gradient</gradient>
    /// </summary>
    /// <param name="text"></param>
    /// <param name="_updateTexureInfo"></param>
    /// <returns></returns>
    CustomFontParsing[] ParsingText(string text, Color colorTop, Color colorBottom, FontStyle fontStyle = FontStyle.Normal)
    {
        text = text.Replace(System.Environment.NewLine, "\n");
        if (fontStyle == FontStyle.Normal)
        {
            fontStyle = _privateProperties.fontStyle;
        }

        List <CustomFontParsing> ret = new List <CustomFontParsing>();

        int index  = 0;
        int length = text.Length;

        if (_privateProperties.richText)
        {
            string outText;
            string outValue;
            while (index < length)
            {
                if (CustomRichText.findTextIndex(text, "b", ref index, out outText, out outValue))
                {
                    ret.AddRange(ParsingText(outText, colorTop, colorBottom, FontStyle.Bold));
                }
                else if (CustomRichText.findTextIndex(text, "i", ref index, out outText, out outValue))
                {
                    ret.AddRange(ParsingText(outText, colorTop, colorBottom, FontStyle.Italic));
                }
                else if (CustomRichText.findTextIndex(text, "bi", ref index, out outText, out outValue))
                {
                    ret.AddRange(ParsingText(outText, colorTop, colorBottom, FontStyle.BoldAndItalic));
                }
                // 컬러 체크.
                // check color
                else if (CustomRichText.findTextIndex(text, "color", ref index, out outText, out outValue))
                {
                    Color parsingColor = CustomRichText.ConvertColor(outValue);
                    ret.AddRange(ParsingText(outText, parsingColor, parsingColor, fontStyle));
                }
                // 그라데이션 체크.
                // check gradient
                else if (CustomRichText.findTextIndex(text, "gradient", ref index, out outText, out outValue))
                {
                    string[] split = outValue.Split(",".ToCharArray());
                    if (split.Length > 1)
                    {
                        Color parsingColorTop    = CustomRichText.ConvertColor(split[0]);
                        Color parsingColorBottom = CustomRichText.ConvertColor(split[1]);
                        ret.AddRange(ParsingText(outText, parsingColorTop, parsingColorBottom, fontStyle));
                    }
                }
                else
                {
                    ret.Add(new CustomFontParsing(text[index], colorTop, colorBottom, fontStyle));
                }
                index++;
            }
        }
        else
        {
            while (index < length)
            {
                ret.Add(new CustomFontParsing(text[index], colorTop, colorBottom, fontStyle));
                index++;
            }
        }
        AnalizeText(ret); //Check for special characters

        return(ret.ToArray());
    }

    /// <summary>
    /// 해당 폰트스타일의 텍스쳐를 업데이트 합니다.
    /// update Texture Font Sytle
    /// </summary>
    /// <param name="fontStyle"></param>
    void updateTextureInfo(FontStyle fontStyle)
    {
        List <char> requestList = new List <char>();

        for (int i = 0; i < parsingList.Length; i++)
        {
            CustomFontParsing parsing = parsingList[i];
            if (fontStyle == parsing.Style)
            {
                requestList.Add(parsing.Char);
            }
        }
        if (requestList.Count > 0)
        {
            _privateProperties.font.RequestCharactersInTexture(new string(requestList.ToArray()), _privateProperties.fontSize, fontStyle);
        }
    }

    void PixelPerfect(bool isRefreshMesh)
    {
        if (_privateProperties.usePixelPerfect)
        {
            Vector3 cameraScreenPoints  = getTextCamera().WorldToScreenPoint(new Vector3(0f, 0f, transform.position.z));
            Vector3 cameraScreenPoints2 = getTextCamera().WorldToScreenPoint(new Vector3(0f, _privateProperties.size, transform.position.z));
            float   px       = cameraScreenPoints2.y - cameraScreenPoints.y;
            float   maxScale = Mathf.Max(transform.lossyScale.x, transform.lossyScale.y);
            int     fontSize = Mathf.RoundToInt(px * maxScale);
            if (_privateProperties.fontSize != fontSize)
            {
                _privateProperties.fontSize = fontSize;
                if (isRefreshMesh)
                {
                    RefreshMesh(true);
                }
            }
        }
    }