diff --git a/src/cam.py b/src/cam.py index b47b052e..4688642f 100644 --- a/src/cam.py +++ b/src/cam.py @@ -97,4 +97,5 @@ def window_to_abs_window(self, window_coord: np.ndarray) -> np.ndarray: @convert_args_to_numpy def abs_window_to_monitor(self, abs_window_coord: np.ndarray) -> np.ndarray: - return self.window_to_monitor(self.abs_window_to_window(abs_window_coord)) + window_coord = self.abs_window_to_window(abs_window_coord) + return self.window_to_monitor(window_coord) diff --git a/src/loot_filter.py b/src/loot_filter.py index 5cc095db..51c0e12f 100644 --- a/src/loot_filter.py +++ b/src/loot_filter.py @@ -81,12 +81,12 @@ def run_loot_filter(): for i in range(check_tabs): chest.switch_to_tab(i) check_items(chest) - elif not inv.is_open(): - inv.open() - if not inv.is_open(): - screenshot("inventory_not_open", img=Cam().grab()) - Logger.error("Inventory did not open up") - return - check_items(inv) + check_items(inv) + else: + if not inv.open(): + screenshot("inventory_not_open", img=Cam().grab()) + Logger.error("Inventory did not open up") + return + check_items(inv) mouse.move(*Cam().abs_window_to_monitor((0, 0))) Logger().info("Loot Filter done") diff --git a/src/overlay.py b/src/overlay.py index 173b6c0b..4a219f06 100644 --- a/src/overlay.py +++ b/src/overlay.py @@ -8,6 +8,7 @@ import logging from scripts.rogue_tb import run_rogue_tb from config import Config +from cam import Cam class ListboxHandler(logging.Handler): @@ -41,9 +42,11 @@ def __init__(self): self.maximized_height = int(self.initial_height * 3.4) self.maximized_width = int(self.initial_width * 5) + self.screen_off_x = Cam().window_roi["left"] + self.screen_off_y = Cam().window_roi["top"] self.canvas = tk.Canvas(self.root, bg="black", height=self.initial_height, width=self.initial_width, highlightthickness=0) self.root.geometry( - f"{self.initial_width}x{self.initial_height}+{self.screen_width//2 - self.initial_width//2}+{self.screen_height - self.initial_height}" + f"{self.initial_width}x{self.initial_height}+{self.screen_width//2 - self.initial_width//2 + self.screen_off_x}+{self.screen_height - self.initial_height + self.screen_off_y}" ) self.canvas.pack() @@ -110,12 +113,12 @@ def toggle_size(self): if not self.is_minimized: self.canvas.config(height=self.initial_height, width=self.initial_width) self.root.geometry( - f"{self.initial_width}x{self.initial_height}+{self.screen_width//2 - self.initial_width//2}+{self.screen_height - self.initial_height}" + f"{self.initial_width}x{self.initial_height}+{self.screen_width//2 - self.initial_width//2 + self.screen_off_x}+{self.screen_height - self.initial_height + self.screen_off_y}" ) else: self.canvas.config(height=self.maximized_height, width=self.maximized_width) self.root.geometry( - f"{self.maximized_width}x{self.maximized_height}+{self.screen_width//2 - self.maximized_width//2}+{self.screen_height - self.maximized_height}" + f"{self.maximized_width}x{self.maximized_height}+{self.screen_width//2 - self.maximized_width//2 + self.screen_off_x}+{self.screen_height - self.maximized_height + self.screen_off_y}" ) self.is_minimized = not self.is_minimized move_window_to_foreground() diff --git a/src/ui/inventory_base.py b/src/ui/inventory_base.py index f927d695..2ade8921 100644 --- a/src/ui/inventory_base.py +++ b/src/ui/inventory_base.py @@ -49,8 +49,8 @@ def get_item_slots(self, img: Optional[np.ndarray] = None) -> tuple[list[ItemSlo for _, slot_roi in enumerate(grid): slot_img = crop(img, slot_roi) hsv_image = cv2.cvtColor(slot_img, cv2.COLOR_BGR2HSV) - mean_value_of_high = np.mean(hsv_image[:, :, 2]) - if mean_value_of_high > 53: + mean_value = np.mean(hsv_image[:, :, 2]) + if mean_value > 37: occupied_slots.append(ItemSlot(bounding_box=slot_roi, center=get_center(slot_roi))) else: empty_slots.append(ItemSlot(bounding_box=slot_roi, center=get_center(slot_roi))) diff --git a/src/utils/window.py b/src/utils/window.py index 644e1cd3..e4b79653 100644 --- a/src/utils/window.py +++ b/src/utils/window.py @@ -78,8 +78,8 @@ def detect_window(window_spec: WindowSpec = D4_WINDOW): def find_and_set_window_position(window_spec: WindowSpec = D4_WINDOW): hwnd = get_window_spec_id(window_spec) if hwnd is not None: - position = GetWindowRect(hwnd) - Cam().update_window_pos(*position) + pos = GetWindowRect(hwnd) + Cam().update_window_pos(pos[0], pos[1], pos[2] - pos[0], pos[3] - pos[1]) wait(0.5)