Skip to content

Commit

Permalink
Some further interface improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Apr 20, 2021
1 parent 234712c commit 668371d
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Penumbra/UI/Custom/ImGuiRenameableCombo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static bool RenameableCombo( string label, ref int currentItem, out strin
}

ImGui.SetNextItemWidth( -1 );
if( ImGui.InputText( $"##{label}_new", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
if( ImGui.InputTextWithHint( $"##{label}_new", "Add new item...", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
{
currentItem = numItems;
newName = newOption;
Expand Down
17 changes: 17 additions & 0 deletions Penumbra/UI/Custom/ImGuiUtil.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
using System.Windows.Forms;
using ImGuiNET;

namespace Penumbra.UI
{
public static partial class ImGuiCustom
{
public static void CopyOnClickSelectable( string text )
{
if( ImGui.Selectable( text ) )
{
Clipboard.SetText( text );
}

if( ImGui.IsItemHovered() )
{
ImGui.SetTooltip( "Click to copy to clipboard." );
}
}
}

public static partial class ImGuiCustom
{
public static void VerticalDistance( float distance )
Expand Down
48 changes: 18 additions & 30 deletions Penumbra/UI/MenuTabs/TabEffective.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.IO;
using System.Linq;
using Dalamud.Interface;
using ImGuiNET;
using Penumbra.Mods;
using Penumbra.Util;
Expand All @@ -13,36 +13,21 @@ private class TabEffective
private const string LabelTab = "Effective File List";
private const float TextSizePadding = 5f;

private ModManager _mods => Service< ModManager >.Get();
private float _maxGamePath;
private ModManager _mods
=> Service< ModManager >.Get();

public TabEffective( SettingsInterface ui )
private static void DrawFileLine( FileInfo file, GamePath path )
{
RebuildFileList( ui._plugin!.Configuration!.ShowAdvanced );
}
ImGui.TableNextColumn();
ImGuiCustom.CopyOnClickSelectable( path );

public void RebuildFileList( bool advanced )
{
if( advanced )
{
_maxGamePath = TextSizePadding + ( _mods.ResolvedFiles.Count > 0
? _mods.ResolvedFiles.Keys.Max( f => ImGui.CalcTextSize( f ).X )
: 0f );
}
else
{
_maxGamePath = 0f;
}
}
ImGui.TableNextColumn();
ImGui.PushFont( UiBuilder.IconFont );
ImGui.TextUnformatted( $"{( char )FontAwesomeIcon.LongArrowAltLeft}" );
ImGui.PopFont();

private void DrawFileLine( FileInfo file, GamePath path )
{
ImGui.Selectable( path );
ImGui.SameLine();
ImGui.SetCursorPosX( _maxGamePath );
ImGui.TextUnformatted( " <-- " );
ImGui.SameLine();
ImGui.Selectable( file.FullName );
ImGui.TableNextColumn();
ImGuiCustom.CopyOnClickSelectable( file.FullName );
}

public void Draw()
Expand All @@ -53,14 +38,17 @@ public void Draw()
return;
}

if( ImGui.BeginListBox( "##effective_files", AutoFillSize ) )
const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;

if( ImGui.BeginTable( "##effective_files", 3, flags, AutoFillSize ) )
{
foreach( var file in _mods.ResolvedFiles )
foreach ( var file in _mods.ResolvedFiles )
{
DrawFileLine( file.Value, file.Key );
ImGui.TableNextRow();
}

ImGui.EndListBox();
ImGui.EndTable();
}

ImGui.EndTabItem();
Expand Down
48 changes: 21 additions & 27 deletions Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Dalamud.Interface;
using ImGuiNET;
using Penumbra.Models;
using Penumbra.Mods;
Expand Down Expand Up @@ -61,7 +62,6 @@ private partial class PluginDetails
private int _selectedOptionIndex;
private Option? _selectedOption;
private (string label, string name)[]? _changedItemsList;
private float? _fileSwapOffset;
private string _currentGamePaths = "";

private (FileInfo name, bool selected, uint color, RelPath relName)[]? _fullFilenameList;
Expand Down Expand Up @@ -116,7 +116,6 @@ private void SelectOption()
public void ResetState()
{
_changedItemsList = null;
_fileSwapOffset = null;
_fullFilenameList = null;
SelectGroup();
SelectOption();
Expand All @@ -141,7 +140,6 @@ private void Save()
var modManager = Service< ModManager >.Get();
modManager.Mods?.Save();
modManager.CalculateEffectiveFileList();
_base._menu.EffectiveTab.RebuildFileList( _base._plugin!.Configuration!.ShowAdvanced );
}

private void DrawAboutTab()
Expand Down Expand Up @@ -275,38 +273,36 @@ private void DrawFileSwapTab()
return;
}

if( !Meta.FileSwaps.Any() )
if( !Meta.FileSwaps.Any() || !ImGui.BeginTabItem( LabelFileSwapTab ) )
{
return;
}

if( ImGui.BeginTabItem( LabelFileSwapTab ) )
{
_fileSwapOffset ??= Meta.FileSwaps
.Max( P => ImGui.CalcTextSize( P.Key ).X )
+ TextSizePadding;
const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;

ImGui.SetNextItemWidth( -1 );
if( ImGui.BeginListBox( LabelFileSwapHeader, AutoFillSize ) )
ImGui.SetNextItemWidth( -1 );
if( ImGui.BeginTable( LabelFileSwapHeader, 3, flags, AutoFillSize ) )
{
foreach( var file in Meta.FileSwaps )
{
foreach( var file in Meta.FileSwaps )
{
ImGui.Selectable( file.Key );
ImGui.SameLine( _fileSwapOffset ?? 0 );
ImGui.TextUnformatted( " -> " );
ImGui.SameLine();
ImGui.Selectable( file.Value );
}
ImGui.TableNextColumn();
ImGuiCustom.CopyOnClickSelectable( file.Key );

ImGui.EndListBox();
ImGui.TableNextColumn();
ImGui.PushFont( UiBuilder.IconFont );
ImGui.TextUnformatted( $"{( char )FontAwesomeIcon.LongArrowAltRight}" );
ImGui.PopFont();

ImGui.TableNextColumn();
ImGuiCustom.CopyOnClickSelectable( file.Value );

ImGui.TableNextRow();
}

ImGui.EndTabItem();
}
else
{
_fileSwapOffset = null;
ImGui.EndTable();
}

ImGui.EndTabItem();
}

private void UpdateFilenameList()
Expand Down Expand Up @@ -480,8 +476,6 @@ private void DrawRemoveFromGroupButton()

private void DrawGamePathInput()
{
ImGui.TextUnformatted( LabelGamePathsEdit );
ImGui.SameLine();
ImGui.SetNextItemWidth( -1 );
ImGui.InputTextWithHint( LabelGamePathsEditBox, "Hover for help...", ref _currentGamePaths, 128 );
if( ImGui.IsItemHovered() )
Expand Down
Loading

0 comments on commit 668371d

Please sign in to comment.