refactor(pixel): Remove last of hardcoded pixel values

This commit is contained in:
aeon0
2021-11-06 14:56:47 +01:00
parent c751259319
commit 06b0d4fb27
4 changed files with 5 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import keyboard
from logger import Logger
import time
from typing import Dict, Tuple
from config import Config
def abstract(f):
@@ -27,6 +28,7 @@ class IChar:
self._template_finder = template_finder
self._ui_manager = ui_manager
self._screen = screen
self._config = Config()
def select_by_template(self, template_type: str) -> bool:
Logger.debug(f"Select {template_type}")
@@ -67,8 +69,7 @@ class IChar:
mouse.click(button="right")
custom_mouse.move(1400 + random.randrange(0, 60), 300 + random.randrange(0, 60), duration=0.1)
time.sleep(1.4) # takes quite a while for tp to be visible
# TODO: 1920x1080 specific params
roi=[530, 180, 820, 600]
roi = self._config.ui_roi["tp_search"]
start = time.time()
while (time.time() - start) < 7:
img = self._screen.grab()

View File

@@ -34,7 +34,6 @@ class Pather:
self._config = Config()
self._screen = screen
self._template_finder = template_finder
# TODO: params based on 1920x1080 (in rel coordinates to ref point)
self._range_x = [-self._config.ui_pos["center_x"] + 10, self._config.ui_pos["center_x"] - 10]
self._range_y = [-self._config.ui_pos["center_y"] + 10, self._config.ui_pos["center_y"] - self._config.ui_pos["skill_bar_height"] - 10]
self._nodes = {

View File

@@ -132,8 +132,7 @@ class TemplateFinder:
start = time.time()
while 1:
img = self._screen.grab()
# TODO: 1920x1080 specific params
is_loading_black_roi = np.average(img[:, 0:500]) < 1.0
is_loading_black_roi = np.average(img[:, 0:self._config.ui_roi["loading_left_black"][2]]) < 1.0
success, pos = self.search(ref, img, roi=roi, threshold=threshold)
if not is_loading_black_roi and success:
return True, pos

1
ui.ini
View File

@@ -94,3 +94,4 @@ cut_skill_bar=0,0,1920,980
merc_icon=0,0,150,150
loading_left_black=0,0,500,1080
death=770,290,380,75
tp_search=530,180,820,600