Skip to content

Commit

Permalink
checking version (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingalek authored Jan 7, 2020
1 parent e3e4c36 commit 5b4cf65
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 5 deletions.
26 changes: 24 additions & 2 deletions OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@
using Newtonsoft.Json;
using OWML.Common;
using OWML.Patcher;
using OWML.Update;

namespace OWML.Launcher
{
public class App
{
private const string Version = "0.3.16";
private const string Version = "0.3.17";

private readonly IOwmlConfig _owmlConfig;
private readonly IModConsole _writer;
private readonly IModFinder _modFinder;
private readonly OutputListener _listener;
private readonly PathFinder _pathFinder;
private readonly ModPatcher _patcher;
private readonly ModUpdate _update;

public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder, OutputListener listener, PathFinder pathFinder, ModPatcher patcher)
public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder, OutputListener listener,
PathFinder pathFinder, ModPatcher patcher, ModUpdate update)
{
_owmlConfig = owmlConfig;
_writer = writer;
_modFinder = modFinder;
_listener = listener;
_pathFinder = pathFinder;
_patcher = patcher;
_update = update;
}

public void Run()
{
_writer.WriteLine($"Started OWML version {Version}");
_writer.WriteLine("For detailed log, see Logs/OWML.Log.txt");

CheckVersion();

LocateGamePath();

CopyGameFiles();
Expand All @@ -49,6 +55,22 @@ public void Run()
Console.ReadLine();
}

private void CheckVersion()
{
var latestVersion = _update.GetLatestVersion();
if (string.IsNullOrEmpty(latestVersion))
{
_writer.WriteLine("Could not check version.");
return;
}
if (Version == latestVersion)
{
_writer.WriteLine("OWML is up to date.");
return;
}
_writer.WriteLine($"Warning: please update OWML to {latestVersion}: {_update.ReleasesUrl}");
}

private void LocateGamePath()
{
var gamePath = _pathFinder.FindGamePath();
Expand Down
4 changes: 4 additions & 0 deletions OWML.Launcher/OWML.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<Project>{5153D37F-3148-45DE-B1A4-7EBF87965569}</Project>
<Name>OWML.Patcher</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.Update\OWML.Update.csproj">
<Project>{55ACB9AB-CDCB-4F37-94E0-78891023E44C}</Project>
<Name>OWML.Update</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion OWML.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using OWML.ModHelper;
using OWML.ModLoader;
using OWML.Patcher;
using OWML.Update;

namespace OWML.Launcher
{
Expand All @@ -18,7 +19,8 @@ static void Main(string[] args)
var outputListener = new OutputListener(owmlConfig);
var pathFinder = new PathFinder(owmlConfig, writer);
var patcher = new ModPatcher(owmlConfig, writer);
var app = new App(owmlConfig, writer, modFinder, outputListener, pathFinder, patcher);
var update = new ModUpdate(writer);
var app = new App(owmlConfig, writer, modFinder, outputListener, pathFinder, patcher, update);
app.Run();
}

Expand Down
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.EnableDebugMode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "EnableDebugMode",
"uniqueName": "Alek.EnableDebugMode",
"version": "0.2",
"owmlVersion": "0.3.16",
"owmlVersion": "0.3.17",
"enabled": false
}
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.LoadCustomAssets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "LoadCustomAssets",
"uniqueName": "Alek.LoadCustomAssets",
"version": "0.4",
"owmlVersion": "0.3.16",
"owmlVersion": "0.3.17",
"enabled": false
}
47 changes: 47 additions & 0 deletions OWML.Update/ModUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using HtmlAgilityPack;
using OWML.Common;

namespace OWML.Update
{
public class ModUpdate
{
private const string BaseUrl = "https://github.com";
public string ReleasesUrl = BaseUrl + "/amazingalek/owml/releases";

private readonly IModConsole _writer;

public ModUpdate(IModConsole writer)
{
_writer = writer;
}

public string GetLatestVersion()
{
var web = new HtmlWeb();

string versionNumber;

try
{
var releasesDoc = web.Load(ReleasesUrl);
var releaseLink = releasesDoc.DocumentNode.QuerySelector("div.release-header a");
versionNumber = releaseLink.InnerText;
}
catch (Exception ex)
{
_writer.WriteLine("Error while getting latest version: " + ex);
return null;
}

if (versionNumber.Contains("+"))
{
var indexOfPlus = versionNumber.IndexOf("+");
versionNumber = versionNumber.Substring(0, indexOfPlus);
}

return versionNumber;
}

}
}
64 changes: 64 additions & 0 deletions OWML.Update/OWML.Update.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{55ACB9AB-CDCB-4F37-94E0-78891023E44C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OWML.Update</RootNamespace>
<AssemblyName>OWML.Update</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.CssSelectors.1.0.2\lib\net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack.CssSelectors, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.CssSelectors.1.0.2\lib\net45\HtmlAgilityPack.CssSelectors.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ModUpdate.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OWML.Common\OWML.Common.csproj">
<Project>{3C00626F-B688-4F32-B493-5B7EC1C879A0}</Project>
<Name>OWML.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
35 changes: 35 additions & 0 deletions OWML.Update/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OWML.Update")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OWML.Update")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("55acb9ab-cdcb-4f37-94e0-78891023e44c")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
5 changes: 5 additions & 0 deletions OWML.Update/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.11.17" targetFramework="net472" />
<package id="HtmlAgilityPack.CssSelectors" version="1.0.2" targetFramework="net472" />
</packages>
6 changes: 6 additions & 0 deletions OWML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OWML.Nuget", "OWML.Nuget\OW
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OWML.ModHelper.Menus", "OWML.ModHelper.Menus\OWML.ModHelper.Menus.csproj", "{B874CC24-8340-4238-AC9D-1BFB41186BB5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OWML.Update", "OWML.Update\OWML.Update.csproj", "{55ACB9AB-CDCB-4F37-94E0-78891023E44C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,6 +79,10 @@ Global
{B874CC24-8340-4238-AC9D-1BFB41186BB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B874CC24-8340-4238-AC9D-1BFB41186BB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B874CC24-8340-4238-AC9D-1BFB41186BB5}.Release|Any CPU.Build.0 = Release|Any CPU
{55ACB9AB-CDCB-4F37-94E0-78891023E44C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55ACB9AB-CDCB-4F37-94E0-78891023E44C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55ACB9AB-CDCB-4F37-94E0-78891023E44C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55ACB9AB-CDCB-4F37-94E0-78891023E44C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ I'm Alek on the [Outer Wilds Discord](https://discord.gg/csKYR3w).

Feature requests, bug reports and PRs are welcome on GitHub.

Nexus page: https://www.nexusmods.com/outerwilds/mods/1

## Credits

* Outer Wilds: http://www.outerwilds.com
Expand All @@ -90,3 +92,5 @@ Dependencies:
* Newtonsoft.Json for Unity: https://github.com/SaladLab/Json.Net.Unity3D
* ObjImporter: https://wiki.unity3d.com/index.php?title=ObjImporter
* NAudio-Unity: https://github.com/WulfMarius/NAudio-Unity
* HtmlAgilityPack: https://html-agility-pack.net/
* HtmlAgilityPack.CssSelector: https://github.com/hcesar/HtmlAgilityPack.CssSelector
3 changes: 3 additions & 0 deletions createrelease.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ copy "OWML.Launcher\bin\Debug\OWML.Config.json" "Release\OWML.Config.json"
copy "OWML.Patcher\bin\Debug\dnpatch.dll" "Release\dnpatch.dll"
copy "OWML.Patcher\bin\Debug\dnlib.dll" "Release\dnlib.dll"
copy "OWML.Launcher\bin\Debug\System.Runtime.Serialization.dll" "Release\System.Runtime.Serialization.dll"
copy "OWML.Update\bin\Debug\OWML.Update.dll" "Release\OWML.Update.dll"
copy "OWML.Update\bin\Debug\HtmlAgilityPack.dll" "Release\HtmlAgilityPack.dll"
copy "OWML.Update\bin\Debug\HtmlAgilityPack.CssSelectors.dll" "Release\HtmlAgilityPack.CssSelectors.dll"

copy "OWML.Nuget\bin\Debug\NAudio-Unity.dll" "Release\NAudio-Unity.dll"
copy "OWML.Nuget\bin\Debug\OWML.Common.dll" "Release\OWML.Common.dll"
Expand Down

0 comments on commit 5b4cf65

Please sign in to comment.