コード例 #1
0
        void RenderProjectLoadPanel()
        {
            ImGui.BulletText("New projects must be placed in an empty directory.");

            ImGui.Text("Project Title:");
            ImGui.SameLine();
            ImGui.InputText("##label", ref projectTitle);

            if (ImGui.Button("Create New"))
            {
                string path = EditorActions.OpenFolderPathDialog();
                if (path != null)
                {
                    if (!ProjectManager.CreateProject(path, projectTitle))
                    {
                        Console.WriteLine("ProjectManager error: " + ProjectManager.ErrorString);
                    }

                    projectTitle = defaultTitle;
                }
            }

            ImGui.Separator();
            if (ImGui.Button("Load Existing"))
            {
                string path = EditorActions.OpenFilePathDialog("Perhaps Project Files (*.phproject)|*.phproject");
                if (path != null)
                {
                    if (!ProjectManager.OpenProject(path))
                    {
                        Console.WriteLine("ProjectManager error: " + ProjectManager.ErrorString);
                    }

                    projectTitle = defaultTitle;
                }
            }

            ImGui.Separator();
            ImGui.BulletText("Recent Projects:");

            FileObject <PerhapsProject>[] projects = ProjectManager.GetRecentProjects();
            ImGui.Separator();
            for (int i = 0; i < projects.Length; i++)
            {
                FileObject <PerhapsProject> projectFile = projects[i];
                PerhapsProject project = projectFile.Object;

                ImGui.PushItemWidth(-1);
                if (ImGui.Button($"{project.ProjectTitle}\n{projectFile.FilePath}\nTime Created: {project.timeCreated.ToString()}"))
                {
                    ProjectManager.OpenProject(projectFile.FilePath);
                    break;
                }
                ImGui.PopItemWidth();

                ImGui.Separator();
            }
        }