From a4af7ba7244c3274eb7922be1d1fc93f2a9622d6 Mon Sep 17 00:00:00 2001 From: Puk06 <86549420+puk06@users.noreply.github.com> Date: Thu, 8 Aug 2024 02:36:25 +0900 Subject: [PATCH] =?UTF-8?q?Updater=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 2 +- Classes/Helper.cs | 38 +++++ Forms/Main.Designer.cs | 153 ++++++++++++++---- Forms/Main.cs | 56 +++++++ Forms/Main.resx | 3 + osu-launcher.Updater/Classes/Updater.cs | 104 ++++++++++++ osu-launcher.Updater/Program.cs | 92 +++++++++++ .../osu-launcher.Updater.csproj | 15 ++ osu-launcher.csproj | 4 + osu-launcher.sln | 6 + packages.config | 1 + 11 files changed, 444 insertions(+), 30 deletions(-) create mode 100644 Classes/Helper.cs create mode 100644 osu-launcher.Updater/Classes/Updater.cs create mode 100644 osu-launcher.Updater/Program.cs create mode 100644 osu-launcher.Updater/osu-launcher.Updater.csproj diff --git a/App.config b/App.config index ea9026f..1f31c0e 100644 --- a/App.config +++ b/App.config @@ -5,7 +5,7 @@ - + diff --git a/Classes/Helper.cs b/Classes/Helper.cs new file mode 100644 index 0000000..f48290e --- /dev/null +++ b/Classes/Helper.cs @@ -0,0 +1,38 @@ +using System; +using System.Threading.Tasks; +using Octokit; + +namespace osu_launcher.Classes +{ + internal class Helper + { + public static async Task GetVersion(string currentVersion) + { + try + { + var releaseType = currentVersion.Split('-')[1]; + var githubClient = new GitHubClient(new ProductHeaderValue("osu-Launcher")); + var tags = await githubClient.Repository.GetAllTags("puk06", "osu-Launcher"); + string latestVersion = currentVersion; + foreach (var tag in tags) + { + if (releaseType == "Release") + { + if (tag.Name.Split('-')[1] != "Release") continue; + latestVersion = tag.Name; + break; + } + + latestVersion = tag.Name; + break; + } + + return latestVersion; + } + catch + { + throw new Exception("アップデートの取得に失敗しました"); + } + } + } +} diff --git a/Forms/Main.Designer.cs b/Forms/Main.Designer.cs index f1b809d..07adfea 100644 --- a/Forms/Main.Designer.cs +++ b/Forms/Main.Designer.cs @@ -30,12 +30,20 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); this.LAUNCH_BUTTON = new System.Windows.Forms.Button(); this.MainTab = new System.Windows.Forms.TabControl(); this.TopTab = new System.Windows.Forms.TabPage(); this.SoftwareTab = new System.Windows.Forms.TabPage(); this.SettingsTab = new System.Windows.Forms.TabPage(); + this.LATEST_VERSION_TEXT = new System.Windows.Forms.Label(); + this.CURRENT_VERSION_TEXT = new System.Windows.Forms.Label(); + this.LATEST_VERSION_LABEL = new System.Windows.Forms.Label(); + this.UPDATE_BUTTON = new System.Windows.Forms.Button(); + this.label14 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.CURRENT_VERSION_LABEL = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.PASSWORDAUTOCOPY_CHECKBOX = new System.Windows.Forms.CheckBox(); this.label12 = new System.Windows.Forms.Label(); @@ -87,6 +95,7 @@ private void InitializeComponent() this.PROFILE_LABEL = new System.Windows.Forms.Label(); this.PROFILE_BUTTON = new System.Windows.Forms.Button(); this.SERVER_BUTTON = new System.Windows.Forms.Button(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.MainTab.SuspendLayout(); this.SettingsTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.AUDIO_BAR)).BeginInit(); @@ -96,7 +105,7 @@ private void InitializeComponent() // // LAUNCH_BUTTON // - this.LAUNCH_BUTTON.Font = new System.Drawing.Font(GuiFont, 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.LAUNCH_BUTTON.Font = new System.Drawing.Font("Quicksand Light", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.LAUNCH_BUTTON.Location = new System.Drawing.Point(281, 418); this.LAUNCH_BUTTON.Name = "LAUNCH_BUTTON"; this.LAUNCH_BUTTON.Size = new System.Drawing.Size(269, 69); @@ -110,7 +119,7 @@ private void InitializeComponent() this.MainTab.Controls.Add(this.TopTab); this.MainTab.Controls.Add(this.SoftwareTab); this.MainTab.Controls.Add(this.SettingsTab); - this.MainTab.Font = new System.Drawing.Font(GuiFont, 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MainTab.Font = new System.Drawing.Font("Quicksand Light", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.MainTab.Location = new System.Drawing.Point(12, 12); this.MainTab.Name = "MainTab"; this.MainTab.SelectedIndex = 0; @@ -119,7 +128,7 @@ private void InitializeComponent() // // TopTab // - this.TopTab.Font = new System.Drawing.Font(GuiFont, 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.TopTab.Font = new System.Drawing.Font("Quicksand Light", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TopTab.Location = new System.Drawing.Point(4, 40); this.TopTab.Name = "TopTab"; this.TopTab.Padding = new System.Windows.Forms.Padding(3); @@ -141,6 +150,13 @@ private void InitializeComponent() // SettingsTab // this.SettingsTab.AutoScroll = true; + this.SettingsTab.Controls.Add(this.LATEST_VERSION_TEXT); + this.SettingsTab.Controls.Add(this.CURRENT_VERSION_TEXT); + this.SettingsTab.Controls.Add(this.LATEST_VERSION_LABEL); + this.SettingsTab.Controls.Add(this.UPDATE_BUTTON); + this.SettingsTab.Controls.Add(this.label14); + this.SettingsTab.Controls.Add(this.label15); + this.SettingsTab.Controls.Add(this.CURRENT_VERSION_LABEL); this.SettingsTab.Controls.Add(this.label3); this.SettingsTab.Controls.Add(this.PASSWORDAUTOCOPY_CHECKBOX); this.SettingsTab.Controls.Add(this.label12); @@ -195,10 +211,76 @@ private void InitializeComponent() this.SettingsTab.TabIndex = 1; this.SettingsTab.Text = "Settings"; // + // LATEST_VERSION_TEXT + // + this.LATEST_VERSION_TEXT.AutoSize = true; + this.LATEST_VERSION_TEXT.Location = new System.Drawing.Point(179, 1014); + this.LATEST_VERSION_TEXT.Name = "LATEST_VERSION_TEXT"; + this.LATEST_VERSION_TEXT.Size = new System.Drawing.Size(53, 33); + this.LATEST_VERSION_TEXT.TabIndex = 88; + this.LATEST_VERSION_TEXT.Text = "Null"; + // + // CURRENT_VERSION_TEXT + // + this.CURRENT_VERSION_TEXT.AutoSize = true; + this.CURRENT_VERSION_TEXT.Location = new System.Drawing.Point(194, 981); + this.CURRENT_VERSION_TEXT.Name = "CURRENT_VERSION_TEXT"; + this.CURRENT_VERSION_TEXT.Size = new System.Drawing.Size(53, 33); + this.CURRENT_VERSION_TEXT.TabIndex = 87; + this.CURRENT_VERSION_TEXT.Text = "Null"; + // + // LATEST_VERSION_LABEL + // + this.LATEST_VERSION_LABEL.AutoSize = true; + this.LATEST_VERSION_LABEL.Location = new System.Drawing.Point(23, 1014); + this.LATEST_VERSION_LABEL.Name = "LATEST_VERSION_LABEL"; + this.LATEST_VERSION_LABEL.Size = new System.Drawing.Size(159, 33); + this.LATEST_VERSION_LABEL.TabIndex = 86; + this.LATEST_VERSION_LABEL.Text = "Latest Version:"; + // + // UPDATE_BUTTON + // + this.UPDATE_BUTTON.Enabled = false; + this.UPDATE_BUTTON.Font = new System.Drawing.Font("Quicksand Light", 12F); + this.UPDATE_BUTTON.Location = new System.Drawing.Point(623, 997); + this.UPDATE_BUTTON.Name = "UPDATE_BUTTON"; + this.UPDATE_BUTTON.Size = new System.Drawing.Size(138, 38); + this.UPDATE_BUTTON.TabIndex = 85; + this.UPDATE_BUTTON.Text = "Update Now!"; + this.UPDATE_BUTTON.UseVisualStyleBackColor = true; + this.UPDATE_BUTTON.Click += new System.EventHandler(this.UPDATE_BUTTON_Click); + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label14.Location = new System.Drawing.Point(23, 931); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(95, 35); + this.label14.TabIndex = 84; + this.label14.Text = "Update"; + // + // label15 + // + this.label15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label15.Location = new System.Drawing.Point(29, 969); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(750, 1); + this.label15.TabIndex = 83; + // + // CURRENT_VERSION_LABEL + // + this.CURRENT_VERSION_LABEL.AutoSize = true; + this.CURRENT_VERSION_LABEL.Location = new System.Drawing.Point(23, 981); + this.CURRENT_VERSION_LABEL.Name = "CURRENT_VERSION_LABEL"; + this.CURRENT_VERSION_LABEL.Size = new System.Drawing.Size(174, 33); + this.CURRENT_VERSION_LABEL.TabIndex = 82; + this.CURRENT_VERSION_LABEL.Text = "Current Version:"; + // // label3 // this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.label3.Location = new System.Drawing.Point(29, 935); + this.label3.Location = new System.Drawing.Point(29, 1059); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(750, 1); this.label3.TabIndex = 81; @@ -216,7 +298,7 @@ private void InitializeComponent() // label12 // this.label12.AutoSize = true; - this.label12.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label12.Location = new System.Drawing.Point(23, 830); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(119, 35); @@ -244,7 +326,7 @@ private void InitializeComponent() // // OSUFOLDER_FOLDEROPEN_BUTTON // - this.OSUFOLDER_FOLDEROPEN_BUTTON.Font = new System.Drawing.Font(GuiFont, 11F); + this.OSUFOLDER_FOLDEROPEN_BUTTON.Font = new System.Drawing.Font("Quicksand Light", 11F); this.OSUFOLDER_FOLDEROPEN_BUTTON.Location = new System.Drawing.Point(696, 57); this.OSUFOLDER_FOLDEROPEN_BUTTON.Name = "OSUFOLDER_FOLDEROPEN_BUTTON"; this.OSUFOLDER_FOLDEROPEN_BUTTON.Size = new System.Drawing.Size(75, 32); @@ -257,7 +339,7 @@ private void InitializeComponent() // this.SKIN_COMBOBOX.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.SKIN_COMBOBOX.Enabled = false; - this.SKIN_COMBOBOX.Font = new System.Drawing.Font(GuiFont, 14F); + this.SKIN_COMBOBOX.Font = new System.Drawing.Font("Quicksand Light", 14F); this.SKIN_COMBOBOX.FormattingEnabled = true; this.SKIN_COMBOBOX.Location = new System.Drawing.Point(34, 781); this.SKIN_COMBOBOX.Name = "SKIN_COMBOBOX"; @@ -278,7 +360,7 @@ private void InitializeComponent() // label5 // this.label5.AutoSize = true; - this.label5.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(23, 725); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(60, 35); @@ -304,7 +386,7 @@ private void InitializeComponent() // // OFFSET_TEXTBOX // - this.OFFSET_TEXTBOX.Font = new System.Drawing.Font(TextFont, 14F); + this.OFFSET_TEXTBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 14F); this.OFFSET_TEXTBOX.Location = new System.Drawing.Point(135, 680); this.OFFSET_TEXTBOX.Name = "OFFSET_TEXTBOX"; this.OFFSET_TEXTBOX.Size = new System.Drawing.Size(115, 35); @@ -313,7 +395,7 @@ private void InitializeComponent() // OFFSET_LABEL // this.OFFSET_LABEL.AutoSize = true; - this.OFFSET_LABEL.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.OFFSET_LABEL.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.OFFSET_LABEL.Location = new System.Drawing.Point(23, 629); this.OFFSET_LABEL.Name = "OFFSET_LABEL"; this.OFFSET_LABEL.Size = new System.Drawing.Size(81, 35); @@ -331,7 +413,7 @@ private void InitializeComponent() // AUDIOVALUE_LABEL // this.AUDIOVALUE_LABEL.AutoSize = true; - this.AUDIOVALUE_LABEL.Font = new System.Drawing.Font(GuiFont, 13F); + this.AUDIOVALUE_LABEL.Font = new System.Drawing.Font("Quicksand Light", 13F); this.AUDIOVALUE_LABEL.Location = new System.Drawing.Point(457, 557); this.AUDIOVALUE_LABEL.Name = "AUDIOVALUE_LABEL"; this.AUDIOVALUE_LABEL.Size = new System.Drawing.Size(55, 26); @@ -341,7 +423,7 @@ private void InitializeComponent() // EFFECTVALUE_LABEL // this.EFFECTVALUE_LABEL.AutoSize = true; - this.EFFECTVALUE_LABEL.Font = new System.Drawing.Font(GuiFont, 13F); + this.EFFECTVALUE_LABEL.Font = new System.Drawing.Font("Quicksand Light", 13F); this.EFFECTVALUE_LABEL.Location = new System.Drawing.Point(456, 528); this.EFFECTVALUE_LABEL.Name = "EFFECTVALUE_LABEL"; this.EFFECTVALUE_LABEL.Size = new System.Drawing.Size(55, 26); @@ -351,7 +433,7 @@ private void InitializeComponent() // MASTERVALUE_LABEL // this.MASTERVALUE_LABEL.AutoSize = true; - this.MASTERVALUE_LABEL.Font = new System.Drawing.Font(GuiFont, 13F); + this.MASTERVALUE_LABEL.Font = new System.Drawing.Font("Quicksand Light", 13F); this.MASTERVALUE_LABEL.Location = new System.Drawing.Point(456, 498); this.MASTERVALUE_LABEL.Name = "MASTERVALUE_LABEL"; this.MASTERVALUE_LABEL.Size = new System.Drawing.Size(55, 26); @@ -427,7 +509,7 @@ private void InitializeComponent() // AUDIO_LABEL // this.AUDIO_LABEL.AutoSize = true; - this.AUDIO_LABEL.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.AUDIO_LABEL.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.AUDIO_LABEL.Location = new System.Drawing.Point(23, 438); this.AUDIO_LABEL.Name = "AUDIO_LABEL"; this.AUDIO_LABEL.Size = new System.Drawing.Size(78, 35); @@ -462,7 +544,7 @@ private void InitializeComponent() // METERSTYLE_COMBOBOX // this.METERSTYLE_COMBOBOX.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.METERSTYLE_COMBOBOX.Font = new System.Drawing.Font(GuiFont, 14F); + this.METERSTYLE_COMBOBOX.Font = new System.Drawing.Font("Quicksand Light", 14F); this.METERSTYLE_COMBOBOX.FormattingEnabled = true; this.METERSTYLE_COMBOBOX.Items.AddRange(new object[] { "Default", @@ -485,7 +567,7 @@ private void InitializeComponent() // // METERSCALE_TEXTBOX // - this.METERSCALE_TEXTBOX.Font = new System.Drawing.Font(TextFont, 14F); + this.METERSCALE_TEXTBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 14F); this.METERSCALE_TEXTBOX.Location = new System.Drawing.Point(109, 389); this.METERSCALE_TEXTBOX.Name = "METERSCALE_TEXTBOX"; this.METERSCALE_TEXTBOX.Size = new System.Drawing.Size(115, 35); @@ -494,7 +576,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(23, 338); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(144, 35); @@ -511,7 +593,7 @@ private void InitializeComponent() // // SONGSFOLDER_DELETE // - this.SONGSFOLDER_DELETE.Font = new System.Drawing.Font(GuiFont, 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SONGSFOLDER_DELETE.Font = new System.Drawing.Font("Quicksand Light", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.SONGSFOLDER_DELETE.Location = new System.Drawing.Point(696, 154); this.SONGSFOLDER_DELETE.Name = "SONGSFOLDER_DELETE"; this.SONGSFOLDER_DELETE.Size = new System.Drawing.Size(85, 33); @@ -541,7 +623,7 @@ private void InitializeComponent() // // WIDTH_TEXTBOX // - this.WIDTH_TEXTBOX.Font = new System.Drawing.Font(TextFont, 14F); + this.WIDTH_TEXTBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 14F); this.WIDTH_TEXTBOX.Location = new System.Drawing.Point(107, 257); this.WIDTH_TEXTBOX.Name = "WIDTH_TEXTBOX"; this.WIDTH_TEXTBOX.Size = new System.Drawing.Size(115, 35); @@ -566,7 +648,7 @@ private void InitializeComponent() // // HEIGHT_TEXTBOX // - this.HEIGHT_TEXTBOX.Font = new System.Drawing.Font(TextFont, 14F); + this.HEIGHT_TEXTBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 14F); this.HEIGHT_TEXTBOX.Location = new System.Drawing.Point(335, 257); this.HEIGHT_TEXTBOX.Name = "HEIGHT_TEXTBOX"; this.HEIGHT_TEXTBOX.Size = new System.Drawing.Size(115, 35); @@ -574,7 +656,7 @@ private void InitializeComponent() // // OSUFOLDER_TEXTBOX // - this.OSUFOLDER_TEXTBOX.Font = new System.Drawing.Font(TextFont, 15.75F); + this.OSUFOLDER_TEXTBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 15.75F); this.OSUFOLDER_TEXTBOX.Location = new System.Drawing.Point(93, 52); this.OSUFOLDER_TEXTBOX.Name = "OSUFOLDER_TEXTBOX"; this.OSUFOLDER_TEXTBOX.Size = new System.Drawing.Size(597, 38); @@ -582,7 +664,7 @@ private void InitializeComponent() // // SONGSFOLDER_COMBOBOX // - this.SONGSFOLDER_COMBOBOX.Font = new System.Drawing.Font(TextFont, 15.75F); + this.SONGSFOLDER_COMBOBOX.Font = new System.Drawing.Font("Noto Sans JP Light", 15.75F); this.SONGSFOLDER_COMBOBOX.FormattingEnabled = true; this.SONGSFOLDER_COMBOBOX.Location = new System.Drawing.Point(93, 151); this.SONGSFOLDER_COMBOBOX.Name = "SONGSFOLDER_COMBOBOX"; @@ -592,7 +674,7 @@ private void InitializeComponent() // RESOLUTION_LABEL // this.RESOLUTION_LABEL.AutoSize = true; - this.RESOLUTION_LABEL.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.RESOLUTION_LABEL.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.RESOLUTION_LABEL.Location = new System.Drawing.Point(23, 209); this.RESOLUTION_LABEL.Name = "RESOLUTION_LABEL"; this.RESOLUTION_LABEL.Size = new System.Drawing.Size(129, 35); @@ -610,7 +692,7 @@ private void InitializeComponent() // SONGSFOLDER_LABEL // this.SONGSFOLDER_LABEL.AutoSize = true; - this.SONGSFOLDER_LABEL.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SONGSFOLDER_LABEL.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.SONGSFOLDER_LABEL.Location = new System.Drawing.Point(23, 104); this.SONGSFOLDER_LABEL.Name = "SONGSFOLDER_LABEL"; this.SONGSFOLDER_LABEL.Size = new System.Drawing.Size(157, 35); @@ -638,7 +720,7 @@ private void InitializeComponent() // OSUFOLDER_LABEL // this.OSUFOLDER_LABEL.AutoSize = true; - this.OSUFOLDER_LABEL.Font = new System.Drawing.Font(GuiFont, 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.OSUFOLDER_LABEL.Font = new System.Drawing.Font("Quicksand Light", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.OSUFOLDER_LABEL.Location = new System.Drawing.Point(23, 3); this.OSUFOLDER_LABEL.Name = "OSUFOLDER_LABEL"; this.OSUFOLDER_LABEL.Size = new System.Drawing.Size(129, 35); @@ -649,7 +731,7 @@ private void InitializeComponent() // this.SERVER_LABEL.AutoSize = true; this.SERVER_LABEL.BackColor = System.Drawing.Color.Transparent; - this.SERVER_LABEL.Font = new System.Drawing.Font(GuiFont, 17F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SERVER_LABEL.Font = new System.Drawing.Font("Quicksand Light", 17F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.SERVER_LABEL.Location = new System.Drawing.Point(86, 408); this.SERVER_LABEL.Name = "SERVER_LABEL"; this.SERVER_LABEL.Size = new System.Drawing.Size(83, 34); @@ -660,7 +742,7 @@ private void InitializeComponent() // this.PROFILE_LABEL.AutoSize = true; this.PROFILE_LABEL.BackColor = System.Drawing.Color.Transparent; - this.PROFILE_LABEL.Font = new System.Drawing.Font(GuiFont, 17F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.PROFILE_LABEL.Font = new System.Drawing.Font("Quicksand Light", 17F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.PROFILE_LABEL.Location = new System.Drawing.Point(671, 405); this.PROFILE_LABEL.Name = "PROFILE_LABEL"; this.PROFILE_LABEL.Size = new System.Drawing.Size(80, 34); @@ -669,7 +751,7 @@ private void InitializeComponent() // // PROFILE_BUTTON // - this.PROFILE_BUTTON.Font = new System.Drawing.Font(TextFont, 15.75F); + this.PROFILE_BUTTON.Font = new System.Drawing.Font("Noto Sans JP Light", 15.75F); this.PROFILE_BUTTON.Location = new System.Drawing.Point(622, 442); this.PROFILE_BUTTON.Name = "PROFILE_BUTTON"; this.PROFILE_BUTTON.Size = new System.Drawing.Size(173, 38); @@ -680,7 +762,7 @@ private void InitializeComponent() // // SERVER_BUTTON // - this.SERVER_BUTTON.Font = new System.Drawing.Font(TextFont, 15.75F); + this.SERVER_BUTTON.Font = new System.Drawing.Font("Noto Sans JP Light", 15.75F); this.SERVER_BUTTON.Location = new System.Drawing.Point(43, 442); this.SERVER_BUTTON.Name = "SERVER_BUTTON"; this.SERVER_BUTTON.Size = new System.Drawing.Size(173, 38); @@ -689,6 +771,11 @@ private void InitializeComponent() this.SERVER_BUTTON.UseVisualStyleBackColor = true; this.SERVER_BUTTON.Click += new System.EventHandler(this.SERVER_BUTTON_Click); // + // contextMenuStrip1 + // + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); + // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -776,6 +863,14 @@ private void InitializeComponent() private Label label13; private Label label3; private Button SERVER_BUTTON; + private Label label14; + private Label label15; + private Label CURRENT_VERSION_LABEL; + private Button UPDATE_BUTTON; + private Label LATEST_VERSION_LABEL; + private Label LATEST_VERSION_TEXT; + private Label CURRENT_VERSION_TEXT; + private ContextMenuStrip contextMenuStrip1; } } diff --git a/Forms/Main.cs b/Forms/Main.cs index e73cdce..bdc1016 100644 --- a/Forms/Main.cs +++ b/Forms/Main.cs @@ -11,11 +11,14 @@ using Newtonsoft.Json.Linq; using osu_launcher.Classes; using Profile = osu_launcher.Classes.Profile; +using static osu_launcher.Classes.Helper; namespace osu_launcher.Forms { public partial class Main : Form { + public const string CurrentVersion = "v1.0.0-Release"; + // Data Values public JObject Data; @@ -60,6 +63,7 @@ public Main() Helper.ValidateRequiredFiles(); AddFontFile(); InitializeComponent(); + GithubUpdateChecker(); InitializeDefaults(); InitializeWebBrowser(); LoadConfigFile(); @@ -82,6 +86,8 @@ private void InitializeDefaults() MASTER_BAR.Value = 100; EFFECT_BAR.Value = 100; AUDIO_BAR.Value = 100; + + CURRENT_VERSION_TEXT.Text = CurrentVersion; } private void InitializeWebBrowser() @@ -852,5 +858,55 @@ private void OSUFOLDER_FOLDEROPEN_BUTTON_Click(object sender, EventArgs e) OSUFOLDER_TEXTBOX.Text = folderBrowserDialog.SelectedPath; } } + + public async void GithubUpdateChecker() + { + try + { + var latestRelease = await GetVersion(CurrentVersion); + LATEST_VERSION_TEXT.Text = latestRelease; + if (latestRelease == CurrentVersion) + { + UPDATE_BUTTON.Enabled = false; + LATEST_VERSION_TEXT.ForeColor = Color.Black; + return; + } + UPDATE_BUTTON.Enabled = true; + LATEST_VERSION_TEXT.ForeColor = Color.Green; + } + catch (Exception exception) + { + MessageBox.Show("アップデートチェック中にエラーが発生しました" + exception.Message, "エラー", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void UPDATE_BUTTON_Click(object sender, EventArgs e) + { + try + { + if (!File.Exists("./Updater/osu-launcher.Updater.exe")) + { + MessageBox.Show("アップデーターが見つかりませんでした。手動でダウンロードしてください。", "エラー", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + + string updaterPath = Path.GetFullPath("./Updater/osu-launcher.Updater.exe"); + ProcessStartInfo args = new ProcessStartInfo() + { + FileName = $"\"{updaterPath}\"", + Arguments = CurrentVersion, + UseShellExecute = true + }; + + Process.Start(args); + } + catch (Exception exception) + { + MessageBox.Show("アップデーターを起動できませんでした" + exception.Message, "エラー", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } } } diff --git a/Forms/Main.resx b/Forms/Main.resx index 7439565..92b63a5 100644 --- a/Forms/Main.resx +++ b/Forms/Main.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + diff --git a/osu-launcher.Updater/Classes/Updater.cs b/osu-launcher.Updater/Classes/Updater.cs new file mode 100644 index 0000000..ae5bf8e --- /dev/null +++ b/osu-launcher.Updater/Classes/Updater.cs @@ -0,0 +1,104 @@ +using System.IO.Compression; +using System.Net; +using System.Reflection; +using System.Text; + +namespace osu_launcher.Updater.Classes +{ + public class Updater + { + private readonly string _version; + + public Updater(string version) + { + _version = version; + } + + private const string Baseurl = "https://github.com/puk06/osu-Launcher/releases/download/"; + + public async Task Update() + { + var downloadUrl = $"{Baseurl}{_version}/osu-Launcher.zip"; + var tempPath = Path.GetTempPath(); + var tempFile = Path.Combine(tempPath, $"osu-Launcher.zip"); + var extractPath = Path.Combine(tempPath, $"osu-Launcher.Temp"); + + Console.WriteLine("ファイルのダウンロードを開始しています..."); + Console.WriteLine("ファイルのダウンロード中です...ソフトを終了しないでください!"); + + using var client = new WebClient(); + await client.DownloadFileTaskAsync(new Uri(downloadUrl), tempFile); + + Console.WriteLine("ダウンロードが完了しました!"); + Console.WriteLine("ファイルの展開中です..."); + + ZipFile.ExtractToDirectory(tempFile, extractPath, Encoding.UTF8, true); + File.Delete(tempFile); + + var folders = Directory.GetDirectories(extractPath); + folders = folders.Where(x => !x.Contains("Updater")).ToArray(); + var files = Directory.GetFiles(extractPath); + + var currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + if (currentPath == null) + { + Console.WriteLine("カレントフォルダの取得に失敗しました。"); + Thread.Sleep(3000); + return; + } + var softwarePath = Directory.GetParent(currentPath)?.FullName; + if (softwarePath == null) + { + Console.WriteLine("ソフトウェアのフォルダの取得に失敗しました。"); + Thread.Sleep(3000); + return; + } + + for (int i = 0; i < files.Length; i++) + { + var file = files[i]; + var fileName = Path.GetFileName(file); + var currentFile = Path.Combine(softwarePath, fileName); + Console.WriteLine($"ファイルのコピー中です... {i + 1}/{files.Length}: {fileName}"); + File.Copy(file, currentFile, true); + } + + for (int i = 0; i < folders.Length; i++) + { + var folder = folders[i]; + var folderName = Path.GetFileName(folder); + var currentFolder = Path.Combine(softwarePath, folderName); + if (!Directory.Exists(currentFolder)) Directory.CreateDirectory(currentFolder); + Console.WriteLine($"フォルダのコピー中です... {i + 1}/{folders.Length}: {folderName}"); + DirectoryCopy(folder, currentFolder, true); + } + + Directory.Delete(extractPath, true); + } + + private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs) + { + var dir = new DirectoryInfo(sourceDirName); + var dirs = dir.GetDirectories(); + + if (!dir.Exists) throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourceDirName); + if (!Directory.Exists(destDirName)) Directory.CreateDirectory(destDirName); + + + var files = dir.GetFiles(); + foreach (var file in files) + { + var tempPath = Path.Combine(destDirName, file.Name); + if (file.Name == "data.json") continue; + file.CopyTo(tempPath, true); + } + + if (!copySubDirs) return; + foreach (var subdir in dirs) + { + var tempPath = Path.Combine(destDirName, subdir.Name); + DirectoryCopy(subdir.FullName, tempPath, true); + } + } + } +} diff --git a/osu-launcher.Updater/Program.cs b/osu-launcher.Updater/Program.cs new file mode 100644 index 0000000..3237d2e --- /dev/null +++ b/osu-launcher.Updater/Program.cs @@ -0,0 +1,92 @@ +using System.Diagnostics; +using Octokit; + +namespace osu_launcher.Updater +{ + internal class Program + { + private static async Task Main(string[] args) + { + try + { + if (args.Length != 1) + { + Console.WriteLine("バージョン情報が取得できませんでした。ソフト内から実行するようにしてください!"); + Thread.Sleep(3000); + return; + } + + var currentVersion = args[0]; + + if (string.IsNullOrEmpty(currentVersion)) + { + Console.WriteLine("バージョン情報が取得できませんでした。ソフト内から実行するようにしてください!"); + Thread.Sleep(3000); + return; + } + + Console.WriteLine("アップデートを確認します。"); + + var latestVersion = await GithubUpdateChecker(currentVersion); + + if (latestVersion == currentVersion) + { + Console.WriteLine("最新バージョンです!ソフトを使ってくれてありがとうございます!"); + Thread.Sleep(3000); + return; + } + + Console.WriteLine($"最新バージョンが見つかりました({currentVersion} → {latestVersion})"); + Console.ReadLine(); + Console.WriteLine("osu-Launcher関係のソフトをすべて終了します。"); + + var processes = Process.GetProcessesByName("osu-launcher"); + foreach (var process in processes) + { + process.Kill(); + } + + Console.WriteLine("osu-Launcherを終了しました。アップデートを開始します。"); + var updater = new Classes.Updater(latestVersion); + + await updater.Update(); + + Console.WriteLine("アップデートが完了しました!ソフトを使ってくれてありがとうございます!"); + Thread.Sleep(3000); + } + catch (Exception e) + { + Console.WriteLine("アップデート中にエラーが発生しました: " + e.Message); + Thread.Sleep(3000); + } + } + + private static async Task GithubUpdateChecker(string currentVersion) + { + var latestRelease = await GetVersion(currentVersion); + return latestRelease == currentVersion ? currentVersion : latestRelease; + } + + private static async Task GetVersion(string currentVersion) + { + var releaseType = currentVersion.Split('-')[1]; + var githubClient = new GitHubClient(new ProductHeaderValue("osu-Launcher")); + var tags = await githubClient.Repository.GetAllTags("puk06", "osu-Launcher"); + string latestVersion = currentVersion; + foreach (var tag in tags) + { + if (releaseType == "Release") + { + if (tag.Name.Split("-")[1] != "Release") continue; + latestVersion = tag.Name; + break; + } + + latestVersion = tag.Name; + break; + } + + return latestVersion; + } + } +} \ No newline at end of file diff --git a/osu-launcher.Updater/osu-launcher.Updater.csproj b/osu-launcher.Updater/osu-launcher.Updater.csproj new file mode 100644 index 0000000..5173ee5 --- /dev/null +++ b/osu-launcher.Updater/osu-launcher.Updater.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + osu_launcher.Updater + enable + enable + + + + + + + diff --git a/osu-launcher.csproj b/osu-launcher.csproj index b6c4310..c713ac2 100644 --- a/osu-launcher.csproj +++ b/osu-launcher.csproj @@ -81,6 +81,9 @@ packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + packages\Octokit.13.0.1\lib\netstandard2.0\Octokit.dll + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll @@ -120,6 +123,7 @@ + Form diff --git a/osu-launcher.sln b/osu-launcher.sln index de79ce9..bce5fd6 100644 --- a/osu-launcher.sln +++ b/osu-launcher.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "osu-launcher", "osu-launcher.csproj", "{85312C2E-4174-48A0-A8A0-75540300E4A4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu-launcher.Updater", "osu-launcher.Updater\osu-launcher.Updater.csproj", "{01CC0C1F-9029-42C2-B320-A723F3D87123}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {85312C2E-4174-48A0-A8A0-75540300E4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU {85312C2E-4174-48A0-A8A0-75540300E4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU {85312C2E-4174-48A0-A8A0-75540300E4A4}.Release|Any CPU.Build.0 = Release|Any CPU + {01CC0C1F-9029-42C2-B320-A723F3D87123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01CC0C1F-9029-42C2-B320-A723F3D87123}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01CC0C1F-9029-42C2-B320-A723F3D87123}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01CC0C1F-9029-42C2-B320-A723F3D87123}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/packages.config b/packages.config index c49baa1..f9c081f 100644 --- a/packages.config +++ b/packages.config @@ -9,6 +9,7 @@ +