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,24 +231,28 @@ 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{ {
OptionName = opt.Name, var optio = new Option
OptionDesc = String.IsNullOrEmpty(opt.Description) ? "" : opt.Description, {
OptionFiles = new Dictionary<string, string>() OptionName = opt.Name,
}; OptionDesc = String.IsNullOrEmpty( opt.Description ) ? "" : opt.Description,
var optDir = new DirectoryInfo(Path.Combine( groupFolder.FullName, opt.Name)); OptionFiles = new Dictionary<string, string>()
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('\\','/'); var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name ) );
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( '\\', '/' );
} }
Inf.Options.Add(optio); Inf.Options.Add( optio );
} }
meta.Groups.Add(group.GroupName, Inf); meta.Groups.Add( group.GroupName, Inf );
} }
private void ImportMetaModPack( FileInfo file ) private void ImportMetaModPack( FileInfo file )

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,16 +102,20 @@ 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);
} }
} }
} }
return (default(InstallerInfo), default(Option), null); return (default( InstallerInfo ), default( Option ), null);
} }
public void CalculateEffectiveFileList() public void CalculateEffectiveFileList()
{ {
@ -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); {
if(negivtron.Item3 != null) { var negivtron = GlobalPosition( relativeFilePath, gps );
if(settings.Conf == null) { if( negivtron.Item3 != 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: { {
addFile = current == flag; case SelectType.Single:
break; {
} addFile = current == flag;
case SelectType.Multi: { break;
flag = 1 << negivtron.Item1.Options.IndexOf(negivtron.Item2); }
addFile = (flag & current)!=0; case SelectType.Multi:
break; {
} flag = 1 << negivtron.Item1.Options.IndexOf( negivtron.Item2 );
addFile = ( flag & current ) != 0;
break;
}
} }
gamePath = negivtron.Item3; gamePath = negivtron.Item3;
} else { }
else
{
gamePath = relativeFilePath.Replace( '\\', '/' ); gamePath = relativeFilePath.Replace( '\\', '/' );
} }
} }

View file

@ -602,39 +602,44 @@ 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; {
if(ImGui.Checkbox(g.Value.GroupName + " - " +opt.OptionName, ref enab)) { var enab = ( flag & 1 << i ) != 0;
flag = flag ^= 1<<i; if( ImGui.Checkbox( g.Value.GroupName + " - " + opt.OptionName, ref enab ) )
conf[g.Key] = flag; {
_plugin.ModManager.Mods.Save(); flag = flag ^= 1 << i;
_plugin.ModManager.CalculateEffectiveFileList(); conf[g.Key] = flag;
_plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList();
}
i++;
} }
i++; break;
} }
break; case SelectType.Single:
} {
case SelectType.Single: var code = conf[g.Key];
{ if( g.Value.Options.Count > 1 )
var code = conf[g.Key]; {
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();
}
} }
break;
} }
break;
}
} }
} }
} }
void DrawInstalledMods() void DrawInstalledMods()