|
@@ -2,9 +2,9 @@
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
|
|
+using System.Linq;
|
|
|
using Base;
|
|
using Base;
|
|
|
using Model;
|
|
using Model;
|
|
|
-using MongoDB.Bson.Serialization;
|
|
|
|
|
using UnityEditor;
|
|
using UnityEditor;
|
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
|
@@ -12,14 +12,22 @@ namespace MyEditor
|
|
|
{
|
|
{
|
|
|
public class ServerCommandLineEditor : EditorWindow
|
|
public class ServerCommandLineEditor : EditorWindow
|
|
|
{
|
|
{
|
|
|
- private const string Path = @"..\Server\App\Start.txt";
|
|
|
|
|
|
|
+ private const string ConfigDir = @"..\Config\StartConfig\";
|
|
|
|
|
+
|
|
|
|
|
+ private List<string> files;
|
|
|
|
|
+
|
|
|
|
|
+ private int selectedIndex;
|
|
|
|
|
+
|
|
|
|
|
+ private string fileName;
|
|
|
|
|
+
|
|
|
|
|
+ private string addFileName;
|
|
|
|
|
|
|
|
private int copyNum = 1;
|
|
private int copyNum = 1;
|
|
|
|
|
|
|
|
private AppType AppType = AppType.Manager;
|
|
private AppType AppType = AppType.Manager;
|
|
|
|
|
|
|
|
private readonly List<StartConfig> startConfigs = new List<StartConfig>();
|
|
private readonly List<StartConfig> startConfigs = new List<StartConfig>();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
[MenuItem("Tools/命令行配置")]
|
|
[MenuItem("Tools/命令行配置")]
|
|
|
private static void ShowWindow()
|
|
private static void ShowWindow()
|
|
|
{
|
|
{
|
|
@@ -28,7 +36,27 @@ namespace MyEditor
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
private void OnEnable()
|
|
|
{
|
|
{
|
|
|
- if (!File.Exists(Path))
|
|
|
|
|
|
|
+ this.files = this.GetConfigFiles();
|
|
|
|
|
+ if (this.files.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ this.fileName = this.files[this.selectedIndex];
|
|
|
|
|
+ this.LoadConfig();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<string> GetConfigFiles()
|
|
|
|
|
+ {
|
|
|
|
|
+ List<string> fs = Directory.GetFiles(ConfigDir).ToList();
|
|
|
|
|
+ DirectoryInfo directoryInfo = new DirectoryInfo(ConfigDir);
|
|
|
|
|
+ FileInfo[] fileInfo = directoryInfo.GetFiles();
|
|
|
|
|
+ fs = fileInfo.Select(x => x.Name).ToList();
|
|
|
|
|
+ return fs;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void LoadConfig()
|
|
|
|
|
+ {
|
|
|
|
|
+ string filePath = this.GetFilePath();
|
|
|
|
|
+ if (!File.Exists(filePath))
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -36,7 +64,8 @@ namespace MyEditor
|
|
|
string s2 = "";
|
|
string s2 = "";
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- string[] ss = File.ReadAllText(Path).Split('\n');
|
|
|
|
|
|
|
+ this.startConfigs.Clear();
|
|
|
|
|
+ string[] ss = File.ReadAllText(filePath).Split('\n');
|
|
|
foreach (string s in ss)
|
|
foreach (string s in ss)
|
|
|
{
|
|
{
|
|
|
s2 = s.Trim();
|
|
s2 = s.Trim();
|
|
@@ -55,8 +84,38 @@ namespace MyEditor
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private string GetFilePath()
|
|
|
|
|
+ {
|
|
|
|
|
+ return Path.Combine(ConfigDir, this.fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void OnGUI()
|
|
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();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.addFileName = EditorGUILayout.TextField("文件名", this.addFileName);
|
|
|
|
|
+
|
|
|
|
|
+ if (GUILayout.Button("添加配置文件"))
|
|
|
|
|
+ {
|
|
|
|
|
+ this.fileName = this.addFileName;
|
|
|
|
|
+ this.addFileName = "";
|
|
|
|
|
+ File.WriteAllText(this.GetFilePath(), "");
|
|
|
|
|
+ this.files = this.GetConfigFiles();
|
|
|
|
|
+ this.selectedIndex = this.files.IndexOf(this.fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+ GUILayout.EndHorizontal();
|
|
|
|
|
+
|
|
|
|
|
+ GUILayout.Label("配置内容:");
|
|
|
for (int i = 0; i < this.startConfigs.Count; ++i)
|
|
for (int i = 0; i < this.startConfigs.Count; ++i)
|
|
|
{
|
|
{
|
|
|
StartConfig startConfig = this.startConfigs[i];
|
|
StartConfig startConfig = this.startConfigs[i];
|
|
@@ -105,23 +164,22 @@ namespace MyEditor
|
|
|
GUILayout.EndHorizontal();
|
|
GUILayout.EndHorizontal();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- GUILayout.BeginHorizontal();
|
|
|
|
|
- this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);
|
|
|
|
|
- GUILayout.EndHorizontal();
|
|
|
|
|
|
|
+ GUILayout.Label("");
|
|
|
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
+ this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);
|
|
|
|
|
|
|
|
GUILayout.Label($"添加的AppType:");
|
|
GUILayout.Label($"添加的AppType:");
|
|
|
this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);
|
|
this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);
|
|
|
|
|
|
|
|
- if (GUILayout.Button("添加"))
|
|
|
|
|
|
|
+ if (GUILayout.Button("添加一行配置"))
|
|
|
{
|
|
{
|
|
|
StartConfig newStartConfig = new StartConfig();
|
|
StartConfig newStartConfig = new StartConfig();
|
|
|
|
|
|
|
|
newStartConfig.AppType = this.AppType;
|
|
newStartConfig.AppType = this.AppType;
|
|
|
newStartConfig.AddComponent<InnerConfig>();
|
|
newStartConfig.AddComponent<InnerConfig>();
|
|
|
|
|
|
|
|
- if (this.AppType == AppType.Gate || this.AppType == AppType.Realm || this.AppType == AppType.Manager)
|
|
|
|
|
|
|
+ if (this.AppType.Is(AppType.Gate) || this.AppType.Is(AppType.Realm) || this.AppType.Is(AppType.Manager))
|
|
|
{
|
|
{
|
|
|
newStartConfig.AddComponent<OuterConfig>();
|
|
newStartConfig.AddComponent<OuterConfig>();
|
|
|
}
|
|
}
|
|
@@ -130,11 +188,13 @@ namespace MyEditor
|
|
|
}
|
|
}
|
|
|
GUILayout.EndHorizontal();
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
|
|
|
if (GUILayout.Button("保存"))
|
|
if (GUILayout.Button("保存"))
|
|
|
{
|
|
{
|
|
|
- using (StreamWriter sw = new StreamWriter(new FileStream(Path, FileMode.Create)))
|
|
|
|
|
|
|
+ string path = this.GetFilePath();
|
|
|
|
|
+ using (StreamWriter sw = new StreamWriter(new FileStream(path, FileMode.Create)))
|
|
|
{
|
|
{
|
|
|
foreach (StartConfig startConfig in this.startConfigs)
|
|
foreach (StartConfig startConfig in this.startConfigs)
|
|
|
{
|
|
{
|
|
@@ -149,7 +209,7 @@ namespace MyEditor
|
|
|
StartConfig startConfig = null;
|
|
StartConfig startConfig = null;
|
|
|
foreach (StartConfig config in this.startConfigs)
|
|
foreach (StartConfig config in this.startConfigs)
|
|
|
{
|
|
{
|
|
|
- if (config.AppType == Model.AppType.Manager)
|
|
|
|
|
|
|
+ if (config.AppType.Is(AppType.Manager))
|
|
|
{
|
|
{
|
|
|
startConfig = config;
|
|
startConfig = config;
|
|
|
}
|
|
}
|
|
@@ -160,13 +220,13 @@ namespace MyEditor
|
|
|
Log.Error("没有配置Manager!");
|
|
Log.Error("没有配置Manager!");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- string arguments = $"--id={startConfig.AppId} --appType={startConfig.AppType}";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config=../Config/StartConfig/{this.fileName}";
|
|
|
|
|
|
|
|
ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments)
|
|
ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments)
|
|
|
{
|
|
{
|
|
|
UseShellExecute = true,
|
|
UseShellExecute = true,
|
|
|
- WorkingDirectory = @"..\Server\Bin\Debug"
|
|
|
|
|
|
|
+ WorkingDirectory = @"..\Bin\"
|
|
|
};
|
|
};
|
|
|
Process.Start(info);
|
|
Process.Start(info);
|
|
|
}
|
|
}
|