From 63407f775fc6574ec444a8a05933c77d1b3abf8e Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 18 Apr 2021 23:03:34 +0200 Subject: [PATCH] Fix imgui deprecation warnings, some formatting. --- Penumbra/UI/MenuTabs/TabEffective.cs | 4 +- .../TabInstalled/TabInstalledDetails.cs | 42 ++++++++++--------- .../TabInstalled/TabInstalledDetailsEdit.cs | 4 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Penumbra/UI/MenuTabs/TabEffective.cs b/Penumbra/UI/MenuTabs/TabEffective.cs index 33a1d8b1..a5e7e3c9 100644 --- a/Penumbra/UI/MenuTabs/TabEffective.cs +++ b/Penumbra/UI/MenuTabs/TabEffective.cs @@ -53,14 +53,14 @@ namespace Penumbra.UI return; } - if( ImGui.ListBoxHeader( "##effective_files", AutoFillSize ) ) + if( ImGui.BeginListBox( "##effective_files", AutoFillSize ) ) { foreach( var file in _mods.ResolvedFiles ) { DrawFileLine( file.Value, file.Key ); } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); } ImGui.EndTabItem(); diff --git a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs index 18aec077..72c369b8 100644 --- a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs +++ b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs @@ -45,8 +45,8 @@ namespace Penumbra.UI private const string LabelConfigurationTab = "Configuration"; private const string TooltipFilesTab = - "Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\n" + - "Yellow files are restricted to some options."; + "Green files replace their standard game path counterpart (not in any option) or are in all options of a Single-Select option.\n" + + "Yellow files are restricted to some options."; private const float TextSizePadding = 5f; private const float OptionSelectionWidth = 140f; @@ -130,8 +130,11 @@ namespace Penumbra.UI } // This is only drawn when we have a mod selected, so we can forgive nulls. - private ModInfo Mod => _selector.Mod()!; - private ModMeta Meta => Mod.Mod.Meta; + private ModInfo Mod + => _selector.Mod()!; + + private ModMeta Meta + => Mod.Mod.Meta; private void Save() { @@ -193,10 +196,10 @@ namespace Penumbra.UI if( ImGui.BeginTabItem( LabelChangedItemsTab ) ) { ImGui.SetNextItemWidth( -1 ); - if( ImGui.ListBoxHeader( LabelChangedItemsHeader, AutoFillSize ) ) + if( ImGui.BeginListBox( LabelChangedItemsHeader, AutoFillSize ) ) { _changedItemsList ??= Meta.ChangedItems - .Select( ( I, index ) => ( $"{LabelChangedItemIdx}{index}", I ) ).ToArray(); + .Select( ( I, index ) => ( $"{LabelChangedItemIdx}{index}", I ) ).ToArray(); for( var i = 0; i < Meta.ChangedItems.Count; ++i ) { @@ -213,14 +216,14 @@ namespace Penumbra.UI { ImGui.SetNextItemWidth( -1 ); if( ImGui.InputText( LabelChangedItemNew, ref newItem, 128, flags ) - && newItem.Length > 0 ) + && newItem.Length > 0 ) { Meta.ChangedItems.Add( newItem ); _selector.SaveCurrentMod(); } } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); } ImGui.EndTabItem(); @@ -239,7 +242,7 @@ namespace Penumbra.UI } ImGui.SetNextItemWidth( -1 ); - if( ImGui.ListBoxHeader( LabelConflictsHeader, AutoFillSize ) ) + if( ImGui.BeginListBox( LabelConflictsHeader, AutoFillSize ) ) { foreach( var kv in Mod.Mod.FileConflicts ) { @@ -258,7 +261,7 @@ namespace Penumbra.UI ImGui.Unindent( 15 ); } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); } ImGui.EndTabItem(); @@ -274,10 +277,11 @@ namespace Penumbra.UI if( ImGui.BeginTabItem( LabelFileSwapTab ) ) { _fileSwapOffset ??= Meta.FileSwaps - .Max( P => ImGui.CalcTextSize( P.Key ).X ) + TextSizePadding; + .Max( P => ImGui.CalcTextSize( P.Key ).X ) + + TextSizePadding; ImGui.SetNextItemWidth( -1 ); - if( ImGui.ListBoxHeader( LabelFileSwapHeader, AutoFillSize ) ) + if( ImGui.BeginListBox( LabelFileSwapHeader, AutoFillSize ) ) { foreach( var file in Meta.FileSwaps ) { @@ -288,7 +292,7 @@ namespace Penumbra.UI ImGui.Selectable( file.Value ); } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); } ImGui.EndTabItem(); @@ -308,7 +312,7 @@ namespace Penumbra.UI var len = Mod.Mod.ModBasePath.FullName.Length; _fullFilenameList = Mod.Mod.ModFiles - .Select( F => ( F, false, ColorGreen, new RelPath( F, Mod.Mod.ModBasePath ) ) ).ToArray(); + .Select( F => ( F, false, ColorGreen, new RelPath( F, Mod.Mod.ModBasePath ) ) ).ToArray(); if( Meta.Groups.Count == 0 ) { @@ -353,7 +357,7 @@ namespace Penumbra.UI } ImGui.SetNextItemWidth( -1 ); - if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize ) ) + if( ImGui.BeginListBox( LabelFileListHeader, AutoFillSize ) ) { UpdateFilenameList(); foreach( var file in _fullFilenameList! ) @@ -363,7 +367,7 @@ namespace Penumbra.UI ImGui.PopStyleColor(); } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); } else { @@ -389,7 +393,7 @@ namespace Penumbra.UI } if( path[ TextDefaultGamePath.Length ] != '-' - || !int.TryParse( path.Substring( TextDefaultGamePath.Length + 1 ), out removeFolders ) ) + || !int.TryParse( path.Substring( TextDefaultGamePath.Length + 1 ), out removeFolders ) ) { return -1; } @@ -442,7 +446,7 @@ namespace Penumbra.UI else { changed = gamePaths - .Aggregate( changed, ( current, gamePath ) => current | option.AddFile( relName, gamePath ) ); + .Aggregate( changed, ( current, gamePath ) => current | option.AddFile( relName, gamePath ) ); } } @@ -545,7 +549,7 @@ namespace Penumbra.UI { string tmp = gamePath; if( ImGui.InputText( $"##{fileName}_{gamePath}", ref tmp, 128, ImGuiInputTextFlags.EnterReturnsTrue ) - && tmp != gamePath ) + && tmp != gamePath ) { gamePaths.Remove( gamePath ); if( tmp.Length > 0 ) diff --git a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsEdit.cs b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsEdit.cs index 7be378d8..c2407826 100644 --- a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsEdit.cs +++ b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsEdit.cs @@ -86,7 +86,7 @@ namespace Penumbra.UI } ImGui.SetNextItemWidth( -1 ); - if( ImGui.ListBoxHeader( LabelFileListHeader, AutoFillSize - new Vector2( 0, 1.5f * ImGui.GetTextLineHeight() ) ) ) + if( ImGui.BeginListBox( LabelFileListHeader, AutoFillSize - new Vector2( 0, 1.5f * ImGui.GetTextLineHeight() ) ) ) { for( var i = 0; i < Mod!.Mod.ModFiles.Count; ++i ) { @@ -94,7 +94,7 @@ namespace Penumbra.UI } } - ImGui.ListBoxFooter(); + ImGui.EndListBox(); DrawGroupRow(); ImGui.EndTabItem();