public static TMPro.TextAlignmentOptions ConvertTextAnchor(TextAnchor ta) { TMPro.TextAlignmentOptions t = TMPro.TextAlignmentOptions.Center; switch (ta) { case TextAnchor.MiddleLeft: t = TMPro.TextAlignmentOptions.MidlineLeft; break; case TextAnchor.UpperLeft: t = TMPro.TextAlignmentOptions.TopLeft; break; case TextAnchor.LowerLeft: t = TMPro.TextAlignmentOptions.BottomLeft; break; case TextAnchor.MiddleRight: t = TMPro.TextAlignmentOptions.MidlineRight; break; case TextAnchor.UpperRight: t = TMPro.TextAlignmentOptions.TopRight; break; case TextAnchor.LowerRight: t = TMPro.TextAlignmentOptions.BottomRight; break; case TextAnchor.MiddleCenter: t = TMPro.TextAlignmentOptions.MidlineJustified; break; case TextAnchor.UpperCenter: t = TMPro.TextAlignmentOptions.TopJustified; break; case TextAnchor.LowerCenter: t = TMPro.TextAlignmentOptions.BottomJustified; break; } return(t); }
public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation) { //--[ Localize Font Object ]---------- { TMPro.TMP_FontAsset newFont = cmp.GetSecondaryTranslatedObj<TMPro.TMP_FontAsset>(ref mainTranslation, ref secondaryTranslation); if (newFont != null) { if (mTarget.font != newFont) mTarget.font = newFont; } else { //--[ Localize Font Material ]---------- Material newMat = cmp.GetSecondaryTranslatedObj<Material>(ref mainTranslation, ref secondaryTranslation); if (newMat != null && mTarget.fontMaterial != newMat) { if (!newMat.name.StartsWith(mTarget.font.name, StringComparison.Ordinal)) { newFont = GetTMPFontFromMaterial(cmp, secondaryTranslation.EndsWith(newMat.name, StringComparison.Ordinal) ? secondaryTranslation : newMat.name); if (newFont != null) mTarget.font = newFont; } mTarget.fontSharedMaterial/* fontMaterial*/ = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mAlignmentWasRTL = LocalizationManager.IsRight2Left; InitAlignment_TMPro(mAlignmentWasRTL, mTarget.alignment, out mAlignment_LTR, out mAlignment_RTL); } else { TMPro.TextAlignmentOptions alignRTL, alignLTR; InitAlignment_TMPro(mAlignmentWasRTL, mTarget.alignment, out alignLTR, out alignRTL); if ((mAlignmentWasRTL && mAlignment_RTL != alignRTL) || (!mAlignmentWasRTL && mAlignment_LTR != alignLTR)) { mAlignment_LTR = alignLTR; mAlignment_RTL = alignRTL; } mAlignmentWasRTL = LocalizationManager.IsRight2Left; } if (mainTranslation != null && mTarget.text != mainTranslation) { if (mainTranslation != null && cmp.CorrectAlignmentForRTL) { mTarget.alignment = (LocalizationManager.IsRight2Left ? mAlignment_RTL : mAlignment_LTR); mTarget.isRightToLeftText = LocalizationManager.IsRight2Left; if (LocalizationManager.IsRight2Left) mainTranslation = I2Utils.ReverseText(mainTranslation); } mTarget.text = mainTranslation; } }
public static Tippy SpawnTippy(string text, float textSize, TMPro.TextAlignmentOptions textAlignment, Vector3 size, float lifetime, Transform location, Vector3 offset, float fadeInDuration, float fadeOutDuration, Tippy.MovementMode mode, bool exclusive = false) { if (exclusive && tippies.ContainsKey(text)) { tippies[text].lifetime = lifetime; return(tippies[text]); } GameObject tippyObject = Instantiate(Resources.Load("Prefabs/Tippy", typeof(GameObject))) as GameObject; Tippy tippy = tippyObject.GetComponent <Tippy>(); tippy.dimensions = size; tippy.lifetime = lifetime; tippy.location = location; tippy.offset = offset; tippy.fadeInDuration = fadeInDuration; tippy.fadeOutDuration = fadeOutDuration; tippy.mode = mode; tippy.Start(); tippy.setText(text, textSize, textAlignment); tippy.transform.SetParent(Instance.transform); if (!tippies.ContainsKey(text)) { tippies.Add(text, tippy); } return(tippy); }
public void SetTextAlignment(TMPro.TextAlignmentOptions alignment) { if (text == null) { return; } text.alignment = alignment; }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); TMPro.TextAlignmentOptions o = (TMPro.TextAlignmentOptions)arg0; ToLua.Push(L, o); return(1); }
public void DoLocalize_TMPUGUILabel(string MainTranslation, string SecondaryTranslation) { { //--[ Localize Font Object ]---------- #if TextMeshPro_Pre53 TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation); #else TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation); #endif if (newFont != null) { if (mTarget_TMPUGUILabel.font != newFont) { mTarget_TMPUGUILabel.font = newFont; } } else { //--[ Localize Font Material ]---------- Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation); if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat) { mTarget_TMPUGUILabel.fontMaterial = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mOriginalAlignmentTMPro = mTarget_TMPUGUILabel.alignment; } if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPUGUILabel.text != MainTranslation) { if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL) { if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.TopJustified) { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.TopRight : mOriginalAlignmentTMPro; } else if (mTarget_TMPUGUILabel.alignment <= TMPro.TextAlignmentOptions.Justified) { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.Right : mOriginalAlignmentTMPro; } else { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.BottomRight : mOriginalAlignmentTMPro; } } mTarget_TMPUGUILabel.text = MainTranslation; mTarget_TMPUGUILabel.SetText(MainTranslation, 0); } }
public void CloneFromTextMeshPro(TMPro.TextMeshProUGUI text) { this.font = text.font; this.fontSharedMaterial = text.fontSharedMaterial; this.fontStyle = text.fontStyle; this.color = text.color; this.colorGradient = text.colorGradient; this.fontSize = text.fontSize; this.alignment = text.alignment; this.enableWordWrapping = text.enableWordWrapping; this.overflowMode = text.overflowMode; }
public void SetCurrentSpeaker(string speaker) { if (speaker.ToLower() == "jason") { currentSpeakerName = "Jason"; textAlign = TMPro.TextAlignmentOptions.Left; } else { currentSpeakerName = otherName; textAlign = TMPro.TextAlignmentOptions.Right; } }
internal static void InitAlignment_TMPro(bool isRTL, TMPro.TextAlignmentOptions alignment, out TMPro.TextAlignmentOptions alignLTR, out TMPro.TextAlignmentOptions alignRTL) { alignLTR = alignRTL = alignment; if (isRTL) { switch (alignment) { case TMPro.TextAlignmentOptions.TopRight: alignLTR = TMPro.TextAlignmentOptions.TopLeft; break; case TMPro.TextAlignmentOptions.Right: alignLTR = TMPro.TextAlignmentOptions.Left; break; case TMPro.TextAlignmentOptions.BottomRight: alignLTR = TMPro.TextAlignmentOptions.BottomLeft; break; case TMPro.TextAlignmentOptions.BaselineRight: alignLTR = TMPro.TextAlignmentOptions.BaselineLeft; break; case TMPro.TextAlignmentOptions.MidlineRight: alignLTR = TMPro.TextAlignmentOptions.MidlineLeft; break; case TMPro.TextAlignmentOptions.CaplineRight: alignLTR = TMPro.TextAlignmentOptions.CaplineLeft; break; case TMPro.TextAlignmentOptions.TopLeft: alignLTR = TMPro.TextAlignmentOptions.TopRight; break; case TMPro.TextAlignmentOptions.Left: alignLTR = TMPro.TextAlignmentOptions.Right; break; case TMPro.TextAlignmentOptions.BottomLeft: alignLTR = TMPro.TextAlignmentOptions.BottomRight; break; case TMPro.TextAlignmentOptions.BaselineLeft: alignLTR = TMPro.TextAlignmentOptions.BaselineRight; break; case TMPro.TextAlignmentOptions.MidlineLeft: alignLTR = TMPro.TextAlignmentOptions.MidlineRight; break; case TMPro.TextAlignmentOptions.CaplineLeft: alignLTR = TMPro.TextAlignmentOptions.CaplineRight; break; } } else { switch (alignment) { case TMPro.TextAlignmentOptions.TopRight: alignRTL = TMPro.TextAlignmentOptions.TopLeft; break; case TMPro.TextAlignmentOptions.Right: alignRTL = TMPro.TextAlignmentOptions.Left; break; case TMPro.TextAlignmentOptions.BottomRight: alignRTL = TMPro.TextAlignmentOptions.BottomLeft; break; case TMPro.TextAlignmentOptions.BaselineRight: alignRTL = TMPro.TextAlignmentOptions.BaselineLeft; break; case TMPro.TextAlignmentOptions.MidlineRight: alignRTL = TMPro.TextAlignmentOptions.MidlineLeft; break; case TMPro.TextAlignmentOptions.CaplineRight: alignRTL = TMPro.TextAlignmentOptions.CaplineLeft; break; case TMPro.TextAlignmentOptions.TopLeft: alignRTL = TMPro.TextAlignmentOptions.TopRight; break; case TMPro.TextAlignmentOptions.Left: alignRTL = TMPro.TextAlignmentOptions.Right; break; case TMPro.TextAlignmentOptions.BottomLeft: alignRTL = TMPro.TextAlignmentOptions.BottomRight; break; case TMPro.TextAlignmentOptions.BaselineLeft: alignRTL = TMPro.TextAlignmentOptions.BaselineRight; break; case TMPro.TextAlignmentOptions.MidlineLeft: alignRTL = TMPro.TextAlignmentOptions.MidlineRight; break; case TMPro.TextAlignmentOptions.CaplineLeft: alignRTL = TMPro.TextAlignmentOptions.CaplineRight; break; } } }
private GameObject CreateLabel( int id, string text, string fontName, float fontSize, TMPro.FontStyles fontStyle, TMPro.TextAlignmentOptions alignment, Transform labelTransform, Vector3 labelPositionOffset, Quaternion labelRotationOffset, Vector2 rectPivot, Vector2 rectSize) { string labelName = internalProp.name + "-" + internalProp.propID + "-" + id; GameObject labelGameObject = new GameObject(labelName); labelGameObject.layer = 20; labelGameObject.transform.SetParent(labelTransform); TMPro.TextMeshPro tmpLabel = labelGameObject.AddComponent <TMPro.TextMeshPro>(); tmpLabel.SetText(text); tmpLabel.fontSize = fontSize; tmpLabel.fontStyle = fontStyle; tmpLabel.alignment = alignment; tmpLabel.rectTransform.pivot = rectPivot; tmpLabel.rectTransform.localPosition = labelPositionOffset; tmpLabel.rectTransform.localRotation = labelRotationOffset; tmpLabel.rectTransform.sizeDelta = rectSize; // find and set font TMPro.TMP_FontAsset tmpFont = AssetLoader.Instance.GetFont(fontName); if (tmpFont != null) { tmpLabel.font = tmpFont; } else { Utils.LogWarning("KVR_DigitalIndicator font not found!"); } return(labelGameObject); }
void InitAlignment_TMPro(TMPro.TextAlignmentOptions alignment, out TMPro.TextAlignmentOptions alignLTR, out TMPro.TextAlignmentOptions alignRTL) { alignLTR = alignRTL = alignment; if (LocalizationManager.IsRight2Left) { switch (alignment) { case TMPro.TextAlignmentOptions.TopRight: alignLTR = TMPro.TextAlignmentOptions.TopLeft; break; case TMPro.TextAlignmentOptions.Right: alignLTR = TMPro.TextAlignmentOptions.Left; break; case TMPro.TextAlignmentOptions.BottomRight: alignLTR = TMPro.TextAlignmentOptions.BottomLeft; break; case TMPro.TextAlignmentOptions.BaselineRight: alignLTR = TMPro.TextAlignmentOptions.BaselineLeft; break; case TMPro.TextAlignmentOptions.MidlineRight: alignLTR = TMPro.TextAlignmentOptions.MidlineLeft; break; case TMPro.TextAlignmentOptions.CaplineRight: alignLTR = TMPro.TextAlignmentOptions.CaplineLeft; break; } } else { switch (alignment) { case TMPro.TextAlignmentOptions.TopLeft: alignRTL = TMPro.TextAlignmentOptions.TopRight; break; case TMPro.TextAlignmentOptions.Left: alignRTL = TMPro.TextAlignmentOptions.Right; break; case TMPro.TextAlignmentOptions.BottomLeft: alignRTL = TMPro.TextAlignmentOptions.BottomRight; break; case TMPro.TextAlignmentOptions.BaselineLeft: alignRTL = TMPro.TextAlignmentOptions.BaselineRight; break; case TMPro.TextAlignmentOptions.MidlineLeft: alignRTL = TMPro.TextAlignmentOptions.MidlineRight; break; case TMPro.TextAlignmentOptions.CaplineLeft: alignRTL = TMPro.TextAlignmentOptions.CaplineRight; break; } } }
static TextAnchor TMPTextAlignToTextAnchor(TMPro.TextAlignmentOptions align) { if (align == TMPro.TextAlignmentOptions.Bottom) { return(TextAnchor.LowerCenter); } else if (align == TMPro.TextAlignmentOptions.BottomLeft) { return(TextAnchor.LowerLeft); } else if (align == TMPro.TextAlignmentOptions.BottomRight) { return(TextAnchor.LowerRight); } if (align == TMPro.TextAlignmentOptions.Top) { return(TextAnchor.UpperCenter); } else if (align == TMPro.TextAlignmentOptions.TopLeft) { return(TextAnchor.UpperLeft); } else if (align == TMPro.TextAlignmentOptions.TopRight) { return(TextAnchor.UpperRight); } else if (align == TMPro.TextAlignmentOptions.Left) { return(TextAnchor.MiddleLeft); } else if (align == TMPro.TextAlignmentOptions.Right) { return(TextAnchor.MiddleRight); } return(TextAnchor.MiddleCenter); }
protected GameObject CreateLabel( string gameObjectName, string text, TMPro.TMP_FontAsset font, float fontSize, TMPro.FontStyles fontStyle, TMPro.TextAlignmentOptions textAlignment, Transform parentTransform, Vector3 positionOffset, Quaternion rotationOffset, Vector2 rectPivot, Vector2 rectSize) { GameObject labelGameObject = new GameObject(gameObjectName); labelGameObject.layer = 20; labelGameObject.transform.SetParent(parentTransform); TMPro.TextMeshPro tmpLabel = labelGameObject.AddComponent <TMPro.TextMeshPro>(); tmpLabel.SetText(text); tmpLabel.fontSize = fontSize; tmpLabel.fontStyle = fontStyle; tmpLabel.alignment = textAlignment; tmpLabel.rectTransform.pivot = rectPivot; tmpLabel.rectTransform.localPosition = positionOffset; tmpLabel.rectTransform.localRotation = rotationOffset; tmpLabel.rectTransform.sizeDelta = rectSize; // find and set font if (font != null) { tmpLabel.font = font; } return(labelGameObject); }
public KVR_Label(InternalProp prop, ConfigNode configuration) { // label text string text = ""; bool success = configuration.TryGetValue("text", ref text); if (success) { Text = text; } // label transform (where to place the label) ParentTransform = ConfigUtils.GetTransform(prop, configuration, "parentTransformName"); // position offset from the transform Vector3 positionOffset = Vector3.zero; success = configuration.TryGetValue("positionOffset", ref positionOffset); if (success) { PositionOffset = positionOffset; } // rotation offset from the transform Quaternion rotationOffset = Quaternion.identity; success = configuration.TryGetValue("rotationOffset", ref rotationOffset); if (success) { RotationOffset = rotationOffset; } // font string fontName = ""; success = configuration.TryGetValue("fontName", ref fontName); if (success) { Font = AssetLoader.Instance.GetFont(fontName); if (Font == null) { Utils.LogWarning("KVR_Label: font \"" + fontName + "\" not found!"); } } // font size float fontSize = 0.1f; success = configuration.TryGetValue("fontSize", ref fontSize); if (success) { FontSize = fontSize; } // font style (bold, italics, etc) TMPro.FontStyles fontStyle = TMPro.FontStyles.Normal; success = configuration.TryGetEnum("fontStyle", ref fontStyle, TMPro.FontStyles.Normal); if (success) { FontStyle = fontStyle; } // font alignment TMPro.TextAlignmentOptions textAlignment = TMPro.TextAlignmentOptions.Center; success = configuration.TryGetEnum("textAlignment", ref textAlignment, TMPro.TextAlignmentOptions.Center); if (success) { TextAlignment = textAlignment; } // canvas pivot (anchor point on the canvas) Vector2 rectPivot = new Vector2(0.5f, 0.5f); success = configuration.TryGetValue("rectPivot", ref rectPivot); if (success) { RectPivot = rectPivot; } // size of the label canvas Vector2 rectSize = new Vector2(0.2f, 0.2f); success = configuration.TryGetValue("rectSize", ref rectSize); if (success) { RectSize = rectSize; } // create the label string gameObjectName = prop.name + "-" + prop.propID + "-" + configuration.id; LabelGameObject = CreateLabel( gameObjectName, Text, Font, FontSize, FontStyle, TextAlignment, ParentTransform, PositionOffset, RotationOffset, RectPivot, RectSize); }
public virtual PUTMPro AddTextWithOptions(PUGameObject container, string content, string fontPath, Color color, float fontScale, string style, TMPro.TextAlignmentOptions alignment) { if (currentY != 0) { currentY -= paragraphSpacing(); } float maxWidth = container.size.Value.x - (padding.left + padding.right); PUTMPro text = new PUTMPro(); text.SetFrame(padding.left, currentY - padding.top, maxWidth, 0, 0, 1, "top,left"); text.font = fontPath; text.fontColor = color; text.fontStyle = style; text.fontSize = (int)(DefaultFontSize() * fontScale); text.sizeToFit = true; text.alignment = alignment; text.value = content; if (urlLinks.Count > 0) { string[] linkURLs = urlLinks.ToArray(); text.OnLinkClickAction = (linkText, linkIdx) => { OpenLink(linkURLs[linkIdx]); }; urlLinks.Clear(); } text.LoadIntoPUGameObject(container); Vector2 size = text.CalculateTextSize(content, maxWidth); text.rectTransform.sizeDelta = size; currentY -= text.rectTransform.sizeDelta.y + padding.bottom; return(text); }
public override void Create_Table(PUGameObject container, TableSpec spec) { float margin = DefaultFontSize(); currentY -= paragraphSpacing(); float savedY = currentY; PUGridLayoutGroup tableGroup = new PUGridLayoutGroup(); tableGroup.SetFrame(padding.left + 2, currentY, container.size.Value.x, 100, 0, 1, "top,left"); tableGroup.LoadIntoPUGameObject(container); // Fill out the group, then figure out the height / widths needed based upon the content float maxCellWidth = 0; float maxCellHeight = 0; int numberOfCols = 0; int numberOfRows = 0; if (spec.Headers != null) { for (int i = 0; i < spec.Headers.Count; i++) { string header = spec.Headers [i]; ColumnAlignment alignment = spec.Columns [i]; TMPro.TextAlignmentOptions tmAlignment = TMPro.TextAlignmentOptions.Left; if (alignment == ColumnAlignment.Right) { tmAlignment = TMPro.TextAlignmentOptions.Right; } if (alignment == ColumnAlignment.Center) { tmAlignment = TMPro.TextAlignmentOptions.Center; } PUTMPro text = AddTextWithOptions(tableGroup, header, DefaultFont(), textColor(), 1.0f, "Bold", tmAlignment); Vector2 size = text.rectTransform.sizeDelta + new Vector2(margin * 2.0f, margin); text.rectTransform.pivot = Vector2.zero; text.rectTransform.anchorMax = Vector2.one; text.rectTransform.anchorMin = Vector2.zero; PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(255, 255, 255, 255)); text.SetStretchStretch(margin * 0.5f, margin, margin * 0.5f, margin); if (size.x > maxCellWidth) { maxCellWidth = size.x; } if (size.y > maxCellHeight) { maxCellHeight = size.y; } } } numberOfCols = spec.Rows[0].Count; numberOfRows = spec.Rows.Count; if (spec.Headers != null && spec.Headers.Count > 0) { numberOfRows++; } for (int i = 0; i < spec.Rows.Count; i++) { List <string> rows = spec.Rows[i]; for (int j = 0; j < rows.Count; j++) { string row = rows[j]; ColumnAlignment alignment = spec.Columns[j]; TMPro.TextAlignmentOptions tmAlignment = TMPro.TextAlignmentOptions.Left; if (alignment == ColumnAlignment.Right) { tmAlignment = TMPro.TextAlignmentOptions.Right; } if (alignment == ColumnAlignment.Center) { tmAlignment = TMPro.TextAlignmentOptions.Center; } PUTMPro text = AddTextWithOptions(tableGroup, row, DefaultFont(), textColor(), 1.0f, "Normal", tmAlignment); Vector2 size = text.rectTransform.sizeDelta + new Vector2(margin * 2.0f, margin); text.rectTransform.pivot = Vector2.zero; text.rectTransform.anchorMax = Vector2.one; text.rectTransform.anchorMin = Vector2.zero; if (i % 2 != 0) { PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(248, 248, 248, 255)); } else { PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(255, 255, 255, 255)); } text.SetStretchStretch(margin * 0.5f, margin, margin * 0.5f, margin); if (size.x > maxCellWidth) { maxCellWidth = size.x; } if (size.y > maxCellHeight) { maxCellHeight = size.y; } } } tableGroup.layout.cellSize = new Vector2(maxCellWidth, maxCellHeight); tableGroup.rectTransform.sizeDelta = new Vector2(maxCellWidth * numberOfCols, maxCellHeight * numberOfRows); currentY = savedY - tableGroup.rectTransform.sizeDelta.y; }
public void DoLocalize_TMPLabel(string mainTranslation, string secondaryTranslation) { // there its a problem with TMPro that disables and renables the inspector when changing fonts, and that breaks the current preview flow if (!Application.isPlaying) { #if UNITY_EDITOR if (UnityEditor.Selection.activeGameObject == gameObject) { if (string.IsNullOrEmpty(TMP_previewLanguage)) { TMP_previewLanguage = LocalizationManager.CurrentLanguage; } } #endif } //--[ Localize Font Object ]---------- { #if TextMeshPro_Pre53 TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref mainTranslation, ref secondaryTranslation); #else TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref mainTranslation, ref secondaryTranslation); #endif if (newFont != null) { if (mTarget_TMPLabel.font != newFont) { mTarget_TMPLabel.font = newFont; } } else { //--[ Localize Font Material ]---------- Material newMat = GetSecondaryTranslatedObj <Material>(ref mainTranslation, ref secondaryTranslation); if (newMat != null && mTarget_TMPLabel.fontMaterial != newMat) { if (!newMat.name.StartsWith(mTarget_TMPLabel.font.name, StringComparison.Ordinal)) { newFont = GetTMPFontFromMaterial(secondaryTranslation.EndsWith(newMat.name, StringComparison.Ordinal) ? secondaryTranslation : newMat.name); if (newFont != null) { mTarget_TMPLabel.font = newFont; } } mTarget_TMPLabel.fontSharedMaterial = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left; InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPLabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL); } else { TMPro.TextAlignmentOptions alignRTL, alignLTR; InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPLabel.alignment, out alignLTR, out alignRTL); if ((mAlignmentTMPwasRTL && mAlignmentTMPro_RTL != alignRTL) || (!mAlignmentTMPwasRTL && mAlignmentTMPro_LTR != alignLTR)) { mAlignmentTMPro_LTR = alignLTR; mAlignmentTMPro_RTL = alignRTL; } mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left; } if (mainTranslation != null && mTarget_TMPLabel.text != mainTranslation) { if (CurrentLocalizeComponent.CorrectAlignmentForRTL) { mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR; mTarget_TMPLabel.isRightToLeftText = LocalizationManager.IsRight2Left; if (LocalizationManager.IsRight2Left) { mainTranslation = ReverseText(mainTranslation); } } mTarget_TMPLabel.text = mainTranslation; //mTarget_TMPLabel.SetText( mainTranslation, 0 ); } }
public void setText(string newText, float fontSize = 2f, TMPro.TextAlignmentOptions alignment = TMPro.TextAlignmentOptions.Left) { text.text = newText; text.fontSize = fontSize; text.alignment = alignment; }
public void DoLocalize_TMPUGUILabel(string MainTranslation, string SecondaryTranslation) { { //--[ Localize Font Object ]---------- #if TextMeshPro_Pre53 TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation); #else TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation); #endif if (newFont != null) { if (mTarget_TMPUGUILabel.font != newFont) { mTarget_TMPUGUILabel.font = newFont; } } else { //--[ Localize Font Material ]---------- Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation); if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat) { if (!newMat.name.StartsWith(mTarget_TMPUGUILabel.font.name)) { newFont = GetTMPFontFromMaterial(newMat.name); if (newFont != null) { mTarget_TMPUGUILabel.font = newFont; } } mTarget_TMPUGUILabel.fontSharedMaterial = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mOriginalAlignmentTMPro = mTarget_TMPUGUILabel.alignment; } if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPUGUILabel.text != MainTranslation) { if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL) { int align = (int)mTarget_TMPUGUILabel.alignment; if (align % 4 == 0) { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? mTarget_TMPUGUILabel.alignment + 2 : mOriginalAlignmentTMPro; } else if (align % 4 == 2) { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? mTarget_TMPUGUILabel.alignment - 2 : mOriginalAlignmentTMPro; } } mTarget_TMPUGUILabel.text = MainTranslation; //mTarget_TMPUGUILabel.SetText(MainTranslation, 0); } }
public void SetMessageAlignment(TMPro.TextAlignmentOptions alignment) { m_MessagesLabel.alignment = alignment; }
public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } // Begin showing lore state FsmState startReading = fsm.GetState("Trink 1"); startReading.ClearTransitions(); startReading.RemoveActionsOfType <FsmStateAction>(); // Yeeting the shop menu probably isn't ideal; however, we can't close it because the shop menu's descendant is carrying // this FSM that's showing the lore. So welcome to spaghetti-land I guess startReading.AddAction(new RandomizerExecuteLambda(() => { GameObject.Find("Shop Menu").transform.SetPositionY(200); })); startReading.AddAction(new RandomizerExecuteLambda(() => GameObject.Find("DialogueManager") .LocateMyFSM("Box Open").SendEvent("BOX UP"))); startReading.AddAction(new Wait() { time = 0.3f, finishEvent = FsmEvent.Finished }); // Reading FsmState loreReading = new FsmState(fsm.GetState("No")) { Name = "Lore Reading" }; loreReading.ClearTransitions(); loreReading.RemoveActionsOfType <FsmStateAction>(); loreReading.AddAction(new RandomizerExecuteLambda(() => { GameObject dialogueManager = GameObject.Find("DialogueManager"); GameObject textObj = dialogueManager.transform.Find("Text").gameObject; // Extract the parameters of the shown lore ReqDef loredef = LogicManager.GetItemDef(fsm.FsmVariables.StringVariables.First(v => v.Name == "PD Bool Name").Value.Split('.')[2]); string key = loredef.loreKey; string sheet = string.IsNullOrEmpty(loredef.loreSheet) ? "Lore Tablets" : loredef.loreSheet; TMPro.TextAlignmentOptions align = loredef.textType == ChangeShinyIntoText.TextType.LeftLore ? TMPro.TextAlignmentOptions.TopLeft : TMPro.TextAlignmentOptions.Top; textObj.GetComponent <TMPro.TextMeshPro>().alignment = align; textObj.GetComponent <DialogueBox>().StartConversation(key, sheet); })); // Finished Reading FsmState finishReading = new FsmState(fsm.GetState("No")) { Name = "Lore Finish Reading" }; finishReading.ClearTransitions(); finishReading.RemoveActionsOfType <FsmStateAction>(); finishReading.AddAction(new RandomizerExecuteLambda(() => { GameObject dialogueManager = GameObject.Find("DialogueManager"); GameObject textObj = dialogueManager.transform.Find("Text").gameObject; dialogueManager.LocateMyFSM("Box Open").SendEvent("BOX DOWN"); textObj.GetComponent <TMPro.TextMeshPro>().alignment = TMPro.TextAlignmentOptions.TopLeft; })); // Add a useless wait here; this is basically just to give the dialogue box time to disappear before returning the shop menu. // The time value isn't a special number; I just found that it seemed to work well. finishReading.AddAction(new Wait() { time = 0.15f, finishEvent = FsmEvent.Finished }); // Return the shop menu to its rightful position fsm.GetState("Reset").AddFirstAction(new RandomizerExecuteLambda(() => { GameObject.Find("Shop Menu").transform.SetPositionY(0.5f); })); // Adding states startReading.AddTransition("FINISHED", loreReading.Name); loreReading.AddTransition("CONVO_FINISH", finishReading.Name); finishReading.AddTransition("FINISHED", "Reset"); fsm.AddState(loreReading); fsm.AddState(finishReading); }
public static LocalizableText AddLine(VerticalLayoutGroup layout, LocalizableText src, string text, TMPro.TextAlignmentOptions aligin) { GameObject aline = new GameObject(); LocalizableText atextline = aline.AddComponent <LocalizableText>(); atextline.fontSizeMax = src.fontSizeMax; atextline.fontSizeMin = src.fontSizeMin; atextline.fontSize = src.fontSize; atextline.SetText(text); atextline.alignment = aligin; atextline.enableWordWrapping = false; aline.transform.SetParent(layout.transform); return(atextline); }
public ConfigManager(BetterUI mod) { ConfigFileComponents = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Components.cfg", true); ConfigFileMisc = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Misc.cfg", true); ConfigFileAdvancedIcons = new ConfigFile(Paths.ConfigPath + "\\BetterUI-AdvancedIcons.cfg", true); ConfigFileBuffs = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Buffs.cfg", true); ConfigFileCommandImprovements = new ConfigFile(Paths.ConfigPath + "\\BetterUI-CommandImprovements.cfg", true); ConfigFileDPSMeter = new ConfigFile(Paths.ConfigPath + "\\BetterUI-DPSMeter.cfg", true); ConfigFileItemCounters = new ConfigFile(Paths.ConfigPath + "\\BetterUI-ItemCounters.cfg", true); ConfigFileStatsDisplay = new ConfigFile(Paths.ConfigPath + "\\BetterUI-StatsDisplay.cfg", true); ConfigFileSorting = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Sorting.cfg", true); // Components ComponentsAdvancedIcons = ConfigFileComponents.Bind("Components", "AdvanedIcons", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsBuffTimers = ConfigFileComponents.Bind("Components", "BuffTimers", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsCommandImprovements = ConfigFileComponents.Bind("Components", "CommandImprovements", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsDPSMeter = ConfigFileComponents.Bind("Components", "DPSMeter", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsItemCounters = ConfigFileComponents.Bind("Components", "ItemCounters", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsItemSorting = ConfigFileComponents.Bind("Components", "ItemSorting", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsMisc = ConfigFileComponents.Bind("Components", "Misc", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsStatsDisplay = ConfigFileComponents.Bind("Components", "StatsDisplay", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); // Misc MiscShowHidden = ConfigFileMisc.Bind("Misc", "ShowHidden", false, "Show hidden items in the item inventory."); MiscAdvancedPickupNotificationsItems = ConfigFileMisc.Bind("Misc", "AdvancedPickupNotificationsItems", false, "Show advanced descriptions when picking up an item."); MiscAdvancedPickupNotificationsEquipements = ConfigFileMisc.Bind("Misc", "AdvancedPickupNotificationsEquipements", false, "Show advanced descriptions when picking up equipment."); MiscHidePickupNotificiationsItems = ConfigFileMisc.Bind("Misc", "HidePickupNotificiationsItems", false, "Hide pickup notifications for items."); MiscHidePickupNotificiationsEquipements = ConfigFileMisc.Bind("Misc", "HidePickupNotificiationsEquipements", false, "Hide pickup notifications for equipment."); MiscHidePickupNotificiationsArtifacts = ConfigFileMisc.Bind("Misc", "HidePickupNotificiationsArtifacts", false, "Hide pickup notifications for artifacts."); MiscShowPickupDescription = ConfigFileMisc.Bind("Misc", "ShowPickupDescription", true, "Show the item description on the interaction popup."); MiscPickupDescriptionAdvanced = ConfigFileMisc.Bind("Misc", "PickupDescriptionAdvanced", false, "Show advanced descriptions for the interaction popup."); // Advanced Icons AdvancedIconsItemAdvancedDescriptions = ConfigFileAdvancedIcons.Bind("Item Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over an item."); AdvancedIconsItemItemStatsIntegration = ConfigFileAdvancedIcons.Bind("Item Improvements", "ItemStatsIntegration", true, "If installed, show item stats from ItemStatsMod where applicable."); AdvancedIconsEquipementShowCooldownStacks = ConfigFileAdvancedIcons.Bind("Equipement Improvements", "ShowCooldownStacks", true, "Show the cooldown for your equipement when charging multiple stacks."); AdvancedIconsEquipementAdvancedDescriptions = ConfigFileAdvancedIcons.Bind("Equipement Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over equipment."); AdvancedIconsEquipementShowBaseCooldown = ConfigFileAdvancedIcons.Bind("Equipement Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over equipment."); AdvancedIconsEquipementShowCalculatedCooldown = ConfigFileAdvancedIcons.Bind("Equipement Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over equipment."); AdvancedIconsSkillShowCooldownStacks = ConfigFileAdvancedIcons.Bind("Skill Improvements", "ShowCooldownStacks", true, "Show the cooldown for skills when charging multiple stacks."); AdvancedIconsSkillShowBaseCooldown = ConfigFileAdvancedIcons.Bind("Skill Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over a skill."); AdvancedIconsSkillShowCalculatedCooldown = ConfigFileAdvancedIcons.Bind("Skill Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over a skill."); AdvancedIconsSkillShowProcCoefficient = ConfigFileAdvancedIcons.Bind("Skill Improvements", "ShowProcCoefficient", true, "Show the proc coefficient when hovering over a skill."); AdvancedIconsSkillCalculateSkillProcEffects = ConfigFileAdvancedIcons.Bind("Skill Improvements", "CalculateProcEffects", true, "Show the effects of proc coefficient of a skill related to the items you are carrying."); // Buffs BuffTimers = ConfigFileBuffs.Bind("Buffs", "BuffTimers", true, "Show buff timers (host only)."); BuffTimersDecimal = ConfigFileBuffs.Bind("Buffs", "BuffTimersDecimal", true, "Show 1 decimal point when timer is below 10."); BuffTooltips = ConfigFileBuffs.Bind("Buffs", "BuffTooltips", true, "Show buff tooltips."); BuffTimersPosition = ConfigFileBuffs.Bind("Buffs", "CountersPosition", "TopRight", "Location of buff timer text.\n" + "Valid options:\n" + "TopLeft\n" + "TopRight\n" + "BottomLeft\n" + "BottomRight\n" + "Center\n"); BuffTimersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), BuffTimersPosition.Value, true); BuffTimersFontSize = ConfigFileBuffs.Bind("Buffs", "CountersFontSize", 23f, "Size of the buff timer text."); // Command / Scrapper Improvements CommandResizeCommandWindow = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "ResizeCommandWindow", true, "Resize the command window depending on the number of items."); CommandRemoveBackgroundBlur = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "RemoveBackgroundBlur", true, "Remove the blur behind the command window that hides the rest of the UI."); CommandCloseOnEscape = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CloseOnEscape", true, "Close the command/scrapper window when you press escape."); CommandCloseOnWASD = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CloseOnWASD", true, "Close the command/scrapper window when you press W, A, S, or D."); CommandCloseOnCustom = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CloseOnCustom", "", "Close the command/scrapper window when you press the key selected here.\n" + "Example: space\n" + "Must be lowercase. Leave blank to disable."); CommandTooltipsShow = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "TooltipsShow", true, "Show tooltips in the command and scrapper windows."); CommandTooltipsItemStatsBeforeAfter = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "TooltipsItemStatsBeforeAfter", true, "If ItemStatsMod is installed, show the stats before and after picking up the item."); CommandCountersShow = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CountersShow", true, "Show counters in the command and scrapper windows."); CommandCountersHideOnZero = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CountersHideOnZero", false, "Hide counters when they are zero."); CommandCountersPosition = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CountersPosition", "TopRight", "Location of the command item counter.\n" + "Valid options:\n" + "TopLeft\n" + "TopRight\n" + "BottomLeft\n" + "BottomRight\n" + "Center\n"); CommandCountersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), CommandCountersPosition.Value, true); CommandCountersFontSize = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CountersFontSize", 20f, "Size of the command item counter text."); CommandCountersPrefix = ConfigFileCommandImprovements.Bind("Command / Scrapper Improvements", "CountersPrefix", "x", "Prefix for the command item counter. Example 'x' will show x0, x1, x2, etc.\nCan be empty."); // DPSMeter DPSMeterTimespan = ConfigFileDPSMeter.Bind("DPSMeter", "Timespan", 5f, "Calculate DPS across this many seconds."); DPSMeterWindowShow = ConfigFileDPSMeter.Bind("DPSMeter", "WindowShow", true, "Show a dedicated DPSMeter."); DPSMeterWindowIncludeMinions = ConfigFileDPSMeter.Bind("DPSMeter", "WindowIncludeMinions", true, "Include minions such as turrets and drones in the DPS meter."); DPSMeterWindowBackground = ConfigFileDPSMeter.Bind("DPSMeter", "WindowBackground", true, "Whether or not the DPS window should have a background."); DPSMeterWindowAnchorMin = ConfigFileDPSMeter.Bind("DPSMeter", "WindowAnchorMin", new Vector2(0, 0), "Screen position the lower left window corner is anchored to.\n" + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); DPSMeterWindowAnchorMax = ConfigFileDPSMeter.Bind("DPSMeter", "WindowAnchorMax", new Vector2(0, 0f), "Screen position the upper right window corner is anchored to.\n" + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); DPSMeterWindowPosition = ConfigFileDPSMeter.Bind("DPSMeter", "WindowPosition", new Vector2(120, 240), "Position of the DPSMeter window relative to the anchor."); DPSMeterWindowPivot = ConfigFileDPSMeter.Bind("DPSMeter", "WindowPivot", new Vector2(0, 1), "Pivot of the DPSMeter window.\n" + "Window Position is from the anchor to the pivot."); DPSMeterWindowSize = ConfigFileDPSMeter.Bind("DPSMeter", "WindowSize", new Vector2(350, 45), "Size of the DPSMeter window."); DPSMeterWindowAngle = ConfigFileDPSMeter.Bind("DPSMeter", "WindowAngle", new Vector3(0, -6, 0), "Angle of the DPSMeter window."); // ItemCounters ItemCountersShowItemCounters = ConfigFileItemCounters.Bind("ItemCounters", "ShowItemCounters", true, "Enable/Disable ItemCounters entirely."); ItemCountersShowItemScore = ConfigFileItemCounters.Bind("ItemCounters", "ShowItemScore", true, "Show your item score."); ItemCountersItemScoreFromTier = ConfigFileItemCounters.Bind("ItemCounters", "ItemScoreFromTier", true, "Whether or not the ItemScore should be based on tier. If disabled, the per-item settings will be used."); ItemCountersShowItemSum = ConfigFileItemCounters.Bind("ItemCounters", "ShowItemSum", true, "Show the how many items you have."); ItemCountersItemSumTiersString = ConfigFileItemCounters.Bind("ItemCounters", "ItemSumTiersString", "01234", "Which tiers to include in the ItemSum.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); ItemCountersItemSumTiers = ItemCountersItemSumTiersString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); ItemCountersShowItemsByTier = ConfigFileItemCounters.Bind("ItemCounters", "ShowItemsByTier", true, "Show how many items you have, by tier."); ItemCountersItemsByTierOrderString = ConfigFileItemCounters.Bind("ItemCounters", "ItemsByTierOrderString", "43210", "Which tiers to include in the ItemsByTier, in order.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); ItemCountersItemsByTierOrder = ItemCountersItemsByTierOrderString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); ItemCountersTierScoreTier1 = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "Tier1", 1, "Score for Tier 1 items."); ItemCountersTierScoreTier2 = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "Tier2", 3, "Score for Tier 2 items."); ItemCountersTierScoreTier3 = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "Tier3", 12, "Score for Tier 3 items."); ItemCountersTierScoreLunar = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "Lunar", 0, "Score for Lunar items."); ItemCountersTierScoreBoss = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "Boss", 4, "Score for Boss items."); ItemCountersTierScoreNoTier = ConfigFileItemCounters.Bind("ItemCounters Tier Score", "NoTier", 0, "Score for items without a tier."); ItemCountersTierScores = new int[] { ItemCountersTierScoreTier1.Value, ItemCountersTierScoreTier2.Value, ItemCountersTierScoreTier3.Value, ItemCountersTierScoreLunar.Value, ItemCountersTierScoreBoss.Value, ItemCountersTierScoreNoTier.Value, }; ItemCountersItemScores = new Dictionary <string, int>(); // StatsDisplay StatsDisplayEnable = ConfigFileStatsDisplay.Bind("StatsDisplay", "Enable", true, "Enable/Disable the StatsDisplay entirely."); StatsDisplayStatString = ConfigFileStatsDisplay.Bind("StatsDisplay", "StatString", "<color=#FFFFFF>" + "<size=18><b>Stats</b></size>\n" + "<size=14>Luck: $luck\n" + "Base Damage: $dmg\n" + "Crit Chance: $luckcrit%\n" + "Attack Speed: $atkspd\n" + "Armor: $armor | $armordmgreduction%\n" + "Regen: $regen\n" + "Speed: $movespeed\n" + "Jumps: $jumps/$maxjumps\n" + "Kills: $killcount\n" + "Mountain Shrines: $mountainshrines\n", "You may format the StatString using formatting tags such as color, size, bold, underline, italics. See Readme for more.\n" + "Valid Parameters:\n" + "$exp $level $luck\n" + "$dmg $crit $luckcrit $atkspd\n" + "$hp $maxhp $shield $maxshield $barrier $maxbarrier\n" + "$armor $armordmgreduction $regen\n" + "$movespeed $jumps $maxjumps\n" + "$killcount $multikill $highestmultikill\n" + "$dps $dpscharacter $dpsminions\n" + "$mountainshrines\n" + "$blueportal $goldportal $celestialportal"); StatsDisplayStatStringCustomBind = ConfigFileStatsDisplay.Bind("StatsDisplay", "StatStringCustomBind", "<color=#FFFFFF>" + "<size=18><b>Stats</b></size>\n" + "<size=14>Luck: $luck\n" + "Base Damage: $dmg\n" + "Crit Chance: $crit%\n" + "Crit w/ Luck: $luckcrit%\n" + "Attack Speed: $atkspd\n" + "Armor: $armor | $armordmgreduction%\n" + "Regen: $regen\n" + "Speed: $movespeed\n" + "Jumps: $jumps/$maxjumps\n" + "Kills: $killcount\n" + "Mountain Shrines: $mountainshrines\n" + "Difficulty: $difficulty\n" + "Blue Portal: $blueportal\n" + "Gold Portal: $goldportal\n" + "Celestial Portal: $celestialportal\n", "StatDisplay string to show when the custom bind is being pressed. This can be the same or different from the normal StatString."); StatsDisplayCustomBind = ConfigFileStatsDisplay.Bind("StatsDisplay", "CustomBind", "tab", "Bind to show secondary StatsDisplay string.\n" + "Example: space\n" + "Must be lowercase. Leave blank to disable."); StatsDisplayShowCustomBindOnly = ConfigFileStatsDisplay.Bind("StatsDisplay", "ShowCustomBindOnly", false, "Only show the StatsDisplay when the scoreboard is open."); StatsDisplayToggleOnBind = ConfigFileStatsDisplay.Bind("StatsDisplay", "ToggleOnBind", false, "Toggle the StatsDisplay when the bind is pressed rather than showing it when it is held."); StatsDisplayPanelBackground = ConfigFileStatsDisplay.Bind("StatsDisplay", "PanelBackground", true, "Whether or not the StatsDisplay panel should have a background."); StatsDisplayAttachToObjectivePanel = ConfigFileStatsDisplay.Bind("StatsDisplay", "AttachToObjectivePanel", true, "Whether to attach the stats display to the objective panel.\n" + "If not, it will be a free-floating window that can be moved with the options below."); StatsDisplayWindowAnchorMin = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowAnchorMin", new Vector2(1, 0.5f), "Screen position the lower left window corner is anchored to.\n" + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); StatsDisplayWindowAnchorMax = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowAnchorMax", new Vector2(1, 0.5f), "Screen position the upper right window corner is anchored to.\n" + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); StatsDisplayWindowPosition = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowPosition", new Vector2(-210, 100), "Position of the StatsDisplay window relative to the anchor."); StatsDisplayWindowPivot = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowPivot", new Vector2(0, 0.5f), "Pivot of the StatsDisplay window.\n" + "Window Position is from the anchor to the pivot."); StatsDisplayWindowSize = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowSize", new Vector2(200, 600), "Size of the StatsDisplay window."); StatsDisplayWindowAngle = ConfigFileStatsDisplay.Bind("StatsDisplay", "WindowAngle", new Vector3(0, 6, 0), "Angle of the StatsDisplay window."); // Sorting SortingSortItemsInventory = ConfigFileSorting.Bind("Sorting", "SortItemsInventory", true, "Sort items in the inventory and scoreboard."); SortingSortItemsCommand = ConfigFileSorting.Bind("Sorting", "SortItemsCommand", true, "Sort items in the command window."); SortingSortItemsScrapper = ConfigFileSorting.Bind("Sorting", "SortItemsScrapper", true, "Sort items in the scrapper window."); SortingTierOrderString = ConfigFileSorting.Bind("Sorting", "TierOrder", "012345", "Tiers in ascending order, left to right.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); SortingTierOrder = new int[] { SortingTierOrderString.Value.IndexOf('0'), SortingTierOrderString.Value.IndexOf('1'), SortingTierOrderString.Value.IndexOf('2'), SortingTierOrderString.Value.IndexOf('3'), SortingTierOrderString.Value.IndexOf('4'), SortingTierOrderString.Value.IndexOf('5'), }; SortingSortOrder = ConfigFileSorting.Bind("Sorting", "SortOrder", "S134", "What to sort the items by, most important to least important.\n" + "Find the full details and an example in the Readme on Thunderstore/Github.\n" + "0 = Tier Ascending\n" + "1 = Tier Descending\n" + "2 = Stack Size Ascending\n" + "3 = Stack Size Descending\n" + "4 = Pickup Order\n" + "5 = Pickup Order Reversed\n" + "6 = Alphabetical\n" + "7 = Alphabetical Reversed\n" + "8 = Random\n" + "i = ItemIndex\n" + "I = ItemIndex Descending\n" + "\n" + "Tag Based:\n" + "s = Scrap First\n" + "S = Scrap Last\n" + "d = Damage First\n" + "D = Damage Last\n" + "h = Healing First\n" + "H = Healing Last\n" + "u = Utility First\n" + "U = Utility Last\n" + "o = On Kill Effect First\n" + "O = On Kill Effect Last\n" + "e = Equipment Related First\n" + "E = Equipment Related Last\n" + "p = Sprint Related First\n" + "P = Sprint Related Last"); SortingSortOrderCommand = ConfigFileSorting.Bind("Sorting", "SortOrderCommand", "6", "Sort order for the command window.\n" + "The command window has a special sort option \"C\" which will place the last selected item in the middle.\n" + "Note: This option must be the last one in the SortOrderCommand option."); SortingSortOrderScrapper = ConfigFileSorting.Bind("Sorting", "SortOrderScrapper", "134", "Sort order for the scrapper window."); }
static void Push(IntPtr L, TMPro.TextAlignmentOptions arg) { ToLua.Push(L, arg); }
protected void PopupMessage(string title, string message, PopupMenuType popupType = PopupMenuType.OK, TMPro.TextAlignmentOptions alignment = TMPro.TextAlignmentOptions.MidlineGeoAligned) { _popupWindow.Open(); _popupWindow.PopupType = popupType; _popupWindow.SetTitle(title); _popupWindow.SetMessage(message, 500, 250); _popupWindow.SetMessageAlignment(alignment); }
static public GameObject SpawnBlueButton(GameObject parent, Vector2 givenPivot, Vector2 givenSize, string givenLabel, TMPro.TextAlignmentOptions alignment, List <Image> images, bool isFallback = false) { ColorBlock colourBlock = new ColorBlock(); colourBlock.disabledColor = new Color(0.255f, 0.201f, 0.201f, 0.714f); colourBlock.highlightedColor = new Color(0.988f, 1.000f, 0.693f, 0.733f); colourBlock.normalColor = new Color(0.327f, 0.403f, 0.472f, 1.000f); colourBlock.pressedColor = new Color(0.740f, 0.755f, 0.445f, 0.984f); colourBlock.colorMultiplier = 1; GameObject button = ElementCreator.SpawnButtonSize(parent, Resources.panelTextures[0], colourBlock, givenPivot, givenSize, isFallback); ElementCreator.SpawnImageOffset(images, button, Resources.panelTextures[7], new Color(1, 1, 1, 1), new Vector2(0.5f, 0.5f), new Vector2(-6, -6), new Vector2(6, 6)); images[images.Count - 1].gameObject.SetActive(false); ElementCreator.SpawnImageOffset(new List <Image>(), button, Resources.panelTextures[1], new Color(1, 1, 1, 0.286f), new Vector2(0.5f, 0.5f), new Vector2(0, 0), new Vector2(0, 0)); Image highlightImage = ElementCreator.SpawnImageOffset(new List <Image>(), button, Resources.panelTextures[2], new Color(1, 1, 1, 1), new Vector2(0.5f, 0.5f), new Vector2(-4, -12), new Vector2(12, 4)); button.GetComponent <RoR2.UI.HGButton>().imageOnHover = highlightImage; List <TMPro.TextMeshProUGUI> buttonText = new List <TMPro.TextMeshProUGUI>(); ElementCreator.SpawnTextOffset(buttonText, button, new Color(1, 1, 1, 1), 24, 0, new Vector2(12, 4), new Vector2(-12, -4)); buttonText[0].alignment = alignment; buttonText[0].text = givenLabel; buttonText[0].lineSpacing = -25; return(button); }
public void DoLocalize_TMPLabel(string MainTranslation, string SecondaryTranslation) { // there its a problem with TMPro that disables and renables the inspector when changing fonts, and that breaks the current preview flow if (!Application.isPlaying) { #if UNITY_EDITOR if (UnityEditor.Selection.activeGameObject == gameObject) { if (string.IsNullOrEmpty(TMP_previewLanguage)) { TMP_previewLanguage = LocalizationManager.CurrentLanguage; } } #endif } //--[ Localize Font Object ]---------- { #if TextMeshPro_Pre53 TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref MainTranslation, ref SecondaryTranslation); #else TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref MainTranslation, ref SecondaryTranslation); #endif if (newFont != null) { if (mTarget_TMPLabel.font != newFont) { mTarget_TMPLabel.font = newFont; } } else { //--[ Localize Font Material ]---------- Material newMat = GetSecondaryTranslatedObj <Material>(ref MainTranslation, ref SecondaryTranslation); if (newMat != null && mTarget_TMPLabel.fontMaterial != newMat) { mTarget_TMPLabel.fontMaterial = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mOriginalAlignmentTMPro = mTarget_TMPLabel.alignment; } if (!string.IsNullOrEmpty(MainTranslation) && mTarget_TMPLabel.text != MainTranslation) { if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL) { if (mTarget_TMPLabel.alignment <= TMPro.TextAlignmentOptions.TopJustified) { mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.TopRight : mOriginalAlignmentTMPro; } else if (mTarget_TMPLabel.alignment <= TMPro.TextAlignmentOptions.Justified) { mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.Right : mOriginalAlignmentTMPro; } else { mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? TMPro.TextAlignmentOptions.BottomRight : mOriginalAlignmentTMPro; } } mTarget_TMPLabel.text = MainTranslation; mTarget_TMPLabel.SetText(MainTranslation, 0); } }
public void DoLocalize_TMPUGUILabel(string mainTranslation, string secondaryTranslation) { { //--[ Localize Font Object ]---------- #if TextMeshPro_Pre53 TMPro.TextMeshProFont newFont = GetSecondaryTranslatedObj <TMPro.TextMeshProFont>(ref mainTranslation, ref secondaryTranslation); #else TMPro.TMP_FontAsset newFont = GetSecondaryTranslatedObj <TMPro.TMP_FontAsset>(ref mainTranslation, ref secondaryTranslation); #endif if (newFont != null) { if (mTarget_TMPUGUILabel.font != newFont) { mTarget_TMPUGUILabel.font = newFont; } } else { //--[ Localize Font Material ]---------- Material newMat = GetSecondaryTranslatedObj <Material>(ref mainTranslation, ref secondaryTranslation); if (newMat != null && mTarget_TMPUGUILabel.fontMaterial != newMat) { if (!newMat.name.StartsWith(mTarget_TMPUGUILabel.font.name, StringComparison.Ordinal)) { newFont = GetTMPFontFromMaterial(secondaryTranslation.EndsWith(newMat.name, StringComparison.Ordinal) ? secondaryTranslation : newMat.name); if (newFont != null) { mTarget_TMPUGUILabel.font = newFont; } } mTarget_TMPUGUILabel.fontSharedMaterial = newMat; } } } if (mInitializeAlignment) { mInitializeAlignment = false; mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left; InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPUGUILabel.alignment, out mAlignmentTMPro_LTR, out mAlignmentTMPro_RTL); } else { TMPro.TextAlignmentOptions alignRTL, alignLTR; InitAlignment_TMPro(mAlignmentTMPwasRTL, mTarget_TMPUGUILabel.alignment, out alignLTR, out alignRTL); if ((mAlignmentTMPwasRTL && mAlignmentTMPro_RTL != alignRTL) || (!mAlignmentTMPwasRTL && mAlignmentTMPro_LTR != alignLTR)) { mAlignmentTMPro_LTR = alignLTR; mAlignmentTMPro_RTL = alignRTL; } mAlignmentTMPwasRTL = LocalizationManager.IsRight2Left; } if (mainTranslation != null && mTarget_TMPUGUILabel.text != mainTranslation) { if (CurrentLocalizeComponent.CorrectAlignmentForRTL) { mTarget_TMPUGUILabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR; mTarget_TMPUGUILabel.isRightToLeftText = LocalizationManager.IsRight2Left; if (LocalizationManager.IsRight2Left) { mainTranslation = ReverseText(mainTranslation); } } mTarget_TMPUGUILabel.text = mainTranslation; //mTarget_TMPUGUILabel.SetText(mainTranslation, 0); } }