Skip to content

Commit

Permalink
default language code fix, configurable resolution assumption
Browse files Browse the repository at this point in the history
  • Loading branch information
jarig committed Jan 18, 2016
1 parent 14f50bc commit c5b9f6e
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 16 deletions.
6 changes: 6 additions & 0 deletions EliteReporter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions EliteReporter/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<section name="EliteReporter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<EliteReporter.Properties.Settings>
<setting name="Language" serializeAs="String">
<value>en</value>
<value>eng</value>
</setting>
<setting name="ExportFilePath" serializeAs="String">
<value>missions.json</value>
Expand All @@ -25,6 +25,9 @@
<setting name="ExportCommandArgs" serializeAs="String">
<value>$exportedFile</value>
</setting>
<setting name="GameResolution" serializeAs="String">
<value>1280, 800</value>
</setting>
</EliteReporter.Properties.Settings>
</userSettings>
</configuration>
48 changes: 47 additions & 1 deletion EliteReporter/EliteReporter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -55,6 +70,26 @@
<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>
<ItemGroup>
<Reference Include="DuoVia.FuzzyStrings, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DuoVia.FuzzyStrings.1.0.1\lib\net40\DuoVia.FuzzyStrings.dll</HintPath>
Expand Down Expand Up @@ -258,7 +293,18 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
27 changes: 25 additions & 2 deletions EliteReporter/Forms/ReportForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions EliteReporter/Forms/ReportForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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();
}
}
}
4 changes: 2 additions & 2 deletions EliteReporter/Forms/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion EliteReporter/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion EliteReporter/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Profiles />
<Settings>
<Setting Name="Language" Type="System.String" Scope="User">
<Value Profile="(Default)">en</Value>
<Value Profile="(Default)">eng</Value>
</Setting>
<Setting Name="ExportFilePath" Type="System.String" Scope="User">
<Value Profile="(Default)">missions.json</Value>
Expand All @@ -17,5 +17,8 @@
<Setting Name="ExportCommandArgs" Type="System.String" Scope="User">
<Value Profile="(Default)">$exportedFile</Value>
</Setting>
<Setting Name="GameResolution" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">1280, 800</Value>
</Setting>
</Settings>
</SettingsFile>
9 changes: 5 additions & 4 deletions EliteReporter/Utils/ScreenAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down

0 comments on commit c5b9f6e

Please sign in to comment.