Mods are now able to auto update
This commit is contained in:
parent
5e88b7e895
commit
84ee6ffad7
|
@ -3,6 +3,8 @@ using System.Reflection;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CodeViewModdingApi;
|
||||
using CodeHubAutoUpdater;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CodeViewAndExec
|
||||
{
|
||||
|
@ -55,7 +57,7 @@ namespace CodeViewAndExec
|
|||
Console.WriteLine("Stopped loading invalid dll: " + fileobj.Name);
|
||||
continue;
|
||||
}
|
||||
LoadedMod modinfo = new LoadedMod(c, this);
|
||||
LoadedMod modinfo = new LoadedMod(c, modpath, this);
|
||||
modlist.Add(modinfo);
|
||||
Console.WriteLine("Started mod: " + modinfo.ModName);
|
||||
}
|
||||
|
@ -101,18 +103,42 @@ namespace CodeViewAndExec
|
|||
{
|
||||
public string ModName = "";
|
||||
public string ModType = "";
|
||||
private readonly string ModPath = "";
|
||||
private dynamic Inst;
|
||||
public bool Loaded = false;
|
||||
public bool Unloaded = false;
|
||||
public ModdingApi Api = new ModdingApi();
|
||||
private ModLoader ModLoader;
|
||||
public LoadedMod(dynamic mod, ModLoader b)
|
||||
public LoadedMod(dynamic mod, string modpath, ModLoader b)
|
||||
{
|
||||
ModName = mod.ModName;
|
||||
ModType = mod.ModType;
|
||||
ModPath = modpath;
|
||||
Inst = mod;
|
||||
ModLoader = b;
|
||||
Api.AddScriptEvent += ScriptAdded;
|
||||
Api.SetAutoUpdateDetailsEvent += SetAutoUpdateDetails;
|
||||
}
|
||||
|
||||
private void SetAutoUpdateDetails(object sender, string user, string repo, string v)
|
||||
{
|
||||
PackageDetails pkg = new PackageDetails
|
||||
{
|
||||
ProjectDirectory = ModPath,
|
||||
AuthorName = user,
|
||||
RepoName = repo,
|
||||
CurrentVersion = v
|
||||
};
|
||||
if (pkg.CheckForUpdates())
|
||||
{
|
||||
Console.WriteLine("Downloading updates");
|
||||
pkg.Update();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No updates");
|
||||
}
|
||||
}
|
||||
|
||||
private void ScriptAdded(object sender, ScriptBlob s)
|
||||
|
|
|
@ -16,6 +16,6 @@ namespace CodeViewAndExec
|
|||
Application.Run(new Form1());
|
||||
}
|
||||
|
||||
public static string Version = "v1.0.4";
|
||||
public static string Version = "v1.0.5";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CodeHubAutoUpdater">
|
||||
<HintPath>..\..\CodeHubAutoUpdater\CodeHubAutoUpdater\bin\Release\CodeHubAutoUpdater.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
using System;
|
||||
using CodeHubAutoUpdater;
|
||||
using System;
|
||||
|
||||
namespace CodeViewModdingApi
|
||||
{
|
||||
public class ModdingApi
|
||||
{
|
||||
public ModdingApi()
|
||||
{
|
||||
|
||||
}
|
||||
public ModdingApi() {}
|
||||
|
||||
public delegate void OnAddScriptEventHandler(object sender, ScriptBlob s);
|
||||
public event OnAddScriptEventHandler AddScriptEvent;
|
||||
public event EventHandler Load;
|
||||
public delegate void OnSetAutoUpdateDetailsEventHandler(object sender, string user, string repo, string v);
|
||||
public event OnSetAutoUpdateDetailsEventHandler SetAutoUpdateDetailsEvent;
|
||||
|
||||
public virtual void OnLoad(EventArgs e)
|
||||
{
|
||||
Load?.Invoke(this, e);
|
||||
}
|
||||
public virtual void OnLoad(EventArgs e) => Load?.Invoke(this, e);
|
||||
|
||||
public void AddScript(ScriptBlob s)
|
||||
{
|
||||
AddScriptEvent?.Invoke(this, s);
|
||||
}
|
||||
public void AddScript(ScriptBlob s) => AddScriptEvent?.Invoke(this, s);
|
||||
|
||||
public void SetAutoUpdateDetails(string user, string repo, string version) => SetAutoUpdateDetailsEvent?.Invoke(this, user, repo, version);
|
||||
}
|
||||
|
||||
public class ScriptBlob
|
||||
|
@ -38,9 +34,6 @@ namespace CodeViewModdingApi
|
|||
CommandExecutor = Command;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ScriptName;
|
||||
}
|
||||
public override string ToString() => ScriptName;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue