diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs index 08afeb93fc..2e804133ad 100644 --- a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs @@ -14,12 +14,15 @@ namespace GameEditor.FrameTool { string tempConfigPath; string configPath; + string downloadConfigPath; string previous; Dictionary dic; - Dictionary curDic; - bool isFinish; + Dictionary indexDic; + //Dictionary curDic; + //bool isFinish; string addKey; string targetPath; + int index; // Add menu named "My Window" to the Window menu [MenuItem("Build/Config")] static void Init() @@ -33,31 +36,50 @@ namespace GameEditor.FrameTool void OnGUI() { EditorGUILayout.BeginVertical(); - if (GUILayout.Button("加载config模板", GUILayout.ExpandWidth(false))) + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("加载config模板"); + tempConfigPath = GUILayout.TextArea(tempConfigPath); + if (GUILayout.Button("Brown", GUILayout.ExpandWidth(false))) { dic.Clear(); - tempConfigPath = EditorUtility.OpenFilePanel("Resource path", tempConfigPath,"*.*"); + tempConfigPath = EditorUtility.OpenFilePanel("Resource path", tempConfigPath, "*.*"); EditorPrefs.SetString("IMPORTCCONFIG_SOURCESFOLDERPATH", tempConfigPath); StreamReader sr = File.OpenText(tempConfigPath); - SetConfigData(sr.ReadToEnd()); + SetConfigData(sr.ReadToEnd()); } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + downloadConfigPath = GUILayout.TextArea(downloadConfigPath); if (GUILayout.Button("下载config模板", GUILayout.ExpandWidth(false))) { - isFinish = false; + if (string.IsNullOrEmpty(downloadConfigPath)) + { + return; + } dic.Clear(); - string path = "http://60.1.1.12/assetbundles/config.txt"; - EditorCoroutineRunner.StartEditorCoroutine(DownLoadTempComfig(path)); + EditorPrefs.SetString("IMPORTCCONFIG_DownLOADCONFIGPATH", downloadConfigPath); + EditorCoroutineRunner.StartEditorCoroutine(DownLoadTempComfig(downloadConfigPath)); } + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("加载数据"); + configPath = GUILayout.TextArea(configPath); + if (GUILayout.Button("Brown", GUILayout.ExpandWidth(false))) + { + configPath = EditorUtility.OpenFilePanel("Resource path", configPath, "*.*"); + EditorPrefs.SetString("IMPORTCCONFIG_DATAFOLDERPATH", configPath); + StreamReader sr = File.OpenText(configPath); + SetConfigData(sr.ReadToEnd()); + } + EditorGUILayout.EndHorizontal(); + if (dic != null && dic.Count > 0) { - RefreshWindowShow(); - } - if (isFinish) - { - if (curDic != null && curDic.Count > 0) - { - RefreshWindowShow1(); - } + index = 0; + RefreshWindowShow2(dic); } EditorGUILayout.BeginHorizontal(); targetPath = GUILayout.TextArea(targetPath); @@ -71,7 +93,7 @@ namespace GameEditor.FrameTool JsonData jsonData = new JsonData(); SetDicToJsonData(jsonData,dic); string json = JsonMapper.ToJson(jsonData); - Debug.Log("jsonData:" + json); + //Debug.Log("jsonData:" + json); File.WriteAllText(targetPath, json, Encoding.UTF8); } EditorGUILayout.EndHorizontal(); @@ -98,12 +120,14 @@ namespace GameEditor.FrameTool void InitWindow() { - isFinish = true; + //isFinish = true; addKey = ""; dic = new Dictionary(); + indexDic = new Dictionary(); tempConfigPath = EditorPrefs.GetString("IMPORTCCONFIG_SOURCESFOLDERPATH"); targetPath = EditorPrefs.GetString("IMPORTCCONFIG_TARGETFOLDERPATH"); configPath = EditorPrefs.GetString("IMPORTCCONFIG_DATAFOLDERPATH"); + downloadConfigPath = EditorPrefs.GetString("IMPORTCCONFIG_DownLOADCONFIGPATH"); } void SetJsonDataToDic(IDictionary data,Dictionary dicc) @@ -111,7 +135,6 @@ namespace GameEditor.FrameTool foreach (var item in data.Keys) { string key = item.ToString(); - //Debug.Log(string.Format("{0}", item)); try { IDictionary localData = data[item] as IDictionary; @@ -136,7 +159,7 @@ namespace GameEditor.FrameTool { foreach (KeyValuePair keyValue in dicc) { - Debug.Log(string.Format("{0}", keyValue.Key)); + //Debug.Log(string.Format("{0}", keyValue.Key)); try { Dictionary localData = keyValue.Value as Dictionary; @@ -146,7 +169,7 @@ namespace GameEditor.FrameTool } catch { - Debug.Log(string.Format("{0}-{1}", keyValue.Key, keyValue.Value.ToString())); + //Debug.Log(string.Format("{0}-{1}", keyValue.Key, keyValue.Value.ToString())); jsonData[keyValue.Key] = keyValue.Value.ToString(); } } @@ -156,7 +179,7 @@ namespace GameEditor.FrameTool { foreach (KeyValuePair keyValue in dicc) { - Debug.Log(string.Format("{0}", keyValue.Key)); + //Debug.Log(string.Format("{0}", keyValue.Key)); try { Dictionary localData = keyValue.Value as Dictionary; @@ -164,97 +187,142 @@ namespace GameEditor.FrameTool } catch { - Debug.Log(string.Format("{0}-{1}", keyValue.Key, keyValue.Value.ToString())); + //Debug.Log(string.Format("{0}-{1}", keyValue.Key, keyValue.Value.ToString())); } } } void SetConfigData(string strinfo) { - Debug.Log(strinfo); + //Debug.Log(strinfo); JsonData modeInfo = JsonMapper.ToObject(strinfo); IDictionary data = modeInfo; SetJsonDataToDic(data,dic); - isFinish = true; + //isFinish = true; //GetDicData(dic); } - void RefreshWindowShow() + //void RefreshWindowShow() + //{ + // EditorGUILayout.BeginVertical(); + + // EditorGUILayout.BeginHorizontal(); + // GUILayout.Label("加载数据"); + // configPath = GUILayout.TextArea(configPath); + // if (GUILayout.Button("Brown", GUILayout.ExpandWidth(false))) + // { + // configPath = EditorUtility.OpenFilePanel("Resource path", configPath, "*.*"); + // EditorPrefs.SetString("IMPORTCCONFIG_DATAFOLDERPATH", configPath); + // StreamReader sr = File.OpenText(configPath); + // SetConfigData(sr.ReadToEnd()); + // } + // EditorGUILayout.EndHorizontal(); + + // EditorGUILayout.BeginHorizontal(); + // foreach (string key in dic.Keys) + // { + // if (GUILayout.Button(key, GUILayout.ExpandWidth(false))) + // { + // curDic = dic[key] as Dictionary; + // } + // } + // //if (isFinish) + // //{ + // if (curDic != null && curDic.Count > 0) + // { + // addKey = GUILayout.TextField(addKey); + // if (GUILayout.Button("添加key", GUILayout.ExpandWidth(false))) + // { + // curDic.Add(addKey, new Dictionary()); + // } + // } + // //} + // EditorGUILayout.EndHorizontal(); + // EditorGUILayout.EndVertical(); + //} + + //void RefreshWindowShow1() + //{ + // EditorGUILayout.BeginVertical(); + + // for (int i = 0; i < curDic.Count; i++) + // { + // EditorGUILayout.BeginHorizontal(); + // GUILayout.Space(30); + // var item = curDic.ElementAt(i); + // var item1 = (curDic[item.Key] as Dictionary); + // GUILayout.Label(item.Key); + // addKey = GUILayout.TextField(addKey); + // if (GUILayout.Button("添加key", GUILayout.ExpandWidth(false))) + // { + // item1.Add(addKey, ""); + // } + // if (GUILayout.Button("删除", GUILayout.ExpandWidth(false))) + // { + // curDic.Remove(item.Key); + // } + // EditorGUILayout.EndHorizontal(); + + // for (int j = 0; j < item1.Count; j++) + // { + // EditorGUILayout.BeginHorizontal(); + // GUILayout.Space(60); + // var item2 = item1.ElementAt(j); + // GUILayout.Label(item2.Key); + // item1[item2.Key] = GUILayout.TextField(item1[item2.Key].ToString()); + // if (GUILayout.Button("删除", GUILayout.ExpandWidth(false))) + // { + // item1.Remove(item2.Key); + // } + // EditorGUILayout.EndHorizontal(); + // } + // } + // EditorGUILayout.EndVertical(); + //} + + void RefreshWindowShow2(Dictionary dicc,string indexDicKey = "0") { - EditorGUILayout.BeginVertical(); - - EditorGUILayout.BeginHorizontal(); - GUILayout.Label("加载数据"); - configPath = GUILayout.TextArea(configPath); - if (GUILayout.Button("Brown", GUILayout.ExpandWidth(false))) + for (int i = 0; i < dicc.Count; i++) { - configPath = EditorUtility.OpenFilePanel("Resource path", configPath, "*.*"); - EditorPrefs.SetString("IMPORTCCONFIG_DATAFOLDERPATH", configPath); - StreamReader sr = File.OpenText(configPath); - SetConfigData(sr.ReadToEnd()); - } - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - foreach (string key in dic.Keys) - { - if (GUILayout.Button(key, GUILayout.ExpandWidth(false))) + var item = dicc.ElementAt(i); + if (!indexDic.ContainsKey(indexDicKey)) { - curDic = dic[key] as Dictionary; + index = index + 1; + indexDic.Add(indexDicKey, index); } - } - if (isFinish) - { - if (curDic != null && curDic.Count > 0) - { - addKey = GUILayout.TextField(addKey); - if (GUILayout.Button("添加key", GUILayout.ExpandWidth(false))) - { - curDic.Add(addKey, new Dictionary()); - } - } - } - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - } - - void RefreshWindowShow1() - { - EditorGUILayout.BeginVertical(); - - for (int i = 0; i < curDic.Count; i++) - { - EditorGUILayout.BeginHorizontal(); - GUILayout.Space(30); - var item = curDic.ElementAt(i); - var item1 = (curDic[item.Key] as Dictionary); - GUILayout.Label(item.Key); - addKey = GUILayout.TextField(addKey); - if (GUILayout.Button("添加key", GUILayout.ExpandWidth(false))) - { - item1.Add(addKey, ""); - } - if (GUILayout.Button("删除", GUILayout.ExpandWidth(false))) - { - curDic.Remove(item.Key); - } - EditorGUILayout.EndHorizontal(); - - for (int j = 0; j < item1.Count; j++) + index = indexDic[indexDicKey]; + //Debug.Log(string.Format("{0}-{1}", item.Key, item.Value)); + Dictionary localData = item.Value as Dictionary; + if (localData == null) { EditorGUILayout.BeginHorizontal(); - GUILayout.Space(60); - var item2 = item1.ElementAt(j); - GUILayout.Label(item2.Key); - item1[item2.Key] = GUILayout.TextField(item1[item2.Key].ToString()); + GUILayout.Space(30 * index); + GUILayout.Label(item.Key); + dicc[item.Key] = GUILayout.TextField(dicc[item.Key].ToString()); if (GUILayout.Button("删除", GUILayout.ExpandWidth(false))) { - item1.Remove(item2.Key); + dicc.Remove(item.Key); } EditorGUILayout.EndHorizontal(); } + else + { + EditorGUILayout.BeginHorizontal(); + GUILayout.Space(30 * index); + GUILayout.Label(item.Key); + addKey = GUILayout.TextField(addKey); + if (GUILayout.Button("添加key", GUILayout.ExpandWidth(false))) + { + localData.Add(addKey, ""); + } + if (GUILayout.Button("删除", GUILayout.ExpandWidth(false))) + { + localData.Remove(item.Key); + } + EditorGUILayout.EndHorizontal(); + RefreshWindowShow2(localData, item.Key); + } } - EditorGUILayout.EndVertical(); } } }