Skip to content

Commit

Permalink
Fixes affix detection issue for rare items.
Browse files Browse the repository at this point in the history
Updated data for v1.4.2.54489
  • Loading branch information
josdemmers committed Jun 11, 2024
1 parent a2023e4 commit 5e0a761
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 370 deletions.
30 changes: 27 additions & 3 deletions D4Companion.Services/OcrHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Prism.Events;
using D4Companion.Events;
using System.Text.RegularExpressions;
using System.Linq;
using D4DataParser.Entities;
using System.Collections.Concurrent;

Expand Down Expand Up @@ -302,8 +301,33 @@ public string ConvertToText(Image image)
{
using (var page = engine.Process(img))
{
var block = page.Layout.FirstOrDefault();
return block?.Text ?? page.Text;
List<(string text, Rect? boundingBox)> lines = new List<(string text, Rect? boundingBox)>();

foreach (var block in page.Layout)
{
foreach (var paragraph in block.Paragraphs)
{
foreach (var textLine in paragraph.TextLines)
{
lines.Add((textLine.Text, textLine.BoundingBox));
}
}
}

if (lines.Count > 0)
{
// Check the x-position of each line to remove right aligned text, e.g, Requires Level.
int startPosText = lines[0].boundingBox?.X1 ?? 0;
int xPosOffset = 20;

lines.RemoveAll(line =>
{
return line.boundingBox != null && line.boundingBox.Value.X1 > startPosText + xPosOffset;
});
return string.Join(' ', lines.Select(line => line.text));
}

return page.Text;
}
}
}
Expand Down
50 changes: 25 additions & 25 deletions D4Companion/Data/Affixes.itIT.json
Original file line number Diff line number Diff line change
Expand Up @@ -2598,31 +2598,6 @@
}
]
},
{
"IdSno": 1934895,
"IdName": "Tempered_Damage_Sorc_Skill_IceSpikes_Tier3",
"ClassRestriction": "(Solo Incantatore)",
"Description": "Danni da Aculeo di Ghiaccio: +#%",
"DescriptionClean": "Danni da Aculeo di Ghiaccio: (Solo Incantatore)",
"IsTemperingAvailable": true,
"MagicType": 0,
"AllowedForPlayerClass": [
1,
0,
0,
0,
0
],
"AllowedItemLabels": [],
"AffixAttributes": [
{
"LocalisationId": "Power_Damage_Percent_Bonus",
"LocalisationParameter": 1040745,
"LocalisationAttributeFormulaValue": "0",
"Localisation": "Danni da {c_important}{VALUE1}{/c}: +[{VALUE2}*100|1%|]"
}
]
},
{
"IdSno": 1862126,
"IdName": "Tempered_Damage_Barb_Skill_Leap_Tier3",
Expand Down Expand Up @@ -4011,6 +3986,31 @@
}
]
},
{
"IdSno": 1934895,
"IdName": "Tempered_Damage_Sorc_Skill_IceSpikes_Tier3",
"ClassRestriction": "(Solo Incantatore)",
"Description": "Danni da Spuntone di Ghiaccio: +#%",
"DescriptionClean": "Danni da Spuntone di Ghiaccio: (Solo Incantatore)",
"IsTemperingAvailable": true,
"MagicType": 0,
"AllowedForPlayerClass": [
1,
0,
0,
0,
0
],
"AllowedItemLabels": [],
"AffixAttributes": [
{
"LocalisationId": "Power_Damage_Percent_Bonus",
"LocalisationParameter": 1040745,
"LocalisationAttributeFormulaValue": "0",
"Localisation": "Danni da {c_important}{VALUE1}{/c}: +[{VALUE2}*100|1%|]"
}
]
},
{
"IdSno": 1862106,
"IdName": "Tempered_Damage_Barb_Skill_Rupture_Tier3",
Expand Down
72 changes: 36 additions & 36 deletions D4Companion/Data/Affixes.plPL.json
Original file line number Diff line number Diff line change
Expand Up @@ -4321,8 +4321,8 @@
"IdSno": 1859261,
"IdName": "Tempered_PassiveRankBonus_Barb_Berserker_T2_N2_ExposeVulnerability_Tier3",
"ClassRestriction": "(Tylko barbarzyńcy)",
"Description": "+# do: Odsłonięcie Wrażliwości",
"DescriptionClean": "do: Odsłonięcie Wrażliwości (Tylko barbarzyńcy)",
"Description": "+# do: Odsłonięcie na Atak",
"DescriptionClean": "do: Odsłonięcie na Atak (Tylko barbarzyńcy)",
"IsTemperingAvailable": true,
"MagicType": 0,
"AllowedForPlayerClass": [
Expand Down Expand Up @@ -8614,40 +8614,6 @@
}
]
},
{
"IdSno": 1834296,
"IdName": "S04_Resistance_All",
"ClassRestriction": "",
"Description": "+#% do Odporności na wszystkie żywioły",
"DescriptionClean": "do Odporności na wszystkie żywioły",
"IsTemperingAvailable": false,
"MagicType": 0,
"AllowedForPlayerClass": [
1,
1,
1,
1,
1
],
"AllowedItemLabels": [
26,
29,
17,
28,
16,
30,
19,
15
],
"AffixAttributes": [
{
"LocalisationId": "Resistance_All",
"LocalisationParameter": 4294967295,
"LocalisationAttributeFormulaValue": "0",
"Localisation": "+[{VALUE}*100|1%|] do Odporności na wszystkie żywioły"
}
]
},
{
"IdSno": 1862244,
"IdName": "Tempered_Generic_Resistance_Single_Lightning_Tier3",
Expand Down Expand Up @@ -8898,6 +8864,40 @@
}
]
},
{
"IdSno": 1834296,
"IdName": "S04_Resistance_All",
"ClassRestriction": "",
"Description": "+#% do odporności na wszystkie żywioły",
"DescriptionClean": "do odporności na wszystkie żywioły",
"IsTemperingAvailable": false,
"MagicType": 0,
"AllowedForPlayerClass": [
1,
1,
1,
1,
1
],
"AllowedItemLabels": [
26,
29,
17,
28,
16,
30,
19,
15
],
"AffixAttributes": [
{
"LocalisationId": "Resistance_All",
"LocalisationParameter": 4294967295,
"LocalisationAttributeFormulaValue": "0",
"Localisation": "+[{VALUE}*100|1%|] do odporności na wszystkie żywioły"
}
]
},
{
"IdSno": 1936620,
"IdName": "Tempered_Resource_After_Skill_Rogue_InvigoratingStrike_Tier3",
Expand Down
50 changes: 25 additions & 25 deletions D4Companion/Data/Affixes.trTR.json
Original file line number Diff line number Diff line change
Expand Up @@ -7838,6 +7838,31 @@
}
]
},
{
"IdSno": 1859261,
"IdName": "Tempered_PassiveRankBonus_Barb_Berserker_T2_N2_ExposeVulnerability_Tier3",
"ClassRestriction": "(Sadece Barbar)",
"Description": "Açığını Bulma için +#",
"DescriptionClean": "Açığını Bulma için (Sadece Barbar)",
"IsTemperingAvailable": true,
"MagicType": 0,
"AllowedForPlayerClass": [
0,
0,
1,
0,
0
],
"AllowedItemLabels": [],
"AffixAttributes": [
{
"LocalisationId": "Talent_Rank_Bonus",
"LocalisationParameter": 212832,
"LocalisationAttributeFormulaValue": "FloatRandomRangeWithInterval(1,1,2)",
"Localisation": "{c_important}{VALUE1}{/c} için +{VALUE2}"
}
]
},
{
"IdSno": 1928773,
"IdName": "S04_SkillRankBonus_Rogue_Category_Imbuements",
Expand Down Expand Up @@ -13471,31 +13496,6 @@
}
]
},
{
"IdSno": 1859261,
"IdName": "Tempered_PassiveRankBonus_Barb_Berserker_T2_N2_ExposeVulnerability_Tier3",
"ClassRestriction": "(Sadece Barbar)",
"Description": "Zayıflığı Ortaya Çıkar için +#",
"DescriptionClean": "Zayıflığı Ortaya Çıkar için (Sadece Barbar)",
"IsTemperingAvailable": true,
"MagicType": 0,
"AllowedForPlayerClass": [
0,
0,
1,
0,
0
],
"AllowedItemLabels": [],
"AffixAttributes": [
{
"LocalisationId": "Talent_Rank_Bonus",
"LocalisationParameter": 212832,
"LocalisationAttributeFormulaValue": "FloatRandomRangeWithInterval(1,1,2)",
"Localisation": "{c_important}{VALUE1}{/c} için +{VALUE2}"
}
]
},
{
"IdSno": 1873221,
"IdName": "S04_SkillRankBonus_Rogue_Special_PoisonImbue",
Expand Down
Loading

0 comments on commit 5e0a761

Please sign in to comment.