Example #1
0
        private async void menuTestGame_Click(object sender, EventArgs e)
        {
            if (IsProjectOpen)
            {
                menuTestGame.Enabled = toolTestGame.Enabled = false;
                menuDebug.Enabled    = toolDebug.Enabled = false;

                // save all non-untitled documents
                foreach (DocumentTab tab in
                         from tab in _tabs where tab.FileName != null
                         select tab)
                {
                    tab.SaveIfDirty();
                }

                if (TestGame != null)
                {
                    TestGame(null, EventArgs.Empty);
                }

                await BuildEngine.Test(Core.Project);
            }

            UpdateControls();
        }
Example #2
0
        public IdeWindow()
        {
            InitializeComponent();

            PluginManager.Core = this;

            InitializeDocking();
            PluginManager.Register(null, _projectTree, "Project Tree");

            Text = string.Format("{0} {1} {2}", Versioning.Name, Versioning.Version,
                                 Environment.Is64BitProcess ? "x64" : "x86");
            toolNew.DropDown = menuNew.DropDown;

            BuildEngine.Initialize();
            Core.Settings.Apply();

            Docking.Show(_projectTree);
            Docking.Activate(_projectTree);
            Refresh();

            if (Core.Settings.AutoOpenLastProject)
            {
                menuOpenLastProject_Click(null, EventArgs.Empty);
            }

            StyleManager.AutoStyle(this);
        }
Example #3
0
        private async Task StartDebugger()
        {
            foreach (DocumentTab tab in
                     from tab in _tabs
                     where tab.FileName != null
                     select tab)
            {
                tab.SaveIfDirty();
            }
            menuTestGame.Enabled = toolTestGame.Enabled = false;
            menuDebug.Enabled    = toolDebug.Enabled = false;

            if (TestGame != null)
            {
                TestGame(null, EventArgs.Empty);
            }

            Debugger = await BuildEngine.Debug(Core.Project);

            if (Debugger != null)
            {
                Debugger.Detached   += debugger_Detached;
                Debugger.Paused     += debugger_Paused;
                Debugger.Resumed    += debugger_Resumed;
                menuTestGame.Enabled = false;
                toolTestGame.Enabled = false;
                _isFirstDebugStop    = true;
                if (await Debugger.Attach())
                {
                    menuDebug.Text = "&Resume";
                    toolDebug.Text = "Resume";
                    var breaks = Core.Project.GetAllBreakpoints();
                    foreach (string filename in breaks.Keys)
                    {
                        foreach (int lineNumber in breaks[filename])
                        {
                            await Debugger.SetBreakpoint(filename, lineNumber);
                        }
                    }
                    await Debugger.Resume();
                }
                else
                {
                    Activate();
                    MessageBox.Show("Sphere Studio failed to start a debugging session.", "Unable to Start Debugging",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Debugger = null;
                    UpdateControls();
                }
            }

            UpdateControls();
        }
Example #4
0
        private async void menuBuildPackage_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog()
            {
                Title            = "Build Game Package",
                InitialDirectory = Core.Project.RootPath,
                Filter           = BuildEngine.GetSaveFileFilters(Core.Project),
                DefaultExt       = "spk",
                AddExtension     = true,
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                await BuildEngine.Package(Core.Project, sfd.FileName, false);
            }
        }
Example #5
0
        private void menuNewProject_Click(object sender, EventArgs e)
        {
            string         sphereDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Sphere Studio");
            string         rootPath  = Path.Combine(sphereDir, "Projects");
            NewProjectForm npf       = new NewProjectForm()
            {
                RootFolder = rootPath
            };

            var starter  = PluginManager.Get <IStarter>(Core.Settings.Engine);
            var compiler = PluginManager.Get <ICompiler>(Core.Settings.Compiler);

            if (starter == null || compiler == null)
            {
                MessageBox.Show(
                    "Unable to create a new Sphere Studio project.\n\nDefault engine and/or compiler plugins have not yet been selected.  Please open Configuration Manager and select a default engine and compiler plugin, then try again.",
                    "Operation Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (npf.ShowDialog() == DialogResult.OK)
            {
                if (!CloseCurrentProject())
                {
                    return;
                }
                if (BuildEngine.Prep(npf.NewProject))
                {
                    npf.NewProject.Save();
                    OpenProject(npf.NewProject.FileName, false);
                    _startPage.PopulateGameList();
                }
                else
                {
                    Directory.Delete(npf.NewProject.RootPath, true);
                }
            }
        }
Example #6
0
        private void UpdateControls()
        {
            var starter = IsProjectOpen
                ? PluginManager.Get <IStarter>(Core.Project.User.Engine)
                : null;
            bool haveConfig      = starter != null && starter.CanConfigure;
            bool haveLastProject = !string.IsNullOrEmpty(Core.Settings.LastProject);

            toolConfigEngine.Enabled = menuConfigEngine.Enabled = haveConfig;

            menuBuildPackage.Enabled = Core.Project != null &&
                                       BuildEngine.CanPackage(Core.Project);

            menuTestGame.Enabled = toolTestGame.Enabled = Core.Project != null &&
                                                          BuildEngine.CanTest(Core.Project) && Debugger == null;
            menuDebug.Enabled = toolDebug.Enabled = Core.Project != null &&
                                                    BuildEngine.CanDebug(Core.Project) &&
                                                    (Debugger == null || !Debugger.Running);
            menuBreakNow.Enabled  = toolPauseDebug.Enabled = Debugger != null && Debugger.Running;
            menuStopDebug.Enabled = toolStopDebug.Enabled = Debugger != null;
            menuStepInto.Enabled  = Debugger != null && !Debugger.Running;
            menuStepOut.Enabled   = Debugger != null && !Debugger.Running;
            menuStepOver.Enabled  = Debugger != null && !Debugger.Running;

            menuOpenLastProject.Enabled = haveLastProject;

            menuProjectProps.Enabled = GameToolButton.Enabled = IsProjectOpen;
            menuOpenGameDir.Enabled  = menuRefreshProject.Enabled = IsProjectOpen;

            SaveToolButton.Enabled = _activeTab != null && _activeTab.View.CanSave;
            CutToolButton.Enabled  = _activeTab != null;
            CopyToolButton.Enabled = _activeTab != null;

            if (_dock != null)
            {
                _dock.Refresh();
            }
        }