public static void ApplyFlags()
        {
            var configs = new List <string>();

            foreach (string flagName in flagRegistry.GetSubKeyNames())
            {
                RegistryKey flagKey = flagRegistry.OpenSubKey(flagName);

                string type  = flagKey.GetString("Type"),
                       value = flagKey.GetString("Value");

                if (type.EndsWith("String", Program.StringFormat))
                {
                    value = $"\"{value.Replace("\"", "")}\"";
                }

                configs.Add($"\t\"{flagName}\": {value}");
            }
            ;

            string json      = "{\r\n" + string.Join(",\r\n", configs) + "\r\n}";
            string studioDir = StudioBootstrapper.GetStudioDirectory();

            string clientSettings = Path.Combine(studioDir, "ClientSettings");

            Directory.CreateDirectory(clientSettings);

            string filePath = Path.Combine(clientSettings, "ClientAppSettings.json");

            File.WriteAllText(filePath, json);
        }
        public static async Task PatchExplorerIcons()
        {
            string studioDir = StudioBootstrapper.GetStudioDirectory();
            string iconPath  = Path.Combine(studioDir, iconManifest);

            var   getPatched = Task.Run(() => getPatchedExplorerIcons());
            Image patched    = await getPatched.ConfigureAwait(true);

            patched.Save(iconPath);
        }
        private static string getExplorerIconDir()
        {
            string studioBin   = StudioBootstrapper.GetStudioDirectory();
            string explorerBin = Path.Combine(studioBin, "ExplorerIcons");

            if (!Directory.Exists(explorerBin))
            {
                Directory.CreateDirectory(explorerBin);
            }

            return(explorerBin);
        }
        private static Image getExplorerIcons()
        {
            string manifestHash = manifestRegistry.GetString(iconManifest);
            string currentHash  = infoRegistry.GetString("LastClassIconhash");

            if (currentHash != manifestHash)
            {
                string studioDir = StudioBootstrapper.GetStudioDirectory();
                UpdateExplorerIcons(studioDir);

                infoRegistry.SetValue("LastClassIconHash", manifestHash);
            }

            string imagePath     = infoRegistry.GetString("SourceLocation");
            Image  explorerIcons = Image.FromFile(imagePath);

            numIcons = explorerIcons.Width / iconSize;
            return(explorerIcons);
        }
Example #5
0
        public static async Task <bool> PatchExplorerIcons()
        {
            bool success = false;

            try
            {
                string studioDir = StudioBootstrapper.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);
        }
Example #6
0
        public static bool ApplyFlags()
        {
            try
            {
                List <string> configs = new List <string>();

                foreach (string flagName in flagRegistry.GetSubKeyNames())
                {
                    RegistryKey flagKey = flagRegistry.OpenSubKey(flagName);

                    string type  = flagKey.GetString("Type"),
                           value = flagKey.GetString("Value");

                    if (type.EndsWith("String"))
                    {
                        value = $"\"{value.Replace("\"", "")}\"";
                    }

                    configs.Add($"\t\"{flagName}\": {value}");
                }
                ;

                string json      = "{\r\n" + string.Join(",\r\n", configs) + "\r\n}";
                string studioDir = StudioBootstrapper.GetStudioDirectory();

                string clientSettings = Path.Combine(studioDir, "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 async void launchStudio_Click(object sender = null, EventArgs e = null)
        {
            string branch = getSelectedBranch();

            var bootstrapper = new StudioBootstrapper
            {
                ForceInstall           = forceRebuild.Checked,
                ApplyModManagerPatches = true,

                SetStartEvent = true,
                Branch        = branch
            };

            Hide();

            using (var installer = new BootstrapperForm(bootstrapper))
            {
                var install = installer.Bootstrap();
                await install.ConfigureAwait(true);
            }

            string studioRoot = StudioBootstrapper.GetStudioDirectory();
            string modPath    = getModPath();

            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))
                        {
                            continue;
                        }

                        modFileControl.CopyTo(relativeFile, true);
                        continue;
                    }

                    File.WriteAllBytes(relativeFile, fileContents);
                }
                catch
                {
                    Console.WriteLine("Failed to overwrite {0}!", modFile);
                }
            }

            var robloxStudioInfo = new ProcessStartInfo()
            {
                FileName  = StudioBootstrapper.GetStudioPath(),
                Arguments = $"-startEvent {StudioBootstrapper.StartEvent}"
            };

            if (args != null)
            {
                string firstArg = args[0];

                if (firstArg != null && firstArg.StartsWith("roblox-studio", Program.StringFormat))
                {
                    // 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"))
                    {
                        string launchMode = argMap["launchmode"];

                        if (launchMode == "plugin")
                        {
                            string pluginId = argMap["pluginid"];
                            robloxStudioInfo.Arguments += "-task InstallPlugin -pluginId " + pluginId;
                        }
                        else if (launchMode == "edit")
                        {
                            robloxStudioInfo.Arguments += "-task EditPlace";
                        }
                    }
                }
                else
                {
                    // Arguments were passed directly.
                    for (int i = 0; i < args.Length; i++)
                    {
                        string arg = args[i];

                        if (arg.Contains(' '))
                        {
                            arg = $"\"{arg}\"";
                        }

                        robloxStudioInfo.Arguments += ' ' + arg;
                    }
                }
            }

            if (openStudioDirectory.Checked)
            {
                Process.Start(studioRoot);
                Environment.Exit(0);
            }
            else
            {
                string currentVersion = versionRegistry.GetString("VersionGuid");
                versionRegistry.SetValue("LastExecutedVersion", currentVersion);

                Process.Start(robloxStudioInfo);
            }
        }