Skip to content

Commit

Permalink
Added Cactbot update button
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Dec 15, 2021
1 parent 9515dfb commit 6c3188d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 9 deletions.
12 changes: 11 additions & 1 deletion OverlayPlugin.Core/Controls/GeneralConfigTab.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions OverlayPlugin.Core/Controls/GeneralConfigTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using RainbowMage.HtmlRenderer;
using Advanced_Combat_Tracker;
using System.Threading;
using System.Reflection;
using System.IO;

namespace RainbowMage.OverlayPlugin
{
Expand Down Expand Up @@ -123,5 +125,46 @@ private void newUserWelcome_Click(object sender, EventArgs e)
{

}

private void btnCactbotUpdate_Click(object sender, EventArgs e)
{
try
{
var asm = Assembly.Load("CactbotEventSource");
var checkerType = asm.GetType("Cactbot.VersionChecker");
var loggerType = asm.GetType("Cactbot.ILogger");
var configType = asm.GetType("Cactbot.CactbotEventSourceConfig");

var esList = container.Resolve<Registry>().EventSources;
IEventSource cactbotEs = null;

foreach (var es in esList)
{
if (es.Name == "Cactbot Config" || es.Name == "Cactbot")
{
cactbotEs = es;
break;
}
}

if (cactbotEs == null)
{
MessageBox.Show("Cactbot is loaded but it never registered with OverlayPlugin!", "Error");
return;
}

var cactbotConfig = cactbotEs.GetType().GetProperty("Config").GetValue(cactbotEs);
configType.GetField("LastUpdateCheck").SetValue(cactbotConfig, DateTime.MinValue);

var checker = checkerType.GetConstructor(new Type[] { loggerType }).Invoke(new object[] { cactbotEs });
checkerType.GetMethod("DoUpdateCheck", new Type[] {configType}).Invoke(checker, new object[] { cactbotConfig });
} catch(FileNotFoundException)
{
MessageBox.Show("Could not find Cactbot!", "Error");
} catch(Exception ex)
{
MessageBox.Show("Failed: " + ex.ToString(), "Error");
}
}
}
}
40 changes: 32 additions & 8 deletions OverlayPlugin.Core/Controls/GeneralConfigTab.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbErrorReports.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="cbUpdateCheck.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -178,7 +178,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbUpdateCheck.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="btnUpdateCheck.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
Expand All @@ -205,7 +205,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnUpdateCheck.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="cbHideOverlaysWhenNotActive.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -235,7 +235,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbHideOverlaysWhenNotActive.ZOrder" xml:space="preserve">
<value>8</value>
<value>9</value>
</data>
<data name="cbHideOverlaysDuringCutscene.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -265,7 +265,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbHideOverlaysDuringCutscene.ZOrder" xml:space="preserve">
<value>7</value>
<value>8</value>
</data>
<data name="lblGithub.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -292,7 +292,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblGithub.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="lnkGithubRepo.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -319,7 +319,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lnkGithubRepo.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="lblNewUserWelcome.Location" type="System.Drawing.Point, System.Drawing">
<value>17, 243</value>
Expand All @@ -346,7 +346,7 @@ Please try using the presets instead of manually setting the URL since this can
<value>$this</value>
</data>
<data name="&gt;&gt;lblNewUserWelcome.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="lblReadMe.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -376,6 +376,30 @@ Please try using the presets instead of manually setting the URL since this can
<value>$this</value>
</data>
<data name="&gt;&gt;lblReadMe.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="btnCactbotUpdate.Location" type="System.Drawing.Point, System.Drawing">
<value>210, 122</value>
</data>
<data name="btnCactbotUpdate.Size" type="System.Drawing.Size, System.Drawing">
<value>185, 23</value>
</data>
<data name="btnCactbotUpdate.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="btnCactbotUpdate.Text" xml:space="preserve">
<value>Check For Cactbot Updates</value>
</data>
<data name="&gt;&gt;btnCactbotUpdate.Name" xml:space="preserve">
<value>btnCactbotUpdate</value>
</data>
<data name="&gt;&gt;btnCactbotUpdate.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnCactbotUpdate.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnCactbotUpdate.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand Down

0 comments on commit 6c3188d

Please sign in to comment.