//private void AddNodes(GameObject obj)
        //{
        //    foreach (GameObject _obj in obj.Children)
        //    {
        //        AddGameObject(_obj.Transform.GameObject, null);
        //        //if (_obj.Children.Count > 0)
        //        //    AddNodes(_obj);
        //    }
        //}

        internal void AddFromState()
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.Title  = "Open State";
            ofd.Filter = @"(*.state)|*.state";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    GameObject gameObject = (GameObject)GibboHelper.DeserializeObject(ofd.FileName);
                    gameObject.Initialize();

                    AddGameObject(gameObject, string.Empty);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Пример #2
0
        public static bool DeployProject(string projectPath, string destinationPath, string platform)
        {
            List <string> blockedDirs = new List <string>();

            blockedDirs.Add("bin");
            blockedDirs.Add("obj");

            List <string> blockedFileExtensions = new List <string>();

            blockedFileExtensions.Add(".cs");
            //blockedFileExtensions.Add(".gibbo");
            blockedFileExtensions.Add(".csproj");
            blockedFileExtensions.Add(".sln");

            switch (platform.ToLower())
            {
            case "windows":
                // creates shadow directories
                foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(dirPath.Replace(projectPath, destinationPath));
                }

                // clear blocked directories from the root folder:
                foreach (string dirPath in Directory.GetDirectories(destinationPath, "*", SearchOption.TopDirectoryOnly))
                {
                    if (blockedDirs.Contains(System.IO.Path.GetFileName(dirPath)))
                    {
                        Directory.Delete(dirPath, true);
                    }
                }

                // copy all the files
                foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories))
                {
                    string filename = System.IO.Path.GetFileName(path);
                    string ext      = System.IO.Path.GetExtension(path);
                    if (!blockedFileExtensions.Contains(ext) &&
                        Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath))))
                    {
                        if (filename.ToLower().Equals("gibbo.engine.windows.exe"))
                        {
                            File.Copy(path, System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)) + "\\" + SceneManager.GameProject.ProjectName + ".exe", true);
                        }
                        else
                        {
                            File.Copy(path, path.Replace(projectPath, destinationPath), true);
                        }
                    }
                }

                RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories);

                return(true);

            case "windowsstore":
                // creates shadow directories
                foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(destinationPath.Replace(projectPath, destinationPath));
                }

                //Copy all the files
                foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories))
                {
                    if (!Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath))))
                    {
                        Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)));
                    }

                    if (path.ToLower().EndsWith(".scene"))
                    {
                        GameScene scene = (GameScene)GibboHelper.DeserializeObject(path);
                        GibboHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), scene);
                    }
                    else if (path.ToLower().EndsWith(".gibbo"))
                    {
                        GibboProject gp = (GibboProject)GibboHelper.DeserializeObject(path);
                        GibboHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), gp);
                    }
                    else
                    {
                        File.Copy(path, path.Replace(projectPath, destinationPath), true);
                    }
                }

                RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories);

                return(true);
            }

            return(false);
        }
Пример #3
0
        internal static bool LoadProject(string filename)
        {
            try
            {
                if (File.Exists(filename))
                {
                    SceneManager.GameProject = GibboProject.Load(filename);

                    //File.Copy("Farseer Engine MonoGame OpenGL.dll", SceneManager.GameProject.ProjectPath + "\\Farseer Engine MonoGame OpenGL.dll", true);
                    File.Copy("Gibbo.Library.dll", SceneManager.GameProject.ProjectPath + "\\Gibbo.Library.dll", true);
                    File.Copy("Project Templates\\Gibbo.Library.xml", SceneManager.GameProject.ProjectPath + "\\Gibbo.Library.xml", true);
                    File.Copy("Project Templates\\Gibbo.Engine.Windows.exe", SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe", true);
                    GibboHelper.CopyDirectory("Project Templates\\libs", SceneManager.GameProject.ProjectPath + "", true);
                    File.Copy("MonoGame.Framework.dll", SceneManager.GameProject.ProjectPath + "\\MonoGame.Framework.dll", true);
                    File.Copy("OpenTK.dll", SceneManager.GameProject.ProjectPath + "\\OpenTK.dll", true);
                    // load user settings:
                    if (!File.Exists(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb"))
                    {
                        UserPreferences.Instance = new UserPreferences();
                        GibboHelper.SerializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb", UserPreferences.Instance);
                    }
                    else
                    {
                        UserPreferences.Instance = GibboHelper.DeserializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb") as Model.UserPreferences;
                    }

                    SceneManager.ActiveScene = null;
                    EditorHandler.SelectedGameObjects.Clear();
                    EditorHandler.ChangeSelectedObjects();
                    EditorHandler.SceneTreeView.CreateView();
                    EditorHandler.ProjectTreeView.CreateView();

                    CompilerWindow cf = new CompilerWindow();
                    cf.ShowDialog();
                    bool success = cf.Result;

                    Reload();

                    if (success)
                    {
                        LoadLastScene();

                        EditorCommands.ShowOutputMessage("Project loaded with success");

                        //kryptonNavigator1.SelectedIndex = 1;
                    }
                    else
                    {
                        EditorCommands.ShowOutputMessage("Project loaded with script errors");
                    }

                    EditorHandler.Settings = new IniFile(SceneManager.GameProject.ProjectPath + "\\settings.ini");

                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid File\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(false);
        }