Пример #1
0
        private void OnGUI()
        {
            EditorGUILayout.Space();
            if (_luaReflect == null)
            {
                List <string> excelFileList = BattleEditorUtility.GetExcelFileList(Setting.excelFolder);
                for (int i = 0; i < excelFileList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(excelFileList[i]);
                    if (NeedGenerateHeaderJson(excelFileList[i]) && GUILayout.Button("Generate"))
                    {
                        ExcelEditor excelEditor = new ExcelEditor(excelFileList[i]);
                        excelEditor.GenerateHeaderJson(false);
                    }
                    if (GUILayout.Button("Force Generate"))
                    {
                        ExcelEditor excelEditor = new ExcelEditor(excelFileList[i]);
                        excelEditor.GenerateHeaderJson(true);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("请先启动游戏,并进入测试关卡", MessageType.Warning);
            }
            else
            {
                if (_luaReflectDict != null)
                {
                    EditorGUILayout.BeginHorizontal();
//                    foreach (var camp in Camp)
                    {
                        var camp = _camp[0];
                        EditorGUILayout.BeginVertical();
                        EditorGUILayout.LabelField(camp);
                        if (_luaReflectDict.TryGetValue(camp, out List <LuaReflect> list))
                        {
                            for (int i = 0; i < list.Count; i++)
                            {
                                LuaReflect luaReflect = list[i];
                                if (luaReflect)
                                {
                                    DrawLuaReflect(list, camp, luaReflect);
                                }
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Add Attacker" + _camp[0]))
                {
                    SelectWnd wnd = SelectWnd.Create("Select Attacker", this, _luaReflect, Setting.battleUnitExcelPath);
                    wnd.rowSelect = delegate(string battleUnit, int index) { AddBattle(battleUnit); };
                }
            }
        }
Пример #2
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);
        }
Пример #3
0
        static void DoExcelToLua(bool isForce)
        {
            setting = BattleEditorUtility.LoadSetting(SettingPath);
            string        md5Path       = Application.dataPath + setting.excelFolder + "md5.txt";
            List <string> excelFileList = BattleEditorUtility.GetExcelFileList(setting.excelFolder);

            md5Dict = BattleEditorUtility.GetDictionaryFromFile(md5Path);
            if (md5Dict == null)
            {
                md5Dict = new Dictionary <string, string>();
            }
            Debug.Log("<color=#3A9BF8FF>Begin Export</color><color=#FFFFFFFF>:</color>");
            for (int i = 0; i < excelFileList.Count; i++)
            {
                var excelFilePath = excelFileList[i];
                var excelFileName = Path.GetFileName(excelFilePath);
                var md5           = BattleEditorUtility.GetFileMD5(excelFilePath.Replace("/../", ""));
                md5Dict.TryGetValue(excelFileName, out string oldMd5);
                bool modify = true;
                if (string.IsNullOrEmpty(oldMd5))
                {
                    md5Dict.Add(excelFileName, md5);
                }
                else if (oldMd5 != md5)
                {
                    md5Dict[excelFileName] = md5;
                }
                else
                {
                    modify = false;
                }
                if (isForce || modify)
                {
                    Debug.Log($"<color=#3A9BF8FF>Export Lua Table - </color><color=#FFFFFFFF>{excelFileName}</color>");
                    ExcelEditor excelEditor = new ExcelEditor(excelFilePath);
                    excelEditor.Reload();
                    var outputPath = $"{setting.outputPath}/{Path.GetFileNameWithoutExtension(excelFilePath)}.lua";
                    GenerateLua(excelEditor.excelReader, outputPath);
                    BattleEditorUtility.DisplayProgress(i, excelFileList.Count, excelFilePath);
                }
            }
            Debug.Log("<color=#3A9BF8FF>End Export</color><color=#FFFFFFFF>:</color>");
            BattleEditorUtility.SaveDictionary(md5Path, md5Dict);
            EditorUtility.ClearProgressBar();
        }
Пример #4
0
        public new static SelectWnd Create(string title, EditorWindow parent, LuaReflect luaReflect, string excelPath)
        {
            Rect      rect = new Rect(parent.position.x + parent.position.width + 20, parent.position.y, parent.position.width, parent.position.height);
            SelectWnd wnd  = EditorWindow.CreateWindow <SelectWnd>(title);

            wnd.position = rect;
            ExcelEditor excelEditor = new ExcelEditor(excelPath);

            wnd.ShowWnd(excelEditor);
            int[] showRows = new int[excelEditor.dataTable.Rows.Count - 2];
            for (int i = 0; i < showRows.Length; i++)
            {
                showRows[i] = i + 2;
            }
            wnd.SetShowRows(showRows, false);
            wnd.luaReflect = luaReflect;
            return(wnd);
        }
Пример #5
0
 public void ShowWnd(EditorWindow parent, LuaReflect luaReflect, string excelPath)
 {
     this.luaReflect        = luaReflect;
     excelEditor            = new ExcelEditor(excelPath);
     excelEditor.LinkEditor = LinkEditor;
 }
Пример #6
0
 protected virtual void ShowWnd(ExcelEditor excelEditor)
 {
     this.excelEditor       = excelEditor;
     excelEditor.LinkEditor = LinkEditor;
 }