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