Ejemplo n.º 1
0
        public static Dictionary <string, ExcelColHeader> GetExcelHeaderList(string excelPath)
        {
            var jsonPath = Application.dataPath + excelPath.Replace(".xlsx", ".json");
            Dictionary <string, ExcelColHeader> excelColHeaders = new Dictionary <string, ExcelColHeader>();
            JsonData jsonData = JsonMapper.ToObject(LoadText(jsonPath));

            foreach (var key in jsonData.Keys)
            {
                ExcelColHeader header = new ExcelColHeader(key, jsonData[key]);
                excelColHeaders.Add(key, header);
            }
            return(excelColHeaders);
        }
Ejemplo n.º 2
0
        protected void LinkEditor(ExcelColHeader excelColHeader, DataRowCollection rows, int rowIndex, int colIndex, bool showAll)
        {
            if (childWnd)
            {
                childWnd.Close();
            }
            string vid = rows?[rowIndex][colIndex].ToString();

            if (showAll)
            {
                childWnd = SelectWnd.Create("Select " + excelColHeader.linkEditorLuaKey, this, luaReflect, excelColHeader.linkEditorUrl);
                ((SelectWnd)childWnd).SetSelectDelegate(delegate(string id)
                {
                    OnSelect(id, rowIndex, colIndex);
                });
            }
            else
            {
                childWnd = ListEditorWnd.Create(excelColHeader.linkEditorLuaKey, this, luaReflect, excelColHeader, vid);
            }
        }
Ejemplo n.º 3
0
        private void DisplayEnum(string title, string comment, int rowIndex, int colIndex, ExcelColHeader header)
        {
            var value       = _dataTable.Rows[rowIndex][colIndex].ToString();
            var options     = header.fieldEnum;
            int selectIndex = Array.IndexOf(options, value);
            var newIndex    = EditorGUILayout.Popup(new GUIContent(title, comment), selectIndex, options);

            if (newIndex != selectIndex)
            {
                _excelReader.SetCellValue(options[newIndex], rowIndex, colIndex);
            }
        }
Ejemplo n.º 4
0
        private void DisplaySliderFloat(string title, string comment, int rowIndex, int colIndex, ExcelColHeader header)
        {
            var value    = float.Parse(_dataTable.Rows[rowIndex][colIndex].ToString());
            var newValue = EditorGUILayout.Slider(new GUIContent(title, comment), value, header.minFloatValue, header.maxFloatValue);

            if (Math.Abs(value - newValue) > 0)
            {
                _excelReader.SetCellValue(newValue, rowIndex, colIndex);
            }
        }
Ejemplo n.º 5
0
        private void DisplayNumber(string title, string comment, int rowIndex, int colIndex, ExcelColHeader header)
        {
            EditorGUILayout.BeginHorizontal();
            string valueStr = _dataTable.Rows[rowIndex][colIndex].ToString();
            var    value    = string.IsNullOrEmpty(valueStr) ? 0 : double.Parse(valueStr);
            var    newValue = EditorGUILayout.DoubleField(new GUIContent(title, comment), value);

            if (Math.Abs(value - newValue) > 0)
            {
                _excelReader.SetCellValue(newValue, rowIndex, colIndex);
            }
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 6
0
        private void DisplayString(string title, string comment, int rowIndex, int colIndex, ExcelColHeader header)
        {
            EditorGUILayout.BeginHorizontal();
            var value    = _dataTable.Rows[rowIndex][colIndex].ToString();
            var newValue = EditorGUILayout.TextField(new GUIContent(title, comment), value);

            if (value != newValue)
            {
                _excelReader.SetCellValue(newValue, rowIndex, colIndex);
            }
            if (!string.IsNullOrEmpty(header.linkEditorUrl))
            {
                if (GUILayout.Button("edit", GUILayout.Width(50)))
                {
                    LinkEditor(header, _dataTable.Rows, rowIndex, colIndex, false);
                }
                if (GUILayout.Button("...", GUILayout.Width(50)))
                {
                    LinkEditor(header, _dataTable.Rows, rowIndex, colIndex, true);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 7
0
        public static ListEditorWnd Create(string title, EditorWindow parent, LuaReflect luaReflect, ExcelColHeader header, string vid)
        {
            Rect          rect = new Rect(parent.position.x + parent.position.width + 20, parent.position.y, parent.position.width, parent.position.height);
            ListEditorWnd wnd  = EditorWindow.CreateWindow <ListEditorWnd>(title);

            wnd.position = rect;
            ExcelEditor excelEditor = new ExcelEditor(header.linkEditorUrl);

            wnd.ShowWnd(excelEditor);
            wnd.SetShowRows(excelEditor.GetRowIndexes(header.linkEditorField, vid), true);
            wnd.header     = header;
            wnd.luaReflect = luaReflect;
            return(wnd);
        }