Skip to content

Commit

Permalink
- Fixed item power detection.
Browse files Browse the repository at this point in the history
- Fixed item type detection.
  • Loading branch information
josdemmers committed Mar 26, 2024
1 parent ed05ac2 commit 20edc36
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions D4Companion.Services/OcrHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ public OcrResultItemType ConvertToItemType(string rawText)

// Check if there is an item power
int powerIndex = -1;
for (int i = 0; i < lines.Count; i++)
for (int i = lines.Count - 1; i >= 0; i--)
{
string resultString = Regex.Match(lines[i], @"\d+").Value;
if (resultString.Length >= 3)
// Item power 150 is the minimum value for Tier 1 items.
if (resultString.Length >= 3 && int.Parse(resultString) >= 150)
{
powerIndex = i;
break;
Expand Down Expand Up @@ -234,12 +235,13 @@ public OcrResult ConvertToPower(string rawText)
var lines = rawText.Split(new string[] { "\n" }, StringSplitOptions.None).ToList();
lines.RemoveAll(line => string.IsNullOrWhiteSpace(line));

foreach (var line in lines)
for (int i = lines.Count - 1; i >= 0; i--)
{
string resultString = Regex.Match(line, @"\d+").Value;
if (resultString.Length >= 3)
string resultString = Regex.Match(lines[i], @"\d+").Value;
// Item power 150 is the minimum value for Tier 1 items.
if (resultString.Length >= 3 && int.Parse(resultString) >= 150)
{
result.Text = line;
result.Text = lines[i];
result.TextClean = resultString;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions D4Companion/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<FileVersion>3.2.0.0</FileVersion>
<Version>3.2.0.0</Version>
<FileVersion>3.2.1.0</FileVersion>
<Version>3.2.1.0</Version>
<Copyright>Copyright © 2024</Copyright>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Currently the following system presets are included:
| 1440p_SMF_en | <img src="./D4Companion/Images/Flags/enUS.png"> | SDR (HDR off) with font set to medium for the English language | ![Static Badge](https://img.shields.io/badge/status-ready-green) | |
| 1600p_SMF_zh-CN | <img src="./D4Companion/Images/Flags/zhCN.png"> | SDR (HDR off) with font set to medium for the Chinese (Simplified) language | ![Static Badge](https://img.shields.io/badge/status-unknown-red) | |
| 2160p_HSF_en | <img src="./D4Companion/Images/Flags/enUS.png"> | HDR with font set to small for the English language. | ![Static Badge](https://img.shields.io/badge/status-unknown-red) | |
| 2160p_SSF_en | <img src="./D4Companion/Images/Flags/enUS.png"> | SDR (HDR off) with font set to small for the English language. | ![Static Badge](https://img.shields.io/badge/status-ready-yellow) | |
| 2160p_SSF_en | <img src="./D4Companion/Images/Flags/enUS.png"> | SDR (HDR off) with font set to small for the English language. | ![Static Badge](https://img.shields.io/badge/status-ready-green) | |

Each preset works for both normal and widescreen resolutions. e.g. for 2560x1440 and 3440x1440 use the 1440p preset.

Expand Down
Binary file modified downloads/systempresets-v3/2160p_SSF_en.zip
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions downloads/systempresets-v3/systempresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
"Language": "English (en)",
"TooltipWidth": "750",
"BrightnessThreshold": "60 / 255",
"AffixAreaHeightOffsetTop": "18",
"AffixAreaHeightOffsetBottom": "18",
"AffixAreaHeightOffsetTop": "12",
"AffixAreaHeightOffsetBottom": "12",
"AffixAspectAreaWidthOffset": "18",
"AspectAreaHeightOffsetTop": "18"
}
Expand Down

0 comments on commit 20edc36

Please sign in to comment.