public static Dictionary <string, string> GatherAnimations(AvatarType avatarType) { Dictionary <string, string> animations = new Dictionary <string, string>(); string avatarTypeName = Enum.GetName(typeof(AvatarType), avatarType); string animFilesDir = "AvatarData/" + avatarTypeName + "/Animations"; List <string> animFilePaths = ResourceUtility.GetFiles(animFilesDir); foreach (string animFilePath in animFilePaths) { string animName = animFilePath.Replace(animFilesDir + "/", "").Replace(".rbxmx", ""); animations[animName] = animFilePath; } return(animations); }
private async void Launcher_Load(object sender, EventArgs e) { string myPath = Application.ExecutablePath; FileInfo myInfo = new FileInfo(myPath); string myName = myInfo.Name; string dir = myInfo.DirectoryName; if (myName.StartsWith("NEW_")) { string newPath = Path.Combine(dir, myName.Substring(4)); File.Copy(myInfo.FullName, newPath, true); Process.Start(newPath); Application.Exit(); } else { foreach (string filePath in Directory.GetFiles(dir)) { FileInfo info = new FileInfo(filePath); string fileName = info.Name; if (fileName.StartsWith("NEW_") && info.Extension.ToLower() == "exe") { File.Delete(info.FullName); break; } } } setStatus("Checking for updates"); string latestVersion = await GetGitHubString("version.txt"); string myVersion = Settings.GetSetting <string>("CurrentVersion"); if (latestVersion != myVersion) { setStatus("Updating Rbx2Source"); byte[] newVersion = await GetGitHubFile("Rbx2Source.exe"); string updatePath = Path.Combine(dir, "NEW_" + myName); File.WriteAllBytes(updatePath, newVersion); Settings.SaveSetting("CurrentVersion", latestVersion); Process.Start(updatePath); Application.Exit(); } bool addedLibraries = false; setStatus("Checking for required DLL files"); foreach (string library in ResourceUtility.GetFiles("Libraries")) { string libName = library.Replace("Libraries/", ""); string libPath = Path.Combine(dir, libName); if (!File.Exists(libPath)) { byte[] content = ResourceUtility.GetResource(library); addedLibraries = true; File.WriteAllBytes(libPath, content); } } if (addedLibraries) { await Task.Delay(1000); Application.Restart(); } setStatus("Starting Rbx2Source"); await Task.Delay(500); Rbx2Source rbx2Source = null; Task startRbx2Source = Task.Run(() => { rbx2Source = new Rbx2Source(); rbx2Source.baseProcess = this; }); await startRbx2Source; rbx2Source.Show(); Hide(); }
private async void Launcher_Load(object sender, EventArgs e) { string myPath = Application.ExecutablePath; FileInfo myInfo = new FileInfo(myPath); try { // Check if the current process is attached to the legacy launcher, so we can phase it out. Process self = Process.GetCurrentProcess(); ManagementObjectSearcher search = new ManagementObjectSearcher(@"root\CIMV2", "SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = " + self.Id); ManagementObjectCollection results = search.Get(); var scanResults = results.GetEnumerator(); // using var because the type name is ridiculous. if (scanResults.MoveNext()) { ManagementBaseObject query = scanResults.Current; uint parentId = (uint)query.GetPropertyValue("ParentProcessId"); Process parent = Process.GetProcessById((int)parentId); string parentPath = parent.MainModule.FileName; FileInfo info = new FileInfo(parentPath); if (info.Name == "Rbx2Source.exe" || info.Name == "Rbx2SourceLauncher.exe") { await setStatus("Phasing out the legacy launcher"); parent.Kill(); parent.WaitForExit(); File.Copy(myPath, parentPath, true); Process.Start(parentPath); Application.Exit(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } string myName = myInfo.Name; string dir = myInfo.DirectoryName; if (myName.StartsWith("NEW_")) { string newPath = Path.Combine(dir, myName.Substring(4)); File.Copy(myInfo.FullName, newPath, true); Process.Start(newPath); Application.Exit(); } else { foreach (string filePath in Directory.GetFiles(dir)) { FileInfo info = new FileInfo(filePath); string fileName = info.Name; if (fileName.StartsWith("NEW_") && info.Extension.ToLower() == "exe") { File.Delete(info.FullName); break; } } } await setStatus("Checking for updates"); string latestVersion = await GetGitHubString("version.txt"); string myVersion = Settings.GetSetting <string>("CurrentVersion"); if (latestVersion != myVersion) { await setStatus("Updating Rbx2Source"); Settings.SetSetting("CurrentVersion", latestVersion); Settings.Save(); byte[] newVersion = await GetGitHubFile("Rbx2Source.exe"); string updatePath = Path.Combine(dir, "NEW_" + myName); File.WriteAllBytes(updatePath, newVersion); Process.Start(updatePath); Application.Exit(); } await setStatus("Checking for required DLL files"); bool addedLibraries = false; foreach (string library in ResourceUtility.GetFiles("Libraries")) { string libName = library.Replace("Libraries/", ""); string libPath = Path.Combine(dir, libName); if (!File.Exists(libPath)) { byte[] content = ResourceUtility.GetResource(library); addedLibraries = true; File.WriteAllBytes(libPath, content); } } if (addedLibraries) { Application.Restart(); } await setStatus("Starting Rbx2Source"); Rbx2Source rbx2Source = new Rbx2Source(); rbx2Source.baseProcess = this; await Task.Delay(1000); rbx2Source.Show(); await Task.Delay(50); Hide(); }