BugFix: Fix indicator_location_to_tab_count (#708)

1) 4 tabs instead of 3
2) Return value should be integer when failed
This commit is contained in:
roozhou
2022-04-17 03:47:34 -07:00
committed by GitHub
parent 16bf599d88
commit a5d7fdaffa

View File

@@ -168,10 +168,11 @@ def tab_properties(idx: int = 0) -> dict[int, int, tuple]:
}
def indicator_location_to_tab_count(pos: tuple) -> int:
for i in range(3):
for i in range(4):
tab = tab_properties(i)
if tab["left"] <= pos[0] < tab["right"]:
return i
return -1
def get_active_tab(indicator: TemplateMatch = None) -> int:
indicator = detect_screen_object(ScreenObjects.TabIndicator) if indicator is None else indicator
@@ -179,7 +180,7 @@ def get_active_tab(indicator: TemplateMatch = None) -> int:
return indicator_location_to_tab_count(indicator.center)
else:
Logger.error("common/get_active_tab(): Error finding tab indicator")
return False
return -1
def select_tab(idx: int):
# stash or vendor must be open
@@ -216,4 +217,4 @@ if __name__ == "__main__":
print(np.sum(b))
cv2.imshow('test', b)
key = cv2.waitKey(1)
key = cv2.waitKey(1)