Clean up formatting

This commit is contained in:
Minizbot2012 2021-01-21 22:17:12 -05:00
parent b3c9fe8902
commit 66a849e38a
4 changed files with 88 additions and 63 deletions

View file

@ -231,19 +231,23 @@ namespace Penumbra.Importer
private void AddMeta( DirectoryInfo baseFolder, DirectoryInfo groupFolder,ModGroup group, ModMeta meta) private void AddMeta( DirectoryInfo baseFolder, DirectoryInfo groupFolder,ModGroup group, ModMeta meta)
{ {
var Inf = new InstallerInfo { var Inf = new InstallerInfo
{
SelectionType = group.SelectionType, SelectionType = group.SelectionType,
GroupName = group.GroupName, GroupName = group.GroupName,
Options = new List<Option>(), Options = new List<Option>(),
}; };
foreach(var opt in group.OptionList) { foreach( var opt in group.OptionList )
var optio = new Option{ {
var optio = new Option
{
OptionName = opt.Name, OptionName = opt.Name,
OptionDesc = String.IsNullOrEmpty( opt.Description ) ? "" : opt.Description, OptionDesc = String.IsNullOrEmpty( opt.Description ) ? "" : opt.Description,
OptionFiles = new Dictionary<string, string>() OptionFiles = new Dictionary<string, string>()
}; };
var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name ) ); var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name ) );
foreach(var file in optDir.EnumerateFiles("*.*", SearchOption.AllDirectories)) { foreach( var file in optDir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
{
optio.OptionFiles[file.FullName.Substring( baseFolder.FullName.Length ).TrimStart( '\\' )] = file.FullName.Substring( optDir.FullName.Length ).TrimStart( '\\' ).Replace( '\\', '/' ); optio.OptionFiles[file.FullName.Substring( baseFolder.FullName.Length ).TrimStart( '\\' )] = file.FullName.Substring( optDir.FullName.Length ).TrimStart( '\\' ).Replace( '\\', '/' );
} }
Inf.Options.Add( optio ); Inf.Options.Add( optio );

View file

@ -2,15 +2,18 @@ using System.Collections.Generic;
namespace Penumbra.Models namespace Penumbra.Models
{ {
public enum SelectType { public enum SelectType
{
Single, Multi Single, Multi
} }
public struct Option { public struct Option
{
public string OptionName; public string OptionName;
public string OptionDesc; public string OptionDesc;
public Dictionary<string, string> OptionFiles; public Dictionary<string, string> OptionFiles;
} }
public struct InstallerInfo { public struct InstallerInfo
{
public string GroupName; public string GroupName;
public SelectType SelectionType; public SelectType SelectionType;
public List<Option> Options; public List<Option> Options;

View file

@ -102,11 +102,15 @@ namespace Penumbra.Mods
// Needed to reload body textures with mods // Needed to reload body textures with mods
//_plugin.GameUtils.ReloadPlayerResources(); //_plugin.GameUtils.ReloadPlayerResources();
} }
private (InstallerInfo, Option, string) GlobalPosition(string rel, Dictionary<string, InstallerInfo> gps) { private (InstallerInfo, Option, string) GlobalPosition( string rel, Dictionary<string, InstallerInfo> gps )
{
string filePath = null; string filePath = null;
foreach(var g in gps) { foreach( var g in gps )
foreach(var opt in g.Value.Options) { {
if(opt.OptionFiles.TryGetValue(rel, out filePath)) { foreach( var opt in g.Value.Options )
{
if( opt.OptionFiles.TryGetValue( rel, out filePath ) )
{
return (g.Value, opt, filePath); return (g.Value, opt, filePath);
} }
} }
@ -134,32 +138,41 @@ namespace Penumbra.Mods
string gamePath; string gamePath;
bool addFile = true; bool addFile = true;
var gps = mod.Meta.Groups; var gps = mod.Meta.Groups;
if(gps.Count >=1) { if( gps.Count >= 1 )
{
var negivtron = GlobalPosition( relativeFilePath, gps ); var negivtron = GlobalPosition( relativeFilePath, gps );
if(negivtron.Item3 != null) { if( negivtron.Item3 != null )
if(settings.Conf == null) { {
if( settings.Conf == null )
{
settings.Conf = new(); settings.Conf = new();
_plugin.ModManager.Mods.Save(); _plugin.ModManager.Mods.Save();
} }
if(!settings.Conf.ContainsKey(negivtron.Item1.GroupName)) { if( !settings.Conf.ContainsKey( negivtron.Item1.GroupName ) )
{
settings.Conf[negivtron.Item1.GroupName] = 0; settings.Conf[negivtron.Item1.GroupName] = 0;
_plugin.ModManager.Mods.Save(); _plugin.ModManager.Mods.Save();
} }
var current = settings.Conf[negivtron.Item1.GroupName]; var current = settings.Conf[negivtron.Item1.GroupName];
var flag = negivtron.Item1.Options.IndexOf( negivtron.Item2 ); var flag = negivtron.Item1.Options.IndexOf( negivtron.Item2 );
switch(negivtron.Item1.SelectionType) { switch( negivtron.Item1.SelectionType )
case SelectType.Single: { {
case SelectType.Single:
{
addFile = current == flag; addFile = current == flag;
break; break;
} }
case SelectType.Multi: { case SelectType.Multi:
{
flag = 1 << negivtron.Item1.Options.IndexOf( negivtron.Item2 ); flag = 1 << negivtron.Item1.Options.IndexOf( negivtron.Item2 );
addFile = ( flag & current ) != 0; addFile = ( flag & current ) != 0;
break; break;
} }
} }
gamePath = negivtron.Item3; gamePath = negivtron.Item3;
} else { }
else
{
gamePath = relativeFilePath.Replace( '\\', '/' ); gamePath = relativeFilePath.Replace( '\\', '/' );
} }
} }

View file

@ -602,15 +602,19 @@ namespace Penumbra.UI
var mod = _plugin.SettingsInterface._selectedMod; var mod = _plugin.SettingsInterface._selectedMod;
var conf = mod.Conf; var conf = mod.Conf;
var settings = mod.Mod.Meta.Groups; var settings = mod.Mod.Meta.Groups;
foreach(var g in settings) { foreach( var g in settings )
switch(g.Value.SelectionType) { {
switch( g.Value.SelectionType )
{
case SelectType.Multi: case SelectType.Multi:
{ {
var i = 0; var i = 0;
var flag = conf[g.Key]; var flag = conf[g.Key];
foreach(var opt in g.Value.Options) { foreach( var opt in g.Value.Options )
{
var enab = ( flag & 1 << i ) != 0; var enab = ( flag & 1 << i ) != 0;
if(ImGui.Checkbox(g.Value.GroupName + " - " +opt.OptionName, ref enab)) { if( ImGui.Checkbox( g.Value.GroupName + " - " + opt.OptionName, ref enab ) )
{
flag = flag ^= 1 << i; flag = flag ^= 1 << i;
conf[g.Key] = flag; conf[g.Key] = flag;
_plugin.ModManager.Mods.Save(); _plugin.ModManager.Mods.Save();
@ -623,8 +627,10 @@ namespace Penumbra.UI
case SelectType.Single: case SelectType.Single:
{ {
var code = conf[g.Key]; var code = conf[g.Key];
if(g.Value.Options.Count >1) { if( g.Value.Options.Count > 1 )
if(ImGui.Combo(g.Value.GroupName, ref code, g.Value.Options.Select(x=>x.OptionName).ToArray(), g.Value.Options.ToArray().Length)) { {
if( ImGui.Combo( g.Value.GroupName, ref code, g.Value.Options.Select( x => x.OptionName ).ToArray(), g.Value.Options.ToArray().Length ) )
{
conf[g.Key] = code; conf[g.Key] = code;
_plugin.ModManager.Mods.Save(); _plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList(); _plugin.ModManager.CalculateEffectiveFileList();
@ -634,7 +640,6 @@ namespace Penumbra.UI
} }
} }
} }
} }
void DrawInstalledMods() void DrawInstalledMods()