mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-18 17:25:22 +00:00
perf: momotalk
This commit is contained in:
parent
5e229d7797
commit
dff39db5b6
@ -33,7 +33,7 @@ class MomoTalk(MomoTalkUI):
|
|||||||
return MomoTalkStatus.OPEN
|
return MomoTalkStatus.OPEN
|
||||||
case MomoTalkStatus.STORY:
|
case MomoTalkStatus.STORY:
|
||||||
if self.skip_story():
|
if self.skip_story():
|
||||||
return MomoTalkStatus.OPEN
|
return MomoTalkStatus.CHAT
|
||||||
case MomoTalkStatus.FINISHED:
|
case MomoTalkStatus.FINISHED:
|
||||||
return status
|
return status
|
||||||
case _:
|
case _:
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class MomoTalkUI(UI):
|
|||||||
super().__init__(config, device)
|
super().__init__(config, device)
|
||||||
self.swipe_vector_range = (0.65, 0.85)
|
self.swipe_vector_range = (0.65, 0.85)
|
||||||
self.list = CHAT_AREA
|
self.list = CHAT_AREA
|
||||||
|
self.click_coords = self.device.click_methods.get(self.config.Emulator_ControlMethod, self.device.click_adb)
|
||||||
|
|
||||||
def swipe_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
|
def swipe_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
|
||||||
"""
|
"""
|
||||||
@ -58,16 +59,6 @@ class MomoTalkUI(UI):
|
|||||||
vector = (-vector[0], -vector[1])
|
vector = (-vector[0], -vector[1])
|
||||||
main.device.swipe_vector(vector, self.list.button)
|
main.device.swipe_vector(vector, self.list.button)
|
||||||
|
|
||||||
def select_then_check(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper, similarity=0.85):
|
|
||||||
timer = Timer(5, 10).start()
|
|
||||||
while 1:
|
|
||||||
self.device.screenshot()
|
|
||||||
self.appear_then_click(dest_enter, interval=1, similarity=similarity)
|
|
||||||
if self.appear(dest_check, similarity=similarity):
|
|
||||||
return True
|
|
||||||
if timer.reached():
|
|
||||||
return False
|
|
||||||
|
|
||||||
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
||||||
timer = Timer(5, 10).start()
|
timer = Timer(5, 10).start()
|
||||||
while 1:
|
while 1:
|
||||||
@ -94,10 +85,8 @@ class MomoTalkUI(UI):
|
|||||||
def click_all(self, template, x_add=0, y_add=0):
|
def click_all(self, template, x_add=0, y_add=0):
|
||||||
"""
|
"""
|
||||||
Find the all the locations of the template adding an offset if specified and click them.
|
Find the all the locations of the template adding an offset if specified and click them.
|
||||||
TODO: filter coords that are not inside the chat area as otherwise it will close momotalk.
|
|
||||||
If after filter, no coords then swipe.
|
If after filter, no coords then swipe.
|
||||||
"""
|
"""
|
||||||
click_coords = self.device.click_methods.get(self.config.Emulator_ControlMethod, self.device.click_adb)
|
|
||||||
image = self.device.screenshot()
|
image = self.device.screenshot()
|
||||||
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
||||||
threshold = 0.8
|
threshold = 0.8
|
||||||
@ -109,7 +98,7 @@ class MomoTalkUI(UI):
|
|||||||
if seen:
|
if seen:
|
||||||
if y_add != 0:
|
if y_add != 0:
|
||||||
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
|
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
|
||||||
[click_coords(coords[0], coords[1]) for coords in seen]
|
[self.click_coords(coords[0], coords[1]) for coords in seen]
|
||||||
self.swipe_page("down", self)
|
self.swipe_page("down", self)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user