private static string getExplorerIconDir() { string studioBin = RobloxStudioInstaller.GetStudioDirectory(); string explorerBin = Path.Combine(studioBin, "ExplorerIcons"); if (!Directory.Exists(explorerBin)) { Directory.CreateDirectory(explorerBin); } return(explorerBin); }
public static bool ApplyFlags() { try { List <string> configs = new List <string>(); foreach (string flagName in flagRegistry.GetSubKeyNames()) { RegistryKey flagKey = flagRegistry.OpenSubKey(flagName); string name = flagKey.GetString("Name"), type = flagKey.GetString("Type"), value = flagKey.GetString("Value"); string key = type + name; if (type.EndsWith("String")) { value = '"' + value.Replace("\"", "\\\"").Replace("\\\\", "\\") + '"'; } configs.Add($"\t\"{key}\": {value}"); } ; string json = "{\r\n" + string.Join(",\r\n", configs.ToArray()) + "\r\n}"; string studioDir = RobloxStudioInstaller.GetStudioDirectory(); string clientSettings = Path.Combine(studioDir, "ClientSettings"); if (!Directory.Exists(clientSettings)) { Directory.CreateDirectory(clientSettings); } string filePath = Path.Combine(clientSettings, "ClientAppSettings.json"); File.WriteAllText(filePath, json); return(true); } catch { Console.WriteLine("Failed to apply flag editor configuration!"); return(false); } }
private static Image getExplorerIcons() { string manifestHash = manifestRegistry.GetString(iconManifest); string currentHash = infoRegistry.GetString("LastClassIconHash"); if (currentHash != manifestHash) { string studioDir = RobloxStudioInstaller.GetStudioDirectory(); updateExplorerIcons(studioDir); infoRegistry.SetValue("LastClassIconHash", manifestHash); } string imagePath = infoRegistry.GetString("SourceLocation"); Image explorerIcons = Image.FromFile(imagePath); numIcons = explorerIcons.Width / iconSize; return(explorerIcons); }
public static async Task <bool> PatchExplorerIcons() { bool success = false; try { string studioDir = RobloxStudioInstaller.GetStudioDirectory(); string iconPath = Path.Combine(studioDir, iconManifest); Image patched = await Task.Factory.StartNew(getPatchedExplorerIcons); patched.Save(iconPath); } catch (Exception e) { Console.WriteLine("An error occurred while trying to patch the explorer icons: {0}", e.Message); } return(success); }
private async void launchStudio_Click(object sender = null, EventArgs e = null) { Hide(); string branch = (string)branchSelect.SelectedItem; RobloxStudioInstaller installer = new RobloxStudioInstaller(forceRebuild.Checked); await installer.RunInstaller(branch); string studioRoot = RobloxStudioInstaller.GetStudioDirectory(); string modPath = getModPath(); string[] studioFiles = Directory.GetFiles(studioRoot); string[] modFiles = Directory.GetFiles(modPath, "*.*", SearchOption.AllDirectories); foreach (string modFile in modFiles) { try { byte[] fileContents = File.ReadAllBytes(modFile); FileInfo modFileControl = new FileInfo(modFile); string relativeFile = modFile.Replace(modPath, studioRoot); string relativeDir = Directory .GetParent(relativeFile) .ToString(); if (!Directory.Exists(relativeDir)) { Directory.CreateDirectory(relativeDir); } if (File.Exists(relativeFile)) { byte[] relativeContents = File.ReadAllBytes(relativeFile); if (!fileContents.SequenceEqual(relativeContents)) { modFileControl.CopyTo(relativeFile, true); } } else { File.WriteAllBytes(relativeFile, fileContents); } } catch { Console.WriteLine("Failed to overwrite {0}!", modFile); } } // Hack in the metadata plugin. // This is used to provide an end-point to custom StarterScripts that are trying to fork what branch they are on. // It creates a BindableFunction inside of the ScriptContext called GetModManagerBranch, which returns the branch set in the launcher. try { Assembly self = Assembly.GetExecutingAssembly(); string metaScript; using (Stream stream = self.GetManifestResourceStream("RobloxStudioModManager.Resources.ModManagerMetadata.lua")) using (StreamReader reader = new StreamReader(stream)) { metaScript = reader.ReadToEnd(); metaScript = metaScript.Replace("%MOD_MANAGER_VERSION%", '"' + branch + '"'); // TODO: Make this something more generic? } string dir = Path.Combine(studioRoot, "BuiltInPlugins"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string metaScriptFile = Path.Combine(dir, "__rbxModManagerMetadata.lua"); FileInfo info = new FileInfo(metaScriptFile); if (info.Exists) { info.Attributes = FileAttributes.Normal; } File.WriteAllText(metaScriptFile, metaScript); // Make the file as readonly so that it (hopefully) won't be messed with. // I can't hide the file because Roblox Studio will ignore it. // If someone has the file open with write permissions, it will fail to write. info.Attributes = FileAttributes.ReadOnly; } catch { Console.WriteLine("Failed to write __rbxModManagerMetadata.lua"); } var robloxStudioInfo = new ProcessStartInfo(); robloxStudioInfo.FileName = RobloxStudioInstaller.GetStudioPath(); if (args != null) { string firstArg = args[0]; if (firstArg != null && firstArg.StartsWith("roblox-studio")) { // Arguments were passed by URI. var argMap = new Dictionary <string, string>(); foreach (string commandPair in firstArg.Split('+')) { if (commandPair.Contains(':')) { string[] kvPair = commandPair.Split(':'); string key = kvPair[0]; string val = kvPair[1]; if (key == "gameinfo") { // The user is authenticating. This argument is a special case. robloxStudioInfo.Arguments += " -url https://www.roblox.com/Login/Negotiate.ashx -ticket " + val; } else { argMap.Add(key, val); robloxStudioInfo.Arguments += " -" + key + ' ' + val; } } } if (argMap.ContainsKey("launchmode") && !argMap.ContainsKey("task")) { robloxStudioInfo.Arguments += "-task "; string launchMode = argMap["launchmode"]; string addToArgs = ""; if (launchMode == "plugin") { addToArgs = "InstallPlugin"; } else if (launchMode == "edit") { addToArgs = "EditPlace"; } robloxStudioInfo.Arguments += addToArgs; } } else { // Arguments were passed directly. string fullArg = string.Join(" ", args); robloxStudioInfo.Arguments += fullArg; } } if (openStudioDirectory.Checked) { Process.Start(studioRoot); } else { string currentVersion = versionRegistry.GetString("VersionGuid"); versionRegistry.SetValue("LastExecutedVersion", currentVersion); Process.Start(robloxStudioInfo); } Environment.Exit(0); }