Пример #1
0
        public async Task RunInstaller(string branch, bool setStartEvent = false)
        {
            restore();

            setStatus("Checking for updates");
            echo("Checking build installation...");

            string currentBranch  = Program.GetString("BuildBranch", "roblox");
            string currentVersion = versionRegistry.GetString("VersionGuid");

            bool   shouldInstall = (forceInstall || currentBranch != branch);
            string fastVersion   = await GetFastVersionGuid(currentBranch);

            ClientVersionInfo versionInfo = null;

            if (shouldInstall || fastVersion != currentVersion)
            {
                if (currentBranch != "roblox")
                {
                    echo("Possible update detected, verifying...");
                }

                versionInfo = await GetCurrentVersionInfo(branch, fastVersion);

                buildVersion = versionInfo.Guid;
            }
            else
            {
                buildVersion = fastVersion;
            }

            if (currentVersion != buildVersion || shouldInstall)
            {
                echo("This build needs to be installed!");
                bool studioClosed = await shutdownStudioProcesses();

                if (studioClosed)
                {
                    string binaryType = GetStudioBinaryType();
                    string studioDir  = GetStudioDirectory();
                    string versionId  = versionInfo.Version;

                    restore();
                    setStatus($"Installing Version {versionId} of Roblox Studio...");

                    var taskQueue = new List <Task>();
                    writtenFiles = new HashSet <string>();

                    echo("Grabbing package manifest...");
                    var pkgManifest = await PackageManifest.Get(branch, buildVersion);

                    echo("Grabbing file manifest...");
                    fileManifest = await FileManifest.Get(branch, buildVersion);

                    progressBar.Maximum = 5000;
                    progressBar.Value   = 0;

                    progressBar.Style = ProgressBarStyle.Continuous;
                    progressBar.Refresh();

                    foreach (var package in pkgManifest)
                    {
                        Task installer = Task.Run(() => installPackage(branch, package));
                        taskQueue.Add(installer);
                    }

                    await Task.WhenAll(taskQueue);

                    echo("Writing AppSettings.xml...");

                    string appSettings = Path.Combine(studioDir, "AppSettings.xml");
                    File.WriteAllText(appSettings, appSettingsXml);

                    setStatus("Deleting unused files...");
                    await deleteUnusedFiles();

                    progressBar.Style = ProgressBarStyle.Marquee;
                    progressBar.Refresh();

                    Program.SetValue("BuildBranch", branch);

                    versionRegistry.SetValue("Version", versionId);
                    versionRegistry.SetValue("VersionGuid", buildVersion);
                }
                else
                {
                    progressBar.Style = ProgressBarStyle.Marquee;
                    progressBar.Refresh();

                    echo("Update cancelled. Launching on current branch and version.");
                }
            }
            else
            {
                echo("This version of Roblox Studio has been installed!");
            }

            setStatus("Configuring Roblox Studio...");

            echo("Updating registry protocols...");
            Program.UpdateStudioRegistryProtocols();

            if (exitWhenClosed)
            {
                echo("Applying flag configuration...");
                FlagEditor.ApplyFlags();

                echo("Patching explorer icons...");
                await ClassIconEditor.PatchExplorerIcons();
            }

            setStatus("Starting Roblox Studio...");
            echo("Roblox Studio is up to date!");

            if (setStartEvent)
            {
                SystemEvent start = new SystemEvent("RobloxStudioModManagerStart");

                autoExitTask = Task.Run(async() =>
                {
                    bool started = await start.WaitForEvent();
                    start.Close();

                    if (started)
                    {
                        await Task.Delay(500);
                        Application.Exit();
                    }
                });

                StartEvent = start;
            }
        }
Пример #2
0
        private async void initializeEditor()
        {
            string localAppData = Environment.GetEnvironmentVariable("LocalAppData");

            string settingsDir  = Path.Combine(localAppData, "Roblox", "ClientSettings");
            string settingsPath = Path.Combine(settingsDir, "StudioAppSettings.json");

            string lastExecVersion = versionRegistry.GetString("LastExecutedVersion");
            string versionGuid     = versionRegistry.GetString("VersionGuid");

            if (lastExecVersion != versionGuid)
            {
                // Reset the settings file.
                Directory.CreateDirectory(settingsDir);
                File.WriteAllText(settingsPath, "");

                // Create some system events for studio so we can hide the splash screen.
                SystemEvent start = new SystemEvent("FFlagExtract");
                SystemEvent show  = new SystemEvent("NoSplashScreen");

                // Run Roblox Studio briefly so we can update the settings file.
                ProcessStartInfo studioStartInfo = new ProcessStartInfo()
                {
                    FileName  = StudioBootstrapper.GetStudioPath(),
                    Arguments = $"-startEvent {start.Name} -showEvent {show.Name}"
                };

                Process studio = Process.Start(studioStartInfo);
                await start.WaitForEvent();

                FileInfo info = new FileInfo(settingsPath);

                // Wait for the settings path to be written.
                while (info.Length == 0)
                {
                    await Task.Delay(30);

                    info.Refresh();
                }

                // Nuke studio and flag the version we updated with.
                versionRegistry.SetValue("LastExecutedVersion", versionGuid);
                studio.Kill();
            }

            // Initialize flag browser
            string[] flagNames = flagRegistry.GetSubKeyNames();

            string settings = File.ReadAllText(settingsPath);
            var    json     = Program.ReadJsonDictionary(settings);

            int numFlags  = json.Count;
            var flagSetup = new List <FVariable>(numFlags);

            var autoComplete = new AutoCompleteStringCollection();

            foreach (var pair in json)
            {
                string key     = pair.Key,
                         value = pair.Value;

                FVariable flag = new FVariable(key, value);
                autoComplete.Add(flag.Name);
                flagSetup.Add(flag);

                if (flagNames.Contains(flag.Name))
                {
                    // Update what the flag should be reset to if removed?
                    RegistryKey flagKey = flagRegistry.GetSubKey(flag.Name);
                    flagKey.SetValue("Reset", value);

                    // Set the flag's editor.
                    flag.SetEditor(flagKey);
                }
            }

            flagSearchFilter.AutoCompleteCustomSource = autoComplete;

            allFlags = flagSetup
                       .OrderBy(flag => flag.Name)
                       .ToList();

            refreshFlags();

            // Initialize override table.
            overrideTable = new DataTable();

            foreach (DataGridViewColumn column in overrideDataGridView.Columns)
            {
                overrideTable.Columns.Add(column.DataPropertyName);
            }

            DataView overrideView = new DataView(overrideTable);

            overrideView.Sort = "Name";

            foreach (string flagName in flagNames)
            {
                if (flagLookup.ContainsKey(flagName))
                {
                    int       index = flagLookup[flagName];
                    FVariable flag  = flags[index];
                    addFlagOverride(flag, true);
                }
            }

            overrideStatus.Visible          = true;
            overrideDataGridView.DataSource = overrideView;
        }
Пример #3
0
        public async Task RunInstaller(string branch, bool setStartEvent = false)
        {
            restore();

            setStatus("检查更新中");
            echo("检查该构建版本是否可安装...");

            string currentBranch  = Program.GetString("BuildBranch", "roblox");
            string currentVersion = versionRegistry.GetString("VersionGuid");

            bool   shouldInstall = (forceInstall || currentBranch != branch);
            string fastVersion   = await GetFastVersionGuid(currentBranch);

            ClientVersionInfo versionInfo = null;

            if (shouldInstall || fastVersion != currentVersion)
            {
                if (currentBranch != "roblox")
                {
                    echo("发现已有更新,验证中...");
                }

                versionInfo = await GetCurrentVersionInfo(branch, fastVersion);

                buildVersion = versionInfo.Guid;
            }
            else
            {
                buildVersion = fastVersion;
            }

            if (currentVersion != buildVersion || shouldInstall)
            {
                echo("此构建版本需要安装!");
                bool studioClosed = await shutdownStudioProcesses();

                if (studioClosed)
                {
                    string binaryType = GetStudioBinaryType();
                    string studioDir  = GetStudioDirectory();
                    string versionId  = versionInfo.Version;

                    restore();
                    setStatus($"正在安装版本为 {versionId} 的 Roblox Studio...");

                    var taskQueue = new List <Task>();
                    writtenFiles = new HashSet <string>();

                    echo("正在获取版本元信息...");
                    var pkgManifest = await PackageManifest.Get(branch, buildVersion);

                    echo("正在获取文件元信息...");
                    fileManifest = await FileManifest.Get(branch, buildVersion);

                    progressBar.Maximum = 5000;
                    progressBar.Value   = 0;

                    progressBar.Style = ProgressBarStyle.Continuous;
                    progressBar.Refresh();

                    foreach (var package in pkgManifest)
                    {
                        Task installer = Task.Run(() => installPackage(branch, package));
                        taskQueue.Add(installer);
                    }

                    await Task.WhenAll(taskQueue);

                    echo("正在写入 AppSettings.xml...");

                    string appSettings = Path.Combine(studioDir, "AppSettings.xml");
                    File.WriteAllText(appSettings, appSettingsXml);

                    setStatus("正在搜索未使用的文件...");
                    await deleteUnusedFiles();

                    progressBar.Style = ProgressBarStyle.Marquee;
                    progressBar.Refresh();

                    Program.SetValue("BuildBranch", branch);

                    versionRegistry.SetValue("Version", versionId);
                    versionRegistry.SetValue("VersionGuid", buildVersion);
                }
                else
                {
                    progressBar.Style = ProgressBarStyle.Marquee;
                    progressBar.Refresh();

                    echo("更新已取消,正在启动当前已有分支版本...");
                }
            }
            else
            {
                echo("该版本安装成功!");
            }

            setStatus("正在配置 Roblox Studio...");

            echo("正在更新注册表...");
            Program.UpdateStudioRegistryProtocols();

            if (exitWhenClosed)
            {
                echo("应用参数配置中...");
                FlagEditor.ApplyFlags();

                echo("修改浏览窗口图标中...");
                await ClassIconEditor.PatchExplorerIcons();
            }

            setStatus("正在启动 Roblox Studio...");
            echo("Roblox Studio 已为最新版!");

            if (setStartEvent)
            {
                SystemEvent start = new SystemEvent("RobloxStudioModManagerStart");

                autoExitTask = Task.Run(async() =>
                {
                    bool started = await start.WaitForEvent();
                    start.Close();

                    if (started)
                    {
                        await Task.Delay(500);
                        Application.Exit();
                    }
                });

                StartEvent = start;
            }
        }