Skip to content

Commit

Permalink
add versions to log, remove copy at compile, fix deprecation
Browse files Browse the repository at this point in the history
• Why is this change needed?
Debugging mods is hard, and fixing up some lingering stuff
Also lots of things were being added to MDD that shouldnt
  • Loading branch information
janxious committed Sep 2, 2018
1 parent 85a55c3 commit 25ea78a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
23 changes: 16 additions & 7 deletions ModTek/ModTek.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,12 @@ private static List<string> GetLoadOrder(Dictionary<string, ModDef> modDefs, out
return loadOrder;
}


// LOADING MODS
private static void LoadMod(ModDef modDef)
{
var potentialAdditions = new List<ModDef.ManifestEntry>();

Log($"Loading {modDef.Name}");
Log($"Loading {modDef.Name} {modDef.Version}");

// load out of the manifest
if (modDef.LoadImplicitManifest && modDef.Manifest.All(x => Path.GetFullPath(Path.Combine(modDef.Directory, x.Path)) != Path.GetFullPath(Path.Combine(modDef.Directory, "StreamingAssets"))))
Expand All @@ -263,7 +262,7 @@ private static void LoadMod(ModDef modDef)
}

entry.Id = Path.GetFileNameWithoutExtension(entry.Path);
potentialAdditions.Add(entry);
if (!FileIsOnDenyList(entry.Path)) potentialAdditions.Add(entry);
continue;
}

Expand All @@ -277,14 +276,14 @@ private static void LoadMod(ModDef modDef)
if (Directory.Exists(entryPath))
{
// path is a directory, add all the files there
var files = Directory.GetFiles(entryPath, "*", SearchOption.AllDirectories);
var files = Directory.GetFiles(entryPath, "*", SearchOption.AllDirectories).Where(filePath => !FileIsOnDenyList(filePath));
foreach (var filePath in files)
{
var childModDef = new ModDef.ManifestEntry(entry, filePath, InferIDFromFile(filePath));
potentialAdditions.Add(childModDef);
}
}
else if (File.Exists(entryPath))
else if (File.Exists(entryPath) && !FileIsOnDenyList(entryPath))
{
// path is a file, add the single entry
entry.Id = entry.Id ?? InferIDFromFile(entryPath);
Expand Down Expand Up @@ -414,8 +413,11 @@ internal static IEnumerator<ProgressReport> LoadMoadsLoop()
foreach (var modName in modLoadOrder)
{
var modDef = modDefs[modName];
yield return new ProgressReport((float)modLoaded++/(float)modLoadOrder.Count, sliderText, string.Format("Loading Mod: {0}", modDef.Name));

yield return new ProgressReport(
(float)modLoaded++/(float)modLoadOrder.Count,
sliderText,
string.Format("Loading Mod: {0} {1}", modDef.Name, modDef.Version)
);
try
{
LoadMod(modDef);
Expand Down Expand Up @@ -503,6 +505,13 @@ private static void PrintHarmonySummary(string path)
}
}

// this is a very rudimentary version of an .ignore list for filetypes
// I have added it to remove my most common problems. PRs welcome.
private static readonly string[] ignoreList = { ".DS_STORE", "~", ".nomedia" };
private static bool FileIsOnDenyList(string filePath)
{
return ignoreList.Any(x => filePath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase));
}

// JSON HANDLING
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion ModTek/ModTek.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetDir)$(TargetFileName)" "$(BattleTechGame)\Mods\" /y</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion ModTek/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void Postfix(string assetBundleName, ref string __result)
}

[HarmonyPatch(typeof(MetadataDatabase))]
[HarmonyPatch("MDD_DB_PATH", PropertyMethod.Getter)]
[HarmonyPatch("MDD_DB_PATH", MethodType.Getter)]
public static class MetadataDatabase_MDD_DB_PATH_Patch
{
public static void Postfix(ref string __result)
Expand Down
2 changes: 1 addition & 1 deletion ModTek/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.0.*")]
[assembly: AssemblyVersion("0.3.1.*")]

0 comments on commit 25ea78a

Please sign in to comment.