mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-23 08:17:59 +01:00
Remove some warnings about nullable.
This commit is contained in:
parent
3f9d97f65f
commit
ef2f2cff5c
26 changed files with 330 additions and 352 deletions
|
|
@ -38,7 +38,7 @@ namespace Penumbra.Importer
|
|||
}
|
||||
}
|
||||
|
||||
public string CurrentModPack { get; private set; }
|
||||
public string? CurrentModPack { get; private set; }
|
||||
|
||||
public TexToolsImport( DirectoryInfo outDirectory )
|
||||
{
|
||||
|
|
@ -145,6 +145,12 @@ namespace Penumbra.Importer
|
|||
{
|
||||
var modList = JsonConvert.DeserializeObject< SimpleModPack >( modRaw );
|
||||
|
||||
if( modList?.TTMPVersion == null )
|
||||
{
|
||||
PluginLog.Error( "Could not extract V2 Modpack. No version given." );
|
||||
return;
|
||||
}
|
||||
|
||||
if( modList.TTMPVersion.EndsWith( "s" ) )
|
||||
{
|
||||
ImportSimpleV2ModPack( extractedModPack, modList );
|
||||
|
|
@ -164,11 +170,11 @@ namespace Penumbra.Importer
|
|||
// Create a new ModMeta from the TTMP modlist info
|
||||
var modMeta = new ModMeta
|
||||
{
|
||||
Author = modList.Author,
|
||||
Name = modList.Name,
|
||||
Author = modList.Author ?? "Unknown",
|
||||
Name = modList.Name ?? "New Mod",
|
||||
Description = string.IsNullOrEmpty( modList.Description )
|
||||
? "Mod imported from TexTools mod pack"
|
||||
: modList.Description
|
||||
: modList.Description!
|
||||
};
|
||||
|
||||
// Open the mod data file from the modpack as a SqPackStream
|
||||
|
|
@ -181,7 +187,7 @@ namespace Penumbra.Importer
|
|||
File.WriteAllText( Path.Combine( newModFolder.FullName, "meta.json" ),
|
||||
JsonConvert.SerializeObject( modMeta ) );
|
||||
|
||||
ExtractSimpleModList( newModFolder, modList.SimpleModsList, modData );
|
||||
ExtractSimpleModList( newModFolder, modList.SimpleModsList ?? Enumerable.Empty< SimpleMod >(), modData );
|
||||
}
|
||||
|
||||
private void ImportExtendedV2ModPack( ZipFile extractedModPack, string modRaw )
|
||||
|
|
@ -193,12 +199,12 @@ namespace Penumbra.Importer
|
|||
// Create a new ModMeta from the TTMP modlist info
|
||||
var modMeta = new ModMeta
|
||||
{
|
||||
Author = modList.Author,
|
||||
Name = modList.Name,
|
||||
Author = modList.Author ?? "Unknown",
|
||||
Name = modList.Name ?? "New Mod",
|
||||
Description = string.IsNullOrEmpty( modList.Description )
|
||||
? "Mod imported from TexTools mod pack"
|
||||
: modList.Description,
|
||||
Version = modList.Version
|
||||
: modList.Description ?? "",
|
||||
Version = modList.Version ?? ""
|
||||
};
|
||||
|
||||
// Open the mod data file from the modpack as a SqPackStream
|
||||
|
|
@ -222,13 +228,14 @@ namespace Penumbra.Importer
|
|||
}
|
||||
|
||||
// Iterate through all pages
|
||||
foreach( var group in modList.ModPackPages.SelectMany( page => page.ModGroups ) )
|
||||
foreach( var group in modList.ModPackPages.SelectMany( page => page.ModGroups )
|
||||
.Where( group => group.GroupName != null && group.OptionList != null ) )
|
||||
{
|
||||
var groupFolder = new DirectoryInfo( Path.Combine( newModFolder.FullName, group.GroupName.ReplaceInvalidPathSymbols() ) );
|
||||
foreach( var option in group.OptionList )
|
||||
var groupFolder = new DirectoryInfo( Path.Combine( newModFolder.FullName, group.GroupName!.ReplaceInvalidPathSymbols() ) );
|
||||
foreach( var option in group.OptionList!.Where( option => option.Name != null && option.ModsJsons != null ) )
|
||||
{
|
||||
var optionFolder = new DirectoryInfo( Path.Combine( groupFolder.FullName, option.Name.ReplaceInvalidPathSymbols() ) );
|
||||
ExtractSimpleModList( optionFolder, option.ModsJsons, modData );
|
||||
var optionFolder = new DirectoryInfo( Path.Combine( groupFolder.FullName, option.Name!.ReplaceInvalidPathSymbols() ) );
|
||||
ExtractSimpleModList( optionFolder, option.ModsJsons!, modData );
|
||||
}
|
||||
|
||||
AddMeta( newModFolder, groupFolder, group, modMeta );
|
||||
|
|
@ -242,21 +249,21 @@ namespace Penumbra.Importer
|
|||
|
||||
private static void AddMeta( DirectoryInfo baseFolder, DirectoryInfo groupFolder, ModGroup group, ModMeta meta )
|
||||
{
|
||||
var Inf = new InstallerInfo
|
||||
var inf = new InstallerInfo
|
||||
{
|
||||
SelectionType = group.SelectionType,
|
||||
GroupName = group.GroupName,
|
||||
GroupName = group.GroupName!,
|
||||
Options = new List< Option >()
|
||||
};
|
||||
foreach( var opt in group.OptionList )
|
||||
foreach( var opt in group.OptionList! )
|
||||
{
|
||||
var option = new Option
|
||||
{
|
||||
OptionName = opt.Name,
|
||||
OptionDesc = string.IsNullOrEmpty( opt.Description ) ? "" : opt.Description,
|
||||
OptionName = opt.Name!,
|
||||
OptionDesc = string.IsNullOrEmpty( opt.Description ) ? "" : opt.Description!,
|
||||
OptionFiles = new Dictionary< string, HashSet< string > >()
|
||||
};
|
||||
var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name.ReplaceInvalidPathSymbols() ) );
|
||||
var optDir = new DirectoryInfo( Path.Combine( groupFolder.FullName, opt.Name!.ReplaceInvalidPathSymbols() ) );
|
||||
if( optDir.Exists )
|
||||
{
|
||||
foreach( var file in optDir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
|
||||
|
|
@ -266,10 +273,10 @@ namespace Penumbra.Importer
|
|||
}
|
||||
}
|
||||
|
||||
Inf.Options.Add( option );
|
||||
inf.Options.Add( option );
|
||||
}
|
||||
|
||||
meta.Groups.Add( group.GroupName, Inf );
|
||||
meta.Groups.Add( group.GroupName!, inf );
|
||||
}
|
||||
|
||||
private void ImportMetaModPack( FileInfo file )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue