Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            InitializeSettings();

            SceneManager.ScriptsAssembly = Assembly.LoadFile(Environment.CurrentDirectory + "\\libs\\Scripts.dll");

            if (!File.Exists(projectFilePath))
            {
                Exit();
            }

            SceneManager.GameProject = GibboProject.Load(projectFilePath);
            SceneManager.GameWindow  = this;

            //IsFixedTimeStep = (SceneManager.GameProject.ProjectSettings.VSyncEnabled) ? true : false;

            if (SceneManager.GameProject.Debug)
            {
                Console.WriteLine("Gibbo 2D - Game Engine Console");
                Console.WriteLine("Scene loaded with success!");
                Console.WriteLine("Path: " + SceneManager.GameProject.ProjectPath);
                Console.WriteLine("Assembly path " + SceneManager.ScriptsAssembly.Location.ToString());
            }

            Window.Title  = SceneManager.GameProject.ProjectName;
            originalTitle = SceneManager.GameProject.ProjectName;

            base.Initialize();
        }
        /// <summary>
        /// Tries to create a project with the given information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createBtn_Click(object sender, RoutedEventArgs e)
        {
            // are the pre-requirements done?
            if (nameTxt.Text.Trim() != string.Empty && pathTxt.Text != string.Empty)
            {
                nameTxt.Text = nameTxt.Text.Trim();
                string path = pathTxt.Text + "\\" + nameTxt.Text;

                // does the project already exist?
                if (Directory.Exists(path))
                {
                    MessageBox.Show("There is already a project with that name, please choose another", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                GibboProject gp = new GibboProject(nameTxt.Text, pathTxt.Text);
                gp.Save();

                File.Copy("Project Templates\\Gibbo.Engine.Windows.exe", path + "\\Gibbo.Engine.Windows.exe", true);
                File.Copy("Project Templates\\GameProject.csproj", path + "\\Scripts.csproj", true);
                File.Copy("Project Templates\\settings.ini", path + "\\settings.ini", true);


                // Solution Preparations
                string slnFile = File.ReadAllText("Project Templates\\GameProject.sln");
                slnFile = slnFile.Replace("{%P_NAME%}", nameTxt.Text);

                // Solution Save
                File.WriteAllText(path + "\\Scripts.sln", slnFile);

                File.Copy("Gibbo.Library.dll", path + "\\Gibbo.Library.dll", true);

                GibboHelper.CopyDirectory("Project Templates\\libs", path + "", true);
                GibboHelper.CopyDirectory("Project Templates\\samples", path + "\\samples", true);

                File.Copy("MonoGame.Framework.dll", path + "\\MonoGame.Framework.dll", true);
                File.Copy("OpenTK.dll", path + "\\OpenTK.dll", true);

                ProjectPath  = gp.ProjectFilePath;
                DialogResult = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("Fill all the required fields please.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #3
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);
        }
Exemple #4
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);
        }