mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Implement screen size auto-set for MO2 games
This commit is contained in:
parent
dfd5d7251d
commit
8b2486059f
@ -3,6 +3,9 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using IniParser;
|
||||
using IniParser.Parser;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
@ -32,7 +35,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
protected override bool _Begin()
|
||||
{
|
||||
ConfigureProcessor(17, RecommendQueueSize());
|
||||
ConfigureProcessor(18, RecommendQueueSize());
|
||||
var game = GameRegistry.Games[ModList.GameType];
|
||||
|
||||
if (GameFolder == null)
|
||||
@ -115,6 +118,9 @@ namespace Wabbajack.Lib
|
||||
UpdateTracker.NextStep("Generating Merges");
|
||||
zEditIntegration.GenerateMerges(this);
|
||||
|
||||
UpdateTracker.NextStep("Updating System-specific ini settings");
|
||||
SetScreenSizeInPrefs();
|
||||
|
||||
UpdateTracker.NextStep("Installation complete! You may exit the program.");
|
||||
return true;
|
||||
}
|
||||
@ -259,6 +265,23 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
private void SetScreenSizeInPrefs()
|
||||
{
|
||||
foreach (var file in Directory.EnumerateFiles(Path.Combine(OutputFolder, "profiles"), "*refs.ini",
|
||||
DirectoryEnumerationOptions.Recursive))
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
var data = parser.ReadFile(file);
|
||||
if (data.Sections["Display"]["iSize W"] != null && data.Sections["Display"]["iSize H"] != null)
|
||||
{
|
||||
data.Sections["Display"]["iSize W"] = SystemParameters.PrimaryScreenWidth.ToString();
|
||||
data.Sections["Display"]["iSize H"] = SystemParameters.PrimaryScreenHeight.ToString();
|
||||
}
|
||||
|
||||
parser.WriteFile(file, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteRemappedFile(RemappedInlineFile directive)
|
||||
{
|
||||
var data = Encoding.UTF8.GetString(LoadBytesFromPath(directive.SourceDataID));
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
@ -108,7 +109,6 @@ namespace Wabbajack.Test
|
||||
[TestMethod]
|
||||
public void CleanedESMTest()
|
||||
{
|
||||
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod("Cleaned ESMs");
|
||||
var update_esm = utils.AddModFile(mod, @"Update.esm", 10);
|
||||
@ -128,8 +128,29 @@ namespace Wabbajack.Test
|
||||
utils.GenerateRandomFileData(game_file, 20);
|
||||
var exception = Assert.ThrowsException<AggregateException>(() => Install(compiler));
|
||||
Assert.AreEqual(exception.InnerExceptions.First().Message, "Game ESM hash doesn't match, is the ESM already cleaned? Please verify your local game files.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SetScreenSizeTest()
|
||||
{
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod("dummy");
|
||||
|
||||
utils.Configure();
|
||||
File.WriteAllLines(Path.Combine(utils.MO2Folder, "profiles", profile, "somegameprefs.ini"),
|
||||
new List<string>
|
||||
{
|
||||
"[Display]",
|
||||
"iSize H=3",
|
||||
"iSize W=-200"
|
||||
});
|
||||
|
||||
var modlist = CompileAndInstall(profile);
|
||||
|
||||
var ini = Path.Combine(utils.InstallFolder, "profiles", profile, "somegameprefs.ini").LoadIniFile();
|
||||
|
||||
Assert.AreEqual(System.Windows.SystemParameters.PrimaryScreenHeight.ToString(), ini?.Display?["iSize H"]);
|
||||
Assert.AreEqual(System.Windows.SystemParameters.PrimaryScreenWidth.ToString(), ini?.Display?["iSize W"]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
Loading…
x
Reference in New Issue
Block a user