Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        public static void DebugGame()
        {
            if (SceneManager.ActiveScene == null)
            {
                KryptonMessageBox.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
                        CompilerForm cf = new CompilerForm();
                        if(cf.ShowDialog() != DialogResult.Yes) 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.CreateNoWindow = true;
                debug.Start();
                debug.WaitForExit();
                debug.Close();
            }
            else
            {
                KryptonMessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
 private void compileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //CompileScripts(true);
     //ScriptsBuilder.ReloadScripts();
     CompilerForm cf = new CompilerForm();
     cf.ShowDialog();
 }
        /// <summary>
        /// 
        /// </summary>
        private void GlobalInput()
        {
            if (GameInput.IsKeyPressed(Keys.F6))
            {
                CompilerForm cf = new CompilerForm();
                cf.Show();
            }

            if (TileSetMode)
            {
                if (GameInput.IsKeyDown(Keys.Escape))
                {
                    EditorHandler.SelectedGameObjects.Clear();
                    EditorHandler.ChangeSelectedObjects();
                }
            }

            if (GameInput.IsKeyPressed(Keys.F5))
                EditorCommands.DebugGame();

            if (GameInput.IsKeyDown(Keys.LeftControl) && GameInput.IsKeyPressed(Keys.S))
            {
                EditorCommands.SaveProject();
                EditorCommands.SaveScene(false);
            }

            if (this.Focused)
            {
                if (GameInput.IsKeyPressed(Keys.Delete))
                {
                    if (EditorHandler.SelectedGameObjects.Count > 0 &&
                        ComponentFactory.Krypton.Toolkit.KryptonMessageBox.Show("Are you sure you want to delete the selected game object(s)?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        foreach (GameObject gameObject in EditorHandler.SelectedGameObjects)
                        {
                            GameObject.Remove(gameObject);
                        }

                        EditorHandler.SceneTreeView.CreateView();
                        EditorHandler.SelectedGameObjects = new List<GameObject>();
                        EditorHandler.ChangeSelectedObjects();
                    }
                }
                else if (GameInput.IsKeyPressed(Keys.Q))
                {
                    editorMode = EditorModes.Select;
                }
                else if (GameInput.IsKeyPressed(Keys.E))
                {
                    editorMode = EditorModes.Move;
                }
                else if (GameInput.IsKeyPressed(Keys.R))
                {
                    editorMode = EditorModes.Rotate;
                }
                else if (GameInput.IsKeyPressed(Keys.T))
                {
                    editorMode = EditorModes.Scale;
                }
                else if (GameInput.IsKeyPressed(Keys.G))
                {
                    SceneManager.GameProject.EditorSettings.ShowGrid = !SceneManager.GameProject.EditorSettings.ShowGrid;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        private bool LoadProject(string filename)
        {
            try
            {
                if (File.Exists(filename))
                {
                    SceneManager.GameProject = GibboProject.Load(filename);

                    File.Copy("Gibbo.Library.dll", SceneManager.GameProject.ProjectPath + "\\Gibbo.Library.dll", 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);
                    
                    SceneManager.ActiveScene = null;
                    EditorHandler.SceneTreeView.CreateView();

                    //CompileScripts(true);        
                    CompilerForm cf = new CompilerForm();
                    bool success = cf.ShowDialog() == System.Windows.Forms.DialogResult.Yes ? true : false;

                    Reload();

                    if (success)
                    {
                        LoadLastScene();
                        EditorCommands.ShowOutputMessage("Project loaded with sucess");

                        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)
            {
                KryptonMessageBox.Show("Invalid File\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return false;
        }