public void LoadTag(CacheBase Cache, CacheBase.IndexItem Tag) { if (vMode == null) { vMode = new ModelViewer(); //this cant go in the constructor because the //tabModel.Controls.Clear(); //ElementHost in the ModelViewer requires an tabModel.Controls.Add(vMode); //STA thread, whereas the map open thread vMode.Dock = DockStyle.Fill; //is MTA because it's done via ThreadPool vMode.DefaultModeFormat = settings.ModeFormat; vMode.TagExtracted += new TagExtractedEventHandler(extractor_TagExtracted); vMode.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting); } else { vMode.Clear(); } if (vSbsp == null) { vSbsp = new BSPViewer(); //tabModel.Controls.Clear(); tabModel.Controls.Add(vSbsp); vSbsp.Dock = DockStyle.Fill; vSbsp.DefaultModeFormat = settings.ModeFormat; vSbsp.TagExtracted += new TagExtractedEventHandler(extractor_TagExtracted); vSbsp.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting); } else { vSbsp.Clear(); } cache = Cache; tag = Tag; metaLoaded = rawLoaded = modelLoaded = false; vMode.RenderBackColor = settings.ViewerColour; vSbsp.RenderBackColor = settings.ViewerColour; vSbsp.TextureScale = settings.mapScale / 100f; switch (Tag.ClassCode) { #region bitm case "bitm": tabControl1.TabPages.Remove(tabModel); tabRaw.Controls.Clear(); if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } tabRaw.Controls.Add(eBitm); eBitm.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } else if (tabControl1.SelectedTab == tabRaw) { eBitm.LoadBitmapTag(cache, tag); rawLoaded = true; } break; #endregion #region mode case "mode": case "mod2": tabRaw.Controls.Clear(); vSbsp.Visible = false; vMode.Visible = true; if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } if (!tabControl1.TabPages.Contains(tabModel)) { tabControl1.TabPages.Add(tabModel); } tabRaw.Controls.Add(eMode); eMode.Dock = DockStyle.Fill; //tabModel.Controls.Clear(); //tabModel.Controls.Add(vMode); //vMode.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } else if (tabControl1.SelectedTab == tabRaw) { eMode.DataFolder = settings.dataFolder; eMode.PermFilter = settings.permFilter; eMode.LoadModelTag(cache, tag); rawLoaded = true; } else if (tabControl1.SelectedTab == tabModel) { //vMode.RenderBackColor = settings.ViewerColour; vMode.PermutationFilter = new List <string>(settings.permFilter.Split(' ')); vMode.LoadModelTag(cache, tag, settings.Flags.HasFlag(SettingsFlags.LoadSpecular), settings.Flags.HasFlag(SettingsFlags.UsePermFilter), settings.Flags.HasFlag(SettingsFlags.ForceLoadModels)); modelLoaded = true; } break; #endregion #region sbsp case "sbsp": tabRaw.Controls.Clear(); vMode.Visible = false; vSbsp.Visible = true; if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } if (!tabControl1.TabPages.Contains(tabModel)) { tabControl1.TabPages.Add(tabModel); } tabRaw.Controls.Add(eSbsp); eSbsp.Dock = DockStyle.Fill; //tabModel.Controls.Clear(); //tabModel.Controls.Add(vSbsp); //vSbsp.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } else if (tabControl1.SelectedTab == tabRaw) { eSbsp.DataFolder = settings.dataFolder; eSbsp.LoadBSPTag(cache, tag); rawLoaded = true; } else if (tabControl1.SelectedTab == tabModel) { vSbsp.LoadBSPTag(cache, tag, settings.Flags.HasFlag(SettingsFlags.ForceLoadModels)); modelLoaded = true; } break; #endregion #region snd! case "snd!": tabControl1.TabPages.Remove(tabModel); tabRaw.Controls.Clear(); if (cache.Version < DefinitionSet.Halo3Retail) { tabControl1.TabPages.Remove(tabRaw); } else { if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } if (cache.Version < DefinitionSet.Halo4Retail) { tabRaw.Controls.Add(eSnd_); eSnd_.Dock = DockStyle.Fill; } else { tabRaw.Controls.Add(eSnd4); eSnd4.Dock = DockStyle.Fill; } } if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } else if (tabControl1.SelectedTab == tabRaw) { if (cache.Version < DefinitionSet.Halo4Retail) { eSnd_.LoadSoundTag(cache, tag); } else { eSnd4.LoadSoundTag(cache, tag); } rawLoaded = true; } break; #endregion #region unic case "unic": tabControl1.TabPages.Remove(tabModel); tabRaw.Controls.Clear(); if (cache.Version < DefinitionSet.Halo3Beta) { tabControl1.TabPages.Remove(tabRaw); } else { if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } tabRaw.Controls.Add(vUnic); vUnic.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } else if (tabControl1.SelectedTab == tabRaw) { vUnic.LoadUnicTag(cache, tag); rawLoaded = true; } } break; #endregion #region other default: tabControl1.TabPages.Remove(tabModel); tabControl1.TabPages.Remove(tabRaw); if (tabControl1.SelectedTab == tabMeta) { vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); metaLoaded = true; } break; #endregion } }
public void LoadTag(PakFile Pak, PakFile.PakTag Tag) { tabMeta.Controls.Clear(); tabMeta.Controls.Add(vS3D); vS3D.Dock = DockStyle.Fill; if (vMode == null) { vMode = new ModelViewer(); //this cant go in the constructor because the //tabModel.Controls.Clear(); //ElementHost in the ModelViewer requires an tabModel.Controls.Add(vMode); //STA thread, whereas the map open thread vMode.Dock = DockStyle.Fill; //is MTA because it's done via ThreadPool vMode.DefaultModeFormat = settings.ModeFormat; vMode.TagExtracted += new TagExtractedEventHandler(extractor_TagExtracted); vMode.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting); } else { vMode.Clear(); } if (vSbsp == null) { vSbsp = new BSPViewer(); //tabModel.Controls.Clear(); tabModel.Controls.Add(vSbsp); vSbsp.Dock = DockStyle.Fill; vSbsp.DefaultModeFormat = settings.ModeFormat; vSbsp.TagExtracted += new TagExtractedEventHandler(extractor_TagExtracted); vSbsp.ErrorExtracting += new ErrorExtractingEventHandler(extractor_ErrorExtracting); } else { vSbsp.Clear(); } pak = Pak; item = Tag; metaLoaded = rawLoaded = modelLoaded = false; vMode.RenderBackColor = settings.ViewerColour; vSbsp.RenderBackColor = settings.ViewerColour; vSbsp.TextureScale = settings.pakScale / 100f; switch (item.Class) { #region bitmaps case TagType.Textures: case TagType.TexturesMips64: tabControl1.TabPages.Remove(tabModel); tabRaw.Controls.Clear(); if (!tabControl1.TabPages.Contains(tabRaw)) { tabControl1.TabPages.Add(tabRaw); } tabRaw.Controls.Add(eBitm); eBitm.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabRaw) { eBitm.LoadBitmapTag(pak, item); rawLoaded = true; } break; #endregion #region models case TagType.Templates: tabControl1.TabPages.Remove(tabRaw); vMode.Visible = true; vSbsp.Visible = false; //if (!tabControl1.TabPages.Contains(tabRaw)) // tabControl1.TabPages.Add(tabRaw); if (!tabControl1.TabPages.Contains(tabModel)) { tabControl1.TabPages.Add(tabModel); } //tabRaw.Controls.Add(eMode); //eMode.Dock = DockStyle.Fill; //tabModel.Controls.Clear(); //tabModel.Controls.Add(vMode); //vMode.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { //vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); vS3D.LoadModelHierarchy(pak, item); metaLoaded = true; } //else if (tabControl1.SelectedTab == tabRaw) //{ // eMode.DataFolder = settings.dataFolder; // eMode.PermFilter = settings.permFilter; // eMode.LoadModelTag(cache, tag); // rawLoaded = true; //} else if (tabControl1.SelectedTab == tabModel) { //vMode.RenderBackColor = settings.ViewerColour; vMode.PermutationFilter = new List <string>(settings.permFilter.Split(' ')); vMode.LoadModelTag(pak, item, settings.Flags.HasFlag(SettingsFlags.LoadSpecular), settings.Flags.HasFlag(SettingsFlags.ForceLoadModels)); modelLoaded = true; } break; #endregion #region bsps case TagType.Scene: tabControl1.TabPages.Remove(tabRaw); vMode.Visible = false; vSbsp.Visible = true; if (!tabControl1.TabPages.Contains(tabModel)) { tabControl1.TabPages.Add(tabModel); } //tabRaw.Controls.Add(eSbsp); //eMode.Dock = DockStyle.Fill; //tabModel.Controls.Clear(); //tabModel.Controls.Add(vSbsp); //vSbsp.Dock = DockStyle.Fill; if (tabControl1.SelectedTab == tabMeta) { //vMeta.LoadTagMeta(cache, tag, settings.Flags.HasFlag(SettingsFlags.ShowInvisibles), settings.pluginFolder); vS3D.LoadModelHierarchy(pak, item); metaLoaded = true; } //else if (tabControl1.SelectedTab == tabRaw) //{ // eMode.DataFolder = settings.dataFolder; // eMode.PermFilter = settings.permFilter; // eMode.LoadModelTag(cache, tag); // rawLoaded = true; //} if (tabControl1.SelectedTab == tabModel) { vSbsp.LoadBSPTag(pak, item, settings.Flags.HasFlag(SettingsFlags.ForceLoadModels)); modelLoaded = true; } break; #endregion #region other default: tabControl1.TabPages.Remove(tabModel); tabControl1.TabPages.Remove(tabRaw); vS3D.DisplayTagInfo(pak, item); break; #endregion } }