Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 1440p templates #26

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/templates_2560x1440/item_descr/affix_bullet_point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/templates_2560x1440/item_descr/aspect_bullet_point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/templates_2560x1440/item_descr/empty_socket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 22 additions & 16 deletions src/item/read_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
from rapidfuzz import process
from config import Config


# Some aspects have their variable number as second (number_idx_1) or third (number_idx_2)
ASPECT_NUMBER_AT_IDX1 = [
"frostbitten_aspect",
"aspect_of_artful_initiative",
"aspect_of_noxious_ice",
"elementalists_aspect",
"snowveiled_aspect",
"aspect_of_might",
]
ASPECT_NUMBER_AT_IDX2 = [
"aspect_of_retribution",
]

affix_dict = dict()
with open("assets/affixes.json", "r") as f:
affix_dict = json.load(f)
Expand Down Expand Up @@ -114,10 +128,13 @@ def read_descr(rarity: ItemRarity, img_item_descr: np.ndarray) -> Item:
item_power_numbers = preceding_word.split("+")
item.power = int(item_power_numbers[0]) + int(item_power_numbers[1])
max_length = 0
last_char_idx = 0
for item_type in ItemType:
if item_type.value in concatenated_str:
if len(item_type.value) > max_length:
if (found_idx := concatenated_str.rfind(item_type.value)) != -1:
tmp_idx = found_idx + len(item_type.value)
if tmp_idx >= last_char_idx and len(item_type.value) > max_length:
item.type = item_type
last_char_idx = tmp_idx
max_length = len(item_type.value)
# common mistake is that "Armor" is on a seperate line and can not be detected properly
if item.type is None:
Expand All @@ -133,7 +150,7 @@ def read_descr(rarity: ItemRarity, img_item_descr: np.ndarray) -> Item:
# Detect textures (2)
# =====================================
start_tex_2 = time.time()
roi_bullets = [0, sep_short_match.center[1], Config().ui_offsets["find_bullet_points_width"], img_height]
roi_bullets = [0, sep_short_match.center[1], Config().ui_offsets["find_bullet_points_width"] + 20, img_height]
if not (affix_bullets := search("affix_bullet_point", img_item_descr, 0.87, roi_bullets, True, mode="all")).success:
Logger.warning("Could not detect affix_bullet_points.")
screenshot("failed_affix_bullet_points", img=img_item_descr)
Expand Down Expand Up @@ -233,20 +250,9 @@ def read_descr(rarity: ItemRarity, img_item_descr: np.ndarray) -> Item:
cleaned_str = _clean_str(concatenated_str)
found_key = _closest_match(cleaned_str, aspect_dict, min_score=77)

# some aspects have their variable number as second:
number_idx_1 = [
"frostbitten_aspect",
"aspect_of_artful_initiative",
"aspect_of_noxious_ice",
"elementalists_aspect",
"snowveiled_aspect",
]
number_idx_2 = [
"aspect_of_retribution",
]
if found_key in number_idx_1:
if found_key in ASPECT_NUMBER_AT_IDX1:
idx = 1
elif found_key in number_idx_2:
elif found_key in ASPECT_NUMBER_AT_IDX2:
idx = 2
else:
idx = 0
Expand Down
4 changes: 2 additions & 2 deletions src/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def _wrapper_run_loot_filter(self):
try:
run_loot_filter()
finally:
if not self.is_minimized:
self.toggle_size()
self.loot_filter_thread = None

def run_scripts(self):
Expand All @@ -147,8 +149,6 @@ def run_scripts(self):
kill_thread(script_thread)
self.script_threads = []
return
if self.is_minimized:
self.toggle_size()
if len(Config().general["run_scripts"]) == 0:
Logger.info("No scripts configured")
return
Expand Down