|
8 | 8 | using System.Diagnostics; |
9 | 9 | using System.Drawing; // for notifyicon |
10 | 10 | using System.IO; |
11 | | -using System.Net; |
12 | | -using System.Net.NetworkInformation; |
13 | 11 | using System.Runtime.InteropServices; |
14 | 12 | using System.Threading; |
15 | 13 | using System.Threading.Tasks; |
@@ -110,7 +108,7 @@ void Start() |
110 | 108 | } |
111 | 109 |
|
112 | 110 | // update projects list |
113 | | - projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked); |
| 111 | + projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked); |
114 | 112 | gridRecent.Items.Clear(); |
115 | 113 | gridRecent.ItemsSource = projectsSource; |
116 | 114 |
|
@@ -598,7 +596,7 @@ public void RefreshRecentProjects() |
598 | 596 | // take currently selected project row |
599 | 597 | lastSelectedProjectIndex = gridRecent.SelectedIndex; |
600 | 598 | // rescan recent projects |
601 | | - projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked); |
| 599 | + projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked); |
602 | 600 | gridRecent.ItemsSource = projectsSource; |
603 | 601 | // focus back |
604 | 602 | Tools.SetFocusToGrid(gridRecent, lastSelectedProjectIndex); |
@@ -1943,170 +1941,9 @@ private void BtnClearBuildReport_Click(object sender, RoutedEventArgs e) |
1943 | 1941 | private void MenuStartWebGLServer_Click(object sender, RoutedEventArgs e) |
1944 | 1942 | { |
1945 | 1943 | var proj = GetSelectedProject(); |
1946 | | - LaunchWebGL(proj); |
| 1944 | + Tools.LaunchWebGL(proj, txtWebglRelativePath.Text); |
1947 | 1945 | } |
1948 | 1946 |
|
1949 | | - // runs unity SimpleWebServer.exe and launches default Browser into project build/ folder' |
1950 | | - void LaunchWebGL(Project proj) |
1951 | | - { |
1952 | | - var projPath = proj?.Path.Replace('/', '\\'); |
1953 | | - if (string.IsNullOrEmpty(projPath) == true) return; |
1954 | | - |
1955 | | - var buildPath = Path.Combine(projPath, "Builds", txtWebglRelativePath.Text); |
1956 | | - if (Directory.Exists(buildPath) == false) return; |
1957 | | - |
1958 | | - if (unityInstalledVersions.ContainsKey(proj.Version) == false) return; |
1959 | | - |
1960 | | - // get mono and server exe paths |
1961 | | - var editorPath = Path.GetDirectoryName(unityInstalledVersions[proj.Version]); |
1962 | | - |
1963 | | - var monoToolsPath = Path.Combine(editorPath, "Data/MonoBleedingEdge/bin"); |
1964 | | - if (Directory.Exists(monoToolsPath) == false) return; |
1965 | | - |
1966 | | - var webglToolsPath = Path.Combine(editorPath, "Data/PlaybackEngines/WebGLSupport/BuildTools"); |
1967 | | - if (Directory.Exists(webglToolsPath) == false) return; |
1968 | | - |
1969 | | - var monoExe = Path.Combine(monoToolsPath, "mono.exe"); |
1970 | | - if (File.Exists(monoExe) == false) return; |
1971 | | - |
1972 | | - var webExe = Path.Combine(webglToolsPath, "SimpleWebServer.exe"); |
1973 | | - if (File.Exists(webExe) == false) return; |
1974 | | - |
1975 | | - // pick initial number for server, TODO make this default start port as setting field (later if needed..) |
1976 | | - int port = 50000; |
1977 | | - |
1978 | | - // check if this project already has server running and process is not closed |
1979 | | - if (webglServerProcesses.ContainsKey(port) && webglServerProcesses[port].HasExited == false) |
1980 | | - { |
1981 | | - Console.WriteLine("Port found in cache: " + port + " process=" + webglServerProcesses[port]); |
1982 | | - |
1983 | | - // check if project matches |
1984 | | - if (webglServerProcesses[port].StartInfo.Arguments.IndexOf("\"" + buildPath + "\"") > -1) |
1985 | | - { |
1986 | | - Console.WriteLine("this project already has webgl server running.. lets open browser url only"); |
1987 | | - // then open browser url only |
1988 | | - Tools.OpenURL("http://localhost:" + port); |
1989 | | - return; |
1990 | | - |
1991 | | - } |
1992 | | - else |
1993 | | - { |
1994 | | - Console.WriteLine("Port in use, but its different project: " + port); |
1995 | | - Console.WriteLine(webglServerProcesses[port].StartInfo.Arguments + " == " + "\"" + buildPath + "\""); |
1996 | | - |
1997 | | - // then open new port and process |
1998 | | - // ----------------------------------------------------------- |
1999 | | - // check if port is available https://stackoverflow.com/a/2793289 |
2000 | | - bool isAvailable = true; |
2001 | | - IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); |
2002 | | - IPEndPoint[] objEndPoints = ipGlobalProperties.GetActiveTcpListeners(); |
2003 | | - |
2004 | | - // NOTE instead of iterating all ports, just try to open port, if fails, open next one |
2005 | | - // compare with existing ports, if available |
2006 | | - for (int i = 0; i < objEndPoints.Length; i++) |
2007 | | - { |
2008 | | - if (objEndPoints[i].Port == port) |
2009 | | - { |
2010 | | - port++; |
2011 | | - if (port > 65535) |
2012 | | - { |
2013 | | - Console.WriteLine("Failed to find open port.."); |
2014 | | - return; |
2015 | | - } |
2016 | | - } |
2017 | | - } |
2018 | | - |
2019 | | - Console.WriteLine("Found available port: " + port); |
2020 | | - |
2021 | | - if (isAvailable == false) |
2022 | | - { |
2023 | | - Console.WriteLine("failed to open port " + port + " (should be open already, or something else is using it?)"); |
2024 | | - } |
2025 | | - else |
2026 | | - { |
2027 | | - // take process id from unity, if have it (then webserver closes automatically when unity is closed) |
2028 | | - var proc = ProcessHandler.Get(proj.Path); |
2029 | | - int pid = proc == null ? -1 : proc.Id; |
2030 | | - var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port |
2031 | | - |
2032 | | - var webglServerProcess = Tools.LaunchExe(monoExe, param); |
2033 | | - |
2034 | | - if (webglServerProcesses.ContainsKey(port)) |
2035 | | - { |
2036 | | - Console.WriteLine("Error> Should not happen - this port is already in dictionary! port: " + port); |
2037 | | - } |
2038 | | - else // keep reference to this process on this port |
2039 | | - { |
2040 | | - // TODO how to remove process once its closed? (or unlikely to have many processes in total? can also remove during check, if process already null) |
2041 | | - webglServerProcesses.Add(port, webglServerProcess); |
2042 | | - Console.WriteLine("Added port " + port); |
2043 | | - } |
2044 | | - |
2045 | | - Tools.OpenURL("http://localhost:" + port); |
2046 | | - } |
2047 | | - // ----------------------------------------------------------- |
2048 | | - |
2049 | | - } |
2050 | | - } |
2051 | | - else |
2052 | | - { |
2053 | | - Console.WriteLine("Port not running in cache or process already closed, remove it from cache: " + port); |
2054 | | - if (webglServerProcesses.ContainsKey(port)) webglServerProcesses.Remove(port); |
2055 | | - |
2056 | | - // TODO remove duplicate code |
2057 | | - // then open new process |
2058 | | - // ----------------------------------------------------------- |
2059 | | - // check if port is available https://stackoverflow.com/a/2793289 |
2060 | | - bool isAvailable = true; |
2061 | | - IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); |
2062 | | - IPEndPoint[] objEndPoints = ipGlobalProperties.GetActiveTcpListeners(); |
2063 | | - |
2064 | | - // compare with existing ports, if available |
2065 | | - for (int i = 0; i < objEndPoints.Length; i++) |
2066 | | - { |
2067 | | - if (objEndPoints[i].Port == port) |
2068 | | - { |
2069 | | - // TODO doesnt stop at max port number 65535 |
2070 | | - port++; |
2071 | | - } |
2072 | | - } |
2073 | | - |
2074 | | - Console.WriteLine("Found available port: " + port); |
2075 | | - |
2076 | | - if (isAvailable == false) |
2077 | | - { |
2078 | | - Console.WriteLine("failed to open port " + port + " (should be open already, or something else is using it?)"); |
2079 | | - } |
2080 | | - else |
2081 | | - { |
2082 | | - // take process id from unity, if have it(then webserver closes automatically when unity is closed) |
2083 | | - var proc = ProcessHandler.Get(proj.Path); |
2084 | | - int pid = proc == null ? -1 : proc.Id; |
2085 | | - var param = "\"" + webExe + "\" \"" + buildPath + "\" " + port + (pid == -1 ? "" : " " + pid); // server exe path, build folder and port |
2086 | | - |
2087 | | - var webglServerProcess = Tools.LaunchExe(monoExe, param); |
2088 | | - |
2089 | | - if (webglServerProcesses.ContainsKey(port)) |
2090 | | - { |
2091 | | - Console.WriteLine("Error> Should not happen - this port is already in dictionary! port: " + port); |
2092 | | - } |
2093 | | - else // keep reference to this process on this port |
2094 | | - { |
2095 | | - // TODO how to remove process once its closed? (or unlikely to have many processes in total? can also remove during check, if process already null) |
2096 | | - webglServerProcesses.Add(port, webglServerProcess); |
2097 | | - Console.WriteLine("Added port " + port); |
2098 | | - } |
2099 | | - |
2100 | | - Tools.OpenURL("http://localhost:" + port); |
2101 | | - } |
2102 | | - // ----------------------------------------------------------- |
2103 | | - |
2104 | | - } |
2105 | | - } // LaunchWebGL() |
2106 | | - |
2107 | | - // reference to already running webgl server processes and ports |
2108 | | - Dictionary<int, Process> webglServerProcesses = new Dictionary<int, Process>(); |
2109 | | - |
2110 | 1947 | private void TxtWebglRelativePath_TextChanged(object sender, TextChangedEventArgs e) |
2111 | 1948 | { |
2112 | 1949 | Properties.Settings.Default.webglBuildPath = txtWebglRelativePath.Text; |
@@ -2590,7 +2427,11 @@ private void MenuBatchBuildIOS_Click(object sender, RoutedEventArgs e) |
2590 | 2427 | Tools.BuildProject(proj, Platform.iOS); |
2591 | 2428 | } |
2592 | 2429 |
|
2593 | | - |
| 2430 | + private void ChkCheckPlasticBranch_Checked(object sender, RoutedEventArgs e) |
| 2431 | + { |
| 2432 | + Properties.Settings.Default.checkPlasticBranch = (bool)chkCheckPlasticBranch.IsChecked; |
| 2433 | + Properties.Settings.Default.Save(); |
| 2434 | + } |
2594 | 2435 |
|
2595 | 2436 | //private void BtnBrowseTemplateUnityPackagesFolder_Click(object sender, RoutedEventArgs e) |
2596 | 2437 | //{ |
|
0 commit comments