Example #1
0
        /// <summary>
        /// Creates a new project from scratch and opens it.
        /// </summary>
        /// <remarks>
        /// A project directory should look like the following:
        /// MyProject
        /// --Content
        /// -----Animations
        /// -----Audios
        /// -----Models
        /// -----Images
        /// --Places
        /// ------default.place
        /// ------place0.place
        /// ------place1.place
        /// --MyProject.game
        /// --MyProject.dproj
        /// --MyProject.ico (optional)
        /// </remarks>
        public static Project Create(string name, string directory)
        {
            var rootPath    = Path.Combine(directory, name);
            var contentPath = Path.Combine(rootPath, "Content");
            var placePath   = Path.Combine(rootPath, "Places");

            if (Directory.Exists(rootPath))
            {
                throw new InvalidOperationException($"The directory \"{directory}/{name}\" already exists.");
            }

            Directory.CreateDirectory(rootPath);
            Directory.CreateDirectory(contentPath);
            Directory.CreateDirectory(placePath);

            var projFile = Path.Combine(rootPath, $"{name}.dproj");

            File.Create(projFile).Close();

            var gameFile = Path.Combine(rootPath, $"{name}.game");

            File.Create(gameFile).Close();

            var proj = new Project
            {
                Name         = name,
                CompanyName  = Environment.UserName,
                ProjectPath  = rootPath,
                ProjectFile  = projFile,
                StartupPlace = "Place1",
                IsNew        = true
            };

            Editor.Current.Project = proj;
            Game.Workspace.PlaceId = proj.StartupPlace;

            NewPlaceViewModel.LoadBaseplate();

            proj.Save();
            proj.Open();


            return(proj);
        }
 public NewPlacePage()
 {
     InitializeComponent();
     BindingContext = new NewPlaceViewModel();
 }
Example #3
0
        public override void Execute(object parameter)
        {
            var model = new NewPlaceViewModel();

            Editor.Current.WindowManager.ShowDialog(model, null, model.GetDialogSettings());
        }