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(); }
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(); } } }