void EditFolder(LuaModuleInfo moduleInfo, LuaFolder folder) { string folderPath = moduleInfo.moduleDirPath + ToLuaGenerater.Folder2Directory(folder); LuaFileStatus status = ToLuaGenerater.GetFileStatus(moduleInfo.moduleDirPath, folder); switch (status) { case LuaFileStatus.Nothing: if (GUILayout.Button("生成 " + folder + " 文件夹")) { ToLuaGenerater.GeneratedFolder(folderPath); } break; case LuaFileStatus.Folder_Only: if (folder == LuaFolder.Vo) { AddVoFile(moduleInfo); } else if (folder == LuaFolder.Controller) { AddCommandFile(moduleInfo); } else if (GUILayout.Button("生成 " + folder + ".lua 文件")) { ToLuaGenerater.GeneratedLuaFile(moduleInfo.moduleDirPath, moduleInfo.moduleName, moduleInfo.moduleName, folder); } break; case LuaFileStatus.Folder_And_LuaFile: if (folder == LuaFolder.Vo) { AddVoFile(moduleInfo); } else if (folder == LuaFolder.Controller) { AddCommandFile(moduleInfo); } else { EditorGUILayout.LabelField(moduleInfo.moduleName + folder + ".lua 文件已经生成"); } break; } }
void EditModulelist() { for (int i = 0; i < moduleInfoList.Count; i++) { LuaModuleInfo moduleInfo = moduleInfoList[i]; if (moduleInfo.isOpen) { DrawFoldout(moduleInfo); 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, "module", moduleInfo.moduleName); 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++; { EditorGUILayout.LabelField("Value Objects:"); if (moduleInfo.voList.Count > 0) { for (int j = 0; j < moduleInfo.voList.Count; j++) { EditorGUILayout.LabelField((j + 1).ToString(), moduleInfo.voList[j] + ".lua"); } } EditFolder(moduleInfo, LuaFolder.Vo); EditorGUILayout.LabelField("Controllers:"); if (moduleInfo.ctrlList.Count > 0) { for (int j = 0; j < moduleInfo.ctrlList.Count; j++) { EditorGUILayout.LabelField((j + 1).ToString(), moduleInfo.ctrlList[j] + ".lua"); } } EditFolder(moduleInfo, LuaFolder.Controller); } 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); luaTable.SetHashTable(viewInfo.viewName, "module", moduleInfo.moduleName); moduleInfo.viewList.Add(viewInfo); moduleInfo.newViewMdrName = ""; } EditorGUILayout.EndHorizontal(); EditorUtils.DrawHorizontalSplitter(); EditorGUI.indentLevel--; } else { DrawFoldout(moduleInfo); } } }