public static TextParameters Clone(TextParameters paramSource, bool useFontname) { if (paramSource == null) { return(null); } var param = new TextParameters(); for (int i = 0; i < paramSource.Count(); i++) { param.m_textFields.Add(TextField.Clone(paramSource.m_textFields[i], useFontname)); } return(param); }
public void DrawUI(Rect rect, TextCustomizationManager textManager, Action <TextureFont> openCharTable) { // GUI.Box(rect, string.Empty); GUI.BeginGroup(rect); // copy if (GUI.Button(new Rect(220, 3, 25, 23), ProceduralObjectsMod.Icons[15])) { ProceduralObjectsLogic.PlaySound(); textManager.copiedField = TextField.Clone(this, false); } if (m_type == 0) { if (!m_font.m_disableColorOverwriting) { painter = GUIPainter.DrawPainterSampleOnly(painter, new Vector2(3, 4), m_fontColor, (c) => { m_fontColor = c; }, () => { if (textManager.colorPickerSelected == painter) { textManager.colorPickerSelected = null; } else { textManager.colorPickerSelected = painter; } }); } GUI.SetNextControlName("TextFieldPOTextCustom"); m_text = GUI.TextField(new Rect(m_font.m_disableColorOverwriting ? 3 : 31, 3, m_font.m_disableColorOverwriting ? 214 : 186, 25), m_text); } else // if m_type == 1 { painter = GUIPainter.DrawPainterSampleOnly(painter, new Vector2(3, 4), m_fontColor, (c) => { m_fontColor = c.KeepAlphaFrom(m_fontColor); }, () => { if (textManager.colorPickerSelected == painter) { textManager.colorPickerSelected = null; } else { textManager.colorPickerSelected = painter; } }); GUI.Label(new Rect(30, 5, 190, 23), LocalizationManager.instance.current["colorRect"]); } GUIUtils.DrawSeparator(new Vector2(3, 75), 241); if (m_type == 0) // TEXT FIELD { //size GUI.Label(new Rect(3, 80, 95, 22), "<size=12>" + LocalizationManager.instance.current["font_size"] + " : " + m_fontSize.ToString() + "</size>"); m_fontSize = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(100, 85, 140, 25), m_fontSize, 5, 150)); //spacing GUI.Label(new Rect(3, 105, 95, 22), "<size=12>" + LocalizationManager.instance.current["font_spacing"] + " : " + m_spacing.ToString() + "</size>"); m_spacing = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(100, 110, 140, 25), m_spacing, 0, 9)); //scale GUI.Label(new Rect(3, 130, 120, 26), LocalizationManager.instance.current["scale_txt"] + " :"); if (GUI.Button(new Rect(3, 155, 24, 26), "X :", GUI.skin.label)) { m_scaleX = 1f; } m_scaleX = GUI.HorizontalSlider(new Rect(30, 158, 90, 18), m_scaleX, 0.1f, 5f); if (GUI.Button(new Rect(125, 155, 24, 26), "Y :", GUI.skin.label)) { m_scaleY = 1f; } m_scaleY = GUI.HorizontalSlider(new Rect(150, 158, 90, 18), m_scaleY, 0.1f, 5f); //font bool supportStyles = m_font.m_boldExists && m_font.m_italicExists; if (GUI.Button(new Rect(3, 180, (supportStyles ? 126 : 213), 25), m_fontName)) { ProceduralObjectsLogic.PlaySound(); openCharTable.Invoke(m_font); } if (GUI.Button(new Rect((supportStyles ? 128 : 215), 180, 26, 25), "▼")) { ProceduralObjectsLogic.PlaySound(); // SetFont(textManager.fontManager.GetNextFont(m_font)); scrollFontsPos = Vector2.zero; expandFontsSelector = !expandFontsSelector; } if (supportStyles) { string[] styles = new string[] { LocalizationManager.instance.current["textStyle_normal"], "<b>" + LocalizationManager.instance.current["textStyle_bold"] + "</b>", "<i>" + LocalizationManager.instance.current["textStyle_italic"] + "</i>" }; if (m_font.m_stylesNames != null) { if (m_font.m_stylesNames.Length == 3) { styles = m_font.m_stylesNames; } } m_style = TextCustomizationManager.IntToStyle(GUI.Toolbar(new Rect(158, 180, 85, 25), TextCustomizationManager.SelectedStyle(m_style), styles)); } if (expandFontsSelector) { TextureFont fontSelected; if (FontManager.instance.FontSelector(new Rect(3, 207, 240, 160), scrollFontsPos, out fontSelected, out scrollFontsPos)) { SetFont(fontSelected); expandFontsSelector = false; scrollFontsPos = Vector2.zero; } } } else if (m_type == 1) // COLOR RECT { GUI.Label(new Rect(4, 80, 100, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_width"] + " :</size>"); // m_width = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(4, 44, 200, 25), m_width, 1, 2048)); if (widthField == null) { widthField = new GUIUtils.FloatInputField(m_width); } m_width = (uint)widthField.DrawField(new Rect(74, 79, 170, 35), m_width, false, 0f, 1024f, true, Mathf.Abs(Mathf.Round(textManager.windowTex.width - x))).returnValue; GUI.Label(new Rect(4, 115, 100, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_height"] + " :</size>"); if (heightField == null) { heightField = new GUIUtils.FloatInputField(m_height); } m_height = (uint)heightField.DrawField(new Rect(74, 117, 170, 35), m_height, false, 0f, 1024f, true, Mathf.Abs(Mathf.Round(textManager.windowTex.height - y))).returnValue; GUI.Label(new Rect(4, 154, 200, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_opacity"] + " : " + ((int)(m_fontColor.a * 100)).ToString() + "%</size>"); m_fontColor.a = GUI.HorizontalSlider(new Rect(4, 176, 200, 25), m_fontColor.a, 0f, 1f); if (borderColor == null) { borderColor = Color.white; } GUI.Label(new Rect(4, 193, 200, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_border"] + " : " + borderSize.ToString() + " px</size>"); borderSize = (uint)Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(4, 215, 200, 25), borderSize, 0f, 20f)); borderPainter = GUIPainter.DrawPainterSampleOnly(borderPainter, new Vector2(214, 198), borderColor, (c) => { borderColor = c; }, () => { if (textManager.colorPickerSelected == borderPainter) { textManager.colorPickerSelected = null; } else { textManager.colorPickerSelected = borderPainter; } }); } // POSITION GUIUtils.DrawSeparator(new Vector2(3, 29), 241); GUI.Label(new Rect(3, 30, 75, 21), "<size=12>" + LocalizationManager.instance.current["position"] + " :</size>"); // float newX, newY; if (posXfield == null) { posXfield = new GUIUtils.FloatInputField(x); posYfield = new GUIUtils.FloatInputField(y); } GUI.Label(new Rect(3, 51, 24, 22), "<size=12>X :</size>"); x = posXfield.DrawField(new Rect(27, 50, 83, 22), "textPosX", x, true).returnValue; GUI.Label(new Rect(111, 51, 24, 22), "<size=12>Y :</size>"); y = posYfield.DrawField(new Rect(135, 50, 83, 22), "textPosY", y, true).returnValue; // rotation if (GUI.Button(new Rect(220, 50, 25, 23), ProceduralObjectsMod.Icons[5])) { ProceduralObjectsLogic.PlaySound(); if (m_type == 0) { if (m_rotation == 0) { m_rotation = 4; } else if (m_rotation == 4) { m_rotation = 1; } else if (m_rotation == 1) { m_rotation = 2; } else if (m_rotation == 2) { m_rotation = 0; } } else if (m_type == 1) { var h = m_height; m_height = m_width; m_width = h; } } GUI.EndGroup(); }
public bool UIButton(Vector2 pos, TextCustomizationManager textManager, bool showDelete) { var rect = new Rect(pos, new Vector2(235, 31)); if (GUI.Button(new Rect(pos.x, pos.y, textManager.parameters.Count() == 1 ? 156 : 130, 31), string.Empty)) { ProceduralObjectsLogic.PlaySound(); expandFontsSelector = false; scrollFontsPos = Vector2.zero; return(true); } GUI.BeginGroup(rect); if (m_type == 0) { GUI.Label(new Rect(3, 5, textManager.parameters.Count() == 1 ? 153 : 127, 23), m_text); } else // if m_type == 1 { GUI.color = m_fontColor; GUI.Label(new Rect(2, 4, 25, 24), "██"); GUI.color = Color.white; GUI.Label(new Rect(26, 5, textManager.parameters.Count() == 1 ? 130 : 104, 23), "<i>" + LocalizationManager.instance.current["colorRect"] + "</i>"); } if (GUI.Button(new Rect(textManager.parameters.Count() == 1 ? 158 : 132, 3, 25, 25), ProceduralObjectsMod.Icons[locked ? 8 : 9])) { ProceduralObjectsLogic.PlaySound(); locked = !locked; } if (textManager.parameters.CanFieldMoveUp(this)) { if (GUI.Button(new Rect(158, 15.5f, 25, 12), ProceduralObjectsMod.Icons[7])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.MoveFieldUp(this); } } if (textManager.parameters.CanFieldMoveDown(this)) { if (GUI.Button(new Rect(158, 3, 25, 12), ProceduralObjectsMod.Icons[6])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.MoveFieldDown(this); } } if (GUI.Button(new Rect(184, 3, 25, 25), ProceduralObjectsMod.Icons[0])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.AddField(TextField.Clone(this, false)); } if (showDelete) { GUI.color = Color.red; if (GUI.Button(new Rect(210, 3, 25, 25), "X")) { ProceduralObjectsLogic.PlaySound(); if (textManager.selectedField == this) { textManager.selectedField = null; } textManager.parameters.RemoveField(this); } GUI.color = Color.white; } GUI.EndGroup(); return(false); }
public void DrawUI(Vector2 position, TextCustomizationManager textManager, Action <TextureFont> openCharTable, bool showDelete) { Rect rect = new Rect(position.x, position.y, 350, minimized ? 31 : 123); GUI.Box(rect, string.Empty); GUI.BeginGroup(rect); if (m_type == 0) { m_text = GUI.TextField(new Rect(3, 3, textManager.parameters.m_textFields.Count == 1 ? 268 : 242, 25), m_text); } else // if m_type == 1 { GUI.color = m_fontColor; GUI.Label(new Rect(3, 4, 25, 24), "██"); GUI.color = Color.white; GUI.Label(new Rect(28, 5, 212, 23), LocalizationManager.instance.current["colorRect"]); if (GUI.Button(new Rect(textManager.parameters.Count() == 1 ? 246 : 220, 3, 25, 25), ProceduralObjectsMod.Icons[locked ? 8 : 9])) { ProceduralObjectsLogic.PlaySound(); locked = !locked; } } if (!minimized) { if (m_type == 0) // TEXT FIELD { GUI.Label(new Rect(4, 26, 75, 22), "<size=12>" + LocalizationManager.instance.current["font_size"] + " : " + m_fontSize.ToString() + "</size>"); m_fontSize = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(80, 32, 113, 25), m_fontSize, 5, 150)); GUI.Label(new Rect(4, 47, 90, 22), "<size=12>" + LocalizationManager.instance.current["font_spacing"] + " : " + m_spacing.ToString() + "</size>"); m_spacing = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(95, 53, 98, 25), m_spacing, 0, 9)); if (!m_font.m_disableColorOverwriting) { GUI.Label(new Rect(205, 29, 75, 22), "<size=12>" + LocalizationManager.instance.current["font_color"] + " :</size>"); m_fontColor.r = GUI.HorizontalSlider(new Rect(205, 52, 80, 18), m_fontColor.r, 0f, 1f); m_fontColor.g = GUI.HorizontalSlider(new Rect(205, 69, 80, 18), m_fontColor.g, 0f, 1f); m_fontColor.b = GUI.HorizontalSlider(new Rect(205, 86, 80, 18), m_fontColor.b, 0f, 1f); GUI.Label(new Rect(289, 48, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_r"] + " : " + (int)(m_fontColor.r * 255f) + "</size>"); GUI.Label(new Rect(289, 65, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_g"] + " : " + (int)(m_fontColor.g * 255f) + "</size>"); GUI.Label(new Rect(289, 82, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_b"] + " : " + (int)(m_fontColor.b * 255f) + "</size>"); } if (textManager.fontManager.previousFontExists(m_font)) { if (GUI.Button(new Rect(4, 68, 26, 25), "◄")) { ProceduralObjectsLogic.PlaySound(); SetFont(textManager.fontManager.GetPreviousFont(m_font)); } } else { GUI.skin.box.normal.textColor = TextCustomizationManager.inactiveGrey; GUI.Label(new Rect(4, 68, 26, 25), "◄", GUI.skin.box); GUI.skin.box.normal.textColor = Color.white; } if (GUI.Button(new Rect(30, 68, 147, 25), m_fontName)) { ProceduralObjectsLogic.PlaySound(); openCharTable.Invoke(m_font); } if (textManager.fontManager.nextFontExists(m_font)) { if (GUI.Button(new Rect(177, 68, 26, 25), "►")) { ProceduralObjectsLogic.PlaySound(); SetFont(textManager.fontManager.GetNextFont(m_font)); } } else { GUI.skin.box.normal.textColor = TextCustomizationManager.inactiveGrey; GUI.Label(new Rect(177, 68, 26, 25), "►", GUI.skin.box); GUI.skin.box.normal.textColor = Color.white; } if (m_font.m_boldExists && m_font.m_italicExists) { string[] styles = new string[] { LocalizationManager.instance.current["textStyle_normal"], "<b>" + LocalizationManager.instance.current["textStyle_bold"] + "</b>", "<i>" + LocalizationManager.instance.current["textStyle_italic"] + "</i>" }; if (m_font.m_stylesNames != null) { if (m_font.m_stylesNames.Length == 3) { styles = m_font.m_stylesNames; } } m_style = TextCustomizationManager.IntToStyle(GUI.Toolbar(new Rect(4, 95, 91, 25), TextCustomizationManager.SelectedStyle(m_style), styles)); } GUI.Label(new Rect(98, 99, 67, 26), LocalizationManager.instance.current["scale_txt"] + " :"); if (GUI.Button(new Rect(165, 99, 10, 26), "X", GUI.skin.label)) { m_scaleX = 1f; } m_scaleX = GUI.HorizontalSlider(new Rect(176, 103, 78, 18), m_scaleX, 0.1f, 5f); if (GUI.Button(new Rect(255, 99, 10, 26), "Y", GUI.skin.label)) { m_scaleY = 1f; } m_scaleY = GUI.HorizontalSlider(new Rect(266, 103, 78, 18), m_scaleY, 0.1f, 5f); } else if (m_type == 1) // COLOR RECT { GUI.Label(new Rect(4, 26, 100, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_width"] + " : " + m_width.ToString() + "</size>"); m_width = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(4, 44, 200, 25), m_width, 1, 2048)); GUI.Label(new Rect(4, 57, 100, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_height"] + " : " + m_height.ToString() + "</size>"); m_height = (uint)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(4, 75, 200, 25), m_height, 1, 2048)); GUI.Label(new Rect(4, 90, 100, 22), "<size=12>" + LocalizationManager.instance.current["colorRect_opacity"] + " : " + ((int)(m_fontColor.a * 100)).ToString() + "%</size>"); m_fontColor.a = GUI.HorizontalSlider(new Rect(4, 108, 150, 25), m_fontColor.a, 0f, 1f); GUI.Label(new Rect(217, 36, 75, 22), "<size=12>" + LocalizationManager.instance.current["font_color"] + " :</size>"); m_fontColor.r = GUI.HorizontalSlider(new Rect(217, 59, 80, 18), m_fontColor.r, 0f, 1f); m_fontColor.g = GUI.HorizontalSlider(new Rect(217, 76, 80, 18), m_fontColor.g, 0f, 1f); m_fontColor.b = GUI.HorizontalSlider(new Rect(217, 93, 80, 18), m_fontColor.b, 0f, 1f); GUI.Label(new Rect(301, 55, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_r"] + " : " + (int)(m_fontColor.r * 255f) + "</size>"); GUI.Label(new Rect(301, 72, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_g"] + " : " + (int)(m_fontColor.g * 255f) + "</size>"); GUI.Label(new Rect(301, 89, 75, 22), "<size=12>" + LocalizationManager.instance.current["rgb_b"] + " : " + (int)(m_fontColor.b * 255f) + "</size>"); } // rotation if (GUI.Button(new Rect(324, 28.6f, 25, 23), ProceduralObjectsMod.Icons[5])) { ProceduralObjectsLogic.PlaySound(); if (m_type == 0) { if (m_rotation == 0) { m_rotation = 4; } else if (m_rotation == 4) { m_rotation = 1; } else if (m_rotation == 1) { m_rotation = 2; } else if (m_rotation == 2) { m_rotation = 0; } } else if (m_type == 1) { var h = m_height; m_height = m_width; m_width = h; } } } if (textManager.parameters.CanFieldMoveUp(this)) { if (GUI.Button(new Rect(246, 3, 25, 12), ProceduralObjectsMod.Icons[6])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.MoveFieldUp(this); } } if (textManager.parameters.CanFieldMoveDown(this)) { if (GUI.Button(new Rect(246, 15.5f, 25, 12), ProceduralObjectsMod.Icons[7])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.MoveFieldDown(this); } } if (GUI.Button(new Rect(272, 3, 25, 25), ProceduralObjectsMod.Icons[0])) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.AddField(TextField.Clone(this, false)); } if (GUI.Button(new Rect(298, 3, 25, 25), ProceduralObjectsMod.Icons[minimized ? 1 : 2])) { ProceduralObjectsLogic.PlaySound(); minimized = !minimized; } if (showDelete) { GUI.color = Color.red; if (GUI.Button(new Rect(324, 3, 25, 25), "X")) { ProceduralObjectsLogic.PlaySound(); textManager.parameters.RemoveField(this); } GUI.color = Color.white; } GUI.EndGroup(); }
private void draw(int id) { GUI.DragWindow(new Rect(0, 0, windowRect.width - 52, 28)); if (GUIUtils.CloseHelpButtons(windowRect, "Text_Customization")) { CloseWindow(); } else { var scrollview = GUI.BeginScrollView(new Rect(5, 30, windowRect.width - 265, windowRect.height - 60), scrollTex, new Rect(0, 0, windowTex.width * zoomFactor, windowTex.height * zoomFactor)); if (!Input.GetKey(KeyCode.LeftControl)) { scrollTex = scrollview; } GUI.DrawTexture(new Rect(0, 0, windowTex.width * zoomFactor, windowTex.height * zoomFactor), windowTex as Texture); if (movingField == -1) { if (!placingRect && !placingText) { for (int i = 0; i < parameters.Count(); i++) { if (parameters[i].locked) { continue; } if (GUI.Button(new Rect(parameters[i].x * zoomFactor, parameters[i].y * zoomFactor, parameters[i].texWidth * zoomFactor, parameters[i].texHeight * zoomFactor), string.Empty, GUI.skin.label)) { ProceduralObjectsLogic.PlaySound(); dragTexPos = new Vector2(((GUIUtils.MousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor) - parameters[i].x, ((GUIUtils.MousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor) - parameters[i].y); movingField = i; placingText = false; placingRect = false; } } } } GUI.EndScrollView(); // zoom if (GUI.RepeatButton(new Rect(5, windowRect.height - 29, 27, 25), "<size=20><b>+</b></size>")) { zoomIn(); } if (GUI.RepeatButton(new Rect(35, windowRect.height - 29, 27, 25), "<size=22><b>-</b></size>")) { zoomOut(); } GUI.Label(new Rect(67, windowRect.height - 28, 220, 27), LocalizationManager.instance.current["zoom"]); // parameters box GUI.Label(new Rect(windowRect.width - 255, 32, 260, 27), "<size=17>" + LocalizationManager.instance.current["text_fields"] + "</size>"); // copy if (copiedField == null) { GUI.Box(new Rect(windowRect.width - 35, 32, 25, 23), ProceduralObjectsMod.Icons[0]); } else { if (GUI.Button(new Rect(windowRect.width - 35, 32, 25, 23), ProceduralObjectsMod.Icons[0])) { ProceduralObjectsLogic.PlaySound(); selectedField = parameters.AddField(TextField.Clone(copiedField, false)); } } if (parameters.Count() == 0) { GUI.Box(new Rect(windowRect.width - 257, 60, 387, separatorListEditionZone - 60), string.Empty); } scrollParams = GUI.BeginScrollView(new Rect(windowRect.width - 256, 62, 254, separatorListEditionZone - 64), scrollParams, new Rect(0, 0, 235, parameters.Count() * 33 + 69)); int j = 2; for (int i = 0; i < parameters.Count(); i++) { var param = parameters[parameters.Count() - i - 1]; if (param.UIButton(new Vector2(0, j), this, movingField == -1)) { if (selectedField == param) { selectedField = null; } else { selectedField = param; } placingRect = false; placingText = false; placingRectFirstpoint = Vector2.down; } j += 33; } if (GUI.Button(new Rect(3, j, 245, 30), "<b>+</b> " + LocalizationManager.instance.current["add_field"])) { ProceduralObjectsLogic.PlaySound(); placingText = true; placingRect = false; placingRectFirstpoint = Vector2.down; // selectedField = parameters.AddField(fontManager.Arial, 0); } if (GUI.Button(new Rect(3, j + 33, 245, 30), "<b>+</b> " + LocalizationManager.instance.current["add_color_rect"])) { ProceduralObjectsLogic.PlaySound(); placingRect = true; placingText = false; placingRectFirstpoint = Vector2.down; // selectedField = parameters.AddField(fontManager.Arial, 1); } GUI.EndScrollView(); if (GUI.RepeatButton(new Rect(windowRect.width - 257, separatorListEditionZone - 1.5f, 387, 6), string.Empty)) { movingField = -3; } GUI.Box(new Rect(windowRect.width - 257, separatorListEditionZone + 5, 387, windowRect.height - separatorListEditionZone - 18), string.Empty); if (selectedField != null) { selectedField.DrawUI(new Rect(windowRect.width - 255, separatorListEditionZone + 9, 245, windowRect.height - 290), this, ShowCharTable); if (_justPlacedTextNowFocusField) { GUI.FocusControl("TextFieldPOTextCustom"); _justPlacedTextNowFocusField = false; } } if (GUI.RepeatButton(new Rect(windowRect.width - 17, windowRect.height - 12, 16, 11), string.Empty)) { movingField = -2; } } }