private void DiscoverGMS2()
        {
            string runtimesPath = Environment.ExpandEnvironmentVariables(SettingsWindow.GameMakerStudio2RuntimesPath);

            if (!Directory.Exists(runtimesPath))
            {
                return;
            }

            Regex runtimePattern = new Regex(@"^runtime-(.*)$");

            foreach (var runtimePath in Directory.EnumerateDirectories(runtimesPath))
            {
                Match m = runtimePattern.Match(System.IO.Path.GetFileName(runtimePath));
                if (!m.Success)
                {
                    continue;
                }

                string runtimeRunner = System.IO.Path.Combine(runtimePath, @"windows\Runner.exe");
                if (!File.Exists(runtimeRunner))
                {
                    continue;
                }

                Runtimes.Add(new Runtime()
                {
                    Version = m.Groups[1].Value, Path = runtimeRunner
                });
            }
        }
        private void DiscoverGMS1()
        {
            string studioRunner = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables(SettingsWindow.GameMakerStudioPath), "Runner.exe");

            if (!File.Exists(studioRunner))
            {
                return;
            }

            string studioDebugger = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables(SettingsWindow.GameMakerStudioPath), @"GMDebug\GMDebug.exe");

            if (!File.Exists(studioDebugger))
            {
                studioDebugger = null;
            }

            Runtimes.Add(new Runtime()
            {
                Version = "1.4.xxx", Path = studioRunner, DebuggerPath = studioDebugger
            });
        }
        private void DiscoverGameExe(string dataFilePath, UndertaleData data)
        {
            string gameExeName = data?.GeneralInfo?.Filename?.Content;

            if (gameExeName == null)
            {
                return;
            }

            string gameExePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(dataFilePath), gameExeName + ".exe");

            if (!File.Exists(gameExePath))
            {
                return;
            }

            Runtimes.Add(new Runtime()
            {
                Version = "Game EXE", Path = gameExePath
            });
        }
        private async Task LoadAsync()
        {
            var rootUri = "https://api.nuviot.com/api/simulator/network/runtime";

            switch (_environment)
            {
            case Environments.Development:
                rootUri = "https://dev.nuviot.com/api/simulator/network/runtime";
                break;

            case Environments.Testing:
                rootUri = "https://test.nuviot.com/api/simulator/network/runtime";
                break;

            case Environments.LocalDevelopment:
                rootUri = "http://localhost:5001/api/simulator/network/runtime";
                break;

            default:
                break;
            }

            var requestId = Guid.NewGuid().ToId();
            var dateStamp = DateTime.UtcNow.ToJSONString();
            var version   = "1.0.0";

            var bldr = new StringBuilder();

            //Adding the \r\n manualy ensures that the we don't have any
            //platform specific code messing with our signature.
            bldr.Append($"{requestId}\r\n");
            bldr.Append($"{dateStamp}\r\n");
            bldr.Append($"{version}\r\n");
            bldr.Append($"{_org.Id}\r\n");
            bldr.Append($"{_user.Id}\r\n");
            bldr.Append($"{_simulatorNetworkId}\r\n");

            var sasKey = GetSignature(requestId, _simAccessKey, bldr.ToString());

            _adminLogger.AddCustomEvent(Core.PlatformSupport.LogLevel.Message, "SimulatorRuntimeManager_InitAsync", $"Requesting configuration from: {rootUri} ");
            Console.WriteLine($"Requesting configuration from: {rootUri}");


            var client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("SAS", sasKey);
            client.DefaultRequestHeaders.Add(REQUEST_ID, requestId);
            client.DefaultRequestHeaders.Add(ORG_ID, _org.Id);
            client.DefaultRequestHeaders.Add(ORG, _org.Text);
            client.DefaultRequestHeaders.Add(USER_ID, _user.Id);
            client.DefaultRequestHeaders.Add(USER, _user.Text);
            client.DefaultRequestHeaders.Add(NETWORK_ID, _simulatorNetworkId);
            client.DefaultRequestHeaders.Add(DATE, dateStamp);
            client.DefaultRequestHeaders.Add(VERSION, version);

            try
            {
                var json = await client.GetStringAsync(rootUri);

                Runtimes.Clear();

                var network = JsonConvert.DeserializeObject <SimulatorNetwork>(json);
                Console.WriteLine($"Loaded simulator network {network.Name}");

                foreach (var sim in network.Simulators)
                {
                    var services = _factory.GetServices();
                    var runtime  = new SimulatorRuntime(services, Publisher, _adminLogger, sim);
                    await runtime.StartAsync();

                    Runtimes.Add(runtime);
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error loading runtime.");
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
        }