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 second screen issues #21

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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
3 changes: 2 additions & 1 deletion src/cam.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 7 additions & 7 deletions src/loot_filter.py
Original file line number Diff line number Diff line change
@@ -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")
9 changes: 6 additions & 3 deletions src/overlay.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions src/ui/inventory_base.py
Original file line number Diff line number Diff line change
@@ -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)))
4 changes: 2 additions & 2 deletions src/utils/window.py
Original file line number Diff line number Diff line change
@@ -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)