-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e8f0a2
commit 66a738d
Showing
9 changed files
with
354 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<Costura /> | ||
</Weavers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="Costura" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:all> | ||
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="DisableCompression" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="DisableCleanup" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="LoadAtModuleInit" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="ExcludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IncludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="Unmanaged32Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="Unmanaged64Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="PreloadOrder" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
using IniParser; | ||
using IniParser.Model; | ||
using Microsoft.Win32; | ||
using SharpBSABA2; | ||
using SharpBSABA2.BA2Util; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Fallout76Proxy | ||
{ | ||
class ModManager | ||
{ | ||
/* STRANGE MOD LOADING | ||
https://www.nexusmods.com/fallout76/mods/162 | ||
https://www.nexusmods.com/fallout76/mods/60 | ||
https://www.nexusmods.com/fallout76/mods/183 | ||
https://www.nexusmods.com/fallout76/mods/91 | ||
*/ | ||
|
||
class ModConflictException : Exception { public ModConflictException(string message) : base(message) { } }; | ||
class Fallout76NotInstalled : Exception { public Fallout76NotInstalled(string message) : base(message) { } }; | ||
|
||
enum LoadType | ||
{ | ||
Default, | ||
StartUp | ||
} | ||
|
||
LoadType GetLoadType(BA2 ba2) | ||
{ | ||
foreach (ArchiveEntry file in ba2.Files) | ||
{ | ||
if (file.FileName.Contains("fonts_")) | ||
{ | ||
return LoadType.StartUp; | ||
} | ||
} | ||
|
||
return LoadType.Default; | ||
} | ||
|
||
string GetFallout76Path() | ||
{ | ||
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Fallout 76"); | ||
if (registryKey == null) | ||
{ | ||
throw new Fallout76NotInstalled("Can't detect Fallout 76 installation!"); | ||
} | ||
|
||
string path = (string) registryKey.GetValue("Path"); | ||
|
||
if (String.IsNullOrEmpty(path)) | ||
{ | ||
throw new Fallout76NotInstalled("Can't detect Fallout 76 directory!"); | ||
} | ||
|
||
path = path.Replace("\"", ""); | ||
|
||
if (!Directory.Exists($"{path}\\Data")) | ||
{ | ||
throw new Fallout76NotInstalled("Fallout 76 data directory missed!"); | ||
} | ||
|
||
return path; | ||
} | ||
|
||
public void Process() | ||
{ | ||
Dictionary<string, string> conflicts = new Dictionary<string, string>(); | ||
|
||
string sResourceArchive2List = "SeventySix - ATX_Main.ba2, SeventySix - ATX_Textures.ba2"; | ||
string sResourceStartUpArchiveList = "SeventySix - Interface.ba2, SeventySix - Localization.ba2, SeventySix - Shaders.ba2, SeventySix - Startup.ba2"; | ||
|
||
string[] ba2Archives = Directory.GetFiles($"{GetFallout76Path()}\\Data\\", "*.ba2"); | ||
|
||
Console.WriteLine($"Detected {ba2Archives.Length} mods."); | ||
|
||
foreach (string ba2Archive in ba2Archives) | ||
{ | ||
// skip F76 files | ||
if (ba2Archive.Contains("SeventySix -")) | ||
{ | ||
continue; | ||
} | ||
|
||
BA2 ba2 = new BA2(ba2Archive); | ||
|
||
foreach (ArchiveEntry file in ba2.Files) | ||
{ | ||
if (conflicts.ContainsKey(file.FullPath)) | ||
{ | ||
throw new ModConflictException(String.Format("Mod {0} conflicts with {1}. Remove one of them.", ba2.FileName, conflicts[file.FullPath])); | ||
} | ||
|
||
conflicts.Add(file.FullPath, ba2.FileName); | ||
} | ||
|
||
LoadType modLoadType = GetLoadType(ba2); | ||
switch (modLoadType) | ||
{ | ||
case LoadType.Default: | ||
sResourceArchive2List += String.Format(", {0}", ba2.FileName); | ||
break; | ||
|
||
case LoadType.StartUp: | ||
sResourceStartUpArchiveList += String.Format(", {0}", ba2.FileName); | ||
break; | ||
} | ||
} | ||
|
||
WriteFallout76Customs(sResourceArchive2List, sResourceStartUpArchiveList); | ||
} | ||
|
||
void WriteFallout76Customs(string sResourceArchive2List, string sResourceStartUpArchiveList) | ||
{ | ||
FileIniDataParser parser = new FileIniDataParser(); | ||
|
||
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); | ||
string fallout76CustomPath = $"{myDocumentsPath}\\My Games\\Fallout 76\\Fallout76Custom.ini"; | ||
|
||
IniData data = new IniData(); | ||
|
||
if (File.Exists(fallout76CustomPath)) | ||
{ | ||
// Remove readonly | ||
File.SetAttributes(fallout76CustomPath, FileAttributes.Normal); | ||
|
||
data = parser.ReadFile(fallout76CustomPath); | ||
} | ||
|
||
data["Archive"]["sResourceArchive2List"] = sResourceArchive2List; | ||
data["Archive"]["sResourceStartUpArchiveList"] = sResourceStartUpArchiveList; | ||
|
||
// Empty old data | ||
data["Archive"].RemoveKey("sResourceArchiveList2"); | ||
data["Archive"].RemoveKey("sResourceIndexFileList"); | ||
|
||
File.WriteAllText(fallout76CustomPath, data.ToString()); | ||
} | ||
} | ||
} |
Oops, something went wrong.