private static bool PrepareInitializationWindow(InitializationWindow initializationWindow) { mCurrentInitWindow = initializationWindow; bool closeInitWindow = false; if (mCurrentInitWindow == null) { closeInitWindow = true; mCurrentInitWindow = new InitializationWindow(); if (GlueGui.ShowGui) { mCurrentInitWindow.Show(MainGlueWindow.Self); } } return closeInitWindow; }
public void LoadProject(string projectFileName, InitializationWindow initializationWindow) { TimeManager.Initialize(); var topSection = Section.GetAndStartContextAndTime("All"); ////////////////// EARLY OUT!!!!!!!!! if (!File.Exists(projectFileName)) { GlueGui.ShowException("Could not find the project " + projectFileName + "\n\nOpening Glue without a project.", "Error Loading Project", null); return; } //////////////////// End EARLY OUT//////////////////////////////// FileWatchManager.PerformFlushing = false; bool closeInitWindow = PrepareInitializationWindow(initializationWindow); ClosePreviousProject(projectFileName); SetInitWindowText("Loading code project"); ProjectManager.ProjectBase = ProjectCreator.CreateProject(projectFileName); bool shouldLoad = true; if (ProjectManager.ProjectBase == null) { DialogResult result = MessageBox.Show( "The project\n\n" + projectFileName + "\n\nis an unknown project type. Would you like more " + "info on how to fix this problem?", "Unknown Project Type", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { System.Diagnostics.Process.Start("http://www.flatredball.com/frb/docs/index.php?title=Glue:Reference:Projects:csproj_File"); } shouldLoad = false; } // see if this project references any plugins that aren't installed: var glueFileName = FileManager.RemoveExtension(projectFileName) + ".glux"; if(System.IO.File.Exists(glueFileName)) { try { var tempGlux = GlueProjectSaveExtensions.Load(glueFileName); var requiredPlugins = tempGlux.PluginData.RequiredPlugins; List<string> missingPlugins = new List<string>(); foreach(var requiredPlugin in requiredPlugins) { if(PluginManager.AllPluginContainers.Any(item=>item.Name == requiredPlugin) == false) { missingPlugins.Add(requiredPlugin); } } if(missingPlugins.Count != 0) { var message = $"The project {glueFileName} requires the following plugins:"; foreach(var item in missingPlugins) { message += "\n" + item; } message += "\nWould you like to load the project anyway? It may not run, or may run incorrectly until all plugins are installed."; var result = MessageBox.Show(message, "Missing Plugins", MessageBoxButtons.YesNo); shouldLoad = result == DialogResult.Yes; } } catch(Exception e) { GlueGui.ShowMessageBox($"Could not load .glux file {glueFileName}. Error:\n\n{e.ToString()}"); shouldLoad = false; } } if (shouldLoad) { ProjectManager.ProjectBase.Load(projectFileName); SetInitWindowText("Finding Game class"); FileWatchManager.UpdateToProjectDirectory(); FileManager.RelativeDirectory = FileManager.GetDirectory(projectFileName); // this will make other threads work properly: FileManager.DefaultRelativeDirectory = FileManager.RelativeDirectory; ElementViewWindow.AddDirectoryNodes(); #region Load the GlueProjectSave file if one exists string glueProjectFile = ProjectManager.GlueProjectFileName; bool shouldSaveGlux = false; if (!FileManager.FileExists(glueProjectFile)) { ProjectManager.GlueProjectSave = new GlueProjectSave(); ProjectManager.FindGameClass(); GluxCommands.Self.SaveGlux(); // no need to do this - will do it in PerformLoadGlux: //PluginManager.ReactToLoadedGlux(ProjectManager.GlueProjectSave, glueProjectFile); //shouldSaveGlux = true; //// There's not a lot of code to generate so we can do it on the main thread //// so we get the save to occur after //GlueCommands.Self.GenerateCodeCommands.GenerateAllCodeSync(); //ProjectManager.SaveProjects(); } PerformGluxLoad(projectFileName, glueProjectFile); #endregion SetInitWindowText("Cleaning extra Screens and Entities"); foreach (ScreenTreeNode screenNode in ElementViewWindow.AllScreens) { if (screenNode.ScreenSave == null) { ScreenSave screenSave = new ScreenSave(); screenSave.Name = screenNode.Text; ProjectManager.GlueProjectSave.Screens.Add(screenSave); screenNode.ScreenSave = screenSave; } } foreach (EntityTreeNode entityNode in ElementViewWindow.AllEntities) { if (entityNode.EntitySave == null) { EntitySave entitySave = new EntitySave(); entitySave.Name = entityNode.Text; entitySave.Tags.Add("GLUE"); entitySave.Source = "GLUE"; ProjectManager.GlueProjectSave.Entities.Add(entitySave); entityNode.EntitySave = entitySave; } } UnreferencedFilesManager.Self.RefreshUnreferencedFiles(true); MainGlueWindow.Self.Text = "FlatRedBall Glue - " + projectFileName; MainGlueWindow.Self.SaveRecentProject(projectFileName); if (shouldSaveGlux) { GluxCommands.Self.SaveGlux(); } // saves the projects if dirty GlueCommands.Self.ProjectCommands.SaveProjects(); FileWatchManager.PerformFlushing = true; } if (closeInitWindow) { mCurrentInitWindow.Close(); } Section.EndContextAndTime(); // If we ever want to make things go faster, turn this back on and let's see what's going on. //topSection.Save("Sections.xml"); }
void ContentPipelineChange(bool useContentPipeline, CurrentElementOrAll currentOrAll) { TextureProcessorOutputFormat? textureFormat = null; if (useContentPipeline) { MultiButtonMessageBox mbmb = new MultiButtonMessageBox(); mbmb.MessageText = "How should the texture formats be set?"; mbmb.AddButton("Set to DXT Compression", DialogResult.Yes); mbmb.AddButton("Set to Color", DialogResult.OK); mbmb.AddButton("Do nothing", DialogResult.No); DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self); switch (result) { case DialogResult.Yes: textureFormat = TextureProcessorOutputFormat.DxtCompressed; break; case DialogResult.OK: textureFormat = TextureProcessorOutputFormat.Color; break; case DialogResult.No: // do nothing, leave it to null break; } } InitializationWindow initWindow = new InitializationWindow(); initWindow.Show(MainGlueWindow.Self); initWindow.Message = "Performing Operation..."; List<ReferencedFileSave> allRfses = new List<ReferencedFileSave>(); if (currentOrAll == CurrentElementOrAll.CurrentElement) { IElement element = EditorLogic.CurrentElement; allRfses.AddRange(element.ReferencedFiles); } else { allRfses.AddRange(ObjectFinder.Self.GetAllReferencedFiles()); } int totalRfs = allRfses.Count; //int count = 0; initWindow.SubMessage = "Removing/adding files as appropriate"; Application.DoEvents(); foreach (ReferencedFileSave rfs in allRfses) { if (rfs.GetAssetTypeInfo() != null && rfs.GetAssetTypeInfo().MustBeAddedToContentPipeline) { rfs.UseContentPipeline = true; } else { rfs.UseContentPipeline = useContentPipeline; } } ContentPipelineHelper.ReactToUseContentPipelineChange(allRfses); if (useContentPipeline) { initWindow.SubMessage = "Updating texture formats"; Application.DoEvents(); foreach (ReferencedFileSave rfs in allRfses) { if (textureFormat.HasValue) { rfs.TextureFormat = textureFormat.Value; } ContentPipelineHelper.UpdateTextureFormatFor(rfs); } } initWindow.SubMessage = "Refreshing UI"; Application.DoEvents(); if (EditorLogic.CurrentElement != null) { GlueCommands.RefreshCommands.RefreshUiForSelectedElement(); } initWindow.SubMessage = "Generating Code"; Application.DoEvents(); if (currentOrAll == CurrentElementOrAll.CurrentElement) { GlueCommands.GenerateCodeCommands.GenerateCurrentElementCode(); } else { GlueCommands.GenerateCodeCommands.GenerateAllCode(); } GlueCommands.GluxCommands.SaveGlux(); GlueCommands.ProjectCommands.SaveProjects(); initWindow.Close(); }
private void LoadGlueSettings(InitializationWindow initializationWindow) { string settingsFileLocation = GlueSettingsSave.SettingsFileName; if (FileManager.FileExists(settingsFileLocation)) { GlueSettingsSave settingsSave = null; bool didErrorOccur = false; try { settingsSave = FileManager.XmlDeserialize<GlueSettingsSave>(settingsFileLocation); } catch (Exception e) { MessageBox.Show("Error loading your settings file which is located at\n\n" + settingsFileLocation + "\n\nError details:\n\n" + e.ToString()); didErrorOccur = true; } if (!didErrorOccur) { ProjectManager.GlueSettingsSave = settingsSave; string csprojToLoad; GetCsprojToLoad(out csprojToLoad); // Load the plugins settings if it exists string gluxDirectory = null; if (!string.IsNullOrEmpty(csprojToLoad)) { gluxDirectory = FileManager.GetDirectory(csprojToLoad); } if (PluginSettings.FileExists(gluxDirectory)) { ProjectManager.PluginSettings = PluginSettings.Load(gluxDirectory); } else { ProjectManager.PluginSettings = new PluginSettings(); } // attempt to update the positions // This sets the last position, but doesn't work on multiple monitors //this.Left = settingsSave.WindowLeft; //this.Top = settingsSave.WindowTop; NumberOfStoredRecentFiles = settingsSave.StoredRecentFiles; // This used to be 0, b this.Height = settingsSave.WindowHeight > 100 ? settingsSave.WindowHeight : 480; this.Width = settingsSave.WindowWidth > 100 ? settingsSave.WindowWidth : 640; this.rightPanelContainer.SplitterDistance = settingsSave.MainSplitterDistance > 0 ? settingsSave.MainSplitterDistance : 450; updateRecentFileMenu(); } } else { ProjectManager.GlueSettingsSave.Save(); } }
private void LoadProjectConsideringSettingsAndArgs(InitializationWindow initializationWindow) { // This must be called after setting the GlueSettingsSave string csprojToLoad; var settingsSave = ProjectManager.GlueSettingsSave; GetCsprojToLoad(out csprojToLoad); if (!string.IsNullOrEmpty(csprojToLoad)) { if (initializationWindow != null) { initializationWindow.Message = "Loading " + csprojToLoad; } LoadProject(csprojToLoad, initializationWindow); } }
internal void StartUpGlue() { // Some stuff can be parallelized. We're going to run stuff // that can be parallelized in parallel, and then block to wait for // all tasks to finish when we need to AddObjectsToIocContainer(); InitializationWindow initializationWindow = new InitializationWindow(); // Initialize GlueGui before using it: GlueGui.Initialize(mMenu); GlueGui.ShowWindow(initializationWindow, this); initializationWindow.Message = "Initializing Glue Systems"; Application.DoEvents(); // Async stuff { initializationWindow.SubMessage = "Initializing WCF"; Application.DoEvents(); TaskManager.Self.AddAsyncTask(() => WcfManager.Self.Initialize(), "Initializing WCF"); initializationWindow.SubMessage = "Initializing EventManager"; Application.DoEvents(); TaskManager.Self.AddAsyncTask(() => EventManager.Initialize(), "Initializing EventManager"); Application.DoEvents(); initializationWindow.SubMessage = "Initializing ExposedVariableManager"; Application.DoEvents(); try { ExposedVariableManager.Initialize(); } catch (Exception excep) { TaskManager.Self.AddAsyncTask(() => GlueGui.ShowException("Could not load assemblies - you probably need to rebuild Glue.", "Error", excep), "Show error message about not being able to load assemblies"); return; } } initializationWindow.SubMessage = "Initialize Error Reporting"; Application.DoEvents(); ErrorReporter.Initialize(this); initializationWindow.SubMessage = "Initializing Right Click Menus"; Application.DoEvents(); RightClickHelper.Initialize(); initializationWindow.SubMessage = "Initializing Property Grids"; Application.DoEvents(); PropertyGridRightClickHelper.Initialize(); initializationWindow.SubMessage = "Initializing InstructionManager"; Application.DoEvents(); InstructionManager.Initialize(); initializationWindow.SubMessage = "Initializing TypeConverter"; Application.DoEvents(); TypeConverterHelper.InitializeClasses(); initializationWindow.SubMessage = "Initializing SearchBar"; Application.DoEvents(); SearchBarHelper.Initialize(SearchTextbox); initializationWindow.SubMessage = "Initializing Navigation Stack"; Application.DoEvents(); TreeNodeStackManager.Self.Initialize(NavigateBackButton, NavigateForwardButton); initializationWindow.Message = "Loading Glue Settings"; Application.DoEvents(); // We need to load the glue settings before loading the plugins so that we can // shut off plugins according to settings LoadGlueSettings(initializationWindow); // Initialize before loading GlueSettings; // Also initialize before loading plugins so that plugins // can access the standard ATIs #if GLUE string startupPath = FileManager.GetDirectory(System.Reflection.Assembly.GetExecutingAssembly().Location); #else string startupPath = FileManager.StartupPath; #endif AvailableAssetTypes.Self.Initialize(startupPath); initializationWindow.Message = "Loading Plugins"; Application.DoEvents(); List<string> pluginsToIgnore = new List<string>(); if (GlueState.Self.CurrentPluginSettings != null) { pluginsToIgnore = GlueState.Self.CurrentPluginSettings.PluginsToIgnore; } PluginManager.SetTabs(tcTop, tcBottom, tcLeft, tcRight, MainTabControl, toolbarControl1); PluginManager.Initialize(true, pluginsToIgnore); ShareUiReferences(PluginCategories.All); try { FileManager.PreserveCase = true; initializationWindow.Message = "Initializing File Watch"; Application.DoEvents(); // Initialize the FileWatchManager before LoadGlueSettings FileWatchManager.Initialize(); initializationWindow.Message = "Loading Custom Type Info"; Application.DoEvents(); // InitializeElementViewWindow needs to happen before LoadGlueSettings InitializeElementViewWindow(); Application.DoEvents(); // Gotta do this too before Loading Glue Settings ProjectManager.Initialize(); initializationWindow.Message = "Loading Project"; Application.DoEvents(); // LoadSettings before loading projects EditorData.LoadPreferenceSettings(); VisibilityManager.ReactivelySetItemViewVisibility(); while (TaskManager.Self.AreAllAsyncTasksDone == false) { System.Threading.Thread.Sleep(100); } LoadProjectConsideringSettingsAndArgs(initializationWindow); // This needs to happen after loading the project: ShareUiReferences(PluginCategories.ProjectSpecific); PropertyGridHelper.Initialize(PropertyGrid); Application.DoEvents(); EditorData.FileAssociationSettings.LoadSettings(); EditorData.LoadGlueLayoutSettings(); rightPanelContainer.Panel2MinSize = 125; try { leftPanelContainer.SplitterDistance = EditorData.GlueLayoutSettings.LeftPanelSplitterPosition; topPanelContainer.SplitterDistance = EditorData.GlueLayoutSettings.TopPanelSplitterPosition; rightPanelContainer.SplitterDistance = EditorData.GlueLayoutSettings.RightPanelSplitterPosition; bottomPanelContainer.SplitterDistance = EditorData.GlueLayoutSettings.BottomPanelSplitterPosition; } catch { // do nothing } if (EditorData.GlueLayoutSettings.Maximized) WindowState = FormWindowState.Maximized; //ProcessLocations.Initialize(); ProjectManager.mForm = this; } catch (Exception exc) { if (GlueGui.ShowGui) { System.Windows.Forms.MessageBox.Show(exc.ToString()); FileManager.SaveText(exc.ToString(), FileManager.UserApplicationDataForThisApplication + "InitError.txt"); PluginManager.ReceiveError(exc.ToString()); HasErrorOccurred = true; } else { throw; } } finally { if (GlueGui.ShowGui) { initializationWindow.Close(); this.BringToFront(); } } }
public void LoadProject(string projectFileName, InitializationWindow initializationWindow) { ProjectLoader.Self.LoadProject(projectFileName, initializationWindow); }