Esempio n. 1
0
    private void OnGUI()
    {
        if (luaTable != null)
        {
            if (moduleInfoList == null)
            {
                if (GUILayout.Button("Load All Modules"))
                {
                    LoadAllModules();
                }
            }
            else
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(position.height * 0.8f));
                EditModulelist();
                EditorGUILayout.EndScrollView();
                if (GUILayout.Button("重新生成 Mvc 文件"))
                {
                    string fileText = luaTable.ToString();
                    FileUtils.SaveTextFile(ViewConfigPath, fileText);
                    Debug.Log("保存成功 \n" + fileText);
                    GeneratedMvcFiles();
                }
            }
        }
        EditorUtils.DrawHorizontalSplitter();
        EditorGUILayout.BeginHorizontal();
        moduleName = EditorGUILayout.TextField("新增模块 模块名:", moduleName);
        if (GUILayout.Button("生成新模块", endButtonWidth))
        {
            if (!ToLuaGenerater.FileNameValid(moduleName, this))
            {
                return;
            }
            if (luaTable.HasTable(moduleName))
            {
                ShowNotification(new GUIContent("该模块已经存在"));
                return;
            }

            Dictionary <string, object> table = luaTable.SetTable(moduleName);
            table.Add("name", moduleName);
            GeneratedModuleFolders(moduleName);

            LoadAllModules();
        }
        EditorGUILayout.EndHorizontal();
    }
Esempio n. 2
0
 void AddVoFile(LuaModuleInfo moduleInfo)
 {
     EditorGUILayout.BeginHorizontal();
     newVoName = EditorGUILayout.TextField("新Vo 名称:", newVoName);
     if (GUILayout.Button("新增", endButtonWidth))
     {
         if (!ToLuaGenerater.FileNameValid(newVoName, this))
         {
             return;
         }
         ToLuaGenerater.GeneratedLuaFile(moduleInfo.moduleDirPath, moduleInfo.moduleName, newVoName, LuaFolder.Vo);
         RefreshVos(moduleInfo);
         newVoName = "";
     }
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 3
0
    void EditModulelist()
    {
        for (int i = 0; i < moduleInfoList.Count; i++)
        {
            EditorGUI.indentLevel++;
            {
                LuaModuleInfo moduleInfo = moduleInfoList[i];
                EditorGUILayout.LabelField("模块:", moduleInfo.moduleName);
                EditorGUI.indentLevel++;
                EditorGUILayout.LabelField("Views:");
                EditorGUI.indentLevel++;
                for (int j = 0; j < moduleInfo.viewList.Count; j++)
                {
                    EditorGUI.indentLevel++;
                    LuaViewInfo viewInfo = moduleInfo.viewList[j];

                    if (luaTable.HasTable(viewInfo.viewName))
                    {//已经存在配置
                        Dictionary <string, object> table = luaTable.GetTable(viewInfo.viewName);
                        EditorGUILayout.LabelField("View name:", viewInfo.viewName);
                        if (string.IsNullOrEmpty(viewInfo.prefabUrl))
                        {
                            viewInfo.prefabUrl = luaTable.GetString(viewInfo.viewName, "prefab");
                        }
                        oldString = viewInfo.prefabUrl;
                        FetchPrefabUrl(viewInfo);
                        if (oldString != viewInfo.prefabUrl)
                        {
                            luaTable.SetHashTable(viewInfo.viewName, "prefab", viewInfo.prefabUrl);
                        }
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("搜索到新的View:" + viewInfo.viewName + "是否新建?");
                        if (GUILayout.Button("新建", endButtonWidth))
                        {
                            luaTable.SetTable(viewInfo.viewName);
                            luaTable.SetHashTable(viewInfo.viewName, "name", viewInfo.viewName);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.BeginHorizontal();
                    {
                        LuaFileStatus status = ToLuaGenerater.GetFileStatus(moduleInfo.moduleDirPath, LuaFolder.Mdr, viewInfo.viewName);
                        if (status == LuaFileStatus.Folder_Only || status == LuaFileStatus.Folder_And_LuaFile)
                        {
                            EditorGUILayout.LabelField("Mdr文件:");
                            if (GUILayout.Button("生成 " + viewInfo.viewName + " 的 Mediator 文件"))
                            {
                                ToLuaGenerater.GeneratedLuaFile(moduleInfo.moduleDirPath, moduleInfo.moduleName, viewInfo.viewName, LuaFolder.Mdr);
                            }
                        }
                        else if (status == LuaFileStatus.Folder_And_TagLuaFile)
                        {
                            EditorGUILayout.LabelField("Mdr文件:", viewInfo.viewName + LuaFolder.Mdr + ".lua 文件已经生成");
                        }
                        else
                        {
                            EditorGUILayout.LabelField("Mdr文件:", status.ToString());
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUI.indentLevel--;
                    EditorGUILayout.Space();
                }
                EditorGUI.indentLevel--;

                //Vos
                EditorGUI.indentLevel++;
                if (moduleInfo.voList.Count > 0)
                {
                    EditorGUILayout.LabelField("Value Objects:");
                    for (int j = 0; j < moduleInfo.voList.Count; j++)
                    {
                        EditorGUILayout.LabelField((j + 1).ToString(), moduleInfo.voList[j] + ".lua");
                    }
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Value Objects:");
                    EditFolder(moduleInfo, LuaFolder.Vo);
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel--;


                EditorGUILayout.Space();
                EditFolder(moduleInfo, LuaFolder.Model);
                EditFolder(moduleInfo, LuaFolder.Service);

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                moduleInfo.newViewMdrName = EditorGUILayout.TextField("新View 名称:", moduleInfo.newViewMdrName);
                if (GUILayout.Button("新增", endButtonWidth))
                {
                    if (!ToLuaGenerater.FileNameValid(moduleInfo.newViewMdrName, this))
                    {
                        return;
                    }
                    LuaViewInfo viewInfo = new LuaViewInfo(moduleInfo.newViewMdrName);
                    viewInfo.viewName    = moduleInfo.newViewMdrName;
                    viewInfo.viewDirPath = moduleInfo.viewDirPath;
                    luaTable.SetTable(viewInfo.viewName);
                    luaTable.SetHashTable(viewInfo.viewName, "name", viewInfo.viewName);
                    moduleInfo.viewList.Add(viewInfo);
                    moduleInfo.newViewMdrName = "";
                }
                EditorGUILayout.EndHorizontal();
                EditorUtils.DrawHorizontalSplitter();
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }
    }