Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Owml manifest (#88)
Browse files Browse the repository at this point in the history
* owml manifest file
amazingalek authored Apr 11, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c577a17 commit 8f27b7f
Showing 5 changed files with 32 additions and 11 deletions.
12 changes: 6 additions & 6 deletions OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@ namespace OWML.Launcher
{
public class App
{
private const string Version = "0.3.42";

private readonly IOwmlConfig _owmlConfig;
private readonly IModManifest _owmlManifest;
private readonly IModConsole _writer;
private readonly IModFinder _modFinder;
private readonly OutputListener _listener;
@@ -23,10 +22,11 @@ public class App
private readonly VRPatcher _vrPatcher;
private readonly CheckVersion _checkVersion;

public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder,
public App(IOwmlConfig owmlConfig, IModManifest owmlManifest, IModConsole writer, IModFinder modFinder,
OutputListener listener, PathFinder pathFinder, OWPatcher owPatcher, VRPatcher vrPatcher, CheckVersion checkVersion)
{
_owmlConfig = owmlConfig;
_owmlManifest = owmlManifest;
_writer = writer;
_modFinder = modFinder;
_listener = listener;
@@ -38,7 +38,7 @@ public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder,

public void Run(string[] args)
{
_writer.WriteLine($"Started OWML v{Version}");
_writer.WriteLine($"Started OWML v{_owmlManifest.Version}");

CheckVersion();

@@ -70,7 +70,7 @@ private void CheckVersion()
_writer.WriteLine("Warning: could not check latest OWML version.");
return;
}
if (Version == latestVersion)
if (_owmlManifest.Version == latestVersion)
{
_writer.WriteLine("OWML is up to date.");
return;
@@ -133,7 +133,7 @@ private void ShowModList(IList<IModData> mods)

private bool IsMadeForSameOwmlMajorVersion(IModManifest manifest)
{
var owmlVersionSplit = Version.Split('.');
var owmlVersionSplit = _owmlManifest.Version.Split('.');
var modVersionSplit = manifest.OWMLVersion.Split('.');
return owmlVersionSplit.Length == modVersionSplit.Length &&
owmlVersionSplit[0] == modVersionSplit[0] &&
3 changes: 3 additions & 0 deletions OWML.Launcher/OWML.Launcher.csproj
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="OWML.Manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="OWML.Config.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
6 changes: 6 additions & 0 deletions OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"author": "Alek",
"name": "OWML",
"uniqueName": "Alek.OWML",
"version": "0.3.43"
}
21 changes: 16 additions & 5 deletions OWML.Launcher/Program.cs
Original file line number Diff line number Diff line change
@@ -14,26 +14,37 @@ public class Program
static void Main(string[] args)
{
var owmlConfig = GetOwmlConfig();
var owmlManifest = GetOwmlManifest();
var writer = new OutputWriter();
var modFinder = new ModFinder(owmlConfig, writer);
var outputListener = new OutputListener(owmlConfig);
var pathFinder = new PathFinder(owmlConfig, writer);
var owPatcher = new OWPatcher(owmlConfig, writer);
var vrPatcher = new VRPatcher(owmlConfig, writer);
var checkVersion = new CheckVersion(writer);
var app = new App(owmlConfig, writer, modFinder, outputListener, pathFinder, owPatcher, vrPatcher, checkVersion);
var app = new App(owmlConfig, owmlManifest, writer, modFinder, outputListener, pathFinder, owPatcher, vrPatcher, checkVersion);
app.Run(args);
}

private static IOwmlConfig GetOwmlConfig()
{
var json = File.ReadAllText("OWML.Config.json")
.Replace("\\\\", "/")
.Replace("\\", "/");
var config = JsonConvert.DeserializeObject<OwmlConfig>(json);
var config = GetJsonObject<OwmlConfig>("OWML.Config.json");
config.OWMLPath = AppDomain.CurrentDomain.BaseDirectory;
return config;
}

private static IModManifest GetOwmlManifest()
{
return GetJsonObject<ModManifest>("OWML.Manifest.json");
}

private static T GetJsonObject<T>(string filename)
{
var json = File.ReadAllText(filename)
.Replace("\\\\", "/")
.Replace("\\", "/");
return JsonConvert.DeserializeObject<T>(json);
}

}
}
1 change: 1 addition & 0 deletions createrelease.bat
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ copy "OWML.Patcher\bin\Debug\OWML.Patcher.dll" "Release\OWML.Patcher.dll"
copy "OWML.ModLoader\bin\Debug\OWML.ModLoader.dll" "Release\OWML.ModLoader.dll"
copy "OWML.Launcher\bin\Debug\OWML.Launcher.exe" "Release\OWML.Launcher.exe"
copy "OWML.Launcher\bin\Debug\OWML.Config.json" "Release\OWML.Config.json"
copy "OWML.Launcher\bin\Debug\OWML.Manifest.json" "Release\OWML.Manifest.json"
copy "OWML.Patcher\dnpatch\dnpatch.dll" "Release\dnpatch.dll"
copy "OWML.Patcher\dnpatch\dnlib.dll" "Release\dnlib.dll"
copy "OWML.Patcher\VR\*" "Release\VR\"

0 comments on commit 8f27b7f

Please sign in to comment.