mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Implemented command for changing the current default and forced collections
This commit is contained in:
parent
1d5ddb0590
commit
a62fa06b03
1 changed files with 62 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ using Penumbra.Mods;
|
||||||
using Penumbra.PlayerWatch;
|
using Penumbra.PlayerWatch;
|
||||||
using Penumbra.UI;
|
using Penumbra.UI;
|
||||||
using Penumbra.Util;
|
using Penumbra.Util;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Penumbra;
|
namespace Penumbra;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,9 @@ public class Penumbra : IDalamudPlugin
|
||||||
|
|
||||||
private WebServer? _webServer;
|
private WebServer? _webServer;
|
||||||
|
|
||||||
|
private readonly ModManager _modManager;
|
||||||
|
private readonly ModCollection[] _collections;
|
||||||
|
|
||||||
public Penumbra( DalamudPluginInterface pluginInterface )
|
public Penumbra( DalamudPluginInterface pluginInterface )
|
||||||
{
|
{
|
||||||
FFXIVClientStructs.Resolver.Initialize();
|
FFXIVClientStructs.Resolver.Initialize();
|
||||||
|
|
@ -52,11 +56,11 @@ public class Penumbra : IDalamudPlugin
|
||||||
var gameUtils = Service< ResidentResources >.Set();
|
var gameUtils = Service< ResidentResources >.Set();
|
||||||
PlayerWatcher = PlayerWatchFactory.Create( Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects );
|
PlayerWatcher = PlayerWatchFactory.Create( Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects );
|
||||||
Service< MetaDefaults >.Set();
|
Service< MetaDefaults >.Set();
|
||||||
var modManager = Service< ModManager >.Set();
|
_modManager = Service< ModManager >.Set();
|
||||||
|
|
||||||
modManager.DiscoverMods();
|
_modManager.DiscoverMods();
|
||||||
|
|
||||||
ObjectReloader = new ObjectReloader( modManager, Config.WaitFrames );
|
ObjectReloader = new ObjectReloader( _modManager, Config.WaitFrames );
|
||||||
|
|
||||||
ResourceLoader = new ResourceLoader( this );
|
ResourceLoader = new ResourceLoader( this );
|
||||||
|
|
||||||
|
|
@ -91,6 +95,8 @@ public class Penumbra : IDalamudPlugin
|
||||||
PluginLog.Debug( "Triggered Redraw of {Player}.", p.Name );
|
PluginLog.Debug( "Triggered Redraw of {Player}.", p.Name );
|
||||||
ObjectReloader.RedrawObject( p, RedrawType.OnlyWithSettings );
|
ObjectReloader.RedrawObject( p, RedrawType.OnlyWithSettings );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_collections = _modManager.Collections.Collections.Values.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Enable()
|
public bool Enable()
|
||||||
|
|
@ -191,12 +197,53 @@ public class Penumbra : IDalamudPlugin
|
||||||
ShutdownWebServer();
|
ShutdownWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetCollection(string type, string collection)
|
||||||
|
{
|
||||||
|
type = type.ToLower();
|
||||||
|
collection = collection.ToLower();
|
||||||
|
|
||||||
|
if( type != "default" && type != "forced" )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( "Second command argument is not default or forced, the correct command format is: /penumbra collection {default|forced} <collectionName>" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentCollection = ( type == "default" ) ? _modManager.Collections.DefaultCollection : _modManager.Collections.ForcedCollection;
|
||||||
|
|
||||||
|
if( collection == currentCollection.Name.ToLower() )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( $"{currentCollection.Name} is already the active collection." );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCollection = ( collection == "none" ) ? ModCollection.Empty : _collections.FirstOrDefault( c => c.Name.ToLower() == collection );
|
||||||
|
|
||||||
|
if ( newCollection == null )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( $"The collection {collection} does not exist." );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( type == "default" )
|
||||||
|
{
|
||||||
|
_modManager.Collections.SetDefaultCollection( newCollection );
|
||||||
|
Dalamud.Chat.Print( $"Set { newCollection.Name } as default collection." );
|
||||||
|
}
|
||||||
|
else if ( type == "forced" )
|
||||||
|
{
|
||||||
|
_modManager.Collections.SetForcedCollection( newCollection );
|
||||||
|
Dalamud.Chat.Print( $"Set { newCollection.Name } as forced collection." );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnCommand( string command, string rawArgs )
|
private void OnCommand( string command, string rawArgs )
|
||||||
{
|
{
|
||||||
const string modsEnabled = "Your mods have now been enabled.";
|
const string modsEnabled = "Your mods have now been enabled.";
|
||||||
const string modsDisabled = "Your mods have now been disabled.";
|
const string modsDisabled = "Your mods have now been disabled.";
|
||||||
|
|
||||||
var args = rawArgs.Split( new[] { ' ' }, 2 );
|
var args = rawArgs.Split( new[] { ' ' }, 3 );
|
||||||
if( args.Length > 0 && args[ 0 ].Length > 0 )
|
if( args.Length > 0 && args[ 0 ].Length > 0 )
|
||||||
{
|
{
|
||||||
switch( args[ 0 ] )
|
switch( args[ 0 ] )
|
||||||
|
|
@ -249,6 +296,17 @@ public class Penumbra : IDalamudPlugin
|
||||||
: modsDisabled );
|
: modsDisabled );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "collection":
|
||||||
|
{
|
||||||
|
if( args.Length == 3 )
|
||||||
|
{
|
||||||
|
SetCollection(args[ 1 ], args[ 2 ]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( "Missing arguments, the correct command format is: /penumbra collection {default|forced} <collectionName>" );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue