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)
{
var Inf = new InstallerInfo {
var Inf = new InstallerInfo
{
SelectionType = group.SelectionType,
GroupName = group.GroupName,
Options = new List<Option>(),
};
foreach(var opt in group.OptionList) {
var optio = new Option{
OptionName = opt.Name,
OptionDesc = String.IsNullOrEmpty(opt.Description) ? "" : opt.Description,
OptionFiles = new Dictionary<string, string>()
};
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('\\','/');
foreach( var opt in group.OptionList )
{
var optio = new Option
{
OptionName = opt.Name,
OptionDesc = String.IsNullOrEmpty( opt.Description ) ? "" : opt.Description,
OptionFiles = new Dictionary<string, string>()
};
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 )

View file

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

View file

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

View file

@ -602,39 +602,44 @@ namespace Penumbra.UI
var mod = _plugin.SettingsInterface._selectedMod;
var conf = mod.Conf;
var settings = mod.Mod.Meta.Groups;
foreach(var g in settings) {
switch(g.Value.SelectionType) {
foreach( var g in settings )
{
switch( g.Value.SelectionType )
{
case SelectType.Multi:
{
var i = 0;
var flag = conf[g.Key];
foreach(var opt in g.Value.Options) {
var enab = (flag & 1<<i)!=0;
if(ImGui.Checkbox(g.Value.GroupName + " - " +opt.OptionName, ref enab)) {
flag = flag ^= 1<<i;
conf[g.Key] = flag;
_plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList();
{
var i = 0;
var flag = conf[g.Key];
foreach( var opt in g.Value.Options )
{
var enab = ( flag & 1 << i ) != 0;
if( ImGui.Checkbox( g.Value.GroupName + " - " + opt.OptionName, ref enab ) )
{
flag = flag ^= 1 << i;
conf[g.Key] = flag;
_plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList();
}
i++;
}
i++;
break;
}
break;
}
case SelectType.Single:
{
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)) {
conf[g.Key] = code;
_plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList();
case SelectType.Single:
{
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 ) )
{
conf[g.Key] = code;
_plugin.ModManager.Mods.Save();
_plugin.ModManager.CalculateEffectiveFileList();
}
}
break;
}
break;
}
}
}
}
void DrawInstalledMods()