From 3b45fb05fff2ec504abfc59489b2098addeae18b Mon Sep 17 00:00:00 2001 From: VladMordock Date: Wed, 17 Feb 2021 12:42:42 +0100 Subject: [PATCH] Current mission displayed at panel --- .../Perun_v1/01_Classes/DatabaseController.cs | 5 ++++ 02_Windows_App/Perun_v1/01_Classes/Globals.cs | 17 ++++++++++- .../Perun_v1/02_Forms/form_Main.Designer.cs | 28 ++++++++++++++----- 02_Windows_App/Perun_v1/02_Forms/form_Main.cs | 15 ++++++++++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs index 6955a34..dc9a5bf 100644 --- a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs @@ -118,6 +118,11 @@ public class DatabaseController SQLQueryTxt += "INSERT INTO `pe_OnlineStatus` (`pe_OnlineStatus_instance`) SELECT '" + Int32.Parse(TCPFrameInstance) + "' FROM DUAL WHERE NOT EXISTS(SELECT * FROM `pe_OnlineStatus` WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "');"; SQLQueryTxt += "UPDATE `pe_OnlineStatus` SET `pe_OnlineStatus_theatre` = '" + TCPFrame.payload.mission.theatre + "', `pe_OnlineStatus_name` = '" + TCPFrame.payload.mission.name + "' , `pe_OnlineStatus_pause` = '" + TCPFrame.payload.mission.pause + "', `pe_OnlineStatus_multiplayer` = '" + TCPFrame.payload.mission.multiplayer + "', `pe_OnlineStatus_realtime` = '" + TCPFrame.payload.mission.realtime + "', `pe_OnlineStatus_modeltime` = '" + TCPFrame.payload.mission.modeltime + "', `pe_OnlineStatus_players` = " + player_count + " WHERE `pe_OnlineStatus_instance` = '" + Int32.Parse(TCPFrameInstance) + "';"; + // Save for GUI + Globals.CurrentMission.Theatre = TCPFrame.payload.mission.theatre; + Globals.CurrentMission.Mission = TCPFrame.payload.mission.name; + Globals.CurrentMission.Pause = TCPFrame.payload.mission.pause; + break; default: diff --git a/02_Windows_App/Perun_v1/01_Classes/Globals.cs b/02_Windows_App/Perun_v1/01_Classes/Globals.cs index 1dcab73..7b47001 100644 --- a/02_Windows_App/Perun_v1/01_Classes/Globals.cs +++ b/02_Windows_App/Perun_v1/01_Classes/Globals.cs @@ -1,5 +1,19 @@ // This class gathers all global variable +// Class to hold current game state/mission information +class CurrentMissionClass +{ + + public string Theatre = ""; + public string Mission = ""; + public string Pause = ""; + + public string ToInfoString() + { + return this.Mission + " (" + this.Theatre + ") Pause:" + this.Pause; + } +} + internal class Globals { public static string[] AppLogHistory = new string[10]; // Log history for GUI @@ -11,7 +25,7 @@ internal class Globals public static bool StatusDatabase = false; // Historic db connection status public static bool StatusSRS = false; // Historic srs connection status public static bool StatusLotATC = false; // Historic lotatc connection status - public static bool StatusHistoryConnection = false; // Historic tcp connection status + public static bool StatusHistoryConnection = false; // Historic tcp connection status public static bool StatusConnection = false; // Flag if is TCP connectionstill alive public static int ErrorsDatabase = 0; // MySQL - Error counter public static int ErrorsGame = 0; // TCP connection - Error counter @@ -22,5 +36,6 @@ internal class Globals public static string VersionDCSHook = ""; // Version - DCS hook public static string VersionDatabase = ""; // Version - Database public static string VersionPerun = "DEBUG"; // Version - Perun + public static CurrentMissionClass CurrentMission = new CurrentMissionClass(); // Mission - name } diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs index 9f34d9c..f2bc0fc 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs @@ -73,6 +73,7 @@ this.TIM_Autostart = new System.Windows.Forms.Timer(this.components); this.con_check_minimize_to_tray = new System.Windows.Forms.CheckBox(); this.con_GroupBox_4 = new System.Windows.Forms.GroupBox(); + this.label16 = new System.Windows.Forms.Label(); this.con_Button_Reset_Flags = new System.Windows.Forms.Button(); this.label12 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); @@ -104,7 +105,7 @@ "Not connected"}); this.con_List_Received.Location = new System.Drawing.Point(8, 44); this.con_List_Received.Name = "con_List_Received"; - this.con_List_Received.Size = new System.Drawing.Size(307, 160); + this.con_List_Received.Size = new System.Drawing.Size(307, 121); this.con_List_Received.TabIndex = 0; // // con_Button_Listen_ON @@ -134,9 +135,9 @@ this.con_GroupBox_1.Controls.Add(this.con_com_loglevel); this.con_GroupBox_1.Controls.Add(this.con_List_Received); this.con_GroupBox_1.Controls.Add(this.con_Button_Add_Marker); - this.con_GroupBox_1.Location = new System.Drawing.Point(344, 147); + this.con_GroupBox_1.Location = new System.Drawing.Point(344, 177); this.con_GroupBox_1.Name = "con_GroupBox_1"; - this.con_GroupBox_1.Size = new System.Drawing.Size(324, 209); + this.con_GroupBox_1.Size = new System.Drawing.Size(324, 179); this.con_GroupBox_1.TabIndex = 4; this.con_GroupBox_1.TabStop = false; this.con_GroupBox_1.Text = "Data log"; @@ -146,7 +147,7 @@ this.label15.AutoSize = true; this.label15.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label15.Location = new System.Drawing.Point(9, 21); + this.label15.Location = new System.Drawing.Point(6, 18); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(50, 13); this.label15.TabIndex = 22; @@ -162,7 +163,7 @@ "Warning", "Info", "Debug"}); - this.con_com_loglevel.Location = new System.Drawing.Point(65, 18); + this.con_com_loglevel.Location = new System.Drawing.Point(62, 12); this.con_com_loglevel.Name = "con_com_loglevel"; this.con_com_loglevel.Size = new System.Drawing.Size(102, 20); this.con_com_loglevel.TabIndex = 23; @@ -172,7 +173,7 @@ // this.con_Button_Add_Marker.Enabled = false; this.con_Button_Add_Marker.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.con_Button_Add_Marker.Location = new System.Drawing.Point(229, 17); + this.con_Button_Add_Marker.Location = new System.Drawing.Point(232, 12); this.con_Button_Add_Marker.Name = "con_Button_Add_Marker"; this.con_Button_Add_Marker.Size = new System.Drawing.Size(86, 20); this.con_Button_Add_Marker.TabIndex = 21; @@ -490,6 +491,7 @@ // // con_GroupBox_4 // + this.con_GroupBox_4.Controls.Add(this.label16); this.con_GroupBox_4.Controls.Add(this.con_Button_Reset_Flags); this.con_GroupBox_4.Controls.Add(this.label12); this.con_GroupBox_4.Controls.Add(this.label11); @@ -501,11 +503,22 @@ this.con_GroupBox_4.Controls.Add(this.con_img_db); this.con_GroupBox_4.Location = new System.Drawing.Point(344, 54); this.con_GroupBox_4.Name = "con_GroupBox_4"; - this.con_GroupBox_4.Size = new System.Drawing.Size(324, 87); + this.con_GroupBox_4.Size = new System.Drawing.Size(324, 117); this.con_GroupBox_4.TabIndex = 25; this.con_GroupBox_4.TabStop = false; this.con_GroupBox_4.Text = "Status"; // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(6, 78); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(76, 13); + this.label16.TabIndex = 27; + this.label16.Text = "[mission name]"; + this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label16.Click += new System.EventHandler(this.label16_Click); + // // con_Button_Reset_Flags // this.con_Button_Reset_Flags.Enabled = false; @@ -712,6 +725,7 @@ private System.Windows.Forms.PictureBox con_img_dcs; private System.Windows.Forms.PictureBox con_img_db; private System.Windows.Forms.GroupBox con_GroupBox_5; + private System.Windows.Forms.Label label16; } } diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index 8b02756..5a5e454 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -103,6 +103,8 @@ namespace Perun_v1 con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); + this.form_Main_SetControlsInit(); + // Display information that we are runing debug build #if !DEBUG @@ -201,8 +203,14 @@ namespace Perun_v1 con_txt_dcs_instance.Enabled = true; con_com_loglevel.Enabled = true; + this.form_Main_SetControlsInit(); } + private void form_Main_SetControlsInit() + { + // Init values for the controls + label16.Text = ""; + } // ################################ User input ################################ private void con_Button_Listen_ON_Click(object sender, EventArgs e) { @@ -438,6 +446,9 @@ namespace Perun_v1 // Do nothing , control does not require update } + // Update mission status + label16.Text = Globals.CurrentMission.ToInfoString(); + // Update status icons at main form - MySQL if ((DatabaseConnection.DatabaseStatus != Globals.StatusDatabase) || Globals.AppForceIconReload) { @@ -701,5 +712,9 @@ namespace Perun_v1 con_Button_Listen_ON_Click(sender,e); // Simulate button click } + private void label16_Click(object sender, EventArgs e) + { + + } } }