mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ask to endorse mods, fixes to broken installers
This commit is contained in:
parent
3127a00d95
commit
d33c1a358d
@ -89,7 +89,6 @@ namespace Wabbajack.Common
|
|||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var p = new Process
|
var p = new Process
|
||||||
@ -98,6 +97,7 @@ namespace Wabbajack.Common
|
|||||||
};
|
};
|
||||||
|
|
||||||
p.Start();
|
p.Start();
|
||||||
|
ChildProcessTracker.AddProcess(p);
|
||||||
p.PriorityClass = ProcessPriorityClass.BelowNormal;
|
p.PriorityClass = ProcessPriorityClass.BelowNormal;
|
||||||
|
|
||||||
p.WaitForExit();
|
p.WaitForExit();
|
||||||
|
@ -321,6 +321,15 @@ namespace Wabbajack.Common
|
|||||||
return result.Result;
|
return result.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Stream PostStreamSync(this HttpClient client, string url, HttpContent content)
|
||||||
|
{
|
||||||
|
var result = client.PostAsync(url, content);
|
||||||
|
result.Wait();
|
||||||
|
var stream = result.Result.Content.ReadAsStreamAsync();
|
||||||
|
stream.Wait();
|
||||||
|
return stream.Result;
|
||||||
|
}
|
||||||
|
|
||||||
public static string ExceptionToString(this Exception ex)
|
public static string ExceptionToString(this Exception ex)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BSDiff.cs" />
|
<Compile Include="BSDiff.cs" />
|
||||||
|
<Compile Include="ChildProcessTracker.cs" />
|
||||||
<Compile Include="Consts.cs" />
|
<Compile Include="Consts.cs" />
|
||||||
<Compile Include="DynamicIniData.cs" />
|
<Compile Include="DynamicIniData.cs" />
|
||||||
<Compile Include="FileExtractor.cs" />
|
<Compile Include="FileExtractor.cs" />
|
||||||
|
@ -972,11 +972,12 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
var result = source.EvolveTo<FromArchive>();
|
var result = source.EvolveTo<FromArchive>();
|
||||||
|
|
||||||
var match = found.Where(f => Path.GetFileName(f.Paths[0]) == Path.GetFileName(source.Path))
|
var match = found.Where(f => Path.GetFileName(f.Paths[f.Paths.Length - 1]) == Path.GetFileName(source.Path))
|
||||||
|
.OrderBy(f => f.Paths.Length)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (match == null)
|
if (match == null)
|
||||||
match = found.FirstOrDefault();
|
match = found.OrderBy(f => f.Paths.Length).FirstOrDefault();
|
||||||
|
|
||||||
result.ArchiveHashPath = match.MakeRelativePaths();
|
result.ArchiveHashPath = match.MakeRelativePaths();
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
using VFS;
|
using VFS;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
|
|
||||||
@ -114,6 +115,38 @@ namespace Wabbajack
|
|||||||
BuildBSAs();
|
BuildBSAs();
|
||||||
|
|
||||||
Info("Installation complete! You may exit the program.");
|
Info("Installation complete! You may exit the program.");
|
||||||
|
AskToEndorse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AskToEndorse()
|
||||||
|
{
|
||||||
|
var mods = ModList.Directives
|
||||||
|
.OfType<NexusMod>()
|
||||||
|
.GroupBy(f => (f.GameName, f.ModID))
|
||||||
|
.Select(mod => mod.First())
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var result = MessageBox.Show(
|
||||||
|
$"Installation has completed, but you have installed ${mods.Length} from the Nexus, would you like to" +
|
||||||
|
" endorse these mods to show support to the authors? It will only take a few moments.", "Endorse Mods?",
|
||||||
|
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
|
||||||
|
if (result != MessageBoxResult.Yes) return;
|
||||||
|
|
||||||
|
// Shuffle mods so that if we hit a API limit we don't always miss the same mods
|
||||||
|
var r = new Random();
|
||||||
|
for (var i = 0; i < mods.Length; i++)
|
||||||
|
{
|
||||||
|
var a = r.Next(mods.Length);
|
||||||
|
var b = r.Next(mods.Length);
|
||||||
|
var tmp = mods[a];
|
||||||
|
mods[a] = mods[b];
|
||||||
|
mods[b] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
mods.PMap(mod => NexusAPI.EndorseMod(mod, NexusAPIKey));
|
||||||
|
Info("Done! You may now exit the application!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LocateGameFolder()
|
private bool LocateGameFolder()
|
||||||
@ -314,7 +347,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
vfiles.DoIndexed((idx, file) =>
|
vfiles.DoIndexed((idx, file) =>
|
||||||
{
|
{
|
||||||
Status($"Installing files", idx * 100 / vfiles.Count);
|
Utils.Status($"Installing files", idx * 100 / vfiles.Count);
|
||||||
File.Copy(file.FromFile.StagedPath, Path.Combine(Outputfolder, file.To));
|
File.Copy(file.FromFile.StagedPath, Path.Combine(Outputfolder, file.To));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,5 +162,25 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EndorsementResponse EndorseMod(NexusMod mod, string apikey)
|
||||||
|
{
|
||||||
|
Utils.Status($"Endorsing ${mod.GameName} - ${mod.ModID}");
|
||||||
|
var url = $"https://api.nexusmods.com/v1/games/{ConvertGameName(mod.GameName)}/mods/{mod.ModID}/endorse.json";
|
||||||
|
var client = BaseNexusClient(apikey);
|
||||||
|
|
||||||
|
var content = new FormUrlEncodedContent(new Dictionary<string, string>() {{"value", "\"\""}});
|
||||||
|
|
||||||
|
using (var s = client.PostStreamSync(url, content))
|
||||||
|
{
|
||||||
|
return s.FromJSON<EndorsementResponse>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EndorsementResponse
|
||||||
|
{
|
||||||
|
public string message;
|
||||||
|
public string status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
<StartArguments>"c:\Mod Organizer 2" "Nexus SSO Test" "c:\tmp\validate"</StartArguments>
|
<StartArguments>"c:\Mod Organizer 2" "Nexus SSO Test" "c:\tmp\validate"</StartArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug %28no commandargs%29|x64'">
|
||||||
|
<StartWorkingDirectory>c:\tmp\vstmp</StartWorkingDirectory>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user