From 1d5ddb0590989636b561b663aad46df4b3e1047a Mon Sep 17 00:00:00 2001 From: Actions User Date: Mon, 31 Jan 2022 21:40:38 +0000 Subject: [PATCH 1/3] [CI] Updating repo.json for refs/tags/0.4.7.3 --- repo.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repo.json b/repo.json index aaeef754..2fb78234 100644 --- a/repo.json +++ b/repo.json @@ -4,8 +4,8 @@ "Name": "Penumbra", "Description": "Runtime mod loader and manager.", "InternalName": "Penumbra", - "AssemblyVersion": "0.4.7.2", - "TestingAssemblyVersion": "0.4.7.2", + "AssemblyVersion": "0.4.7.3", + "TestingAssemblyVersion": "0.4.7.3", "RepoUrl": "https://github.com/xivdev/Penumbra", "ApplicableVersion": "any", "DalamudApiLevel": 5, @@ -14,9 +14,9 @@ "DownloadCount": 0, "LastUpdate": 0, "LoadPriority": 69420, - "DownloadLinkInstall": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.2/Penumbra.zip", - "DownloadLinkTesting": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.2/Penumbra.zip", - "DownloadLinkUpdate": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.2/Penumbra.zip", + "DownloadLinkInstall": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.3/Penumbra.zip", + "DownloadLinkTesting": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.3/Penumbra.zip", + "DownloadLinkUpdate": "https://github.com/xivdev/Penumbra/releases/download/0.4.7.3/Penumbra.zip", "IconUrl": "https://raw.githubusercontent.com/xivdev/Penumbra/master/images/icon.png" } ] From a62fa06b03041703ba6727b9b4ced01f935af983 Mon Sep 17 00:00:00 2001 From: Lucy Awrey <35198881+lucyawrey@users.noreply.github.com> Date: Thu, 3 Feb 2022 17:02:03 -0500 Subject: [PATCH 2/3] Implemented command for changing the current default and forced collections --- Penumbra/Penumbra.cs | 66 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index 7b9c9bb5..563bbee7 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -13,6 +13,7 @@ using Penumbra.Mods; using Penumbra.PlayerWatch; using Penumbra.UI; using Penumbra.Util; +using System.Linq; namespace Penumbra; @@ -36,6 +37,9 @@ public class Penumbra : IDalamudPlugin private WebServer? _webServer; + private readonly ModManager _modManager; + private readonly ModCollection[] _collections; + public Penumbra( DalamudPluginInterface pluginInterface ) { FFXIVClientStructs.Resolver.Initialize(); @@ -52,11 +56,11 @@ public class Penumbra : IDalamudPlugin var gameUtils = Service< ResidentResources >.Set(); PlayerWatcher = PlayerWatchFactory.Create( Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects ); 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 ); @@ -91,6 +95,8 @@ public class Penumbra : IDalamudPlugin PluginLog.Debug( "Triggered Redraw of {Player}.", p.Name ); ObjectReloader.RedrawObject( p, RedrawType.OnlyWithSettings ); }; + + _collections = _modManager.Collections.Collections.Values.ToArray(); } public bool Enable() @@ -191,12 +197,53 @@ public class Penumbra : IDalamudPlugin 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} " ); + 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 ) { const string modsEnabled = "Your mods have now been enabled."; 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 ) { switch( args[ 0 ] ) @@ -249,6 +296,17 @@ public class Penumbra : IDalamudPlugin : modsDisabled ); 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} " ); + } + break; + } } return; From 09c92ef0b177d516157df4a868d83bd5332d1786 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 3 Feb 2022 23:53:27 +0100 Subject: [PATCH 3/3] Small fixes. --- Penumbra/Penumbra.cs | 84 ++++++++------- Penumbra/UI/MenuTabs/TabCollections.cs | 4 +- Penumbra/UI/SettingsInterface.cs | 141 +++++++++++++------------ 3 files changed, 120 insertions(+), 109 deletions(-) diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index 563bbee7..3a9ffab1 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -1,3 +1,4 @@ +using System; using Dalamud.Game.Command; using Dalamud.Logging; using Dalamud.Plugin; @@ -38,7 +39,6 @@ public class Penumbra : IDalamudPlugin private WebServer? _webServer; private readonly ModManager _modManager; - private readonly ModCollection[] _collections; public Penumbra( DalamudPluginInterface pluginInterface ) { @@ -95,8 +95,6 @@ public class Penumbra : IDalamudPlugin PluginLog.Debug( "Triggered Redraw of {Player}.", p.Name ); ObjectReloader.RedrawObject( p, RedrawType.OnlyWithSettings ); }; - - _collections = _modManager.Collections.Collections.Values.ToArray(); } public bool Enable() @@ -171,7 +169,7 @@ public class Penumbra : IDalamudPlugin .WithWebApi( "/api", m => m .WithController( () => new ModsController( this ) ) ); - _webServer.StateChanged += ( s, e ) => PluginLog.Information( $"WebServer New State - {e.NewState}" ); + _webServer.StateChanged += ( _, e ) => PluginLog.Information( $"WebServer New State - {e.NewState}" ); _webServer.RunAsync(); } @@ -197,45 +195,50 @@ public class Penumbra : IDalamudPlugin ShutdownWebServer(); } - public bool SetCollection(string type, string collection) + public bool SetCollection( string type, string collectionName ) { - type = type.ToLower(); - collection = collection.ToLower(); + type = type.ToLowerInvariant(); + collectionName = collectionName.ToLowerInvariant(); - 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} " ); - 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 ) + var collection = string.Equals( collectionName, ModCollection.Empty.Name, StringComparison.InvariantCultureIgnoreCase ) + ? ModCollection.Empty + : _modManager.Collections.Collections.Values.FirstOrDefault( c + => string.Equals( c.Name, collectionName, StringComparison.InvariantCultureIgnoreCase ) ); + if( collection == null ) { Dalamud.Chat.Print( $"The collection {collection} does not exist." ); return false; } - if( type == "default" ) + switch( type ) { - _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." ); - } + case "default": + if( collection == _modManager.Collections.DefaultCollection ) + { + Dalamud.Chat.Print( $"{collection.Name} already is the default collection." ); + return false; + } - return true; + _modManager.Collections.SetDefaultCollection( collection ); + Dalamud.Chat.Print( $"Set {collection.Name} as default collection." ); + SettingsInterface.ResetDefaultCollection(); + return true; + case "forced": + if( collection == _modManager.Collections.ForcedCollection ) + { + Dalamud.Chat.Print( $"{collection.Name} already is the forced collection." ); + return false; + } + + _modManager.Collections.SetForcedCollection( collection ); + Dalamud.Chat.Print( $"Set {collection.Name} as forced collection." ); + SettingsInterface.ResetForcedCollection(); + return true; + default: + Dalamud.Chat.Print( + "Second command argument is not default or forced, the correct command format is: /penumbra collection {default|forced} " ); + return false; + } } private void OnCommand( string command, string rawArgs ) @@ -252,7 +255,7 @@ public class Penumbra : IDalamudPlugin { Service< ModManager >.Get().DiscoverMods(); Dalamud.Chat.Print( - $"Reloaded Penumbra mods. You have {Service< ModManager >.Get()?.Mods.Count} mods." + $"Reloaded Penumbra mods. You have {_modManager.Mods.Count} mods." ); break; } @@ -300,11 +303,14 @@ public class Penumbra : IDalamudPlugin { if( args.Length == 3 ) { - SetCollection(args[ 1 ], args[ 2 ]); - } else - { - Dalamud.Chat.Print( "Missing arguments, the correct command format is: /penumbra collection {default|forced} " ); + SetCollection( args[ 1 ], args[ 2 ] ); } + else + { + Dalamud.Chat.Print( "Missing arguments, the correct command format is:" + + " /penumbra collection {default|forced} " ); + } + break; } } diff --git a/Penumbra/UI/MenuTabs/TabCollections.cs b/Penumbra/UI/MenuTabs/TabCollections.cs index cf6cbb92..cee1bd71 100644 --- a/Penumbra/UI/MenuTabs/TabCollections.cs +++ b/Penumbra/UI/MenuTabs/TabCollections.cs @@ -54,10 +54,10 @@ public partial class SettingsInterface private void UpdateIndex() => _currentCollectionIndex = GetIndex( _manager.Collections.CurrentCollection ) - 1; - private void UpdateForcedIndex() + public void UpdateForcedIndex() => _currentForcedIndex = GetIndex( _manager.Collections.ForcedCollection ); - private void UpdateDefaultIndex() + public void UpdateDefaultIndex() => _currentDefaultIndex = GetIndex( _manager.Collections.DefaultCollection ); private void UpdateCharacterIndices() diff --git a/Penumbra/UI/SettingsInterface.cs b/Penumbra/UI/SettingsInterface.cs index 3a21ee22..20eaff02 100644 --- a/Penumbra/UI/SettingsInterface.cs +++ b/Penumbra/UI/SettingsInterface.cs @@ -3,81 +3,86 @@ using System.Numerics; using Penumbra.Mods; using Penumbra.Util; -namespace Penumbra.UI +namespace Penumbra.UI; + +public partial class SettingsInterface : IDisposable { - public partial class SettingsInterface : IDisposable + private const float DefaultVerticalSpace = 20f; + + private static readonly Vector2 AutoFillSize = new(-1, -1); + private static readonly Vector2 ZeroVector = new(0, 0); + + private readonly Penumbra _penumbra; + + private readonly ManageModsButton _manageModsButton; + private readonly MenuBar _menuBar; + private readonly SettingsMenu _menu; + private readonly ModManager _modManager; + + public SettingsInterface( Penumbra penumbra ) { - private const float DefaultVerticalSpace = 20f; + _penumbra = penumbra; + _manageModsButton = new ManageModsButton( this ); + _menuBar = new MenuBar( this ); + _menu = new SettingsMenu( this ); + _modManager = Service< ModManager >.Get(); - private static readonly Vector2 AutoFillSize = new( -1, -1 ); - private static readonly Vector2 ZeroVector = new( 0, 0 ); + Dalamud.PluginInterface.UiBuilder.DisableGposeUiHide = true; + Dalamud.PluginInterface.UiBuilder.Draw += Draw; + Dalamud.PluginInterface.UiBuilder.OpenConfigUi += OpenConfig; + } - private readonly Penumbra _penumbra; + public void Dispose() + { + _manageModsButton.Dispose(); + _menu.InstalledTab.Selector.Cache.Dispose(); + Dalamud.PluginInterface.UiBuilder.Draw -= Draw; + Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig; + } - private readonly ManageModsButton _manageModsButton; - private readonly MenuBar _menuBar; - private readonly SettingsMenu _menu; - private readonly ModManager _modManager; + private void OpenConfig() + => _menu.Visible = true; - public SettingsInterface( Penumbra penumbra ) + public void FlipVisibility() + => _menu.Visible = !_menu.Visible; + + public void MakeDebugTabVisible() + => _menu.DebugTabVisible = true; + + public void Draw() + { + _menuBar.Draw(); + _menu.Draw(); + } + + private void ReloadMods() + { + _menu.InstalledTab.Selector.ClearSelection(); + _modManager.DiscoverMods( Penumbra.Config.ModDirectory ); + _menu.InstalledTab.Selector.Cache.TriggerListReset(); + } + + private void SaveCurrentCollection( bool recalculateMeta ) + { + var current = _modManager.Collections.CurrentCollection; + current.Save(); + RecalculateCurrent( recalculateMeta ); + } + + private void RecalculateCurrent( bool recalculateMeta ) + { + var current = _modManager.Collections.CurrentCollection; + if( current.Cache != null ) { - _penumbra = penumbra; - _manageModsButton = new ManageModsButton( this ); - _menuBar = new MenuBar( this ); - _menu = new SettingsMenu( this ); - _modManager = Service< ModManager >.Get(); - - Dalamud.PluginInterface.UiBuilder.DisableGposeUiHide = true; - Dalamud.PluginInterface.UiBuilder.Draw += Draw; - Dalamud.PluginInterface.UiBuilder.OpenConfigUi += OpenConfig; - } - - public void Dispose() - { - _manageModsButton.Dispose(); - _menu.InstalledTab.Selector.Cache.Dispose(); - Dalamud.PluginInterface.UiBuilder.Draw -= Draw; - Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig; - } - - private void OpenConfig() - => _menu.Visible = true; - - public void FlipVisibility() - => _menu.Visible = !_menu.Visible; - - public void MakeDebugTabVisible() - => _menu.DebugTabVisible = true; - - public void Draw() - { - _menuBar.Draw(); - _menu.Draw(); - } - - private void ReloadMods() - { - _menu.InstalledTab.Selector.ClearSelection(); - _modManager.DiscoverMods( Penumbra.Config.ModDirectory ); - _menu.InstalledTab.Selector.Cache.TriggerListReset(); - } - - private void SaveCurrentCollection( bool recalculateMeta ) - { - var current = _modManager.Collections.CurrentCollection; - current.Save(); - RecalculateCurrent( recalculateMeta ); - } - - private void RecalculateCurrent( bool recalculateMeta ) - { - var current = _modManager.Collections.CurrentCollection; - if( current.Cache != null ) - { - current.CalculateEffectiveFileList( _modManager.TempPath, recalculateMeta, - current == _modManager.Collections.ActiveCollection ); - _menu.InstalledTab.Selector.Cache.TriggerFilterReset(); - } + current.CalculateEffectiveFileList( _modManager.TempPath, recalculateMeta, + current == _modManager.Collections.ActiveCollection ); + _menu.InstalledTab.Selector.Cache.TriggerFilterReset(); } } + + public void ResetDefaultCollection() + => _menu.CollectionsTab.UpdateDefaultIndex(); + + public void ResetForcedCollection() + => _menu.CollectionsTab.UpdateForcedIndex(); } \ No newline at end of file