Skip to content

Commit

Permalink
Create experimental YAMDCC updater
Browse files Browse the repository at this point in the history
- Add auto-update prompt on first YAMDCC config editor launch

- Add "Check for updates" button to config editor

This updater is still pretty experimental. I wouldn't store anything important (including configs) in the same directory as where YAMDCC is installed.
  • Loading branch information
Sparronator9999 committed Jan 8, 2025
1 parent 3473aa1 commit d5c566e
Show file tree
Hide file tree
Showing 20 changed files with 1,539 additions and 12 deletions.
7 changes: 7 additions & 0 deletions YAMDCC.Common/CommonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public class CommonConfig
[XmlElement]
public LogLevel LogLevel { get; set; } = LogLevel.Debug;

/// <summary>
/// <c>true</c> if we've already asked to enable auto-updating,
/// otherwise <c>false</c>.
/// </summary>
[XmlElement]
public bool AutoUpdateAsked { get; set; }

/// <summary>
/// Loads the global app config XML and returns a
/// <see cref="CommonConfig"/> object.
Expand Down
30 changes: 20 additions & 10 deletions YAMDCC.ConfigEditor/MainWindow.Designer.cs

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

32 changes: 32 additions & 0 deletions YAMDCC.ConfigEditor/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ public MainWindow()
break;
}

if (!GlobalConfig.AutoUpdateAsked)
{
if (Utils.ShowInfo(
"Would you like YAMDCC to check for updates automatically?\n\n" +
"You may change this setting by launching `Updater.exe` and " +
"clicking `Update options` > `Check for updates automatically`.",
"Check for updates?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
Process.Start("Updater", "--setautoupdate true");
}
catch (FileNotFoundException)
{
Utils.ShowError("Updater.exe not found!");
}
}
GlobalConfig.AutoUpdateAsked = true;
}

DisableAll();
}

Expand Down Expand Up @@ -1298,6 +1318,18 @@ private static NumericUpDown FanCurveNUD(int tag, float scale)
};
}

private void tsiCheckUpdate_Click(object sender, EventArgs e)
{
try
{
Process.Start("Updater", "--checkupdate");
}
catch (FileNotFoundException)
{
Utils.ShowError("Updater.exe not found!");
}
}

private void DisableAll()
{
btnProfAdd.Enabled = false;
Expand Down
3 changes: 3 additions & 0 deletions YAMDCC.ConfigEditor/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<metadata name="tsiLogLevel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tsiCheckUpdate.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tcMain.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
Expand Down
1 change: 1 addition & 0 deletions YAMDCC.ConfigEditor/YAMDCC.ConfigEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<ProjectReference Include="..\YAMDCC.ECInspector\YAMDCC.ECInspector.csproj" />
<ProjectReference Include="..\YAMDCC.Service\YAMDCC.Service.csproj" />
<ProjectReference Include="..\YAMDCC.IPC\YAMDCC.IPC.csproj" />
<ProjectReference Include="..\YAMDCC.Updater\YAMDCC.Updater.csproj" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
Expand Down
31 changes: 29 additions & 2 deletions YAMDCC.ConfigEditor/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"version": 1,
"dependencies": {
".NETFramework,Version=v4.8": {
"Markdig": {
"type": "Transitive",
"resolved": "0.39.1",
"contentHash": "QrH/Aq9A5P7fIdy4tEBQGqVvrJoEew9+jL0k2WlrmgD0yxXP0UUtdkhJWgpVgwT18R0ubpt9cyF+LQXbTUSOrg==",
"dependencies": {
"System.Memory": "4.5.5"
}
},
"MessagePack": {
"type": "Transitive",
"resolved": "3.1.1",
Expand Down Expand Up @@ -44,6 +52,11 @@
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"Octokit": {
"type": "Transitive",
"resolved": "13.0.1",
"contentHash": "tjXTa2FXzbd3n17VWpi8UXe05EIJqHcWJW8C2kukftIve00duWiZL8x4i1vlZQ0zQ4RbRANbRc7J5K7Co/1spQ=="
},
"System.Buffers": {
"type": "Transitive",
"resolved": "4.5.1",
Expand Down Expand Up @@ -86,11 +99,25 @@
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
}
},
"TaskScheduler": {
"type": "Transitive",
"resolved": "2.11.0",
"contentHash": "p9wH58XSNIyUtO7PIFAEldaKUzpYmlj+YWAfnUqBKnGxIZRY51I9BrsBGJijUVwlxrgmLLPUigRIv2ZTD4uPJA=="
},
"ec-inspect": {
"type": "Project",
"dependencies": {
"YAMDCC.Common": "[1.0.0-dev, )",
"YAMDCC.IPC": "[2.1.2-release, )"
"YAMDCC.IPC": "[2.1.3-release, )"
}
},
"Updater": {
"type": "Project",
"dependencies": {
"Markdig": "[0.39.1, )",
"Octokit": "[13.0.1, )",
"TaskScheduler": "[2.11.0, )",
"YAMDCC.Common": "[1.0.0-dev, )"
}
},
"yamdcc.common": {
Expand Down Expand Up @@ -123,7 +150,7 @@
"YAMDCC.Common": "[1.0.0-dev, )",
"YAMDCC.Config": "[1.0.0-dev, )",
"YAMDCC.ECAccess": "[1.0.0-dev, )",
"YAMDCC.IPC": "[2.1.2-release, )",
"YAMDCC.IPC": "[2.1.3-release, )",
"YAMDCC.Logs": "[1.0.0-dev, )"
}
}
Expand Down
10 changes: 10 additions & 0 deletions YAMDCC.Updater/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2"/>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true"/>
</System.Windows.Forms.ApplicationConfigurationSection>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
Loading

0 comments on commit d5c566e

Please sign in to comment.