Пример #1
0
        public void Select(DropDownCellData data)
        {
            this.sel = data;
            UIText title = trigger.GetComponentInChildren <UIText>();

            title.textKey = null;
            if (preStrKey != null)
            {
                title.SetText("{0}  {1}", Lexicon.Get(preStrKey), data.comboText);
            }
            else
            {
                title.SetText(data.comboText);
            }
            if (ui.activeSelf)
            {
                sortGrid.SelectCell(data);
            }
            if (!prefId.IsEmpty())
            {
                UITableCell c = sortGrid.GetSelectedCell <UITableCell>();
                if (c != null)
                {
                    int index = sortGrid.GetIndex(c);
                    pref.SetInt(prefId, index);
                }
            }
        }
Пример #2
0
        private bool DrawTextMod()
        {
            bool changed = false;
            int  row     = grid.rowCount;
            int  col     = grid.columnCount;

            mod = EditorGUILayout.Foldout(mod, "Text Mod");
            if (mod)
            {
                EditorGUI.indentLevel += 2;
                for (int r = 0; r < row; r++)
                {
                    EditorGUILayout.BeginHorizontal();
                    for (int c = 0; c < col; c++)
                    {
                        UITableCell cell = grid.GetCell(r, c);
                        UILabel     l    = cell != null?cell.GetComponentInChildren <UILabel>() : null;

                        string s = l != null? l.text: "";
                        if (EditorGUIUtil.TextField(null, ref s, GUILayout.Width(70)) && l != null)
                        {
                            l.SetText(s);
                            changed = true;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel -= 2;
            }
            return(changed);
        }
Пример #3
0
 public UITablePrefabs(UITableCell defaultPrefab,
                       UITableCell[] rowPrefabs, UITableCell[] columnPrefabs,
                       int rowHeader, int colHeader)
 {
     this.defaultPrefab = defaultPrefab;
     this.rowPrefab     = rowPrefabs;
     this.columnPrefab  = columnPrefabs;
     this.rowHeader     = rowHeader;
     this.columnHeader  = colHeader;
 }
Пример #4
0
        private bool DrawCell(int r, int c)
        {
            bool        changed = false;
            UITableCell cell    = table.GetCell(r, c);

            if (EditorGUIUtil.ObjectField <UITableCell>(ref cell, true, W_Option, GUILayout.Height(HEIGHT - 1)))
            {
                table.SetCell(r, c, cell);
                changed = true;
            }
            return(changed);
        }
Пример #5
0
 private void SetCell(int r, int c, UITableCell cell)
 {
     if (cell != null)
     {
         int oldIndex = table.GetIndex(cell);
         if (oldIndex >= 0)
         {
             table.components[oldIndex] = null;
         }
         NGUIUtil.DisableAnchor(cell.transform);
     }
     table.SetCell(r, c, cell);
 }
Пример #6
0
        public UITableCell Instantiate(int row, int col)
        {
            UITableCell prefab   = GetPrefab(row, col);
            UITableCell instance = prefab.InstantiateEx(prefab.transform.parent, false);

            instance.go.SetActive(true);
            StringBuilder str = new StringBuilder(prefab.name.Length + 8);

            str.Append(prefab.name);
            str.Append("_").Append(row);
            str.Append("_").Append(col);
            instance.name = str.ToString();
            return(instance);
        }
Пример #7
0
 /// <summary>
 /// Default behaviour for the Label, Slider, Sprite
 /// </summary>
 /// <param name="t">T.</param>
 /// <param name="val">Value.</param>
 /// <param name="status">Status.</param>
 public static void SetValue(UITableLayout grid, UITableCell c, int row, int column, object val, Action <UITableCell> initFunc = null)
 {
     if (c != null)
     {
         c.containerGrid = grid;
         c.row           = row;
         c.column        = column;
         c.SetCell(val, initFunc);
     }
     else
     {
         c.go.SetActive(val != null);
     }
 }
Пример #8
0
        private bool DrawAddColumn()
        {
            showAddColumn = EditorGUILayout.Foldout(showAddColumn, "Add Column");
            if (showAddColumn)
            {
                if (!grid.isHorizontal)
                {
                    EditorGUILayout.HelpBox("Currently only Horizontal grid type is supported", MessageType.Warning);
                    return(false);
                }
                EditorGUIUtil.ObjectField <UILabel>("Title Label(Prefab)", ref titleLabelPrefab, true, GUILayout.ExpandWidth(false));
                if (EditorGUIUtil.PopupNullable <GridStyle>(null, ref currentStyle, gridStyles))
                {
                    selectedColumn = null;
                    return(true);
                }
                if (GUILayout.Button("Apply"))
                {
                    grid.totalWidth = currentStyle.width;
                    Vector2 minSize = grid.cellMinSize;
                    minSize.y        = currentStyle.rowHeight;
                    grid.cellMinSize = minSize;
                }
                if (currentStyle != null)
                {
                    EditorGUIUtil.PopupNullable <ColumnWidth>(null, ref selectedColumn, currentStyle.columnWidth);
                    GUI.enabled = titleLabelPrefab != null && selectedColumn != null;
                    if (GUILayout.Button("Add"))
                    {
                        int lastCol = GetLastColumn();

                        for (int r = 1, max = grid.rowHeader; r < max; r++)
                        {
                            UITableCell cell = null;
                            #pragma warning disable 0618
                            grid.Insert((lastCol + 1) * r - 1, cell);
                            #pragma warning restore 0618
                        }
                        grid.maxPerLine = Math.Max(lastCol + 1, grid.maxPerLine);
                        grid.InitArray();
                        grid.columnWidth[lastCol] = selectedColumn.width;
                        grid.SetCell(grid.rowHeader - 1, lastCol, CreateLabel(selectedColumn.name, lastCol + 1));
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #9
0
        /**
         * Row중 UILabel인 경우 text color를 바꾸어준다.
         * @param row row 값은 title row를 포함한 실제 row번호(zero-based)
         */
        public static void SetRowColor(this UITableLayout table, int row, Color color)
        {
            string colorStr = NGUIUtil.ConvertColor2Str(color);

            for (int col = table.columnHeader; col < table.columnCount; col++)
            {
                UITableCell c = table.GetCell(row + table.rowHeader, col);
                if (c != null)
                {
                    UILabel label = c.GetComponent <UILabel>();
                    if (label != null)
                    {
                        label.SetText(colorStr + label.text);
                    }
                }
            }
        }
Пример #10
0
        private bool DrawTest()
        {
            showTest = EditorGUILayout.Foldout(showTest, "Test");
            bool changed = false;

            if (showTest)
            {
                EditorGUI.indentLevel += 2;
                EditorGUIUtil.ObjectField <UIFont>("Font", ref testFont, true);
                int row = grid.rowCount;
                int col = grid.columnCount;
                if (EditorGUIUtil.IntField("Font Size", ref fontSize, GUILayout.ExpandWidth(false)))
                {
                    for (int r = 0; r < row; r++)
                    {
                        for (int c = 0; c < col; c++)
                        {
                            UILabel label = grid.GetCell(r, c).GetComponent <UILabel>();
                            if (label != null)
                            {
                                label.transform.localScale = new Vector3(fontSize, fontSize, 1);
                            }
                        }
                    }
                }
                if (EditorGUIUtil.ColorField("Font Color", ref fontColor, GUILayout.ExpandWidth(false)))
                {
                    for (int r = grid.rowHeader; r < row; r++)
                    {
                        for (int c = grid.columnHeader; c < col; c++)
                        {
                            UILabel label = grid.GetCell(r, c).GetComponent <UILabel>();
                            if (label != null)
                            {
                                label.color = fontColor;
                                label.MarkAsChanged();
                            }
                        }
                    }
                }
                Array.Resize(ref testStrings, grid.maxPerLine);
                for (int i = 0; i < grid.maxPerLine; i++)
                {
                    EditorGUIUtil.TextField(i.ToString(), ref testStrings[i], GUILayout.ExpandWidth(false));
                }
                GUI.enabled = testFont != null;
                if (GUILayout.Button("Fill Data"))
                {
                    for (int r = grid.rowHeader; r < row; r++)
                    {
                        for (int c = grid.columnHeader; c < col; c++)
                        {
                            UITableCell cell = grid.GetCell(r, c);
                            if (cell == null)
                            {
                                UILabel label = NGUITools.AddWidget <UILabel>(grid.gameObject);
                                label.bitmapFont = testFont;
                                label.name       = "__TEST__";
                                label.SetText(testStrings[grid.isHorizontal?c:r]);
                                label.transform.localScale = new Vector3(fontSize, fontSize, 1);
                                label.color = fontColor;
                                label.MarkAsChanged();
                                UILabelCell lc = label.gameObject.AddComponent <UILabelCell>();
                                lc.label = label;
                                grid.SetCell(r, c, lc);
                            }
                        }
                    }
                    changed = true;
                }
                GUI.enabled            = true;
                EditorGUI.indentLevel -= 2;
            }
            return(changed);
        }
Пример #11
0
 public UITablePrefabs(UITableCell defaultPrefab)
 {
     this.defaultPrefab = defaultPrefab;
 }