mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Add default mod import folder.
This commit is contained in:
parent
7390f97d81
commit
2aed252820
5 changed files with 80 additions and 7 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit f401cea47e45d12e09d1668187e3bb2781af21dd
|
||||
Subproject commit a9a5b2a4bbf061d9cfed5234ca731bd2d94bcb96
|
||||
|
|
@ -44,6 +44,7 @@ public partial class Configuration : IPluginConfiguration
|
|||
public float ModSelectorAbsoluteSize { get; set; } = Constants.DefaultAbsoluteSize;
|
||||
public int ModSelectorScaledSize { get; set; } = Constants.DefaultScaledSize;
|
||||
public bool OpenFoldersByDefault { get; set; } = false;
|
||||
public string DefaultImportFolder { get; set; } = string.Empty;
|
||||
|
||||
public bool FixMainWindow { get; set; } = false;
|
||||
public bool ShowAdvanced { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
using Dalamud.Logging;
|
||||
|
|
@ -14,6 +9,11 @@ using OtterGui.Raii;
|
|||
using Penumbra.Collections;
|
||||
using Penumbra.Import;
|
||||
using Penumbra.Mods;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Penumbra.UI.Classes;
|
||||
|
||||
|
|
@ -31,6 +31,8 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
SubscribeRightClickFolder( DisableDescendants, 10 );
|
||||
SubscribeRightClickFolder( InheritDescendants, 15 );
|
||||
SubscribeRightClickFolder( OwnDescendants, 15 );
|
||||
SubscribeRightClickFolder( SetDefaultImportFolder, 100 );
|
||||
SubscribeRightClickMain( ClearDefaultImportFolder, 100 );
|
||||
AddButton( AddNewModButton, 0 );
|
||||
AddButton( AddImportModButton, 1 );
|
||||
AddButton( AddHelpButton, 2 );
|
||||
|
|
@ -107,6 +109,7 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
var mod = Penumbra.ModManager.LastOrDefault();
|
||||
if( mod != null )
|
||||
{
|
||||
MoveModToDefaultDirectory( mod );
|
||||
SelectByValue( mod );
|
||||
}
|
||||
}
|
||||
|
|
@ -154,6 +157,28 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
}
|
||||
}
|
||||
|
||||
private static void SetDefaultImportFolder( ModFileSystem.Folder folder )
|
||||
{
|
||||
if( ImGui.MenuItem( "Set As Default Import Folder" ) )
|
||||
{
|
||||
var newName = folder.FullName();
|
||||
if( newName != Penumbra.Config.DefaultImportFolder )
|
||||
{
|
||||
Penumbra.Config.DefaultImportFolder = newName;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearDefaultImportFolder()
|
||||
{
|
||||
if( ImGui.MenuItem( "Clear Default Import Folder" ) && Penumbra.Config.DefaultImportFolder.Length > 0 )
|
||||
{
|
||||
Penumbra.Config.DefaultImportFolder = string.Empty;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add custom buttons.
|
||||
private string _newModName = string.Empty;
|
||||
|
|
@ -385,6 +410,34 @@ public sealed partial class ModFileSystemSelector : FileSystemSelector< Mod, Mod
|
|||
}
|
||||
}
|
||||
|
||||
// If a default import folder is setup, try to move the given mod in there.
|
||||
// If the folder does not exist, create it if possible.
|
||||
private void MoveModToDefaultDirectory( Mod mod )
|
||||
{
|
||||
if( Penumbra.Config.DefaultImportFolder.Length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var leaf = FileSystem.Root.GetChildren( SortMode.Lexicographical )
|
||||
.FirstOrDefault( f => f is FileSystem< Mod >.Leaf l && l.Value == mod );
|
||||
if( leaf == null )
|
||||
{
|
||||
throw new Exception( "Mod was not found at root." );
|
||||
}
|
||||
|
||||
var folder = FileSystem.FindOrCreateAllFolders( Penumbra.Config.DefaultImportFolder );
|
||||
FileSystem.Move( leaf, folder );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Warning(
|
||||
$"Could not move newly imported mod {mod.Name} to default import folder {Penumbra.Config.DefaultImportFolder}:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawHelpPopup()
|
||||
{
|
||||
ImGuiUtil.HelpPopup( "ExtendedHelp", new Vector2( 1000 * ImGuiHelpers.GlobalScale, 33.5f * ImGui.GetTextLineHeightWithSpacing() ), () =>
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public partial class ConfigWindow
|
|||
// on the top-right corner of the window/tab.
|
||||
private void DrawRemoveSettings()
|
||||
{
|
||||
const string text = "Remove Settings";
|
||||
const string text = "Inherit Settings";
|
||||
if( _inherited || _emptySetting )
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public partial class ConfigWindow
|
|||
Penumbra.Config.AlwaysOpenDefaultImport, v => Penumbra.Config.AlwaysOpenDefaultImport = v );
|
||||
DrawDefaultModImportPath();
|
||||
DrawDefaultModAuthor();
|
||||
DrawDefaultModImportFolder();
|
||||
|
||||
ImGui.NewLine();
|
||||
}
|
||||
|
|
@ -225,5 +226,23 @@ public partial class ConfigWindow
|
|||
|
||||
ImGuiUtil.LabeledHelpMarker( "Default Mod Author", "Set the default author stored for newly created mods." );
|
||||
}
|
||||
|
||||
private void DrawDefaultModImportFolder()
|
||||
{
|
||||
var tmp = Penumbra.Config.DefaultImportFolder;
|
||||
ImGui.SetNextItemWidth( _window._inputTextWidth.X );
|
||||
if( ImGui.InputText( "##defaultImportFolder", ref tmp, 64 ) )
|
||||
{
|
||||
Penumbra.Config.DefaultImportFolder = tmp;
|
||||
}
|
||||
|
||||
if( ImGui.IsItemDeactivatedAfterEdit() )
|
||||
{
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
ImGuiUtil.LabeledHelpMarker( "Default Mod Import Folder",
|
||||
"Set the default Penumbra mod folder to place newly imported mods into.\nLeave blank to import into Root." );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue