private static void AddEmptyTreeItems() { #region Add the build items to the project - this generates UI for them // We need a project to be loaded so that we can investigate it for // what is a Screen/Entity in case there is no generated code already // present. // Update - I don't think this matters anymore, we should base it off of the // glux below Section.GetAndStartContextAndTime("Screens"); foreach (ScreenSave screen in ProjectManager.GlueProjectSave.Screens) { ElementViewWindow.AddScreen(screen);; } Section.EndContextAndTime(); Section.GetAndStartContextAndTime("Entities"); foreach (EntitySave entity in ProjectManager.GlueProjectSave.Entities) { ElementViewWindow.AddEntity(entity, generateCode: false); } ElementViewWindow.ResumeLayout(); Section.EndContextAndTime(); #endregion }
public void AddScreen(ScreenSave screenSave, bool suppressAlreadyExistingFileMessage = false) { var glueProject = GlueState.Self.CurrentGlueProject; string screenName = FileManager.RemovePath(screenSave.Name); string fileName = screenSave.Name + ".cs"; screenSave.Tags.Add("GLUE"); screenSave.Source = "GLUE"; glueProject.Screens.Add(screenSave); glueProject.Screens.SortByName(); #region Create the Screen code (not the generated version) var fullNonGeneratedFileName = FileManager.RelativeDirectory + fileName; var addedScreen = GlueCommands.Self.ProjectCommands.CreateAndAddCodeFile(fullNonGeneratedFileName, save: false); string projectNamespace = ProjectManager.ProjectNamespace; StringBuilder stringBuilder = new StringBuilder(CodeWriter.ScreenTemplateCode); CodeWriter.SetClassNameAndNamespace( projectNamespace + ".Screens", screenName, stringBuilder); string modifiedTemplate = stringBuilder.ToString(); if (addedScreen == null) { if (!suppressAlreadyExistingFileMessage) { MessageBox.Show("There is already a file named\n\n" + fullNonGeneratedFileName + "\n\nThis file will be used instead of creating a new one just in case you have code that you want to keep there."); } } else { FileManager.SaveText( modifiedTemplate, fullNonGeneratedFileName ); } #endregion #region Create <ScreenName>.Generated.cs string generatedFileName = @"Screens\" + screenName + ".Generated.cs"; ProjectManager.CodeProjectHelper.CreateAndAddPartialCodeFile(generatedFileName, true); #endregion // We used to set the // StartUpScreen whenever // the user made a new Screen. // The reason is we assumed that // the user wanted to work on this // Screen, so we set it as the startup // so they could run the game right away. // Now we only want to do it if there are no // other Screens. Otherwise they can just use // GlueView. var screenTreeNode = ElementViewWindow.AddScreen(screenSave); if (glueProject.Screens.Count == 1) { ElementViewWindow.StartUpScreen = screenTreeNode; } GlueCommands.Self.GenerateCodeCommands.GenerateElementCodeTask(screenSave); PluginManager.ReactToNewScreenCreated(screenSave); ProjectManager.SaveProjects(); GluxCommands.Self.SaveGlux(); }