private void ChangeLocalization(object sender, EventArgs e) { FailedToDeleteFileNotification = Resources.Failed_to_delete_image___0_; FailedToRenameFileNotification = Resources.Unable_to_rename_image___0_; ReasonFileInUse = Resources.The_image_file_is_in_use_by_another_process_; ReasonFileNotExisting = Resources.The_image_file_doesn_t_exist_anymore_; ReasonDublicateFileName = Resources.A_duplicate_image_name_was_specified_; ReasonEmptyFileName = Resources.Image_name_cannot_be_empty_; ReasonInvalidFileName = Resources.The_image_name_contains_invalid_characters_; PromptChangeFileName = Resources.Please_enter_a_different_image_name_; InvalidFileNameCharactersHint = Resources.The_following_characters_are_not_allowed___0_; FileDeletionPrompt = Resources.Delete_Image_; RenameFileTooltipText = Resources.Rename_Image; ZoomInThumbnailTooltipText = Resources.Click_To_Zoom; SearchBoxPlaceHolder = Resources.Search___; FavoriteMarkerTooltip = Resources.Favourite; UnfavoriteMarkerTooltip = Resources.Unfavourite; ScreenshotCreated = Resources.Screenshot_Created_; //TODO: Implement as View so panel reloads automatically. modulePanel?.Dispose(); modulePanel = BuildModulePanel(GameService.Overlay.BlishHudWindow); if (moduleTab != null) { GameService.Overlay.BlishHudWindow.RemoveTab(moduleTab); } moduleTab = GameService.Overlay.BlishHudWindow.AddTab(Name, _icon64, modulePanel, 0); }
/// <inheritdoc /> protected override void Unload() { // Unload CleanFavorites(); GameService.Overlay.UserLocaleChanged -= ChangeLocalization; printScreenKey.Enabled = false; printScreenKey.Activated -= ScreenshotNotify; printScreenKey = null; modulePanel.Hidden -= ToggleFileSystemWatchers; modulePanel.Shown -= ToggleFileSystemWatchers; modulePanel.Shown -= LoadImages; GameService.Overlay.BlishHudWindow.RemoveTab(moduleTab); moduleTab = null; modulePanel?.Dispose(); moduleCornerIcon?.Dispose(); thumbnailFlowPanel?.Dispose(); // avoiding resource leak for (var i = 0; i < screensPathWatchers.Count; i++) { if (screensPathWatchers[i] == null) { continue; } screensPathWatchers[i].Created -= OnScreenshotCreated; screensPathWatchers[i].Deleted -= OnScreenshotDeleted; screensPathWatchers[i].Renamed -= OnScreenshotRenamed; screensPathWatchers[i].Dispose(); screensPathWatchers[i] = null; } displayedThumbnails.Clear(); displayedThumbnails = null; // All static members must be manually unset ModuleInstance = null; }
public override void OnEnabled() { base.OnEnabled(); Directory.CreateDirectory(Path.Combine(GameService.FileSrv.BasePath, "musician")); xmlParser = new XmlMusicSheetReader(); displayedSheets = new List <SheetButton>(); MusicianTab = GameService.Director.BlishHudWindow.AddTab("Musician", ICON, BuildHomePanel(GameService.Director.BlishHudWindow), 0); }
private void CreateWindowTab() { WriteBlock.AppendTask(() => { var command = Command.Create(Guid.NewGuid().ToString()); command.Image = Resources.robot; command.Text = "WindowTab Created by EllieWare"; command.IsVisible = true; var tab = WindowTab.Create(command, new TextBox(), null); }); }
/// <summary> /// Allows you to perform an action once your module has finished loading (once /// <see cref="LoadAsync"/> has completed). You must call "base.OnModuleLoaded(e)" at the /// end for the <see cref="ExternalModule.ModuleLoaded"/> event to fire and for /// <see cref="ExternalModule.Loaded" /> to update correctly. /// </summary> protected override void OnModuleLoaded(EventArgs e) { _todoTab = GameService.Overlay.BlishHudWindow.AddTab("To-Do", _mugTexture, _tabPanel); // Add a mug icon in the top left next to the other icons _exampleIcon = new CornerIcon() { Icon = _mugTexture, BasicTooltipText = $"{this.Name} [{this.Namespace}]", Parent = GameService.Graphics.SpriteScreen }; base.OnModuleLoaded(e); }
protected override void OnModuleLoaded(EventArgs e) { MusicianTab = GameService.Overlay.BlishHudWindow.AddTab("Musician", ICON, BuildHomePanel(GameService.Overlay.BlishHudWindow), 0); base.OnModuleLoaded(e); }
private void OnGUI_Tabs() { if (currentTab == WindowTab.None) currentTab = WindowTab.Lines; // Tile the background texture Texture2D texture = EditorGUIUtility.isProSkin ? backgroundTextureDark : backgroundTextureLight; if (texture != null) GUI.DrawTextureWithTexCoords( new Rect(0, 0, Screen.width, Screen.height), texture, new Rect(0, 0, Screen.width / (float)texture.width, Screen.height / (float)texture.height), false); // Draw main menu GUI.BeginGroup(new Rect(2, 2, spacingInfo.totalWidth, SpacingInfo.menuHeight), ""); if (logoTexture != null) GUI.DrawTexture(new Rect(0, 0, 33, 21), logoTexture); int toolbarButtonWidth = (spacingInfo.totalWidth - 40) / 2; GUI.SetNextControlName("LinesToggle"); // So we can "focus" it bool linesToggle = GUI.Toggle(new Rect(40, 2, toolbarButtonWidth, 18), currentTab == WindowTab.Lines, "Lines", OurStyles.ToolbarButton); if (linesToggle) { currentTab = WindowTab.Lines; if (currentTab != lastTab) // Make sure this only happens once -- when actual state is switched, future toggle re-activations don't count { GUI.FocusControl("LinesToggle"); // Make sure we don't mess up focused field values } } GUI.SetNextControlName("SettingsToggle"); // So we can "focus" it bool settingsToggle = GUI.Toggle(new Rect(40 + toolbarButtonWidth + 2, 2, toolbarButtonWidth, 18), currentTab == WindowTab.Settings, "Settings", OurStyles.ToolbarButton); if (settingsToggle) { currentTab = WindowTab.Settings; deleteConfirmActive = false; // no delete confirmations if (currentTab != lastTab) // Make sure this only happens once -- when actual state is switched, future toggle re-activations don't count { GUI.FocusControl("SettingsToggle"); // Make sure we don't mess up focused field values } } GUI.EndGroup(); lastTab = currentTab; }
private void OnGUI_FullDataAssetSelection() { EditorGUILayout.HelpBox("EasyVoice could not find or automatically create its data asset!", MessageType.Warning); EditorGUILayout.Separator(); EasyVoiceDataAsset foundAsset = (EasyVoiceDataAsset)AssetDatabase.LoadAssetAtPath("Assets/" + EasyVoiceSettings.dataAssetName, typeof(EasyVoiceDataAsset)); if (foundAsset != null) { EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("You can use the existing data asset at \"Assets/" + EasyVoiceSettings.dataAssetName + "\":"); if (GUILayout.Button("Use existing data (recommended)", GUILayout.Width(300))) { AssignDataAssetToSettings(foundAsset); EditorUtility.SetDirty(settings); currentTab = WindowTab.Lines; // switch to lines if we were in settings } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("You may want to try and create a new one at \"Assets/" + EasyVoiceSettings.dataAssetName + "\":"); if (GUILayout.Button("Create data asset" + (foundAsset == null ? " (recommended)" : ""), GUILayout.Width(300))) { EasyVoiceDataAsset existingAsset = AssetDatabase.LoadAssetAtPath("Assets/" + EasyVoiceSettings.dataAssetName, typeof(EasyVoiceDataAsset)) as EasyVoiceDataAsset; bool okay = true; if (existingAsset != null) { okay = EditorUtility.DisplayDialog("Overwrite existing asset?", "There already is an \"Assets/" + EasyVoiceSettings.dataAssetName + "\" asset, do you want to overwrite it?", "Yes", "No"); } if (okay) CreateDataAssetForSettings(); EditorUtility.SetDirty(settings); } GUILayout.Label("(You may move, rename or assign different data later)"); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("Or assign an existing data asset from another location -- drop it here:"); EasyVoiceDataAsset newDataAsset = (EasyVoiceDataAsset)EditorGUILayout.ObjectField(null, typeof(EasyVoiceDataAsset), false, GUILayout.Width(300)); if (newDataAsset != null) { AssignDataAssetToSettings(newDataAsset); EditorUtility.SetDirty(settings); } EditorGUILayout.EndVertical(); }
private void OnGUI_SettingsTab() { GUILayout.Label("", GUILayout.Height(26)); settingsScrollPosition = EditorGUILayout.BeginScrollView(settingsScrollPosition); int labelWidth; EditorGUILayout.BeginVertical(OurStyles.SettingsBox); labelWidth = 150; GUILayout.Label("Defaults", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Label("Default speaker voice:", GUILayout.Width(labelWidth)); string[] speakerNames = settings.GetSpeakerNamesForEditor(true, true); string currentSpeakerName = settings.defaultVoice; if (settings.ValidVoiceName(currentSpeakerName, true)) { if (settings.SetDefaultVoice(settings.GetSpeakerName(EditorGUILayout.Popup(settings.GetSpeakerIndex(currentSpeakerName, true), speakerNames, GUILayout.Width(labelWidth)), true))) EasyVoiceIssueChecker.CheckAllFileNamesOrClips(); } else { settings.SetDefaultVoice(EditorGUILayout.TextField(settings.defaultVoice, GUILayout.Width(labelWidth - 24))); if (GUILayout.Button(new GUIContent("X", "Select voice from available voice list"), GUILayout.Width(24))) { if (settings.SetDefaultVoice(settings.GetFirstSpeakerNameOrDefault())) EasyVoiceIssueChecker.CheckAllFileNamesOrClips(); GUI.FocusControl("LinesToggle"); // make sure we are not focused on a wrong control (probably default file name edit box) } } if (GUILayout.Button(SafeTextureContent(refreshTextureDark, refreshTextureLight, "R", "Refresh the available system voice list"), OurStyles.RefreshButton, GUILayout.Width(20), GUILayout.Height(16))) { settings.querier.QueryForVoiceList(settings); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default output folder:", GUILayout.Width(labelWidth)); bool valid = settings.IsDefaultFolderValid(); if (!valid) GUI.backgroundColor = Color.red; if (settings.SetDefaultFolder(EditorGUILayout.TextField(settings.defaultFolder, GUILayout.MaxWidth(400)))) EasyVoiceIssueChecker.CheckAllFileNamesOrClips(); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (valid) { GUILayout.Label("", GUILayout.Width(labelWidth)); string fullPath = settings.GetFullClipDefaultPath(); //bool exists = Directory.Exists(fullPath); //-- very slow on Mac bool exists = new DirectoryInfo(fullPath).Exists; //FileAttributes fileAttributes = File.GetAttributes(fullPath); //bool exists = (FileAttributes.Directory & fileAttributes) != 0; if (!exists) { if (GUILayout.Button("Create", GUILayout.Width(150))) { try { Directory.CreateDirectory(fullPath); AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogError("EasyVoice failed to create the folder \"" + fullPath + "\" with error: " + e); } } } //if (!exists) // GUI.color = Color.red; GUILayout.Label(fullPath); //GUI.color = Color.white; } else { GUILayout.Label("", GUILayout.Width(labelWidth)); GUILayout.Label("Path must be a sub-path of your /Assets/ folder, such as \"/Audio/TTS clips/\""); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default file name:", GUILayout.Width(labelWidth)); if (settings.SetBaseDefaultFileName(EditorGUILayout.TextField(settings.baseDefaultFileName, GUILayout.MaxWidth(400)))) EasyVoiceIssueChecker.CheckAllFileNamesOrClips(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(labelWidth)); GUILayout.Label("Preview: \"" + settings.MakeFileNameFromTemplate(settings.defaultVoice, 3) + "\""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(labelWidth)); GUILayout.Label("You can use '$' to insert the default voice name and '#' to insert a unique number (multiple '#' for zero-padding)", OurStyles.WordWrappedLabel); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); labelWidth = 200; GUILayout.Label("Assets", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Label("Link lines with created audio clips?", GUILayout.Width(labelWidth)); settings.SetLinkClips(GUILayout.Toggle(settings.linkClips, "")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("When audio clips for lines are created, the generated asset will be linked to this line, so you can move/edit/rename it afterwards without losing the link to the line that created it.", OurStyles.WordWrappedLabel); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); labelWidth = 180; GUILayout.Label("Audio Clip Import Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Label("Apply custom settings", GUILayout.Width(labelWidth)); settings.audioImportSettings.applyCustomSettings = GUILayout.Toggle(settings.audioImportSettings.applyCustomSettings, new GUIContent("Yes", "If checked, newly created audio assets will have their (default) import settings set to the value specified below."), GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (!settings.audioImportSettings.applyCustomSettings) GUI.enabled = false; GUILayout.BeginHorizontal(); GUILayout.Label("Force to mono:", GUILayout.Width(labelWidth)); settings.audioImportSettings.forceToMono = GUILayout.Toggle(settings.audioImportSettings.forceToMono, "Yes"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Load in background:", GUILayout.Width(labelWidth)); settings.audioImportSettings.loadInBackground = GUILayout.Toggle(settings.audioImportSettings.loadInBackground, "Yes"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Preload data:", GUILayout.Width(labelWidth)); settings.audioImportSettings.preloadAudioData = GUILayout.Toggle(settings.audioImportSettings.preloadAudioData, "Yes"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default load type:", GUILayout.Width(labelWidth)); //settings.audioImportSettings.loadType = // EasyVoiceAudioClipImporter.LoadType( // (AudioClipLoadType)EditorGUILayout.EnumPopup( // EasyVoiceAudioClipImporter.LoadType(settings.audioImportSettings.loadType), GUILayout.Width(200))); settings.audioImportSettings.loadType = (EasyVoiceSettings.AudioImportSettings.LoadType)EditorGUILayout.EnumPopup(settings.audioImportSettings.loadType, GUILayout.Width(200)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default compression format:", GUILayout.Width(labelWidth)); //settings.audioImportSettings.compressionFormat = // EasyVoiceAudioClipImporter.CompressionFormat( // (AudioCompressionFormat)EditorGUILayout.EnumPopup( // EasyVoiceAudioClipImporter.CompressionFormat(settings.audioImportSettings.compressionFormat), GUILayout.Width(200))); settings.audioImportSettings.compressionFormat = (EasyVoiceSettings.AudioImportSettings.CompressionFormat)EditorGUILayout.EnumPopup(settings.audioImportSettings.compressionFormat, GUILayout.Width(200)); GUILayout.EndHorizontal(); // Note that default option only shows PCM, Vorbis and ADPCM if (settings.audioImportSettings.compressionFormat == EasyVoiceSettings.AudioImportSettings.CompressionFormat.Vorbis) // only default with this { GUILayout.BeginHorizontal(); GUILayout.Label("Default compression quality:", GUILayout.Width(labelWidth)); settings.audioImportSettings.quality = EditorGUILayout.Slider(Mathf.RoundToInt(settings.audioImportSettings.quality * 100f), 1, 100, GUILayout.Width(200)) / 100f; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("Default sample rate:", GUILayout.Width(labelWidth)); //settings.audioImportSettings.sampleRateSetting = // EasyVoiceAudioClipImporter.SampleRate( // (AudioSampleRateSetting)EditorGUILayout.EnumPopup( // EasyVoiceAudioClipImporter.SampleRate(settings.audioImportSettings.sampleRateSetting), GUILayout.Width(200))); settings.audioImportSettings.sampleRateSetting = (EasyVoiceSettings.AudioImportSettings.SampleRate)EditorGUILayout.EnumPopup(settings.audioImportSettings.sampleRateSetting, GUILayout.Width(200)); GUILayout.EndHorizontal(); if (settings.audioImportSettings.sampleRateSetting == EasyVoiceSettings.AudioImportSettings.SampleRate.OverrideSampleRate) { GUILayout.BeginHorizontal(); GUILayout.Label("Default compression quality:", GUILayout.Width(labelWidth)); settings.audioImportSettings.overrideSampleRate = SampleRatePopup(settings.audioImportSettings.overrideSampleRate); GUILayout.EndHorizontal(); } if (GUILayout.Button(new GUIContent("Reset to Unity defaults", "Revert import settings to match what Unity selects by default"), GUILayout.Width(200))) settings.audioImportSettings = new EasyVoiceSettings.AudioImportSettings(); //if (!settings.audioImportSettings.applyCustomSettings) GUI.enabled = true; GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("Import/Export", EditorStyles.boldLabel); GUILayout.Label("Import or export the lines data to or from an external CSV file"); GUILayout.BeginHorizontal(); if (settings.data.LineCount() != 0) { if (GUILayout.Button("Export data to file...", GUILayout.Width(200))) { string savePath = EditorUtility.SaveFilePanel("Export Easy Voice data file", "", "Easy Voice Data.csv", "csv"); if (savePath.Length != 0) { EasyVoiceDataImporter.ExportData(savePath); } } } else { GUI.enabled = false; GUILayout.Button(new GUIContent("Export data to file...", "You cannot export 0 lines, please create at least 1 voice line before exporting"), GUILayout.Width(200)); GUI.enabled = true; } if (GUILayout.Button("Import data from file...", GUILayout.Width(200))) { int option = -66; if (settings.data.LineCount() != 0) option = EditorUtility.DisplayDialogComplex("Importing over existing data", "Warning: Importing data from file will overwrite your existing lines, are you sure? You may also add to existing lines.", "Overwrite", "Append", "Cancel"); if (option == -66 || option == 0 || option == 1) { string loadPath = EditorUtility.OpenFilePanel("Import EasyVoice CSV file", "", "csv"); if (loadPath.Length != 0) { if (EasyVoiceDataImporter.ImportData(loadPath, settings, option == 1) == EasyVoiceDataImporter.ImportResult.matchingClipsFound) { if (settings.linkClips) if (EditorUtility.DisplayDialog("Link matching AudioClip assets?", "Your imported lines have file names that match existing AudioClips, do you want to automatically link these clips?", "Yes", "No")) EasyVoiceDataImporter.LinkClipsAfterImport(); } } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); settings.exportCSVFileEncodingUTF8 = EditorGUILayout.ToggleLeft("Set file to UTF8 encoding", settings.exportCSVFileEncodingUTF8, GUILayout.Width(170)); GUILayout.Label("(this will preserve non-ASCII characters, but some software may be incompatible with this setting)", OurStyles.WordWrappedLabel); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("Reference", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Label("External links", GUILayout.Width(100)); if (GUILayout.Button("Documentation", GUILayout.Width(200))) Application.OpenURL(EasyVoiceSettings.documentationUrl); if (GUILayout.Button("Help/support", GUILayout.Width(200))) Application.OpenURL(EasyVoiceSettings.forumUrl); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); advancedSettings = EditorGUILayout.Foldout(advancedSettings, "Advanced settings"); if (advancedSettings) { EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.BeginHorizontal(); GUILayout.Label("Force text-to-speech platform", GUILayout.Width(labelWidth)); settings.SetDefaultQuerier((DefaultQuerier)EditorGUILayout.EnumPopup(settings.defaultQuerier, GUILayout.Width(200))); GUILayout.EndHorizontal(); EditorGUILayout.HelpBox("Warning: selecting incompatible platform will cause speech generation to fail. Use this if Unity/EasyVoice cannot detect your platform automatically.", MessageType.Warning); if (settings.querier != null) { GUILayout.Label("Currently used text-to-speech platform: " + settings.querier.Name); } else { GUILayout.Label("Currently used text-to-speech: -none-"); } List<string> voiceNames = settings.voiceNames; // thread safer if (voiceNames != null) { GUILayout.Label("Currently available speaker names:"); foreach (string voiceName in voiceNames) { GUILayout.Label("* " + voiceName); } } else { GUILayout.Label("No speakers are available"); } // DEBUG EditorGUILayout.BeginHorizontal(); GUILayout.Label("Mac OS X output file format:", GUILayout.Width(200)); settings.osxFileFormat = EditorGUILayout.TextField(settings.osxFileFormat, GUILayout.Width(200)); if (GUILayout.Button("Default", GUILayout.Width(80))) { settings.osxFileFormat = "AIFFLE"; GUI.FocusControl("SettingsToggle"); // Make sure we don't mess up focused field values } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(OurStyles.SettingsBox); GUILayout.Label("If you want to manually unlink (forget) the current data asset, you can unlink it and the lines tab will offer you to create a new one or select another", OurStyles.WordWrappedLabel); if (GUILayout.Button("Unlink current data asset", GUILayout.Width(200))) { settings.UnlinkDataAsset(); currentTab = WindowTab.Lines; // because afterwards, creating new on linking will go back to settings } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); }
protected override void OnModuleLoaded(EventArgs e) { _eventsTab = GameService.Overlay.BlishHudWindow.AddTab("Events and Metas", this.ContentsManager.GetTexture(@"textures\1466345.png"), _tabPanel); base.OnModuleLoaded(e); }