From c5b9f6e7211ed059e85b97af7322108d71b5c3e3 Mon Sep 17 00:00:00 2001 From: jarig Date: Mon, 18 Jan 2016 21:52:37 +0200 Subject: [PATCH] default language code fix, configurable resolution assumption --- EliteReporter.sln | 6 +++ EliteReporter/App.config | 7 ++- EliteReporter/EliteReporter.csproj | 48 ++++++++++++++++++- EliteReporter/Forms/ReportForm.Designer.cs | 27 ++++++++++- EliteReporter/Forms/ReportForm.cs | 29 +++++++++-- EliteReporter/Forms/SettingsForm.Designer.cs | 4 +- EliteReporter/Properties/Settings.Designer.cs | 14 +++++- EliteReporter/Properties/Settings.settings | 5 +- EliteReporter/Utils/ScreenAnalyzer.cs | 9 ++-- 9 files changed, 133 insertions(+), 16 deletions(-) diff --git a/EliteReporter.sln b/EliteReporter.sln index 06f547b..75ff59c 100644 --- a/EliteReporter.sln +++ b/EliteReporter.sln @@ -9,18 +9,24 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|x64.ActiveCfg = Debug|x64 {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|x64.Build.0 = Debug|x64 + {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|x86.ActiveCfg = Debug|x86 + {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Debug|x86.Build.0 = Debug|x86 {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|Any CPU.Build.0 = Release|Any CPU {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|x64.ActiveCfg = Release|x64 {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|x64.Build.0 = Release|x64 + {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|x86.ActiveCfg = Release|x86 + {8F3440E0-32B2-4C98-9B31-20D2FD06F705}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EliteReporter/App.config b/EliteReporter/App.config index 0f8b814..2bd1ecd 100644 --- a/EliteReporter/App.config +++ b/EliteReporter/App.config @@ -5,13 +5,13 @@
- + - en + eng missions.json @@ -25,6 +25,9 @@ $exportedFile + + 1280, 800 + \ No newline at end of file diff --git a/EliteReporter/EliteReporter.csproj b/EliteReporter/EliteReporter.csproj index 72de3f3..dcc516e 100644 --- a/EliteReporter/EliteReporter.csproj +++ b/EliteReporter/EliteReporter.csproj @@ -15,6 +15,21 @@ true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -55,6 +70,26 @@ MinimumRecommendedRules.ruleset true + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + ..\packages\DuoVia.FuzzyStrings.1.0.1\lib\net40\DuoVia.FuzzyStrings.dll @@ -258,7 +293,18 @@ Always - + + + False + Microsoft .NET Framework 4.5.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + diff --git a/EliteReporter/Forms/ReportForm.Designer.cs b/EliteReporter/Forms/ReportForm.Designer.cs index 95c32f7..59686a3 100644 --- a/EliteReporter/Forms/ReportForm.Designer.cs +++ b/EliteReporter/Forms/ReportForm.Designer.cs @@ -45,6 +45,8 @@ private void InitializeComponent() this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.applicationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gameResolutionTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -124,11 +126,11 @@ private void InitializeComponent() // this.missionDetailTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); - this.missionDetailTextBox.Location = new System.Drawing.Point(632, 26); + this.missionDetailTextBox.Location = new System.Drawing.Point(632, 102); this.missionDetailTextBox.Margin = new System.Windows.Forms.Padding(2); this.missionDetailTextBox.Name = "missionDetailTextBox"; this.missionDetailTextBox.ReadOnly = true; - this.missionDetailTextBox.Size = new System.Drawing.Size(191, 360); + this.missionDetailTextBox.Size = new System.Drawing.Size(191, 284); this.missionDetailTextBox.TabIndex = 3; this.missionDetailTextBox.Text = ""; // @@ -190,11 +192,30 @@ private void InitializeComponent() this.settingsToolStripMenuItem.Text = "Settings"; this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click); // + // gameResolutionTextBox + // + this.gameResolutionTextBox.Location = new System.Drawing.Point(633, 51); + this.gameResolutionTextBox.Name = "gameResolutionTextBox"; + this.gameResolutionTextBox.Size = new System.Drawing.Size(190, 20); + this.gameResolutionTextBox.TabIndex = 7; + this.gameResolutionTextBox.TextChanged += new System.EventHandler(this.gameResolutionTextBox_TextChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(634, 32); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(97, 13); + this.label1.TabIndex = 8; + this.label1.Text = "Resolution in game"; + // // ReportForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(831, 454); + this.Controls.Add(this.label1); + this.Controls.Add(this.gameResolutionTextBox); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.exportButton); @@ -238,6 +259,8 @@ private void InitializeComponent() private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem applicationToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.TextBox gameResolutionTextBox; + private System.Windows.Forms.Label label1; } } diff --git a/EliteReporter/Forms/ReportForm.cs b/EliteReporter/Forms/ReportForm.cs index 530437e..9663d04 100644 --- a/EliteReporter/Forms/ReportForm.cs +++ b/EliteReporter/Forms/ReportForm.cs @@ -30,6 +30,7 @@ public ReportForm() InitializeComponent(); edapi = new EDAPI(); ghk = new GlobalHotkey(GlobalHotkey.CTRL + GlobalHotkey.ALT, Keys.M, this); + gameResolutionTextBox.Text = string.Format("{0};{1}", Properties.Settings.Default.GameResolution.Width, Properties.Settings.Default.GameResolution.Height); } private void RegisterMission() @@ -62,6 +63,8 @@ private void RegisterMission() { //new mission var edProfile = edapi.getProfile(); + if (string.IsNullOrEmpty(commanderName)) + commanderName = edProfile.CommanderName; result.MissionTakenDateTime = DateTime.UtcNow; result.MissionTakenEDProfile = edProfile; ListViewItem lvItem = new ListViewItem(result.MissionTakenDateTime.ToString("dd/MM/yyyy HH:mm")); @@ -92,7 +95,7 @@ private void activateButton_Click(object sender, EventArgs e) activateButton.Text = "Deactivate"; toolStripStatusLabel1.Text = "Watching for missions!"; ghk.Register(); - analyzer = new ScreenAnalyzer(Properties.Settings.Default.Language); + analyzer = new ScreenAnalyzer(Properties.Settings.Default.Language, Properties.Settings.Default.GameResolution); } } @@ -168,9 +171,29 @@ private void ReportForm_Shown(object sender, EventArgs e) //show login form showLoginForm(); } - commanderName = edapi.getProfile().CommanderName; - toolStripStatusLabel1.Text = "Welcome CMDR " + commanderName + ". "; + else + { + commanderName = edapi.getProfile().CommanderName; + if (!string.IsNullOrEmpty(commanderName)) + toolStripStatusLabel1.Text = "Welcome CMDR " + commanderName + ". "; + } toolStripStatusLabel1.Text += "Press Activate button to register global hotkey for mission registration (CTRL + ALT + M)"; } + + private void gameResolutionTextBox_TextChanged(object sender, EventArgs e) + { + try { + Properties.Settings.Default.GameResolution = new Size(int.Parse(gameResolutionTextBox.Text.Split(';')[0].Trim()), + int.Parse(gameResolutionTextBox.Text.Split(';')[1].Trim())); + if (analyzer != null) + analyzer.ScreenSize = Properties.Settings.Default.GameResolution; + toolStripStatusLabel1.Text = "Resolution changed to: " + Properties.Settings.Default.GameResolution; + Properties.Settings.Default.Save(); + } catch (Exception ex) + { + toolStripStatusLabel1.Text = "Error parsing resolution!"; + } + Properties.Settings.Default.Save(); + } } } diff --git a/EliteReporter/Forms/SettingsForm.Designer.cs b/EliteReporter/Forms/SettingsForm.Designer.cs index d7fe8f0..7daa4c3 100644 --- a/EliteReporter/Forms/SettingsForm.Designer.cs +++ b/EliteReporter/Forms/SettingsForm.Designer.cs @@ -63,7 +63,7 @@ private void InitializeComponent() // // saveButton // - this.saveButton.Location = new System.Drawing.Point(276, 258); + this.saveButton.Location = new System.Drawing.Point(280, 261); this.saveButton.Name = "saveButton"; this.saveButton.Size = new System.Drawing.Size(75, 45); this.saveButton.TabIndex = 2; @@ -73,7 +73,7 @@ private void InitializeComponent() // // closeButton // - this.closeButton.Location = new System.Drawing.Point(12, 258); + this.closeButton.Location = new System.Drawing.Point(12, 261); this.closeButton.Name = "closeButton"; this.closeButton.Size = new System.Drawing.Size(75, 45); this.closeButton.TabIndex = 3; diff --git a/EliteReporter/Properties/Settings.Designer.cs b/EliteReporter/Properties/Settings.Designer.cs index 351147d..0f52b0e 100644 --- a/EliteReporter/Properties/Settings.Designer.cs +++ b/EliteReporter/Properties/Settings.Designer.cs @@ -25,7 +25,7 @@ public static Settings Default { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("en")] + [global::System.Configuration.DefaultSettingValueAttribute("eng")] public string Language { get { return ((string)(this["Language"])); @@ -82,5 +82,17 @@ public string ExportCommandArgs { this["ExportCommandArgs"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1280, 800")] + public global::System.Drawing.Size GameResolution { + get { + return ((global::System.Drawing.Size)(this["GameResolution"])); + } + set { + this["GameResolution"] = value; + } + } } } diff --git a/EliteReporter/Properties/Settings.settings b/EliteReporter/Properties/Settings.settings index 4f08e1a..16af36d 100644 --- a/EliteReporter/Properties/Settings.settings +++ b/EliteReporter/Properties/Settings.settings @@ -3,7 +3,7 @@ - en + eng missions.json @@ -17,5 +17,8 @@ $exportedFile + + 1280, 800 + \ No newline at end of file diff --git a/EliteReporter/Utils/ScreenAnalyzer.cs b/EliteReporter/Utils/ScreenAnalyzer.cs index 553a3ec..fbc4410 100644 --- a/EliteReporter/Utils/ScreenAnalyzer.cs +++ b/EliteReporter/Utils/ScreenAnalyzer.cs @@ -20,16 +20,17 @@ public class ScreenAnalyzer { private Tesseract ocr; private Size baseSize = new Size(1280, 800); - private Size testSize = new Size(1280, 800); - public ScreenAnalyzer(string languageCode) + public Size ScreenSize { get; set; } + + public ScreenAnalyzer(string languageCode, Size screenSize) { + ScreenSize = screenSize; ocr = new Tesseract("Assets\\", languageCode, OcrEngineMode.TesseractCubeCombined); - //ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890"); } public MissionInfo findAndAnalyzeMissionSummaryPage(bool includeImages = false) { - double factor = ((double)testSize.Width / (double)baseSize.Width); + double factor = ((double)ScreenSize.Width / (double)baseSize.Width); var bounds = new Rectangle(0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); using (var bitmap = new Bitmap(bounds.Width, bounds.Height)) {