Ejemplo n.º 1
0
 public static void SaveAs()
 {
     if (Engine.MapLoaded)
     {
         if (NfdResult.OKAY == NFD.SaveDialog("bin", Settings.CelesteDirectory, out string mapPath))
         {
             MapEditor.Instance.State.LoadedPath = mapPath + (mapPath.EndsWith(".bin") ? "" : ".bin");
             MapEditor.Instance.State.Save();
         }
         Input.Reset();
     }
 }
Ejemplo n.º 2
0
 public static void Open()
 {
     if (Engine.MapLoaded && MapEditor.Instance.State.Unsaved)
     {
         Engine.CreateWindow(new WindowUnsavedChanges(Open));
         return;
     }
     else if (NfdResult.OKAY == NFD.OpenDialog("bin", Settings.CelesteDirectory, out string mapPath))
     {
         MapEditor editor = new MapEditor();
         editor.LoadLevel(mapPath + (mapPath.EndsWith(".bin") ? "" : ".bin"));
         Engine.SetScene(editor);
     }
     Input.Reset();
 }
Ejemplo n.º 3
0
        public static void SaveRoomImage()
        {
            if (!Engine.MapLoaded || MapEditor.Instance == null)
            {
                return;
            }

            if (NfdResult.OKAY == NFD.SaveDialog("png", Settings.CelesteDirectory, out string pngPath))
            {
                if (!File.Exists(pngPath))
                {
                    using (FileStream stream = File.Create(pngPath + ".png")) {
                        stream.Close();
                    }
                }

                using (FileStream stream = File.Open(pngPath, FileMode.Truncate)) {
                    DrawableRoom dr = MapEditor.Instance.Renderer.SelectedRoom;

                    dr.Target.SaveAsPng(stream, dr.Room.Width, dr.Room.Height);
                }
            }
        }
Ejemplo n.º 4
0
        public static bool Save()
        {
            if (Engine.MapLoaded && MapEditor.Instance.State.Unsaved)
            {
                if (string.IsNullOrEmpty(MapEditor.Instance.State.LoadedPath))
                {
                    if (NfdResult.OKAY == NFD.SaveDialog("bin", Settings.CelesteDirectory, out string mapPath))
                    {
                        MapEditor.Instance.State.LoadedPath = mapPath + (mapPath.EndsWith(".bin") ? "" : ".bin");
                    }
                    Input.Reset();
                }

                if (string.IsNullOrEmpty(MapEditor.Instance.State.LoadedPath))
                {
                    return(false);
                }

                MapEditor.Instance.State.Save();
                return(true);
            }

            return(true);
        }
Ejemplo n.º 5
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();
            }
        }