Skip to content

Commit

Permalink
owml-config-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingalek committed Jan 7, 2020
1 parent 5b4cf65 commit e1bd5b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions OWML.Common/IModHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public interface IModHelper
IModMenus Menus { get; }
IModManifest Manifest { get; }
IModConfig Config { get; }
IOwmlConfig OwmlConfig { get; }
}
}
6 changes: 3 additions & 3 deletions OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OWML.Launcher
{
public class App
{
private const string Version = "0.3.17";
private const string Version = "0.3.18";

private readonly IOwmlConfig _owmlConfig;
private readonly IModConsole _writer;
Expand All @@ -21,8 +21,8 @@ public class App
private readonly ModPatcher _patcher;
private readonly ModUpdate _update;

public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder, OutputListener listener,
PathFinder pathFinder, ModPatcher patcher, ModUpdate update)
public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder,
OutputListener listener, PathFinder pathFinder, ModPatcher patcher, ModUpdate update)
{
_owmlConfig = owmlConfig;
_writer = writer;
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.17",
"owmlVersion": "0.3.18",
"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.17",
"owmlVersion": "0.3.18",
"enabled": false
}
19 changes: 12 additions & 7 deletions OWML.Update/ModUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace OWML.Update
{
public class ModUpdate
{
private const string BaseUrl = "https://github.com";
public string ReleasesUrl = BaseUrl + "/amazingalek/owml/releases";
public string ReleasesUrl = "https://github.com/amazingalek/owml/releases";

private readonly IModConsole _writer;

Expand All @@ -19,25 +18,31 @@ public ModUpdate(IModConsole writer)
public string GetLatestVersion()
{
var web = new HtmlWeb();

string versionNumber;
HtmlNode releaseLink;

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

var versionNumber = releaseLink?.InnerText;

if (string.IsNullOrEmpty(versionNumber))
{
_writer.WriteLine("Error: version number is null or empty");
return null;
}

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

return versionNumber;
Expand Down

0 comments on commit e1bd5b1

Please sign in to comment.