Преглед изворни кода

美化了命令行配置工具

tanghai пре 7 година
родитељ
комит
5e33a62a78

+ 9 - 9
Config/StartConfig/127.0.0.1.txt

@@ -1,9 +1,9 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10000", "Address2" : "127.0.0.1:10000" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565862653976"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:10001" }], "AppId" : 2, "AppType" : "Location", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20001" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }], "AppId" : 3, "AppType" : "Realm", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20002" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10003", "Address2" : "127.0.0.1:10003" }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20003" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10004", "Address2" : "127.0.0.1:10004" }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20004" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10005", "Address2" : "127.0.0.1:10005" }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20005" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10006", "Address2" : "127.0.0.1:10006" }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20006" }], "AppId" : 8, "AppType" : "Map", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20007" }], "AppId" : 9, "AppType" : "Map", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20001" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10001", "Address2" : "127.0.0.1:10001" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20002" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }], "AppId" : 2, "AppType" : "Realm", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565862653976"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:10003" }], "AppId" : 3, "AppType" : "Location", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20004" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10004", "Address2" : "127.0.0.1:10004" }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20005" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10005", "Address2" : "127.0.0.1:10005" }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20006" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10006", "Address2" : "127.0.0.1:10006" }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20007" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10007", "Address2" : "127.0.0.1:10007" }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20008" }], "AppId" : 8, "AppType" : "Map", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20009" }], "AppId" : 9, "AppType" : "Map", "ServerIP" : "*" }

+ 1 - 1
Config/StartConfig/LocalAllServer.txt

@@ -1 +1 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : "mongodb://172.16.100.40:27017/", "DBName" : "ET" }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20002" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : "mongodb://172.16.100.40:27017/", "DBName" : "ET" }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 167 - 120
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -111,173 +111,220 @@ namespace ETEditor
 			}
 		}
 
+		private Vector2 scrollPos;
+		
 		private void OnGUI()
 		{
-			GUILayout.BeginHorizontal();
-			string[] filesArray = this.files.ToArray();
-			this.selectedIndex = EditorGUILayout.Popup(this.selectedIndex, filesArray);
-
-			string lastFile = this.fileName;
-			this.fileName = this.files[this.selectedIndex];
-
-			if (this.fileName != lastFile)
 			{
-				this.LoadConfig();
-			}
+				GUILayout.BeginHorizontal();
+				string[] filesArray = this.files.ToArray();
+				this.selectedIndex = EditorGUILayout.Popup(this.selectedIndex, filesArray);
 
-			this.newFileName = EditorGUILayout.TextField("文件名", this.newFileName);
+				string lastFile = this.fileName;
+				this.fileName = this.files[this.selectedIndex];
 
-			if (GUILayout.Button("添加"))
-			{
-				this.fileName = this.newFileName;
-				this.newFileName = "";
-				File.WriteAllText(this.GetFilePath(), "");
-				this.files = this.GetConfigFiles();
-				this.selectedIndex = this.files.IndexOf(this.fileName);
-				this.LoadConfig();
-			}
+				if (this.fileName != lastFile)
+				{
+					this.LoadConfig();
+				}
 
-			if (GUILayout.Button("复制"))
-			{
-				this.fileName = $"{this.fileName}-copy";
-				this.Save();
-				this.files = this.GetConfigFiles();
-				this.selectedIndex = this.files.IndexOf(this.fileName);
-				this.newFileName = "";
-			}
+				this.newFileName = EditorGUILayout.TextField("文件名", this.newFileName);
 
-			if (GUILayout.Button("重命名"))
-			{
-				if (this.newFileName == "")
+				if (GUILayout.Button("添加"))
 				{
-					Log.Debug("请输入新名字!");
+					this.fileName = this.newFileName;
+					this.newFileName = "";
+					File.WriteAllText(this.GetFilePath(), "");
+					this.files = this.GetConfigFiles();
+					this.selectedIndex = this.files.IndexOf(this.fileName);
+					this.LoadConfig();
 				}
-				else
+
+				if (GUILayout.Button("复制"))
 				{
-					File.Delete(this.GetFilePath());
-					this.fileName = this.newFileName;
+					this.fileName = $"{this.fileName}-copy";
 					this.Save();
 					this.files = this.GetConfigFiles();
 					this.selectedIndex = this.files.IndexOf(this.fileName);
 					this.newFileName = "";
 				}
-			}
 
-			if (GUILayout.Button("删除"))
-			{
-				File.Delete(this.GetFilePath());
-				this.files = this.GetConfigFiles();
-				this.selectedIndex = 0;
-				this.newFileName = "";
-			}
+				if (GUILayout.Button("重命名"))
+				{
+					if (this.newFileName == "")
+					{
+						Log.Debug("请输入新名字!");
+					}
+					else
+					{
+						File.Delete(this.GetFilePath());
+						this.fileName = this.newFileName;
+						this.Save();
+						this.files = this.GetConfigFiles();
+						this.selectedIndex = this.files.IndexOf(this.fileName);
+						this.newFileName = "";
+					}
+				}
 
-			GUILayout.EndHorizontal();
+				if (GUILayout.Button("删除"))
+				{
+					File.Delete(this.GetFilePath());
+					this.files = this.GetConfigFiles();
+					this.selectedIndex = 0;
+					this.newFileName = "";
+				}
 
-			GUILayout.Label("配置内容:");
+				GUILayout.EndHorizontal();
+			}
+
+			scrollPos = GUILayout.BeginScrollView(this.scrollPos, true, true);
 			for (int i = 0; i < this.startConfigs.Count; ++i)
 			{
 				StartConfig startConfig = this.startConfigs[i];
+
+				
 				GUILayout.BeginHorizontal();
-				GUILayout.Label($"AppId:");
-				startConfig.AppId = EditorGUILayout.IntField(startConfig.AppId, GUILayout.Width(30));
-				GUILayout.Label($"服务器IP:");
-				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP, GUILayout.Width(100));
-				GUILayout.Label($"AppType:");
-				startConfig.AppType = (AppType) EditorGUILayout.EnumPopup(startConfig.AppType);
-
-				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
-				if (innerConfig != null)
 				{
-					GUILayout.Label($"内网地址:");
-					innerConfig.Address = EditorGUILayout.TextField(innerConfig.Address, GUILayout.Width(120));
-				}
+					GUILayout.BeginHorizontal(GUILayout.Width(1700));
+					{
+						GUILayout.BeginHorizontal(GUILayout.Width(350));
+						GUILayout.Label($"AppId:");
+						startConfig.AppId = EditorGUILayout.IntField(startConfig.AppId, GUILayout.Width(30));
+						GUILayout.Label($"服务器IP:");
+						startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP, GUILayout.Width(100));
+						GUILayout.Label($"AppType:");
+						startConfig.AppType = (AppType) EditorGUILayout.EnumPopup(startConfig.AppType);
+						GUILayout.EndHorizontal();
+					}
+					{
+						GUILayout.BeginHorizontal(GUILayout.Width(150));
+						InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
+						if (innerConfig != null)
+						{
+							GUILayout.Label($"内网地址:");
+							innerConfig.Address = EditorGUILayout.TextField(innerConfig.Address, GUILayout.Width(120));
+						}
 
-				OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();
-				if (outerConfig != null)
-				{
-					GUILayout.Label($"外网地址:");
-					outerConfig.Address = EditorGUILayout.TextField(outerConfig.Address, GUILayout.Width(120));
-					GUILayout.Label($"外网地址2:");
-					outerConfig.Address2 = EditorGUILayout.TextField(outerConfig.Address2, GUILayout.Width(120));
-				}
+						GUILayout.EndHorizontal();
+					}
+					{
+						GUILayout.BeginHorizontal(GUILayout.Width(350));
+						OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();
+						if (outerConfig != null)
+						{
+							GUILayout.Label($"外网地址:");
+							outerConfig.Address = EditorGUILayout.TextField(outerConfig.Address, GUILayout.Width(120));
+							GUILayout.Label($"外网地址2:");
+							outerConfig.Address2 = EditorGUILayout.TextField(outerConfig.Address2, GUILayout.Width(120));
+						}
 
-				ClientConfig clientConfig = startConfig.GetComponent<ClientConfig>();
-				if (clientConfig != null)
-				{
-					GUILayout.Label($"连接地址:");
-					clientConfig.Address = EditorGUILayout.TextField(clientConfig.Address, GUILayout.Width(120));
-				}
+						GUILayout.EndHorizontal();
+					}
+					{
+						GUILayout.BeginHorizontal(GUILayout.Width(350));
+						ClientConfig clientConfig = startConfig.GetComponent<ClientConfig>();
+						if (clientConfig != null)
+						{
+							GUILayout.Label($"连接地址:");
+							clientConfig.Address = EditorGUILayout.TextField(clientConfig.Address, GUILayout.Width(120));
+						}
 
-				HttpConfig httpConfig = startConfig.GetComponent<HttpConfig>();
-				if (httpConfig != null)
-				{
-					GUILayout.Label($"AppId:");
-					httpConfig.AppId = EditorGUILayout.IntField(httpConfig.AppId, GUILayout.Width(20));
-					GUILayout.Label($"AppKey:");
-					httpConfig.AppKey = EditorGUILayout.TextField(httpConfig.AppKey);
-					GUILayout.Label($"Url:");
-					httpConfig.Url = EditorGUILayout.TextField(httpConfig.Url);
-					GUILayout.Label($"ManagerSystemUrl:");
-					httpConfig.ManagerSystemUrl = EditorGUILayout.TextField(httpConfig.ManagerSystemUrl);
-				}
+						HttpConfig httpConfig = startConfig.GetComponent<HttpConfig>();
+						if (httpConfig != null)
+						{
+							GUILayout.Label($"AppId:");
+							httpConfig.AppId = EditorGUILayout.IntField(httpConfig.AppId, GUILayout.Width(20));
+							GUILayout.Label($"AppKey:");
+							httpConfig.AppKey = EditorGUILayout.TextField(httpConfig.AppKey);
+							GUILayout.Label($"Url:");
+							httpConfig.Url = EditorGUILayout.TextField(httpConfig.Url);
+							GUILayout.Label($"ManagerSystemUrl:");
+							httpConfig.ManagerSystemUrl = EditorGUILayout.TextField(httpConfig.ManagerSystemUrl);
+						}
 
-				DBConfig dbConfig = startConfig.GetComponent<DBConfig>();
-				if (dbConfig != null)
-				{
-					GUILayout.Label($"Connection:");
-					dbConfig.ConnectionString = EditorGUILayout.TextField(dbConfig.ConnectionString);
+						DBConfig dbConfig = startConfig.GetComponent<DBConfig>();
+						if (dbConfig != null)
+						{
+							GUILayout.Label($"Connection:");
+							dbConfig.ConnectionString = EditorGUILayout.TextField(dbConfig.ConnectionString);
 
-					GUILayout.Label($"DBName:");
-					dbConfig.DBName = EditorGUILayout.TextField(dbConfig.DBName);
-				}
+							GUILayout.Label($"DBName:");
+							dbConfig.DBName = EditorGUILayout.TextField(dbConfig.DBName);
+						}
 
-				if (GUILayout.Button("删除"))
-				{
-					this.startConfigs.Remove(startConfig);
-					break;
+						GUILayout.EndHorizontal();
+					}
+					GUILayout.EndHorizontal();
 				}
-				if (GUILayout.Button("复制"))
+
 				{
-					for (int j = 1; j < this.copyNum + 1; ++j)
+					GUILayout.BeginHorizontal();
+					if (GUILayout.Button("删除"))
 					{
-						StartConfig newStartConfig = MongoHelper.FromBson<StartConfig>(startConfig.ToBson());
-						newStartConfig.AppId += j;
-						this.startConfigs.Add(newStartConfig);
+						this.startConfigs.Remove(startConfig);
+						break;
 					}
-					break;
-				}
 
-				if (i > 0)
-				{
-					if (GUILayout.Button("上移"))
+					if (GUILayout.Button("复制"))
 					{
-						StartConfig s = this.startConfigs[i];
-						this.startConfigs.RemoveAt(i);
-						this.startConfigs.Insert(i - 1, s);
-						for (int j = 0; j < startConfigs.Count; ++j)
+						for (int j = 1; j < this.copyNum + 1; ++j)
 						{
-							this.startConfigs[j].AppId = j + 1;
+							StartConfig newStartConfig = MongoHelper.FromBson<StartConfig>(startConfig.ToBson());
+							newStartConfig.AppId += j;
+							this.startConfigs.Add(newStartConfig);
 						}
+
 						break;
 					}
-				}
 
-				if (i < this.startConfigs.Count - 1)
-				{
-					if (GUILayout.Button("下移"))
+					if (i >= 0)
 					{
-						StartConfig s = this.startConfigs[i];
-						this.startConfigs.RemoveAt(i);
-						this.startConfigs.Insert(i + 1, s);
-						for (int j = 0; j < startConfigs.Count; ++j)
+						if (GUILayout.Button("上移"))
 						{
-							this.startConfigs[j].AppId = j + 1;
+							if (i == 0)
+							{
+								break;
+							}
+							StartConfig s = this.startConfigs[i];
+							this.startConfigs.RemoveAt(i);
+							this.startConfigs.Insert(i - 1, s);
+							for (int j = 0; j < startConfigs.Count; ++j)
+							{
+								this.startConfigs[j].AppId = j + 1;
+							}
+
+							break;
 						}
-						break;
 					}
+
+					if (i <= this.startConfigs.Count - 1)
+					{
+						if (GUILayout.Button("下移"))
+						{
+							if (i == this.startConfigs.Count - 1)
+							{
+								break;
+							}
+							StartConfig s = this.startConfigs[i];
+							this.startConfigs.RemoveAt(i);
+							this.startConfigs.Insert(i + 1, s);
+							for (int j = 0; j < startConfigs.Count; ++j)
+							{
+								this.startConfigs[j].AppId = j + 1;
+							}
+
+							break;
+						}
+					}
+					GUILayout.EndHorizontal();
 				}
 				GUILayout.EndHorizontal();
 			}
+			GUILayout.EndScrollView();
+			
+			
+			
+			
 
 			GUILayout.Label("");
 

+ 1 - 0
Unity/Assets/Model/Module/Demo/Unit.cs

@@ -20,6 +20,7 @@ namespace ETModel
 		public void Awake(GameObject gameObject)
 		{
 			this.GameObject = gameObject;
+			this.GameObject.AddComponent<ComponentView>().Component = this;
 		}
 		
 		public Vector3 Position