Check for updates + Auto updater

This commit is contained in:
Souryo 2016-02-08 23:23:31 -05:00
parent 84d4b3ff1f
commit 3bc956067d
22 changed files with 873 additions and 96 deletions

View file

@ -58,6 +58,30 @@ namespace Mesen.GUI.Config
}
}
public static string DownloadFolder
{
get
{
string downloadFolder = Path.Combine(ConfigManager.HomeFolder, "Downloads");
if(!Directory.Exists(downloadFolder)) {
Directory.CreateDirectory(downloadFolder);
}
return downloadFolder;
}
}
public static string BackupFolder
{
get
{
string backupFolder = Path.Combine(ConfigManager.HomeFolder, "Backups");
if(!Directory.Exists(backupFolder)) {
Directory.CreateDirectory(backupFolder);
}
return backupFolder;
}
}
public static string TestFolder
{
get

View file

@ -29,6 +29,7 @@ namespace Mesen.GUI.Config
public bool AssociateMstFiles = false;
public bool PauseOnMovieEnd = true;
public bool AutomaticallyCheckForUpdates = true;
public bool UseAlternativeMmc3Irq = false;

View file

@ -52,8 +52,8 @@
this.chkRemoveSpriteLimit = new System.Windows.Forms.CheckBox();
this.chkFdsAutoLoadDisk = new System.Windows.Forms.CheckBox();
this.chkFdsFastForwardOnLoad = new System.Windows.Forms.CheckBox();
this.chkAutomaticallyCheckForUpdates = new System.Windows.Forms.CheckBox();
this.tlpMain.SuspendLayout();
this.flowLayoutPanel6.SuspendLayout();
this.tabMain.SuspendLayout();
this.tpgGeneral.SuspendLayout();
this.tpgFileAssociations.SuspendLayout();
@ -72,17 +72,20 @@
//
this.tlpMain.ColumnCount = 1;
this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tlpMain.Controls.Add(this.chkPauseOnMovieEnd, 0, 4);
this.tlpMain.Controls.Add(this.chkAllowBackgroundInput, 0, 3);
this.tlpMain.Controls.Add(this.chkPauseWhenInBackground, 0, 2);
this.tlpMain.Controls.Add(this.chkAutoLoadIps, 0, 1);
this.tlpMain.Controls.Add(this.chkSingleInstance, 0, 1);
this.tlpMain.Controls.Add(this.chkAutomaticallyCheckForUpdates, 0, 0);
this.tlpMain.Controls.Add(this.chkPauseOnMovieEnd, 0, 5);
this.tlpMain.Controls.Add(this.chkAllowBackgroundInput, 0, 4);
this.tlpMain.Controls.Add(this.chkPauseWhenInBackground, 0, 3);
this.tlpMain.Controls.Add(this.chkAutoLoadIps, 0, 2);
this.tlpMain.Controls.Add(this.flowLayoutPanel6, 0, 0);
this.tlpMain.Controls.Add(this.chkDisableScreensaver, 0, 5);
this.tlpMain.Controls.Add(this.btnOpenMesenFolder, 0, 7);
this.tlpMain.Controls.Add(this.chkDisableScreensaver, 0, 6);
this.tlpMain.Controls.Add(this.btnOpenMesenFolder, 0, 8);
this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpMain.Location = new System.Drawing.Point(3, 3);
this.tlpMain.Name = "tlpMain";
this.tlpMain.RowCount = 8;
this.tlpMain.RowCount = 9;
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
@ -97,7 +100,7 @@
// chkPauseOnMovieEnd
//
this.chkPauseOnMovieEnd.AutoSize = true;
this.chkPauseOnMovieEnd.Location = new System.Drawing.Point(3, 95);
this.chkPauseOnMovieEnd.Location = new System.Drawing.Point(3, 118);
this.chkPauseOnMovieEnd.Name = "chkPauseOnMovieEnd";
this.chkPauseOnMovieEnd.Size = new System.Drawing.Size(199, 17);
this.chkPauseOnMovieEnd.TabIndex = 15;
@ -107,7 +110,7 @@
// chkAllowBackgroundInput
//
this.chkAllowBackgroundInput.AutoSize = true;
this.chkAllowBackgroundInput.Location = new System.Drawing.Point(3, 72);
this.chkAllowBackgroundInput.Location = new System.Drawing.Point(3, 95);
this.chkAllowBackgroundInput.Name = "chkAllowBackgroundInput";
this.chkAllowBackgroundInput.Size = new System.Drawing.Size(177, 17);
this.chkAllowBackgroundInput.TabIndex = 14;
@ -117,7 +120,7 @@
// chkPauseWhenInBackground
//
this.chkPauseWhenInBackground.AutoSize = true;
this.chkPauseWhenInBackground.Location = new System.Drawing.Point(3, 49);
this.chkPauseWhenInBackground.Location = new System.Drawing.Point(3, 72);
this.chkPauseWhenInBackground.Name = "chkPauseWhenInBackground";
this.chkPauseWhenInBackground.Size = new System.Drawing.Size(204, 17);
this.chkPauseWhenInBackground.TabIndex = 13;
@ -128,7 +131,7 @@
// chkAutoLoadIps
//
this.chkAutoLoadIps.AutoSize = true;
this.chkAutoLoadIps.Location = new System.Drawing.Point(3, 26);
this.chkAutoLoadIps.Location = new System.Drawing.Point(3, 49);
this.chkAutoLoadIps.Name = "chkAutoLoadIps";
this.chkAutoLoadIps.Size = new System.Drawing.Size(132, 17);
this.chkAutoLoadIps.TabIndex = 9;
@ -138,18 +141,17 @@
// flowLayoutPanel6
//
this.flowLayoutPanel6.AutoSize = true;
this.flowLayoutPanel6.Controls.Add(this.chkSingleInstance);
this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel6.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel6.Name = "flowLayoutPanel6";
this.flowLayoutPanel6.Size = new System.Drawing.Size(380, 23);
this.flowLayoutPanel6.Size = new System.Drawing.Size(380, 1);
this.flowLayoutPanel6.TabIndex = 10;
//
// chkSingleInstance
//
this.chkSingleInstance.AutoSize = true;
this.chkSingleInstance.Location = new System.Drawing.Point(3, 3);
this.chkSingleInstance.Location = new System.Drawing.Point(3, 26);
this.chkSingleInstance.Name = "chkSingleInstance";
this.chkSingleInstance.Size = new System.Drawing.Size(228, 17);
this.chkSingleInstance.TabIndex = 11;
@ -160,7 +162,7 @@
//
this.chkDisableScreensaver.AutoSize = true;
this.chkDisableScreensaver.Enabled = false;
this.chkDisableScreensaver.Location = new System.Drawing.Point(3, 118);
this.chkDisableScreensaver.Location = new System.Drawing.Point(3, 141);
this.chkDisableScreensaver.Name = "chkDisableScreensaver";
this.chkDisableScreensaver.Size = new System.Drawing.Size(245, 17);
this.chkDisableScreensaver.TabIndex = 11;
@ -366,6 +368,16 @@
this.chkFdsFastForwardOnLoad.Text = "Automatically fast forward FDS games when disk or BIOS is loading";
this.chkFdsFastForwardOnLoad.UseVisualStyleBackColor = true;
//
// chkAutomaticallyCheckForUpdates
//
this.chkAutomaticallyCheckForUpdates.AutoSize = true;
this.chkAutomaticallyCheckForUpdates.Location = new System.Drawing.Point(3, 3);
this.chkAutomaticallyCheckForUpdates.Name = "chkAutomaticallyCheckForUpdates";
this.chkAutomaticallyCheckForUpdates.Size = new System.Drawing.Size(177, 17);
this.chkAutomaticallyCheckForUpdates.TabIndex = 17;
this.chkAutomaticallyCheckForUpdates.Text = "Automatically check for updates";
this.chkAutomaticallyCheckForUpdates.UseVisualStyleBackColor = true;
//
// frmPreferences
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -382,8 +394,6 @@
this.Controls.SetChildIndex(this.tabMain, 0);
this.tlpMain.ResumeLayout(false);
this.tlpMain.PerformLayout();
this.flowLayoutPanel6.ResumeLayout(false);
this.flowLayoutPanel6.PerformLayout();
this.tabMain.ResumeLayout(false);
this.tpgGeneral.ResumeLayout(false);
this.tpgFileAssociations.ResumeLayout(false);
@ -424,5 +434,6 @@
private System.Windows.Forms.CheckBox chkAllowBackgroundInput;
private System.Windows.Forms.CheckBox chkPauseOnMovieEnd;
private System.Windows.Forms.Button btnOpenMesenFolder;
private System.Windows.Forms.CheckBox chkAutomaticallyCheckForUpdates;
}
}

View file

@ -19,6 +19,7 @@ namespace Mesen.GUI.Forms.Config
Entity = ConfigManager.Config.PreferenceInfo;
AddBinding("AutomaticallyCheckForUpdates", chkAutomaticallyCheckForUpdates);
AddBinding("SingleInstance", chkSingleInstance);
AddBinding("AutoLoadIpsPatches", chkAutoLoadIps);
AddBinding("AssociateNesFiles", chkNesFormat);

View file

@ -29,13 +29,12 @@
this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.logoPictureBox = new System.Windows.Forms.PictureBox();
this.labelProductName = new System.Windows.Forms.Label();
this.labelVersion = new System.Windows.Forms.Label();
this.labelCopyright = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.lblWebsite = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.lblWebsite = new System.Windows.Forms.Label();
this.lblLink = new System.Windows.Forms.Label();
this.lblCredits = new System.Windows.Forms.Label();
this.labelVersion = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.tableLayoutPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();
this.flowLayoutPanel1.SuspendLayout();
@ -46,7 +45,6 @@
this.tableLayoutPanel.ColumnCount = 2;
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 70F));
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel.Controls.Add(this.lblCredits, 0, 4);
this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0);
this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0);
this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);
@ -63,7 +61,7 @@
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel.Size = new System.Drawing.Size(347, 144);
this.tableLayoutPanel.Size = new System.Drawing.Size(347, 99);
this.tableLayoutPanel.TabIndex = 0;
//
// logoPictureBox
@ -88,16 +86,6 @@
this.labelProductName.Text = "Mesen";
this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// labelVersion
//
this.labelVersion.Location = new System.Drawing.Point(76, 17);
this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
this.labelVersion.Name = "labelVersion";
this.labelVersion.Size = new System.Drawing.Size(146, 17);
this.labelVersion.TabIndex = 0;
this.labelVersion.Text = "Version: 0.1 (Beta)";
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// labelCopyright
//
this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill;
@ -110,15 +98,15 @@
this.labelCopyright.Text = "© 2016 M. Bibaud";
this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// okButton
// flowLayoutPanel1
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.okButton.Location = new System.Drawing.Point(269, 118);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 24;
this.okButton.Text = "&OK";
this.flowLayoutPanel1.Controls.Add(this.lblWebsite);
this.flowLayoutPanel1.Controls.Add(this.lblLink);
this.flowLayoutPanel1.Location = new System.Drawing.Point(70, 51);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(236, 18);
this.flowLayoutPanel1.TabIndex = 26;
//
// lblWebsite
//
@ -131,16 +119,6 @@
this.lblWebsite.Text = "Website:";
this.lblWebsite.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.lblWebsite);
this.flowLayoutPanel1.Controls.Add(this.lblLink);
this.flowLayoutPanel1.Location = new System.Drawing.Point(70, 51);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(236, 18);
this.flowLayoutPanel1.TabIndex = 26;
//
// lblLink
//
this.lblLink.AutoSize = true;
@ -155,31 +133,39 @@
this.lblLink.Text = "www.mesen.ca";
this.lblLink.Click += new System.EventHandler(this.lblLink_Click);
//
// lblCredits
// labelVersion
//
this.tableLayoutPanel.SetColumnSpan(this.lblCredits, 2);
this.lblCredits.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCredits.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblCredits.Location = new System.Drawing.Point(3, 70);
this.lblCredits.Name = "lblCredits";
this.lblCredits.Size = new System.Drawing.Size(341, 45);
this.lblCredits.TabIndex = 27;
this.lblCredits.Text = "A big thanks to all the members of the NesDev community.\r\nBoth the forums and wik" +
"i have been invaluable to the development of Mesen.";
this.labelVersion.Location = new System.Drawing.Point(76, 17);
this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
this.labelVersion.Name = "labelVersion";
this.labelVersion.Size = new System.Drawing.Size(146, 17);
this.labelVersion.TabIndex = 0;
this.labelVersion.Text = "Version: 0.1.0 (Beta)";
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.okButton.Location = new System.Drawing.Point(269, 73);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 24;
this.okButton.Text = "&OK";
//
// frmAbout
//
this.AcceptButton = this.okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(357, 154);
this.CancelButton = this.okButton;
this.ClientSize = new System.Drawing.Size(357, 109);
this.Controls.Add(this.tableLayoutPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmAbout";
this.Padding = new System.Windows.Forms.Padding(5);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About - Mesen";
@ -202,6 +188,5 @@
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label lblWebsite;
private System.Windows.Forms.Label lblLink;
private System.Windows.Forms.Label lblCredits;
}
}

View file

@ -9,7 +9,7 @@ using System.Windows.Forms;
namespace Mesen.GUI.Forms
{
partial class frmAbout : Form
partial class frmAbout : BaseForm
{
public frmAbout()
{

View file

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -45,7 +45,6 @@ namespace Mesen.GUI.Forms
this.components = new System.ComponentModel.Container();
this.menuTimer = new System.Windows.Forms.Timer(this.components);
this.panelRenderer = new System.Windows.Forms.Panel();
this.ctrlRenderer = new Mesen.GUI.Controls.ctrlRenderer();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.mnuFile = new System.Windows.Forms.ToolStripMenuItem();
this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem();
@ -137,6 +136,7 @@ namespace Mesen.GUI.Forms
this.mnuCheckForUpdates = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem();
this.ctrlRenderer = new Mesen.GUI.Controls.ctrlRenderer();
this.panelRenderer.SuspendLayout();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
@ -156,16 +156,6 @@ namespace Mesen.GUI.Forms
this.panelRenderer.TabIndex = 2;
this.panelRenderer.Click += new System.EventHandler(this.panelRenderer_Click);
//
// ctrlRenderer
//
this.ctrlRenderer.BackColor = System.Drawing.Color.Black;
this.ctrlRenderer.Location = new System.Drawing.Point(0, 0);
this.ctrlRenderer.Margin = new System.Windows.Forms.Padding(0);
this.ctrlRenderer.Name = "ctrlRenderer";
this.ctrlRenderer.Size = new System.Drawing.Size(263, 176);
this.ctrlRenderer.TabIndex = 1;
this.ctrlRenderer.Enter += new System.EventHandler(this.ctrlRenderer_Enter);
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -886,10 +876,10 @@ namespace Mesen.GUI.Forms
//
// mnuCheckForUpdates
//
this.mnuCheckForUpdates.Enabled = false;
this.mnuCheckForUpdates.Name = "mnuCheckForUpdates";
this.mnuCheckForUpdates.Size = new System.Drawing.Size(170, 22);
this.mnuCheckForUpdates.Text = "Check for updates";
this.mnuCheckForUpdates.Click += new System.EventHandler(this.mnuCheckForUpdates_Click);
//
// toolStripMenuItem5
//
@ -904,6 +894,16 @@ namespace Mesen.GUI.Forms
this.mnuAbout.Text = "About";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// ctrlRenderer
//
this.ctrlRenderer.BackColor = System.Drawing.Color.Black;
this.ctrlRenderer.Location = new System.Drawing.Point(0, 0);
this.ctrlRenderer.Margin = new System.Windows.Forms.Padding(0);
this.ctrlRenderer.Name = "ctrlRenderer";
this.ctrlRenderer.Size = new System.Drawing.Size(263, 176);
this.ctrlRenderer.TabIndex = 1;
this.ctrlRenderer.Enter += new System.EventHandler(this.ctrlRenderer_Enter);
//
// frmMain
//
this.AllowDrop = true;

View file

@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Mesen.GUI.Config;
using Mesen.GUI.Debugger;
using Mesen.GUI.Forms.Cheats;
@ -67,6 +69,28 @@ namespace Mesen.GUI.Forms
if(_romToLoad != null) {
LoadFile(this._romToLoad);
}
if(ConfigManager.Config.PreferenceInfo.AutomaticallyCheckForUpdates) {
CheckForUpdates(false);
}
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
PerformUpgrade();
}
void PerformUpgrade()
{
if(new Version(ConfigManager.Config.MesenVersion) < new Version(InteropEmu.GetMesenVersion())) {
//Upgrade
ConfigManager.Config.MesenVersion = InteropEmu.GetMesenVersion();
ConfigManager.ApplyChanges();
MessageBox.Show("Upgrade completed successfully.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void menuTimer_Tick(object sender, EventArgs e)
@ -1017,5 +1041,37 @@ namespace Mesen.GUI.Forms
{
new frmAbout().ShowDialog();
}
private void CheckForUpdates(bool displayResult)
{
Task.Run(() => {
try {
using(var client = new WebClient()) {
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(client.DownloadString("http://www.mesen.ca/Services/GetLatestVersion.php?v=" + InteropEmu.GetMesenVersion() + "&p=win"));
Version currentVersion = new Version(InteropEmu.GetMesenVersion());
Version latestVersion = new Version(xmlDoc.SelectSingleNode("VersionInfo/LatestVersion").InnerText);
string changeLog = xmlDoc.SelectSingleNode("VersionInfo/ChangeLog").InnerText;
if(latestVersion > currentVersion) {
this.BeginInvoke((MethodInvoker)(() => {
frmUpdatePrompt frmUpdate = new frmUpdatePrompt(currentVersion, latestVersion, changeLog);
frmUpdate.ShowDialog(null, this);
}));
} else if(displayResult) {
MessageBox.Show("You are running the latest version of Mesen.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
} catch(Exception ex) {
if(displayResult) {
MessageBox.Show("An error has occurred while trying to check for updates." + Environment.NewLine + Environment.NewLine + "Error details:" + Environment.NewLine + ex.ToString(), "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
});
}
private void mnuCheckForUpdates_Click(object sender, EventArgs e)
{
CheckForUpdates(true);
}
}
}

200
GUI.NET/Forms/frmUpdatePrompt.Designer.cs generated Normal file
View file

@ -0,0 +1,200 @@
namespace Mesen.GUI.Forms
{
partial class frmUpdatePrompt
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.lblLatestVersionString = new System.Windows.Forms.Label();
this.lblLatestVersion = new System.Windows.Forms.Label();
this.lblCurrentVersion = new System.Windows.Forms.Label();
this.txtChangelog = new System.Windows.Forms.TextBox();
this.lblChangeLog = new System.Windows.Forms.Label();
this.lblCurrentVersionString = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.lblLatestVersionString, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.lblLatestVersion, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.lblCurrentVersion, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.txtChangelog, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.lblChangeLog, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.lblCurrentVersionString, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 3);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5, 10, 5, 0);
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(395, 222);
this.tableLayoutPanel1.TabIndex = 0;
//
// lblLatestVersionString
//
this.lblLatestVersionString.AutoSize = true;
this.lblLatestVersionString.Location = new System.Drawing.Point(91, 10);
this.lblLatestVersionString.Name = "lblLatestVersionString";
this.lblLatestVersionString.Size = new System.Drawing.Size(31, 13);
this.lblLatestVersionString.TabIndex = 7;
this.lblLatestVersionString.Text = "0.1.1";
//
// lblLatestVersion
//
this.lblLatestVersion.AutoSize = true;
this.lblLatestVersion.Location = new System.Drawing.Point(8, 10);
this.lblLatestVersion.Name = "lblLatestVersion";
this.lblLatestVersion.Size = new System.Drawing.Size(77, 13);
this.lblLatestVersion.TabIndex = 2;
this.lblLatestVersion.Text = "Latest Version:";
//
// lblCurrentVersion
//
this.lblCurrentVersion.AutoSize = true;
this.lblCurrentVersion.Location = new System.Drawing.Point(191, 10);
this.lblCurrentVersion.Name = "lblCurrentVersion";
this.lblCurrentVersion.Size = new System.Drawing.Size(82, 13);
this.lblCurrentVersion.TabIndex = 3;
this.lblCurrentVersion.Text = "Current Version:";
//
// txtChangelog
//
this.txtChangelog.BackColor = System.Drawing.Color.White;
this.tableLayoutPanel1.SetColumnSpan(this.txtChangelog, 4);
this.txtChangelog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtChangelog.Location = new System.Drawing.Point(8, 49);
this.txtChangelog.Multiline = true;
this.txtChangelog.Name = "txtChangelog";
this.txtChangelog.ReadOnly = true;
this.txtChangelog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtChangelog.Size = new System.Drawing.Size(379, 141);
this.txtChangelog.TabIndex = 4;
this.txtChangelog.TabStop = false;
//
// lblChangeLog
//
this.lblChangeLog.AutoSize = true;
this.lblChangeLog.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblChangeLog.Location = new System.Drawing.Point(8, 33);
this.lblChangeLog.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0);
this.lblChangeLog.Name = "lblChangeLog";
this.lblChangeLog.Size = new System.Drawing.Size(61, 13);
this.lblChangeLog.TabIndex = 5;
this.lblChangeLog.Text = "Changelog:";
//
// lblCurrentVersionString
//
this.lblCurrentVersionString.AutoSize = true;
this.lblCurrentVersionString.Location = new System.Drawing.Point(279, 10);
this.lblCurrentVersionString.Name = "lblCurrentVersionString";
this.lblCurrentVersionString.Size = new System.Drawing.Size(31, 13);
this.lblCurrentVersionString.TabIndex = 6;
this.lblCurrentVersionString.Text = "0.1.0";
//
// flowLayoutPanel1
//
this.tableLayoutPanel1.SetColumnSpan(this.flowLayoutPanel1, 4);
this.flowLayoutPanel1.Controls.Add(this.btnCancel);
this.flowLayoutPanel1.Controls.Add(this.btnUpdate);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(5, 193);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(385, 29);
this.flowLayoutPanel1.TabIndex = 8;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(311, 3);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(71, 23);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// btnUpdate
//
this.btnUpdate.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnUpdate.Location = new System.Drawing.Point(230, 3);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(75, 23);
this.btnUpdate.TabIndex = 0;
this.btnUpdate.Text = "Update";
this.btnUpdate.UseVisualStyleBackColor = true;
//
// frmUpdatePrompt
//
this.AcceptButton = this.btnUpdate;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(395, 222);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmUpdatePrompt";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Mesen - Update Available";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label lblLatestVersionString;
private System.Windows.Forms.Label lblLatestVersion;
private System.Windows.Forms.Label lblCurrentVersion;
private System.Windows.Forms.TextBox txtChangelog;
private System.Windows.Forms.Label lblChangeLog;
private System.Windows.Forms.Label lblCurrentVersionString;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnUpdate;
}
}

View file

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mesen.GUI.Config;
namespace Mesen.GUI.Forms
{
public partial class frmUpdatePrompt : BaseForm
{
public frmUpdatePrompt(Version currentVersion, Version latestVersion, string changeLog)
{
InitializeComponent();
lblCurrentVersionString.Text = currentVersion.ToString();
lblLatestVersionString.Text = latestVersion.ToString();
txtChangelog.Text = changeLog.Replace("\n", Environment.NewLine);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
btnUpdate.Focus();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
if(DialogResult == DialogResult.OK) {
string destFilePath = Process.GetCurrentProcess().MainModule.FileName;
string srcFilePath = Path.Combine(ConfigManager.DownloadFolder, "Mesen." + lblLatestVersionString.Text + ".exe");
string backupFilePath = Path.Combine(ConfigManager.BackupFolder, "Mesen." + lblCurrentVersionString.Text + ".exe");
string updateHelper = Path.Combine(ConfigManager.HomeFolder, "MesenUpdater.exe");
if(!string.IsNullOrWhiteSpace(srcFilePath)) {
frmDownloadProgress frmDownload = new frmDownloadProgress("http://www.mesen.ca/Services/GetLatestVersion.php?a=download&&p=win", srcFilePath);
if(frmDownload.ShowDialog() == DialogResult.OK) {
Process.Start(updateHelper, string.Format("\"{0}\" \"{1}\" \"{2}\"", srcFilePath, destFilePath, backupFilePath));
Application.Exit();
}
}
}
}
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -143,6 +143,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -376,6 +379,12 @@
<Compile Include="Forms\frmDownloadProgress.Designer.cs">
<DependentUpon>frmDownloadProgress.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmUpdatePrompt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\frmUpdatePrompt.Designer.cs">
<DependentUpon>frmUpdatePrompt.cs</DependentUpon>
</Compile>
<Compile Include="Forms\NetPlay\frmClientConfig.cs">
<SubType>Form</SubType>
</Compile>
@ -508,6 +517,9 @@
<EmbeddedResource Include="Forms\frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\frmUpdatePrompt.resx">
<DependentUpon>frmUpdatePrompt.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\NetPlay\frmClientConfig.resx">
<DependentUpon>frmClientConfig.cs</DependentUpon>
</EmbeddedResource>
@ -605,7 +617,9 @@ copy "$(SolutionDir)bin\x64\$(ConfigurationName)\WinMesen.dll" "Dependencies\Win
copy "$(SolutionDir)bin\x64\$(ConfigurationName)\BlipBuffer.dll" "Dependencies\BlipBuffer.x64.dll"
copy "$(SolutionDir)bin\x64\$(ConfigurationName)\NesNtsc.dll" "Dependencies\NesNtsc.x64.dll"
)
call DependencyPacker.exe</PreBuildEvent>
copy "MesenUpdater.exe" "Dependencies\MesenUpdater.exe"
call DependencyPacker.exe
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -15,6 +15,8 @@ namespace Mesen.GUI
private const string DLLPath = "WinMesen.dll";
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool TestDll();
[DllImport(DLLPath, EntryPoint = "GetMesenVersion")] private static extern UInt32 GetMesenVersionWrapper();
[DllImport(DLLPath)] public static extern void InitializeEmu([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(UTF8Marshaler))]string homeFolder, IntPtr windowHandle, IntPtr dxViewerHandle);
[DllImport(DLLPath)] public static extern void Release();
@ -243,6 +245,15 @@ namespace Mesen.GUI
}
}
public static string GetMesenVersion()
{
UInt32 version = GetMesenVersionWrapper();
UInt32 revision = version & 0xFF;
UInt32 minor = (version >> 8) & 0xFF;
UInt32 major = (version >> 16) & 0xFFFF;
return string.Format("{0}.{1}.{2}", major.ToString(), minor.ToString(), revision.ToString());
}
public static Int32[] GetRgbPalette()
{
Int32[] paleteData = new Int32[64];

View file

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Mesen")]
[assembly: AssemblyTitle("Mesen (Beta)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mesen")]
[assembly: AssemblyProduct("Mesen")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyProduct("Mesen (Beta)")]
[assembly: AssemblyCopyright("Copyright © 2016 M. Bibaud")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]

View file

@ -29,6 +29,18 @@ namespace Mesen.GUI
}
}
private static void ExtractFile(ZipArchiveEntry entry, string outputFilename)
{
if(File.Exists(outputFilename)) {
try {
File.Delete(outputFilename);
} catch { }
}
try {
entry.ExtractToFile(outputFilename);
} catch { }
}
public static void ExtractResources()
{
Directory.CreateDirectory(Path.Combine(ConfigManager.HomeFolder, "Resources"));
@ -38,17 +50,9 @@ namespace Mesen.GUI
//Extract all needed files
string suffix = IntPtr.Size == 4 ? ".x86" : ".x64";
foreach(ZipArchiveEntry entry in zip.Entries) {
if(entry.Name.Contains(suffix)) {
if(entry.Name.Contains(suffix) || entry.Name == "MesenUpdater.exe") {
string outputFilename = Path.Combine(ConfigManager.HomeFolder, entry.Name.Replace(suffix, ""));
if(File.Exists(outputFilename)) {
try {
File.Delete(outputFilename);
} catch { }
}
try {
entry.ExtractToFile(outputFilename);
} catch { }
ExtractFile(entry, outputFilename);
}
}

View file

@ -46,6 +46,8 @@ namespace InteropEmu {
return true;
}
DllExport uint32_t __stdcall GetMesenVersion() { return EmulationSettings::GetMesenVersion(); }
DllExport void __stdcall InitializeEmu(const char* homeFolder, HWND windowHandle, HWND dxViewerHandle)
{
FolderUtilities::SetHomeFolder(homeFolder);

26
NES.sln
View file

@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyPacker", "Depende
{37749BB2-FA78-4EC9-8990-5628FC0BBA19} = {37749BB2-FA78-4EC9-8990-5628FC0BBA19}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateHelper", "UpdateHelper\UpdateHelper.csproj", "{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -274,6 +276,30 @@ Global
{AABB5225-3A49-47FF-8A48-031673CADCE9}.Release|x64.Build.0 = Release|x64
{AABB5225-3A49-47FF-8A48-031673CADCE9}.Release|x86.ActiveCfg = Release|x86
{AABB5225-3A49-47FF-8A48-031673CADCE9}.Release|x86.Build.0 = Release|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|x64.ActiveCfg = Debug|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|x64.Build.0 = Debug|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|x86.ActiveCfg = Debug|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Debug|x86.Build.0 = Debug|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|Any CPU.ActiveCfg = PGO Optimize|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|Any CPU.Build.0 = PGO Optimize|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|x64.ActiveCfg = PGO Optimize|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|x64.Build.0 = PGO Optimize|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|x86.ActiveCfg = PGO Optimize|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Optimize|x86.Build.0 = PGO Optimize|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|Any CPU.ActiveCfg = PGO Profile|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|Any CPU.Build.0 = PGO Profile|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|x64.ActiveCfg = PGO Profile|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|x64.Build.0 = PGO Profile|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|x86.ActiveCfg = PGO Profile|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.PGO Profile|x86.Build.0 = PGO Profile|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|Any CPU.Build.0 = Release|Any CPU
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|x64.ActiveCfg = Release|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|x64.Build.0 = Release|x64
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|x86.ActiveCfg = Release|x86
{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

BIN
UpdateHelper/Icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

58
UpdateHelper/Program.cs Normal file
View file

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
namespace MesenUpdater
{
class Program
{
static void Main(string[] args)
{
string srcFile = args[0];
string destFile = args[1];
string backupDestFile = args[2];
bool isAdmin = args.Length > 3 && args[3] == "admin";
int retryCount = 0;
while(retryCount < 10) {
try {
using(FileStream file = File.Open(destFile, FileMode.Open, FileAccess.ReadWrite, FileShare.Delete | FileShare.ReadWrite)) { }
break;
} catch {
retryCount++;
System.Threading.Thread.Sleep(1000);
}
}
try {
File.Copy(destFile, backupDestFile, true);
File.Copy(srcFile, destFile, true);
} catch {
try {
if(!isAdmin) {
ProcessStartInfo proc = new ProcessStartInfo();
proc.WindowStyle = ProcessWindowStyle.Normal;
proc.FileName = Process.GetCurrentProcess().MainModule.FileName;
proc.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\" admin", srcFile, destFile, backupDestFile);
proc.UseShellExecute = true;
proc.Verb = "runas";
Process.Start(proc);
return;
} else {
MessageBox.Show("Update failed. Please try downloading and installing the new version manually.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
} catch {
MessageBox.Show("Update failed. Please try downloading and installing the new version manually.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
Process.Start(destFile);
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MesenUpdater")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MesenUpdater")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("36abbf1c-66e1-4577-828a-619a2ef0dae9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{36ABBF1C-66E1-4577-828A-619A2EF0DAE9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MesenUpdater</RootNamespace>
<AssemblyName>MesenUpdater</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Any CPU\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Any CPU\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Profile|AnyCPU'">
<OutputPath>..\bin\Any CPU\PGO Profile\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Profile|x64'">
<OutputPath>..\bin\x64\PGO Profile\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Profile|x86'">
<OutputPath>..\bin\x86\PGO Profile\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Optimize|AnyCPU'">
<OutputPath>..\bin\Any CPU\PGO Optimize\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Optimize|x64'">
<OutputPath>..\bin\x64\PGO Optimize\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'PGO Optimize|x86'">
<OutputPath>..\bin\x86\PGO Optimize\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>