diff --git a/OpenFK/DebugWindow.Designer.cs b/OpenFK/DebugWindow.Designer.cs new file mode 100644 index 0000000..c111639 --- /dev/null +++ b/OpenFK/DebugWindow.Designer.cs @@ -0,0 +1,90 @@ + +namespace OpenFK +{ + partial class DebugWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.generalLog = new System.Windows.Forms.RichTextBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.logTab = new System.Windows.Forms.TabPage(); + this.tabControl1.SuspendLayout(); + this.logTab.SuspendLayout(); + this.SuspendLayout(); + // + // generalLog + // + this.generalLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.generalLog.Location = new System.Drawing.Point(3, 3); + this.generalLog.Name = "generalLog"; + this.generalLog.ReadOnly = true; + this.generalLog.Size = new System.Drawing.Size(593, 423); + this.generalLog.TabIndex = 0; + this.generalLog.Text = ""; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.logTab); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(607, 455); + this.tabControl1.TabIndex = 1; + // + // logTab + // + this.logTab.Controls.Add(this.generalLog); + this.logTab.Location = new System.Drawing.Point(4, 22); + this.logTab.Name = "logTab"; + this.logTab.Padding = new System.Windows.Forms.Padding(3); + this.logTab.Size = new System.Drawing.Size(599, 429); + this.logTab.TabIndex = 0; + this.logTab.Text = "Log"; + this.logTab.UseVisualStyleBackColor = true; + // + // DebugWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(607, 455); + this.Controls.Add(this.tabControl1); + this.Name = "DebugWindow"; + this.Text = "OpenFK - Debug"; + this.tabControl1.ResumeLayout(false); + this.logTab.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.RichTextBox generalLog; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage logTab; + } +} \ No newline at end of file diff --git a/OpenFK/DebugWindow.cs b/OpenFK/DebugWindow.cs new file mode 100644 index 0000000..b8a2326 --- /dev/null +++ b/OpenFK/DebugWindow.cs @@ -0,0 +1,22 @@ +using OpenFK.OFK.Common; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OpenFK +{ + public partial class DebugWindow : Form + { + public DebugWindow() + { + InitializeComponent(); + LogManager.debugLogText = generalLog; + } + } +} diff --git a/OpenFK/DebugWindow.resx b/OpenFK/DebugWindow.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OpenFK/DebugWindow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs index 2c4e0c9..be7bb62 100644 --- a/OpenFK/Form1.cs +++ b/OpenFK/Form1.cs @@ -1,6 +1,7 @@ using AxShockwaveFlashObjects; using DiscordRPC; using Microsoft.Win32; +using OpenFK.OFK.Common; using OpenFK.Properties; using System; using System.Collections.Generic; @@ -77,9 +78,14 @@ namespace OpenFK public DiscordRpcClient client; private FileSystemWatcher watcher; - public Form1() + public Form1(string[] args) { InitializeComponent(); + if (args.Contains("/debug")) + { + DebugWindow debug = new DebugWindow(); + debug.Show(); + } } private void Form1_Load(object sender, EventArgs e) @@ -109,7 +115,7 @@ namespace OpenFK AS2Container.ScaleMode = Settings.Default.ScaleMode; AS2Container.Movie = Directory.GetCurrentDirectory() + @"\Main.swf"; //Sets Main.swf as the Flash Movie to Play. AS2Container.Play(); //Plays Main.swf - Debug.WriteLine("[AS2Container] Main.swf is Loaded"); + LogManager.LogToForm("[AS2Container] Main.swf is Loaded"); AS2Container.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(flashPlayer_FSCommand); //This sets up the FSCommand handler, which CCommunicator likes to use a lot. try @@ -118,13 +124,13 @@ namespace OpenFK AS3Container.Quality2 = "High"; AS3Container.ScaleMode = Settings.Default.ScaleMode; AS3Container.Movie = Directory.GetCurrentDirectory() + @"\MainAS3.swf"; //Sets MainAS3.swf as the Flash Movie to Play. - Debug.WriteLine("[AS3Container] MainAS3.swf is Loaded"); + LogManager.LogToForm("[AS3Container] MainAS3.swf is Loaded"); AS3Container.FSCommand += new _IShockwaveFlashEvents_FSCommandEventHandler(flashPlayerAS3_FSCommand); AS3Container.FlashCall += new _IShockwaveFlashEvents_FlashCallEventHandler(flashPlayerAS3_FlashCall); } catch { - Debug.WriteLine("[AS3Container] AS3 Failed to Load! Potentially an older version."); + LogManager.LogToForm("[AS3Container] AS3 Failed to Load! Potentially an older version."); } //End of Flash initialization @@ -167,7 +173,7 @@ namespace OpenFK private void flashPlayerAS3_FSCommand(object sender, _IShockwaveFlashEvents_FSCommandEvent e) { - Debug.WriteLine("[AS3] [SendMsg] " + e.args); + LogManager.LogToForm("[AS3] [SendMsg] " + e.args); if(e.args.Contains(""); @@ -279,7 +285,7 @@ namespace OpenFK void flashPlayer_FSCommand(object sender, _IShockwaveFlashEvents_FSCommandEvent e) //FSCommand Handler { - Debug.WriteLine("[AS2] [SendMsg] " + e.args); + LogManager.LogToForm("[AS2] [SendMsg] " + e.args); // // XML LOAD COMMANDS @@ -298,7 +304,7 @@ namespace OpenFK //XML LOADING filename = xn.Attributes["section"].Value; foldername = xn.Attributes["name"].Value; - Debug.WriteLine("[Load] File Requested - {1}/{0}", filename, foldername); + LogManager.LogToForm("[Load] File Requested - " + filename + "/" + foldername); loadFile(filename, foldername); //Rich Prescense @@ -388,7 +394,7 @@ namespace OpenFK { filename = xn.Attributes["section"].Value; foldername = xn.Attributes["name"].Value; - Debug.WriteLine("[Save] File Requested - {1}/{0}", filename, foldername); //debug output + LogManager.LogToForm("[Save] File Requested - " + filename + "/" + foldername); //debug output XDocument args = XDocument.Parse(e.args); @@ -411,7 +417,7 @@ namespace OpenFK File.WriteAllBytes(Directory.GetCurrentDirectory() + @"\data\" + foldername + @"\" + filename + ".rdf", iso_8859_1.GetBytes(RDFTool.encode(iso_8859_1.GetString(RDFData)))); } else File.WriteAllText(Directory.GetCurrentDirectory() + @"\data\" + foldername + @"\" + filename + ".xml", output.ToString()); //saves - Debug.WriteLine("[Save] Successfully saved - " + foldername + "/" + filename); //Debug Output + LogManager.LogToForm("[Save] Successfully saved - " + foldername + "/" + filename); //Debug Output } } @@ -501,7 +507,7 @@ namespace OpenFK var updateprocess = Process.Start(updatescript); } Application.Exit(); //Closes OpenFK - Debug.WriteLine("[OpenFK] Radicaclose was called"); //Debug output + LogManager.LogToForm("[OpenFK] Radicaclose was called"); //Debug output } // @@ -554,7 +560,7 @@ namespace OpenFK //HTTP POST (CRIB SAVING + POSTCARDS) if (e.args.Contains(""); try { @@ -602,21 +608,21 @@ namespace OpenFK } catch { - Debug.WriteLine("[Network] [Update] Update.xml was not found"); + LogManager.LogToForm("[Network] [Update] Update.xml was not found"); } setVar(@""); try { - Debug.WriteLine("[Network] [Update] Downloading Update.xml from GitHub"); + LogManager.LogToForm("[Network] [Update] Downloading Update.xml from GitHub"); netStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/OpenFK/master/update.xml")); - Debug.WriteLine("[Network] [Update] Update.xml was downloaded"); + LogManager.LogToForm("[Network] [Update] Update.xml was downloaded"); string netVersion = netStore.Root.Attribute("name").Value; string netVersionNum = netStore.Root.Attribute("version").Value; string netVersionSize = netStore.Root.Attribute("size").Value; setVar(@""); if (localVersion != netVersion) { - Debug.WriteLine("[Network] [Update] An update is needed"); + LogManager.LogToForm("[Network] [Update] An update is needed"); netStore.Save(Directory.GetCurrentDirectory() + @"\update.xml"); setVar(@""); } @@ -630,14 +636,14 @@ namespace OpenFK } catch { - Debug.WriteLine("[Network] [Update] FSGUI Update.xml was not found"); + LogManager.LogToForm("[Network] [Update] FSGUI Update.xml was not found"); } setVar(@""); try { - Debug.WriteLine("[Network] [Update] Downloading FSGUI Update.xml from GitHub"); + LogManager.LogToForm("[Network] [Update] Downloading FSGUI Update.xml from GitHub"); fsnetStore = XDocument.Parse(Get(@"https://raw.githubusercontent.com/GittyMac/FunkeySelectorGUI/master/update.xml")); - Debug.WriteLine("[Network] [Update] FSGUI Update.xml was downloaded"); + LogManager.LogToForm("[Network] [Update] FSGUI Update.xml was downloaded"); string fsnetVersion = fsnetStore.Root.Attribute("name").Value; string fsnetVersionNum = fsnetStore.Root.Attribute("version").Value; string fsnetVersionSize = fsnetStore.Root.Attribute("size").Value; @@ -651,9 +657,9 @@ namespace OpenFK } catch { - Debug.WriteLine("[Network] [Update] Cannot close FSGUI"); + LogManager.LogToForm("[Network] [Update] Cannot close FSGUI"); } - Debug.WriteLine("[Network] [Update] A FSGUI update is needed"); + LogManager.LogToForm("[Network] [Update] A FSGUI update is needed"); setVar(@""); } else @@ -663,7 +669,7 @@ namespace OpenFK } catch { - Debug.WriteLine("[Network] [Update] No FSGUI update"); + LogManager.LogToForm("[Network] [Update] No FSGUI update"); setVar(@""); } } @@ -674,7 +680,7 @@ namespace OpenFK } catch { - Debug.WriteLine("[Network] [Update] No update"); + LogManager.LogToForm("[Network] [Update] No update"); setVar(@""); } } @@ -753,7 +759,7 @@ namespace OpenFK savepassword = xn.Attributes["savepassword"].Value; hintq = xn.Attributes["hintq"].Value; hinta = xn.Attributes["hinta"].Value; - Debug.WriteLine("[Load] File Requested - system/users"); + LogManager.LogToForm("[Load] File Requested - system/users"); loadFile("users", "system"); string userString = userData.OuterXml; string data2send = userString.Replace("", "") + @""; @@ -768,7 +774,7 @@ namespace OpenFK File.WriteAllBytes(Directory.GetCurrentDirectory() + @"\data\" + "system" + @"\" + "users" + ".rdf", iso_8859_1.GetBytes(RDFTool.encode(iso_8859_1.GetString(RDFData)))); } else File.WriteAllText(Directory.GetCurrentDirectory() + @"\data\" + "system" + @"\" + "users" + ".xml", data2send.ToString()); //saves - Debug.WriteLine("[UserAdd] Successfully added user - " + username); //Debug Output + LogManager.LogToForm("[UserAdd] Successfully added user - " + username); //Debug Output } } @@ -910,7 +916,7 @@ namespace OpenFK index = @""; //I would just let dotNET handle this, but UGLevels needs an error to continue. } setVar(index.ToString()); //Sends XML data to the game - Debug.WriteLine("[Load] Successfully loaded - " + folder + "/" + file); //Debug Output + LogManager.LogToForm("[Load] Successfully loaded - " + folder + "/" + file); //Debug Output } // @@ -923,6 +929,7 @@ namespace OpenFK public void setVar(string msg) { + LogManager.LogToForm("[SetVar/Return] Returned Message - " + msg); AS2Container.SetVariable("msg", msg); //Sends message (msg) to the game } diff --git a/OpenFK/OFK.Common/LogManager.cs b/OpenFK/OFK.Common/LogManager.cs new file mode 100644 index 0000000..b15f00f --- /dev/null +++ b/OpenFK/OFK.Common/LogManager.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OpenFK.OFK.Common +{ + static class LogManager + { + public static RichTextBox debugLogText; + public static void LogToForm(string logElement) + { + if(debugLogText != null) + { + try + { + debugLogText.AppendText("\n" + logElement); + } + catch + { + Debug.WriteLine(logElement); + } + } + } + } +} diff --git a/OpenFK/OpenFK.csproj b/OpenFK/OpenFK.csproj index 0b673f0..6717e89 100644 --- a/OpenFK/OpenFK.csproj +++ b/OpenFK/OpenFK.csproj @@ -117,6 +117,12 @@ ConfigForm.cs + + Form + + + DebugWindow.cs + Component @@ -126,12 +132,16 @@ Form1.cs + ConfigForm.cs + + DebugWindow.cs + Form1.cs diff --git a/OpenFK/Program.cs b/OpenFK/Program.cs index d199733..e03b6f6 100644 --- a/OpenFK/Program.cs +++ b/OpenFK/Program.cs @@ -45,7 +45,7 @@ namespace OpenFK { try { - Application.Run(new Form1()); + Application.Run(new Form1(args)); } catch { @@ -57,7 +57,7 @@ namespace OpenFK { try { - Application.Run(new Form1()); + Application.Run(new Form1(args)); } catch { diff --git a/OpenFK/Properties/AssemblyInfo.cs b/OpenFK/Properties/AssemblyInfo.cs index 3b7b4a3..9c5b72d 100644 --- a/OpenFK/Properties/AssemblyInfo.cs +++ b/OpenFK/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("GittyMac")] [assembly: AssemblyProduct("OpenFK")] -[assembly: AssemblyCopyright("Copyright © GittyMac 2022")] +[assembly: AssemblyCopyright("Copyright © GittyMac 2023")] [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("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("3.0.0.0")] +[assembly: AssemblyFileVersion("3.0.0.0")]