Add memory of last mod path as well as default directory. Add default Author. Fix bugs.

This commit is contained in:
Ottermandias 2022-04-27 23:31:56 +02:00
parent c2a030aa6b
commit 545536f66f
5 changed files with 86 additions and 8 deletions

@ -1 +1 @@
Subproject commit 1a3cd1f881f3b6c2c4d9d4b20f054d1ab5ccc014
Subproject commit 6b918d67fb7370340b1b310a03dbf033b9950450

View file

@ -4,6 +4,7 @@ using System.Linq;
using Dalamud.Configuration;
using Dalamud.Logging;
using OtterGui.Filesystem;
using Penumbra.Import;
using Penumbra.UI.Classes;
namespace Penumbra;
@ -38,6 +39,9 @@ public partial class Configuration : IPluginConfiguration
public bool DisableSoundStreaming { get; set; } = true;
public bool EnableHttpApi { get; set; }
public string DefaultModImportPath { get; set; } = string.Empty;
public string DefaultModAuthor { get; set; } = DefaultTexToolsData.Author;
public Dictionary< ColorId, uint > Colors { get; set; }
= Enum.GetValues< ColorId >().ToDictionary( c => c, c => c.Data().DefaultColor );

View file

@ -132,7 +132,7 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
try
{
var newDir = Mod.CreateModFolder( Penumbra.ModManager.BasePath, _newModName );
Mod.CreateMeta( newDir, _newModName, string.Empty, string.Empty, "1.0", string.Empty );
Mod.CreateMeta( newDir, _newModName, Penumbra.Config.DefaultModAuthor, string.Empty, "1.0", string.Empty );
Penumbra.ModManager.AddMod( newDir );
_newModName = string.Empty;
}
@ -144,11 +144,18 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
}
// Add an import mods button that opens a file selector.
// Only set the initial directory once.
private bool _hasSetFolder;
private void AddImportModButton( Vector2 size )
{
if( ImGuiUtil.DrawDisabledButton( FontAwesomeIcon.FileImport.ToIconString(), size,
"Import one or multiple mods from Tex Tools Mod Pack Files.", !Penumbra.ModManager.Valid, true ) )
{
var modPath = _hasSetFolder ? null
: Penumbra.Config.DefaultModImportPath.Length > 0 ? Penumbra.Config.DefaultModImportPath
: Penumbra.Config.ModDirectory.Length > 0 ? Penumbra.Config.ModDirectory : null;
_hasSetFolder = true;
_fileManager.OpenFileDialog( "Import Mod Pack", "TexTools Mod Packs{.ttmp,.ttmp2}", ( s, f ) =>
{
if( s )
@ -156,7 +163,7 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
_import = new TexToolsImporter( Penumbra.ModManager.BasePath, f.Count, f.Select( file => new FileInfo( file ) ) );
ImGui.OpenPopup( "Import Status" );
}
}, 0, Penumbra.Config.ModDirectory );
}, 0, modPath );
}
_fileManager.Draw();
@ -202,7 +209,7 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
}
catch( Exception e )
{
PluginLog.Error($"Error cleaning up failed mod extraction of {file.FullName} to {dir.FullName}:\n{e}" );
PluginLog.Error( $"Error cleaning up failed mod extraction of {file.FullName} to {dir.FullName}:\n{e}" );
}
}

View file

@ -1,4 +1,7 @@
using System;
using System.IO;
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
using OtterGui;
using OtterGui.Filesystem;
@ -12,7 +15,7 @@ public partial class ConfigWindow
{
private void DrawModSelectorSettings()
{
if( !ImGui.CollapsingHeader( "Mod Selector" ) )
if( !ImGui.CollapsingHeader( "General" ) )
{
return;
}
@ -20,6 +23,9 @@ public partial class ConfigWindow
DrawFolderSortType();
DrawAbsoluteSizeSelector();
DrawRelativeSizeSelector();
ImGui.Dummy( _window._defaultSpace );
DrawDefaultModImportPath();
DrawDefaultModAuthor();
ImGui.NewLine();
}
@ -93,5 +99,66 @@ public partial class ConfigWindow
ImGuiUtil.LabeledHelpMarker( "Mod Selector Relative Size",
"Instead of keeping the mod-selector in the Installed Mods tab a fixed width, this will let it scale with the total size of the Penumbra window." );
}
private void DrawDefaultModImportPath()
{
var tmp = Penumbra.Config.DefaultModImportPath;
var spacing = new Vector2( 3 * ImGuiHelpers.GlobalScale );
using var style = ImRaii.PushStyle( ImGuiStyleVar.ItemSpacing, spacing );
ImGui.SetNextItemWidth( _window._inputTextWidth.X - _window._iconButtonSize.X - spacing.X );
if( ImGui.InputText( "##defaultModImport", ref tmp, 256 ) )
{
Penumbra.Config.DefaultModImportPath = tmp;
}
if( ImGui.IsItemDeactivatedAfterEdit() )
{
Penumbra.Config.Save();
}
ImGui.SameLine();
if( ImGuiUtil.DrawDisabledButton( $"{FontAwesomeIcon.Folder.ToIconString()}##import", _window._iconButtonSize,
"Select a directory via dialog.", false, true ) )
{
if( _dialogOpen )
{
_dialogManager.Reset();
_dialogOpen = false;
}
else
{
var startDir = Directory.Exists( Penumbra.Config.ModDirectory ) ? Penumbra.Config.ModDirectory : ".";
_dialogManager.OpenFolderDialog( "Choose Default Import Directory", ( b, s ) =>
{
Penumbra.Config.DefaultModImportPath = b ? s : Penumbra.Config.DefaultModImportPath;
Penumbra.Config.Save();
_dialogOpen = false;
}, startDir );
_dialogOpen = true;
}
}
style.Pop();
ImGuiUtil.LabeledHelpMarker( "Default Mod Import Directory",
"Set the directory that gets opened when using the file picker to import mods for the first time." );
}
private void DrawDefaultModAuthor()
{
var tmp = Penumbra.Config.DefaultModAuthor;
ImGui.SetNextItemWidth( _window._inputTextWidth.X );
if( ImGui.InputText( "##defaultAuthor", ref tmp, 64 ) )
{
Penumbra.Config.DefaultModAuthor = tmp;
}
if( ImGui.IsItemDeactivatedAfterEdit() )
{
Penumbra.Config.Save();
}
ImGuiUtil.LabeledHelpMarker( "Default Mod Author", "Set the default author stored for newly created mods." );
}
}
}

View file

@ -45,6 +45,8 @@ public partial class ConfigWindow
DrawModSelectorSettings();
DrawColorSettings();
DrawAdvancedSettings();
_dialogManager.Draw();
}
// Changing the base mod directory.
@ -92,8 +94,6 @@ public partial class ConfigWindow
_dialogOpen = true;
}
}
_dialogManager.Draw();
}
private static void DrawOpenDirectoryButton( int id, DirectoryInfo directory, bool condition )
@ -137,7 +137,7 @@ public partial class ConfigWindow
ImGui.NewLine();
if( Penumbra.Config.ModDirectory != _newModDirectory
&& _newModDirectory.Length == 0
&& _newModDirectory.Length != 0
&& ( save || DrawPressEnterWarning( Penumbra.Config.ModDirectory, pos ) ) )
{
Penumbra.ModManager.DiscoverMods( _newModDirectory );