mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Working on the selector.
This commit is contained in:
parent
8db54ef4f4
commit
069ae772a5
15 changed files with 558 additions and 358 deletions
|
|
@ -1,7 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Logging;
|
||||
using Penumbra.UI;
|
||||
using Penumbra.UI.Classes;
|
||||
|
||||
namespace Penumbra;
|
||||
|
||||
|
|
@ -37,17 +41,21 @@ public partial class Configuration : IPluginConfiguration
|
|||
public bool SortFoldersFirst { get; set; } = false;
|
||||
public bool HasReadCharacterCollectionDesc { get; set; } = false;
|
||||
|
||||
public Dictionary< ColorId, uint > Colors { get; set; }
|
||||
= Enum.GetValues< ColorId >().ToDictionary( c => c, c => c.Data().DefaultColor );
|
||||
|
||||
public static Configuration Load()
|
||||
{
|
||||
var iConfiguration = Dalamud.PluginInterface.GetPluginConfig();
|
||||
var configuration = iConfiguration as Configuration ?? new Configuration();
|
||||
if( iConfiguration is { Version: CurrentVersion } )
|
||||
{
|
||||
configuration.AddColors( false );
|
||||
return configuration;
|
||||
}
|
||||
|
||||
MigrateConfiguration.Migrate( configuration );
|
||||
configuration.Save();
|
||||
configuration.AddColors( true );
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
|
@ -63,4 +71,19 @@ public partial class Configuration : IPluginConfiguration
|
|||
PluginLog.Error( $"Could not save plugin configuration:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
// Add missing colors to the dictionary if necessary.
|
||||
private void AddColors( bool forceSave )
|
||||
{
|
||||
var save = false;
|
||||
foreach( var color in Enum.GetValues< ColorId >() )
|
||||
{
|
||||
save |= Colors.TryAdd( color, color.Data().DefaultColor );
|
||||
}
|
||||
|
||||
if( save || forceSave )
|
||||
{
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue