private void imgbAuxTag_Click(object sender, EventArgs e) { Platform platform = (Platform)cboxxSystemList.SelectedItem; string gameid = GameDefinition.GetGameID((string)cboxxGameList.SelectedItem, platform); GameDefinition selectedGame = null; foreach (GameDefinition game in Core.Prometheus.Instance.Games) { if (game.GameID == gameid) { selectedGame = game; break; } } if (selectedGame != null) { TagBrowserDialog _tagBrowser = new TagBrowserDialog(); if (_tagBrowser.ShowDialog(selectedGame) == DialogResult.OK) { txtbxAuxTag.Text = _tagBrowser.TagPath; pbAuxTag.Enabled = !String.IsNullOrEmpty(txtbxAuxTag.Text); } } }
private bool GenerateProject() { // Handle the creation of the project file. try { Platform platform = (Platform)cboxxSystemList.SelectedItem; string gameID = GameDefinition.GetGameID((string)cboxxGameList.SelectedItem, platform); projectFile = Core.Prometheus.Instance.ProjectManager.CreateProject(txtbxProjectName.Text, txtbxProjectAuthor.Text, gameID, cboxxTemplateList.SelectedItem as ProjectTemplate, txtbxProjectName.Text); } catch (CreateProjectFailedException) { return(false); } return(true); }
/// <summary> /// Loads the specified project file into a ProjectFile object, optionally notifying /// the GUI to load the scenario file. /// </summary> public ProjectFile OpenProject(string filename, ScenarioAction action) { // TODO: Ensure that the file exists. StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open)); string xmlText = reader.ReadToEnd(); reader.Close(); XmlDocument projectDoc = new XmlDocument(); projectDoc.LoadXml(xmlText); // Setup the object and locate its GameDef/Template objects. ProjectFile project = new ProjectFile(projectDoc); Platform platform = (Platform)Enum.Parse(typeof(Platform), project.GamePlatform); string gameID = GameDefinition.GetGameID(project.GameName, platform); GameDefinition def = Prometheus.Instance.GetGameDefinitionByGameID(gameID); gameDefinition = def; foreach (ProjectTemplate template in def.ProjectTemplates) { if (template.Name == project.TemplateName) { project.Template = template; } } // Locate the scenario tag. if (project.Templates.ContainsTemplateElement("Scenario")) { scenarioTag = project.Templates["Scenario"].Path; } else { throw new Exception("The project does not reference a scenario, which is a required element."); } // Open the DiskFileLibrary for the project. string projectFolder = Path.GetDirectoryName(filename); DiskFileLibrary library = new DiskFileLibrary(projectFolder + "\\Tags", project.MapName); // TODO: Decide which one of these is neccessary. project.ProjectFolder = library; this.projectFolder = library; // Add the project to the list and register it with the Pool. this.filename = filename; this.project = project; this.project.Dirty += new EventHandler(project_Dirty); Prometheus.Instance.Pool.RegisterProject(def.Name, library); // Hey other code! Guess what we just did!!!!!11 OnOpenedProject(); bool loadScenario = false; if (action == ScenarioAction.Load) { loadScenario = true; } else if (action == ScenarioAction.PromptUser) { CancelEventArgs e = new CancelEventArgs(false); if (ScenarioOpening != null) { ScenarioOpening(this, e); } loadScenario = !e.Cancel; } if (loadScenario) { try { TagPath path = new TagPath(project.Templates["Scenario"].Path, GameID, TagLocation.Project); Prometheus.Instance.OnAddScene(path); } catch (TagAlreadyExistsException ex) { Output.Write(OutputTypes.Warning, ex.Message); } catch (PoolException ex) { Output.Write(OutputTypes.Warning, ex.Message); } } return(project); }