Fix imgui deprecation warnings, some formatting.

This commit is contained in:
Ottermandias 2021-04-18 23:03:34 +02:00
parent c25334ea58
commit 63407f775f
3 changed files with 27 additions and 23 deletions

View file

@ -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();

View file

@ -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 )

View file

@ -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();