Beispiel #1
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);

                    // 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;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        internal static void DebugGame()
        {
            if (SceneManager.ActiveScene == null)
            {
                MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);

            SaveProject();
            SaveScene(false);

            if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
            {
                if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
                    File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");

                if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
                    Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");

                // Compile scripts:
                // old (depracated): CompileScripts(false);
                //if (SceneManager.ScriptsAssembly != null)
                //{
                string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";

                // The scripts .dll exists?
                if (!File.Exists(dllpath))
                {
                    // Compile scripts
                    CompilerWindow cf = new CompilerWindow();
                    cf.ShowDialog();

                    if (cf.DialogResult.Value) return;

                    // Update path
                    dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
                }

                File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);
                //}

                Process debug = new Process();
                debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
                debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
                debug.StartInfo.Arguments = "";
                debug.StartInfo.CreateNoWindow = true;
                debug.Start();
                debug.WaitForExit();
                debug.Close();
            }
            else
            {
                MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        internal static void DebugGame()
        {
            if (SceneManager.ActiveScene == null)
            {
                MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);

            SaveProject();
            SaveScene(false);

            if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
            {
                if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
                    File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");

                if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
                    Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");

                // Compile scripts:
                // old (depracated): CompileScripts(false);
                //if (SceneManager.ScriptsAssembly != null)
                //{
                string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";

                // The scripts .dll exists?
                if (!File.Exists(dllpath))
                {
                    // Compile scripts
                    CompilerWindow cf = new CompilerWindow();
                    cf.ShowDialog();

                    if (cf.DialogResult.Value) return;

                    // Update path
                    dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
                }

                File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);

                try
                {
                    Process debug = new Process();
                    debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
                    debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
                    debug.StartInfo.Arguments = "";
                    debug.StartInfo.CreateNoWindow = true;
                    debug.Start();

                    if (Properties.Settings.Default.AttachVisualStudio)
                    {
                        EnvDTE.DTE vsInstance;

                        // Try to restore the current project visual studio solution instance, returning it if successful
                        if (TryToRestoreSolution(out vsInstance))
                        {
                            // Tries to attach the retrieved instance to the game debug process
                            debug.Attach(vsInstance);
                        }

                        /*
                        if (VisualStudioInstancePID != 0 && Extensions.TryToRetrieveVSInstance(VisualStudioInstancePID, out vsInstance))
                        {
                            // restore window, in case the process is only running on background
                            vsInstance.MainWindow.Visible = true;

                            debug.Attach(vsInstance);
                        }
                        else // if PID attempt failed, try using the project solution name
                        {
                            // reset PID
                            VisualStudioInstancePID = 0;

                            // try to retrieve instance based on solution name
                            vsInstance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath);
                            if (vsInstance != null)
                            {
                                // restore window, in case the process is only running on background
                                vsInstance.MainWindow.Visible = true;

                                debug.Attach(vsInstance); // Attach visual studio dte
                            }
                        }*/


                    }

                    debug.WaitForExit();
                    debug.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private bool compileProject()
        {
            EditorCommands.ApplyBlurEffect(this);

            CompilerWindow cw = new CompilerWindow();

            cw.ShowDialog();
            EditorCommands.ClearEffect(this);
            EditorCommands.CreatePropertyGridView();

            return cw.Result;
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        internal static void DebugGame()
        {
            if (SceneManager.ActiveScene == null)
            {
                MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);

            SaveProject();
            SaveScene(false);

            if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
            {
                if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
                {
                    File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");
                }

                if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
                {
                    Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");
                }

                // Compile scripts:
                // old (depracated): CompileScripts(false);
                //if (SceneManager.ScriptsAssembly != null)
                //{
                string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";

                // The scripts .dll exists?
                if (!File.Exists(dllpath))
                {
                    // Compile scripts
                    CompilerWindow cf = new CompilerWindow();
                    cf.ShowDialog();

                    if (cf.DialogResult.Value)
                    {
                        return;
                    }

                    // Update path
                    dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
                }

                File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);

                try
                {
                    Process debug = new Process();
                    debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
                    debug.StartInfo.FileName         = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
                    debug.StartInfo.Arguments        = "";
                    debug.StartInfo.CreateNoWindow   = true;
                    debug.Start();

                    if (Properties.Settings.Default.AttachVisualStudio)
                    {
                        EnvDTE.DTE vsInstance;

                        // Try to restore the current project visual studio solution instance, returning it if successful
                        if (TryToRestoreSolution(out vsInstance))
                        {
                            // Tries to attach the retrieved instance to the game debug process
                            debug.Attach(vsInstance);
                        }

                        /*
                         * if (VisualStudioInstancePID != 0 && Extensions.TryToRetrieveVSInstance(VisualStudioInstancePID, out vsInstance))
                         * {
                         *  // restore window, in case the process is only running on background
                         *  vsInstance.MainWindow.Visible = true;
                         *
                         *  debug.Attach(vsInstance);
                         * }
                         * else // if PID attempt failed, try using the project solution name
                         * {
                         *  // reset PID
                         *  VisualStudioInstancePID = 0;
                         *
                         *  // try to retrieve instance based on solution name
                         *  vsInstance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath);
                         *  if (vsInstance != null)
                         *  {
                         *      // restore window, in case the process is only running on background
                         *      vsInstance.MainWindow.Visible = true;
                         *
                         *      debug.Attach(vsInstance); // Attach visual studio dte
                         *  }
                         * }*/
                    }

                    debug.WaitForExit();
                    debug.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
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);
        }
Beispiel #7
0
        /// <summary>
        /// 
        /// </summary>
        internal static void DebugGame()
        {
            if (SceneManager.ActiveScene == null)
            {
                MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);

            SaveProject();
            SaveScene(false);

            if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
            {
                if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
                    File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");

                if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
                    Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");

                // Compile scripts:
                // old (depracated): CompileScripts(false);
                //if (SceneManager.ScriptsAssembly != null)
                //{
                string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";

                // The scripts .dll exists?
                if (!File.Exists(dllpath))
                {
                    // Compile scripts
                    CompilerWindow cf = new CompilerWindow();
                    cf.ShowDialog();

                    if (cf.DialogResult.Value) return;

                    // Update path
                    dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
                }

                File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);

                try
                {
                    Process debug = new Process();
                    debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
                    debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
                    debug.StartInfo.Arguments = "";
                    debug.StartInfo.CreateNoWindow = true;
                    debug.Start();

                    if (Properties.Settings.Default.AttachVisualStudio)
                    {
                        EnvDTE.DTE instance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath);
                        if (instance != null)
                        {
                            debug.Attach(instance); // Attach visual studio dte
                        }
                    }

                    debug.WaitForExit();
                    debug.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }