Finalized updates

This commit is contained in:
GittyMac 2021-03-20 10:42:09 -04:00
parent 4fa32bd97c
commit e577940095
13 changed files with 4954 additions and 40 deletions

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConfigForm));
this.QualityCB = new System.Windows.Forms.ComboBox();
this.customFtoggle = new System.Windows.Forms.CheckBox();
this.RPCToggle = new System.Windows.Forms.CheckBox();
@ -142,6 +143,7 @@
this.Controls.Add(this.customFtoggle);
this.Controls.Add(this.QualityCB);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "ConfigForm";
this.Text = "Config";

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
using AxShockwaveFlashObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,12 +13,13 @@ namespace OpenFK
{
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x204) //If it's a right click.
if(m.Msg == 0x0204) //If it's a right click.
{
if(!ModifierKeys.HasFlag(Keys.Control)) //If control is not held down | If it is, the context menu will show
{
this.SetVariable("msg", @"<rightclick x=""" + Cursor.Position.X + @""" y=""" + Cursor.Position.Y + @""" />"); //Sends right click command to flash.
m.Result = IntPtr.Zero; //Blocks context menu from showing
Debug.WriteLine("right click");
m.Result = IntPtr.Zero; //Blocks context menu from showing on versions that aren't the fetched OCX... No clue why it doesn't work.
return;
}
}

View File

@ -63,6 +63,7 @@
this.Controls.Add(this.AS3Container);
this.Name = "Form1";
this.Text = "OpenFK";
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.AS3Container)).EndInit();

View File

@ -43,6 +43,10 @@ namespace OpenFK
public string Store; //FilestoreV2 (For updates)
public string TStore; //Trunk
public XDocument netStore; //GitHub update.xml
public XDocument fsnetStore; //GitHub update.xml for FSGUI
public bool WasUpdated = false; //Determines if the OpenFK update script should run.
//Rich Presence Data
public string currentBitty;
public string currentBittyName;
@ -233,7 +237,7 @@ namespace OpenFK
}
catch
{
bittyTimer.Stop();
}
}
//
@ -293,13 +297,6 @@ namespace OpenFK
Debug.WriteLine("RDF Request: Section - {0} Name - {1}", filename, foldername);
loadFile(filename, foldername);
//Server Data
//TO BE IMPLEMENTED!!!
if (e.args.Contains("config"))
{
}
//Rich Prescense
if (Settings.Default.RPC == true)
{
@ -359,7 +356,6 @@ namespace OpenFK
//LOADED
//
if(e.args.Contains("<loaded ")){
//BityByte
if (Settings.Default.customF == true) //If using no USB
{
@ -482,9 +478,23 @@ namespace OpenFK
}
catch
{
if (WasUpdated == true) //If the game was updated. I don't know why it doesn't use a special command, but fine I guess...
{
File.WriteAllText(Directory.GetCurrentDirectory() + @"\update.bat", Properties.Resources.Update);
ProcessStartInfo updatescript = new ProcessStartInfo(Directory.GetCurrentDirectory() + @"\update.bat");
updatescript.UseShellExecute = true;
var updateprocess = Process.Start(updatescript);
}
Application.Exit();
}
}
if(WasUpdated == true) //If the game was updated. I don't know why it doesn't use a special command, but fine I guess...
{
File.WriteAllText(Directory.GetCurrentDirectory() + @"\update.bat", Properties.Resources.Update);
ProcessStartInfo updatescript = new ProcessStartInfo(Directory.GetCurrentDirectory() + @"\update.bat");
updatescript.UseShellExecute = true;
var updateprocess = Process.Start(updatescript);
}
Application.Exit(); //Closes OpenFK
Debug.WriteLine("radicaclose called, goodbye!"); //Debug output
}
@ -550,9 +560,142 @@ namespace OpenFK
//UPDATE CHECKS (Not standard netcommands)
if (e.args.Contains("checkupdate"))
{
string localVersion = "";
string localVerNum = "1.6";
string fslocalVersion = "";
string fslocalVerNum = "1.0";
Debug.WriteLine("UPDATE - Requested!");
var localStore = XDocument.Load(Directory.GetCurrentDirectory() + @"\Store.xml");
var netStore = XDocument.Parse(Get(Store + @"/Store.xml"));
setVar(@"<progress percent=""0.25"" />");
try
{
var localStore = XDocument.Load(Directory.GetCurrentDirectory() + @"\update.xml");
localVersion = localStore.Root.Attribute("name").Value;
localVerNum = localStore.Root.Attribute("version").Value;
}
catch
{
Debug.WriteLine("No update.xml found...");
}
setVar(@"<progress percent=""25.00"" />");
try
{
Debug.WriteLine("getting github xml");
netStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/OpenFK/master/update.xml"));
Debug.WriteLine("got the xml");
string netVersion = netStore.Root.Attribute("name").Value;
string netVersionNum = netStore.Root.Attribute("version").Value;
string netVersionSize = netStore.Root.Attribute("size").Value;
setVar(@"<progress percent=""50.00"" />");
if (localVersion != netVersion)
{
Debug.WriteLine("update needed!");
netStore.Save(Directory.GetCurrentDirectory() + @"\update.xml");
setVar(@"<checkupdate result=""2"" reason=""New version of OpenFK found."" version=""2009_07_16_544"" size=""" + netVersionSize + @""" curversion=""" + localVerNum + @""" extversion=""" + netVersionNum + @""" extname=""" + netVersion + @""" />");
}
else if(File.Exists(Directory.GetCurrentDirectory() + @"\FunkeySelectorGUI.exe"))
{
try
{
var localStore = XDocument.Load(Directory.GetCurrentDirectory() + @"\fsguiupdate.xml");
fslocalVersion = localStore.Root.Attribute("name").Value;
fslocalVerNum = localStore.Root.Attribute("version").Value;
}
catch
{
Debug.WriteLine("No update.xml found...");
}
setVar(@"<progress percent=""75.00"" />");
try
{
Debug.WriteLine("getting github xml");
fsnetStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/FunkeySelectorGUI/master/update.xml"));
Debug.WriteLine("got the xml");
string fsnetVersion = fsnetStore.Root.Attribute("name").Value;
string fsnetVersionNum = fsnetStore.Root.Attribute("version").Value;
string fsnetVersionSize = fsnetStore.Root.Attribute("size").Value;
setVar(@"<progress percent=""90.00"" />");
if (fslocalVersion != fsnetVersion)
{
try
{
Process process = Process.GetProcessesByName("FunkeySelectorGUI")[0];
process.Kill();
}
catch
{
Debug.WriteLine("no fsgui to close...");
}
Debug.WriteLine("update needed!");
setVar(@"<checkupdate result=""2"" reason=""New version of FSGUI found."" version=""2009_07_16_544"" size=""" + fsnetVersionSize + @""" curversion=""" + fslocalVerNum + @""" extversion=""" + fsnetVersionNum + @""" extname=""" + fsnetVersion + @""" />");
}
else
{
setVar(@"<checkupdate result=""0"" reason=""Everything is up to date."" />");
}
}
catch
{
Debug.WriteLine("No update!");
setVar(@"<checkupdate result=""1"" reason=""Could not find the FunkeySelectorGUI update!"" />");
}
}
else
{
setVar(@"<checkupdate result=""0"" reason=""Everything is up to date."" />");
}
}
catch
{
Debug.WriteLine("No update!");
setVar(@"<checkupdate result=""1"" reason=""Could not find the OpenFK update!"" />");
}
}
if(e.args.Contains(@"<loadupdate "))
{
try
{
if (fsnetStore != null)
{
string fsnetDL = fsnetStore.Root.Attribute("url").Value;
using (var client = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
client.DownloadFile(fsnetDL, Directory.GetCurrentDirectory() + @"\FunkeySelectorGUI.exe");
}
fsnetStore.Save(Directory.GetCurrentDirectory() + @"\fsguiupdate.xml");
setVar(@"<loadupdate result=""0"" reason=""good"" />");
}
else
{
string netDL = "";
if (Environment.Is64BitProcess)
{
netDL = netStore.Root.Attribute("url64").Value;
}
else
{
netDL = netStore.Root.Attribute("url32").Value;
}
using (var client = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
client.DownloadFile(netDL, Directory.GetCurrentDirectory() + @"\tmpdl.zip");
}
netStore.Save(Directory.GetCurrentDirectory() + @"\update.xml");
Directory.CreateDirectory(Path.GetDirectoryName(Directory.GetCurrentDirectory() + @"\tmpdl\"));
System.IO.Compression.ZipFile.ExtractToDirectory(Directory.GetCurrentDirectory() + @"\tmpdl.zip", Directory.GetCurrentDirectory() + @"\tmpdl\");
setVar(@"<loadupdate result=""0"" reason=""good"" />");
WasUpdated = true;
}
}
catch
{
setVar(@"<loadupdate result=""1"" reason=""The update has failed! Try restarting OpenFK..."" />");
}
}
//
@ -771,6 +914,8 @@ namespace OpenFK
//
public string Get(string uri)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

File diff suppressed because it is too large Load Diff

View File

@ -83,6 +83,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>openfkicon1.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
@ -95,6 +98,8 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -152,6 +157,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Resources\FetchOCX.bat" />
<EmbeddedResource Include="Resources\Update.bat" />
</ItemGroup>
<ItemGroup>
<COMReference Include="AxShockwaveFlashObjects">
@ -175,6 +181,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml" />
<Content Include="openfkicon1.ico" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />

View File

@ -17,6 +17,10 @@ namespace OpenFK
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (File.Exists(Directory.GetCurrentDirectory() + @"\update.bat"))
{
File.Delete(Directory.GetCurrentDirectory() + @"\update.bat");
}
if (args.Contains("/config"))
{
Application.Run(new ConfigForm());

View File

@ -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("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]

View File

@ -80,5 +80,19 @@ namespace OpenFK.Properties {
return ResourceManager.GetString("FetchOCX", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to echo OpenFK Update in progress...
///taskkill /f /im OpenFK.exe
///xcopy /s /y &quot;%cd%\tmpdl&quot; &quot;%cd%&quot;
///rmdir /s &quot;%cd%\tmpdl&quot;
///del &quot;%cd%\tmpdl.zip&quot;
///start &quot;&quot; &quot;%cd%\OpenFK.exe&quot;.
/// </summary>
internal static string Update {
get {
return ResourceManager.GetString("Update", resourceCulture);
}
}
}
}

View File

@ -121,4 +121,7 @@
<data name="FetchOCX" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FetchOCX.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\update.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@ -0,0 +1,7 @@
@echo off
echo OpenFK Update in progress...
taskkill /f /im OpenFK.exe
xcopy /s /y "%cd%\tmpdl" "%cd%"
rmdir /s /Q "%cd%\tmpdl"
del /q "%cd%\tmpdl.zip"
start "" "%cd%\OpenFK.exe"

BIN
OpenFK/openfkicon1.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB