private void GUIFile() { if (bShowFileButton == false) { if (GUILayout.Button("[+]File", skin.customStyles[1])) { bShowFileButton = true; } } else { if (GUILayout.Button("[-]File", skin.customStyles[1])) { bShowFileButton = false; } } if (bShowFileButton) { //GUILayout.BeginVertical(skin.customStyles[0]); GUILayout.BeginHorizontal(); if (GUILayout.Button("New")) { curPath = ""; viewer.Clear(); } if (GUILayout.Button("Load")) { browser.OpenFile(Application.persistentDataPath, LoadModel); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save")) { if (curPath != "") { SaveModel(curPath); } else { browser.SaveFile(Application.persistentDataPath, Application.persistentDataPath, SaveModel); } } if (GUILayout.Button("Save As")) { browser.SaveFile(Application.persistentDataPath, Application.persistentDataPath, SaveModel); } GUILayout.EndHorizontal(); //GUILayout.BeginVertical(); } }
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 } }