Skip to content

Commit

Permalink
Merge pull request #24 from anon5r/software-update
Browse files Browse the repository at this point in the history
Software update for #23
  • Loading branch information
anon5r authored Feb 22, 2022
2 parents ebe416c + cc1964a commit 408a5eb
Show file tree
Hide file tree
Showing 19 changed files with 582 additions and 14 deletions.
6 changes: 6 additions & 0 deletions KsGameLauncher/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
<setting name="Language" serializeAs="String">
<value>system</value>
</setting>
<setting name="UpdateCheckInterval" serializeAs="String">
<value>0</value>
</setting>
<setting name="UpdateCheckIntervalUnit" serializeAs="String">
<value>0</value>
</setting>
</KsGameLauncher.Properties.Settings>
<KonaStaGameLauncher.Properties.Settings>
<setting name="appInfoURL" serializeAs="String">
Expand Down
53 changes: 47 additions & 6 deletions KsGameLauncher/Forms/OptionsForm.Designer.cs

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

77 changes: 72 additions & 5 deletions KsGameLauncher/Forms/OptionsForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using KsGameLauncher.Utils;
using KsGameLauncher.Structures;
using System;
using System.Diagnostics;
using System.Windows.Forms;
Expand All @@ -24,15 +25,15 @@ public OptionsForm()
private void OptionsForm_Load(object sender, EventArgs e)
{
Icon = Properties.Resources.appIcon;
string[] items = {
string[] menuSizes = {
// Normal
Properties.Strings.ContextMenuSize_Text_Normal,
// Large
Properties.Strings.ContextMenuSize_Text_Large
};
comboBox_ContextMenuSize.Items.Clear();
comboBox_ContextMenuSize.Items.AddRange(items);
// Language
comboBox_ContextMenuSize.Items.AddRange(menuSizes);
// Languages
Language currentLang = (string.IsNullOrEmpty(Properties.Settings.Default.Language)
|| Properties.Settings.Default.Language == Properties.Resources.DefaultLanguage)
? Languages.GetLanguage(Properties.Resources.DefaultLanguage)
Expand All @@ -47,13 +48,48 @@ private void OptionsForm_Load(object sender, EventArgs e)
Debug.WriteLine(String.Format("[OPTION:Load] Language comboBox selectedIndex: {0}", comboBox_Languages.Items.IndexOf(currentLang)));
#endif

// Check update
int[] updateIntervalsDays = { 1, 3, 7, 14 }; // None, everyday, 3 days, 7 days, 2 weeks
comboBox_CheckInterval.Items.Clear();
comboBox_CheckInterval.Items.Add(new CheckInterval(0, CheckInterval.UnitType.None));
for (int i = 0; i < updateIntervalsDays.Length; i++)
{
CheckInterval check = new CheckInterval(updateIntervalsDays[i], CheckInterval.UnitType.Days);
comboBox_CheckInterval.Items.Add(check);
}
#if DEBUG
for (int i = 0; i < updateIntervalsDays.Length; i++)
{
CheckInterval check = new CheckInterval(updateIntervalsDays[i], CheckInterval.UnitType.Minutes);
comboBox_CheckInterval.Items.Add(check);
}
#endif



// Default values
checkBox_UseProxy.Checked = Properties.Settings.Default.UseProxy;
checkBox_Notification.Checked = Properties.Settings.Default.EnableNotification;
checkBox_ConfirmExit.Checked = Properties.Settings.Default.ShowConfirmExit;
checkBox_DisplayInstalledGamesOnly.Checked = Properties.Settings.Default.ShowOnlyInstalledGames;
checkBox_RegisterCustomURI.Checked = Properties.Settings.Default.RegisterCustomURI;
comboBox_ContextMenuSize.SelectedIndex = Properties.Settings.Default.ContextMenuSize;
int intervalSelectedIndex = 0;
if (Properties.Settings.Default.UpdateCheckInterval > 0)
{
int settingInterval = Properties.Settings.Default.UpdateCheckInterval;
CheckInterval.UnitType settingUnit = Properties.Settings.Default.UpdateCheckIntervalUnit;
for (int i = 0; i < comboBox_CheckInterval.Items.Count; i++)
{
CheckInterval intervalItem = (CheckInterval)comboBox_CheckInterval.Items[i];
if (intervalItem.Interval == settingInterval && intervalItem.Unit == settingUnit)
{
intervalSelectedIndex = i;
break;
}
}
}
comboBox_CheckInterval.SelectedIndex = intervalSelectedIndex;

// String
Text = Properties.Strings.OptionsWindowTitle;
Expand All @@ -66,6 +102,8 @@ private void OptionsForm_Load(object sender, EventArgs e)
linkLabel_OpenProxySettings.Text = Properties.Strings.OptionsProxySettingsLink;
button_Save.Text = Properties.Strings.ButtonSave;
button_SyncAppInfo.Text = Properties.Strings.SynchWithServerButton;
label_CheckAutoUpdateInterval.Text = Properties.Strings.CheckAutoUpdate;
button_ManualCheck.Text = Properties.Strings.ManualUpdateCheckButton;

checkBox_RegisterCustomURI.Text = (checkBox_RegisterCustomURI.Checked)
? Properties.Strings.ShortcutLaunchCheckboxDisable
Expand Down Expand Up @@ -104,17 +142,38 @@ private void Button_Save_Click(object sender, EventArgs e)
restartApp = true;
}

// AutoUpdate settings
CheckInterval selectedInterval = (CheckInterval)comboBox_CheckInterval.Items[comboBox_CheckInterval.SelectedIndex];
#if DEBUG
Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval before changes: {0}", Properties.Settings.Default.UpdateCheckInterval));
Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval before unit: {0}", Properties.Settings.Default.UpdateCheckIntervalUnit));
Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval selected: {0}", selectedInterval.Interval));
Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval unit: {0}", selectedInterval.Unit));
#endif
// need to update thread interval
bool reloadAutoUpdate = false;
if (Properties.Settings.Default.UpdateCheckInterval != selectedInterval.Interval
|| Properties.Settings.Default.UpdateCheckIntervalUnit != selectedInterval.Unit)
reloadAutoUpdate = true;


// Save settings
Properties.Settings.Default.UseProxy = checkBox_UseProxy.Checked;
Properties.Settings.Default.EnableNotification = checkBox_Notification.Checked;
Properties.Settings.Default.ShowConfirmExit = checkBox_ConfirmExit.Checked;
Properties.Settings.Default.ShowOnlyInstalledGames = checkBox_DisplayInstalledGamesOnly.Checked;
Properties.Settings.Default.ContextMenuSize = comboBox_ContextMenuSize.SelectedIndex;
Properties.Settings.Default.Language = ((Language)comboBox_Languages.Items[comboBox_Languages.SelectedIndex]).ID;
Properties.Settings.Default.Language = selectedLang.ID;
Properties.Settings.Default.UpdateCheckInterval = selectedInterval.Interval;
Properties.Settings.Default.UpdateCheckIntervalUnit = selectedInterval.Unit;
Properties.Settings.Default.Save();

if (needsUpdateGames)
Program.mainContext.LoadGamesMenu(); // Re-load menu
Program.mainContext.LoadGamesMenu(); // Reload menu

if (reloadAutoUpdate)
UpdateChecker.UpdateInterval(selectedInterval.Interval, selectedInterval.Unit);


if (restartApp)
{
Expand Down Expand Up @@ -203,5 +262,13 @@ private void CheckBox_RegisterCustomURI_Click(object sender, EventArgs e)
checkBox_RegisterCustomURI.Checked = true;
}
}

private void Button_ManualCheck_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(Properties.Strings.ConfirmToExecuteCheckManualUpdate,
Properties.Strings.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
if (result == DialogResult.Yes)
AppUtil.CheckUpdate();
}
}
}
11 changes: 10 additions & 1 deletion KsGameLauncher/KsGameLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
<Reference Include="AngleSharp, Version=0.16.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
<HintPath>..\packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll</HintPath>
</Reference>
<Reference Include="AutoUpdater.NET, Version=1.7.0.0, Culture=neutral, PublicKeyToken=501435c91b35f4bc, processorArchitecture=MSIL">
<HintPath>..\packages\Autoupdater.NET.Official.1.7.0\lib\net45\AutoUpdater.NET.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="PresentationCore" />
Expand All @@ -118,7 +121,9 @@
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
Expand All @@ -128,6 +133,7 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
Expand All @@ -145,6 +151,7 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -228,9 +235,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="Structures\CheckInterval.cs" />
<Compile Include="Structures\InternetShortcut.cs" />
<Compile Include="Exceptions\InvalidFormatException.cs" />
<Compile Include="Utils\AppUtil.cs" />
<Compile Include="Utils\UpdateChecker.cs" />
<Compile Include="Utils\Common.cs" />
<Compile Include="Utils\Crypt.cs" />
<Compile Include="Utils\GameRegistry.cs" />
Expand Down Expand Up @@ -343,6 +352,6 @@ set outpath=publish
set ILMERGE="$(SolutionDir)\packages\ILMerge.3.0.40\tools\net452\ILMerge.exe"
if not exist %25outpath%25 mkdir %25outpath%25

%25ILMERGE%25 /wildcards /ndebug:fase /out:%25outpath%25\%25output%25 $(TargetFileName) *.dll</PostBuildEvent>
%25ILMERGE%25 /wildcards /ndebug:fase /allowDup /out:%25outpath%25\%25output%25 $(TargetFileName) *.dll</PostBuildEvent>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions KsGameLauncher/MainContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public MainContext(MainForm _form) : base()
mainForm = _form;
InitializeComponent();
CreateNotificationIcon();


if (Properties.Settings.Default.UpdateCheckInterval > 0)
Utils.UpdateChecker.CreateUpdateCheker(Properties.Settings.Default.UpdateCheckInterval,
Properties.Settings.Default.UpdateCheckIntervalUnit);
else
Utils.AppUtil.CheckUpdate();
}

~MainContext()
Expand Down
4 changes: 2 additions & 2 deletions KsGameLauncher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.1")]
[assembly: AssemblyFileVersion("1.0.1.1")]
[assembly: AssemblyVersion("1.0.1.2")]
[assembly: AssemblyFileVersion("1.0.1.2")]
Loading

0 comments on commit 408a5eb

Please sign in to comment.