Skip to content

Commit 668371d

Browse files
committed
Some further interface improvements.
1 parent 234712c commit 668371d

File tree

10 files changed

+125
-135
lines changed

10 files changed

+125
-135
lines changed

Penumbra/UI/Custom/ImGuiRenameableCombo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static bool RenameableCombo( string label, ref int currentItem, out strin
3333
}
3434

3535
ImGui.SetNextItemWidth( -1 );
36-
if( ImGui.InputText( $"##{label}_new", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
36+
if( ImGui.InputTextWithHint( $"##{label}_new", "Add new item...", ref newOption, 64, ImGuiInputTextFlags.EnterReturnsTrue ) )
3737
{
3838
currentItem = numItems;
3939
newName = newOption;

Penumbra/UI/Custom/ImGuiUtil.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
using System.Windows.Forms;
12
using ImGuiNET;
23

34
namespace Penumbra.UI
45
{
6+
public static partial class ImGuiCustom
7+
{
8+
public static void CopyOnClickSelectable( string text )
9+
{
10+
if( ImGui.Selectable( text ) )
11+
{
12+
Clipboard.SetText( text );
13+
}
14+
15+
if( ImGui.IsItemHovered() )
16+
{
17+
ImGui.SetTooltip( "Click to copy to clipboard." );
18+
}
19+
}
20+
}
21+
522
public static partial class ImGuiCustom
623
{
724
public static void VerticalDistance( float distance )

Penumbra/UI/MenuTabs/TabEffective.cs

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.IO;
2-
using System.Linq;
2+
using Dalamud.Interface;
33
using ImGuiNET;
44
using Penumbra.Mods;
55
using Penumbra.Util;
@@ -13,36 +13,21 @@ private class TabEffective
1313
private const string LabelTab = "Effective File List";
1414
private const float TextSizePadding = 5f;
1515

16-
private ModManager _mods => Service< ModManager >.Get();
17-
private float _maxGamePath;
16+
private ModManager _mods
17+
=> Service< ModManager >.Get();
1818

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

24-
public void RebuildFileList( bool advanced )
25-
{
26-
if( advanced )
27-
{
28-
_maxGamePath = TextSizePadding + ( _mods.ResolvedFiles.Count > 0
29-
? _mods.ResolvedFiles.Keys.Max( f => ImGui.CalcTextSize( f ).X )
30-
: 0f );
31-
}
32-
else
33-
{
34-
_maxGamePath = 0f;
35-
}
36-
}
24+
ImGui.TableNextColumn();
25+
ImGui.PushFont( UiBuilder.IconFont );
26+
ImGui.TextUnformatted( $"{( char )FontAwesomeIcon.LongArrowAltLeft}" );
27+
ImGui.PopFont();
3728

38-
private void DrawFileLine( FileInfo file, GamePath path )
39-
{
40-
ImGui.Selectable( path );
41-
ImGui.SameLine();
42-
ImGui.SetCursorPosX( _maxGamePath );
43-
ImGui.TextUnformatted( " <-- " );
44-
ImGui.SameLine();
45-
ImGui.Selectable( file.FullName );
29+
ImGui.TableNextColumn();
30+
ImGuiCustom.CopyOnClickSelectable( file.FullName );
4631
}
4732

4833
public void Draw()
@@ -53,14 +38,17 @@ public void Draw()
5338
return;
5439
}
5540

56-
if( ImGui.BeginListBox( "##effective_files", AutoFillSize ) )
41+
const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;
42+
43+
if( ImGui.BeginTable( "##effective_files", 3, flags, AutoFillSize ) )
5744
{
58-
foreach( var file in _mods.ResolvedFiles )
45+
foreach ( var file in _mods.ResolvedFiles )
5946
{
6047
DrawFileLine( file.Value, file.Key );
48+
ImGui.TableNextRow();
6149
}
6250

63-
ImGui.EndListBox();
51+
ImGui.EndTable();
6452
}
6553

6654
ImGui.EndTabItem();

Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.IO;
4+
using Dalamud.Interface;
45
using ImGuiNET;
56
using Penumbra.Models;
67
using Penumbra.Mods;
@@ -61,7 +62,6 @@ private partial class PluginDetails
6162
private int _selectedOptionIndex;
6263
private Option? _selectedOption;
6364
private (string label, string name)[]? _changedItemsList;
64-
private float? _fileSwapOffset;
6565
private string _currentGamePaths = "";
6666

6767
private (FileInfo name, bool selected, uint color, RelPath relName)[]? _fullFilenameList;
@@ -116,7 +116,6 @@ private void SelectOption()
116116
public void ResetState()
117117
{
118118
_changedItemsList = null;
119-
_fileSwapOffset = null;
120119
_fullFilenameList = null;
121120
SelectGroup();
122121
SelectOption();
@@ -141,7 +140,6 @@ private void Save()
141140
var modManager = Service< ModManager >.Get();
142141
modManager.Mods?.Save();
143142
modManager.CalculateEffectiveFileList();
144-
_base._menu.EffectiveTab.RebuildFileList( _base._plugin!.Configuration!.ShowAdvanced );
145143
}
146144

147145
private void DrawAboutTab()
@@ -275,38 +273,36 @@ private void DrawFileSwapTab()
275273
return;
276274
}
277275

278-
if( !Meta.FileSwaps.Any() )
276+
if( !Meta.FileSwaps.Any() || !ImGui.BeginTabItem( LabelFileSwapTab ) )
279277
{
280278
return;
281279
}
282280

283-
if( ImGui.BeginTabItem( LabelFileSwapTab ) )
284-
{
285-
_fileSwapOffset ??= Meta.FileSwaps
286-
.Max( P => ImGui.CalcTextSize( P.Key ).X )
287-
+ TextSizePadding;
281+
const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;
288282

289-
ImGui.SetNextItemWidth( -1 );
290-
if( ImGui.BeginListBox( LabelFileSwapHeader, AutoFillSize ) )
283+
ImGui.SetNextItemWidth( -1 );
284+
if( ImGui.BeginTable( LabelFileSwapHeader, 3, flags, AutoFillSize ) )
285+
{
286+
foreach( var file in Meta.FileSwaps )
291287
{
292-
foreach( var file in Meta.FileSwaps )
293-
{
294-
ImGui.Selectable( file.Key );
295-
ImGui.SameLine( _fileSwapOffset ?? 0 );
296-
ImGui.TextUnformatted( " -> " );
297-
ImGui.SameLine();
298-
ImGui.Selectable( file.Value );
299-
}
288+
ImGui.TableNextColumn();
289+
ImGuiCustom.CopyOnClickSelectable( file.Key );
300290

301-
ImGui.EndListBox();
291+
ImGui.TableNextColumn();
292+
ImGui.PushFont( UiBuilder.IconFont );
293+
ImGui.TextUnformatted( $"{( char )FontAwesomeIcon.LongArrowAltRight}" );
294+
ImGui.PopFont();
295+
296+
ImGui.TableNextColumn();
297+
ImGuiCustom.CopyOnClickSelectable( file.Value );
298+
299+
ImGui.TableNextRow();
302300
}
303301

304-
ImGui.EndTabItem();
305-
}
306-
else
307-
{
308-
_fileSwapOffset = null;
302+
ImGui.EndTable();
309303
}
304+
305+
ImGui.EndTabItem();
310306
}
311307

312308
private void UpdateFilenameList()
@@ -480,8 +476,6 @@ private void DrawRemoveFromGroupButton()
480476

481477
private void DrawGamePathInput()
482478
{
483-
ImGui.TextUnformatted( LabelGamePathsEdit );
484-
ImGui.SameLine();
485479
ImGui.SetNextItemWidth( -1 );
486480
ImGui.InputTextWithHint( LabelGamePathsEditBox, "Hover for help...", ref _currentGamePaths, 128 );
487481
if( ImGui.IsItemHovered() )

0 commit comments

Comments
 (0)