Beispiel #1
0
        public override void Update(GameTime gt)
        {
            if (!StartupHelper.HasErrored)
            {
                LogoRotation = LogoRotation % (MathHelper.Pi * 2) + (float)gt.ElapsedGameTime.TotalSeconds * 2;
            }
            else
            {
                if (LogoRotation % (MathHelper.Pi * 2) > 0.001)
                {
                    float mod = LogoRotation % (MathHelper.Pi * 2);
                    LogoRotation = mod / 1.05f;
                }
                else
                {
                    LogoRotation = 0;
                }
            }

            TaskInterval -= (float)gt.ElapsedGameTime.TotalSeconds;

            // Continuously update the startup helper to check for finished tasks.
            if (TaskInterval < 0 && StartupHelper.CurrentlyStarting)
            {
                TaskInterval = 0.25f;
                StartupHelper.Update();
            }

            // Check if startup helper finished
            if (StartupHelper.Finished)
            {
                if (Alpha > 0.01)
                {
                    Alpha = Alpha /= 1.3f;
                }
                else
                {
                    SDL2.SDL.SDL_MaximizeWindow(Engine.Instance.Window.Handle);
                    Engine.SetScene(new BlankScene());
                }
            }
        }
Beispiel #2
0
 public virtual void Run()
 {
     StartupHelper.Finish(this);
 }
Beispiel #3
0
        public override void Render(GameTime gt)
        {
            Engine.Instance.GraphicsDevice.Clear(Settings.BackgroundColor);

            if (ShowInstallWindow)
            {
                // Show the window for selecting a Celeste installation.

                UIHelper.CenterWindow(new Vector2(500f, 280f));
                ImGui.Begin("Startup",
                            ImGuiWindowFlags.NoScrollbar |
                            ImGuiWindowFlags.NoResize |
                            ImGuiWindowFlags.NoCollapse |
                            ImGuiWindowFlags.NoMove |
                            ImGuiWindowFlags.NoTitleBar
                            );

                ImGui.TextWrapped("Please select the Celeste installation you would like Starforge to use. Click the Choose button to manually locate it.");

                ImGui.SetCursorPos(new System.Numerics.Vector2(10f, 50f));
                ImGui.SetNextItemWidth(480f);
                if (ImGui.ListBox("", ref Current, AutolocatedInstalls, AutolocatedInstalls.Length, 8))
                {
                    TryPath = AutolocatedInstalls[Current];
                }

                ImGui.SetCursorPosX(10f);
                ImGui.Text("Selected Location");

                ImGui.SetCursorPosX(10f);
                ImGui.SetNextItemWidth(480f);
                ImGui.InputText("", ref TryPath, 4096, ImGuiInputTextFlags.ReadOnly);

                ImGui.SetCursorPos(new System.Numerics.Vector2(294f, 250f));
                if (ImGui.Button("Quit", new System.Numerics.Vector2(50f, 20f)))
                {
                    Engine.Instance.Exit();
                }

                ImGui.SameLine();
                if (ImGui.Button("Choose", new System.Numerics.Vector2(60f, 20f)))
                {
                    if (NFD.PickFolder(Engine.RootDirectory, out string celestePath) == NfdResult.OKAY)
                    {
                        TryPath = celestePath;
                    }
                }

                ImGui.SameLine();
                if (ImGui.Button("Continue", new System.Numerics.Vector2(70f, 20f)))
                {
                    if (string.IsNullOrEmpty(TryPath))
                    {
                        PopupMsg = "No installation was selected.";
                        Popup    = true;
                    }
                    else
                    {
                        if (StartupHelper.IsCelesteInstall(TryPath))
                        {
                            Settings.CelesteDirectory = TryPath;
                            ShowInstallWindow         = false;

                            StartupHelper.BeginStartupTasks();
                        }
                        else
                        {
                            PopupMsg = "The selected folder is not a valid installation.";
                            Popup    = true;
                        }
                    }
                }

                ImGui.End();

                if (Popup)
                {
                    ImGui.OpenPopup("Notification");

                    UIHelper.CenterWindow(new Vector2(200f, 100f));
                    if (ImGui.BeginPopupModal("Notification", ref Popup, ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize))
                    {
                        ImGui.TextWrapped(PopupMsg);
                    }
                    ImGui.EndPopup();
                }
            }
            else
            {
                if (UnpackAtlases && !StartupHelper.Finished)
                {
                    StartupHelper.UnpackAtlases();
                }

                // Show the launch window.
                Engine.Batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null);
                Engine.Batch.Draw(GFX.Logo, new Vector2(Engine.Instance.GraphicsDevice.Viewport.Width / 2 - 128, Engine.Instance.GraphicsDevice.Viewport.Height / 2), GFX.Logo.Bounds, Color.White * Alpha, LogoRotation, new Vector2(GFX.Logo.Bounds.Center.X, GFX.Logo.Bounds.Center.Y), 1f, SpriteEffects.None, 0f);
                Engine.Batch.End();

                ImGui.PushStyleVar(ImGuiStyleVar.Alpha, Alpha);
                ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0f);
                ImGui.PushStyleColor(ImGuiCol.WindowBg, new System.Numerics.Vector4(0f, 0f, 0f, 0f));
                ImGui.SetNextWindowPos(new System.Numerics.Vector2(Engine.Instance.GraphicsDevice.Viewport.Width / 2, Engine.Instance.GraphicsDevice.Viewport.Height / 2 - ImGui.GetTextLineHeightWithSpacing()));
                ImGui.SetNextWindowSize(new System.Numerics.Vector2(256f, 64f));

                ImGui.Begin("Boot", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize);

                if (StartupHelper.FinishedFirstStage)
                {
                    ImGui.Text("Loading textures...");
                    ImGui.Text("This may take a moment.");

                    // Use this workaround to wait a frame to unpack atlases
                    UnpackAtlases = true;
                }
                else
                {
                    if (StartupHelper.HasErrored)
                    {
                        ImGui.Text("Starforge encountered an error.");
                        if (ImGui.Button("Open log"))
                        {
                            Logger.Close();
                            Process.Start(Path.Combine(Settings.ConfigDirectory, "log.txt"));
                        }
                    }
                    else
                    {
                        ImGui.Text("Launching Starforge...");
                        ImGui.Text($"{StartupHelper.FinishedTasks} / {StartupHelper.TotalTasks} tasks complete");
                    }
                }

                ImGui.End();
                ImGui.PopStyleVar(2);
                ImGui.PopStyleColor();
            }
        }