Add: Switch among relic pages
BIN
assets/cn/relics/ui/ENHANCE_CHECK.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
assets/cn/relics/ui/FILTER_CONFIRM.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
assets/cn/relics/ui/FILTER_RESET.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
assets/en/relics/ui/ENHANCE_CHECK.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
assets/en/relics/ui/FILTER_CONFIRM.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/en/relics/ui/FILTER_RESET.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
assets/share/relics/ui/ENHANCE_FILTER.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/share/relics/ui/ENHANCE_GOTO_SALVAGE.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/share/relics/ui/SALVAGE_CHECK_OFF.SEARCH.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/share/relics/ui/SALVAGE_CHECK_OFF.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/share/relics/ui/SALVAGE_CHECK_ON.SEARCH.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/share/relics/ui/SALVAGE_CHECK_ON.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/share/relics/ui/SALVAGE_FILTER.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
106
tasks/relics/assets/assets_relics_ui.py
Normal file
@ -0,0 +1,106 @@
|
||||
from module.base.button import Button, ButtonWrapper
|
||||
|
||||
# This file was auto-generated, do not modify it manually. To generate:
|
||||
# ``` python -m dev_tools.button_extract ```
|
||||
|
||||
ENHANCE_CHECK = ButtonWrapper(
|
||||
name='ENHANCE_CHECK',
|
||||
cn=Button(
|
||||
file='./assets/cn/relics/ui/ENHANCE_CHECK.png',
|
||||
area=(1134, 645, 1185, 670),
|
||||
search=(1114, 625, 1205, 690),
|
||||
color=(179, 180, 180),
|
||||
button=(1134, 645, 1185, 670),
|
||||
),
|
||||
en=Button(
|
||||
file='./assets/en/relics/ui/ENHANCE_CHECK.png',
|
||||
area=(1115, 646, 1204, 671),
|
||||
search=(1095, 626, 1224, 691),
|
||||
color=(183, 184, 184),
|
||||
button=(1115, 646, 1204, 671),
|
||||
),
|
||||
)
|
||||
ENHANCE_FILTER = ButtonWrapper(
|
||||
name='ENHANCE_FILTER',
|
||||
share=Button(
|
||||
file='./assets/share/relics/ui/ENHANCE_FILTER.png',
|
||||
area=(159, 650, 185, 676),
|
||||
search=(139, 630, 205, 696),
|
||||
color=(193, 195, 196),
|
||||
button=(159, 650, 185, 676),
|
||||
),
|
||||
)
|
||||
ENHANCE_GOTO_SALVAGE = ButtonWrapper(
|
||||
name='ENHANCE_GOTO_SALVAGE',
|
||||
share=Button(
|
||||
file='./assets/share/relics/ui/ENHANCE_GOTO_SALVAGE.png',
|
||||
area=(685, 653, 705, 673),
|
||||
search=(665, 633, 725, 693),
|
||||
color=(140, 142, 143),
|
||||
button=(685, 653, 705, 673),
|
||||
),
|
||||
)
|
||||
FILTER_CONFIRM = ButtonWrapper(
|
||||
name='FILTER_CONFIRM',
|
||||
cn=Button(
|
||||
file='./assets/cn/relics/ui/FILTER_CONFIRM.png',
|
||||
area=(1103, 651, 1151, 677),
|
||||
search=(1083, 631, 1171, 697),
|
||||
color=(180, 180, 180),
|
||||
button=(1103, 651, 1151, 677),
|
||||
),
|
||||
en=Button(
|
||||
file='./assets/en/relics/ui/FILTER_CONFIRM.png',
|
||||
area=(1081, 652, 1172, 677),
|
||||
search=(1061, 632, 1192, 697),
|
||||
color=(189, 189, 189),
|
||||
button=(1081, 652, 1172, 677),
|
||||
),
|
||||
)
|
||||
FILTER_RESET = ButtonWrapper(
|
||||
name='FILTER_RESET',
|
||||
cn=Button(
|
||||
file='./assets/cn/relics/ui/FILTER_RESET.png',
|
||||
area=(887, 652, 936, 675),
|
||||
search=(867, 632, 956, 695),
|
||||
color=(160, 160, 160),
|
||||
button=(887, 652, 936, 675),
|
||||
),
|
||||
en=Button(
|
||||
file='./assets/en/relics/ui/FILTER_RESET.png',
|
||||
area=(879, 652, 946, 677),
|
||||
search=(859, 632, 966, 697),
|
||||
color=(185, 185, 185),
|
||||
button=(879, 652, 946, 677),
|
||||
),
|
||||
)
|
||||
SALVAGE_CHECK_OFF = ButtonWrapper(
|
||||
name='SALVAGE_CHECK_OFF',
|
||||
share=Button(
|
||||
file='./assets/share/relics/ui/SALVAGE_CHECK_OFF.png',
|
||||
area=(1067, 646, 1091, 670),
|
||||
search=(1002, 641, 1143, 675),
|
||||
color=(54, 55, 48),
|
||||
button=(1067, 646, 1091, 670),
|
||||
),
|
||||
)
|
||||
SALVAGE_CHECK_ON = ButtonWrapper(
|
||||
name='SALVAGE_CHECK_ON',
|
||||
share=Button(
|
||||
file='./assets/share/relics/ui/SALVAGE_CHECK_ON.png',
|
||||
area=(1067, 646, 1091, 670),
|
||||
search=(1002, 641, 1143, 675),
|
||||
color=(124, 116, 99),
|
||||
button=(1067, 646, 1091, 670),
|
||||
),
|
||||
)
|
||||
SALVAGE_FILTER = ButtonWrapper(
|
||||
name='SALVAGE_FILTER',
|
||||
share=Button(
|
||||
file='./assets/share/relics/ui/SALVAGE_FILTER.png',
|
||||
area=(441, 645, 467, 671),
|
||||
search=(421, 625, 487, 691),
|
||||
color=(193, 194, 195),
|
||||
button=(441, 645, 467, 671),
|
||||
),
|
||||
)
|
257
tasks/relics/ui.py
Normal file
@ -0,0 +1,257 @@
|
||||
from module.logger import logger
|
||||
from tasks.base.assets.assets_base_page import CLOSE
|
||||
from tasks.base.page import page_item
|
||||
from tasks.item.keywords import KEYWORDS_ITEM_TAB
|
||||
from tasks.item.ui import ItemUI
|
||||
from tasks.relics.assets.assets_relics_ui import *
|
||||
|
||||
|
||||
class RelicsUI(ItemUI):
|
||||
def is_in_relics_enhance(self, interval=0):
|
||||
if self.appear(ENHANCE_CHECK, interval=interval):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_in_relics_salvage(self, interval=0):
|
||||
if self.appear(SALVAGE_CHECK_OFF, interval=interval):
|
||||
return True
|
||||
if self.appear(SALVAGE_CHECK_ON, interval=interval):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_filter_active(self, button, interval=0) -> bool:
|
||||
"""
|
||||
Args:
|
||||
button: ENHANCE_FILTER or SALVAGE_FILTER
|
||||
interval:
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
self.device.stuck_record_add(button)
|
||||
|
||||
if interval and not self.interval_is_reached(button, interval=interval):
|
||||
return False
|
||||
|
||||
appear = self.image_color_count(button, color=(242, 158, 56), threshold=180, count=20)
|
||||
|
||||
if appear and interval:
|
||||
self.interval_reset(button, interval=interval)
|
||||
|
||||
return appear
|
||||
|
||||
def is_filter_appear(self, button, interval=0) -> bool:
|
||||
if self.appear(button, interval=interval):
|
||||
return True
|
||||
if self.is_filter_active(button, interval=interval):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_filter_opened(self, interval=0) -> bool:
|
||||
return self.appear(FILTER_CONFIRM, interval=interval)
|
||||
|
||||
def handle_filter_confirm(self, button, interval=2) -> bool:
|
||||
"""
|
||||
Confirm filter aside
|
||||
|
||||
Args:
|
||||
button: ENHANCE_FILTER or SALVAGE_FILTER
|
||||
interval:
|
||||
|
||||
Returns:
|
||||
bool: If clicked
|
||||
"""
|
||||
if self.appear(button):
|
||||
if self.appear_then_click(FILTER_CONFIRM, interval=interval):
|
||||
self.interval_clear(FILTER_RESET)
|
||||
return True
|
||||
return False
|
||||
|
||||
def handle_filter_reset(self, button, interval=2):
|
||||
"""
|
||||
Reset filter aside
|
||||
|
||||
Args:
|
||||
button: ENHANCE_FILTER or SALVAGE_FILTER
|
||||
interval:
|
||||
|
||||
Returns:
|
||||
bool: If clicked
|
||||
"""
|
||||
if self.is_filter_active(button):
|
||||
if self.appear_then_click(FILTER_RESET, interval=interval):
|
||||
self.interval_clear(FILTER_CONFIRM)
|
||||
return True
|
||||
return False
|
||||
|
||||
def handle_filter_close(self, opened=None, interval=2):
|
||||
"""
|
||||
Args:
|
||||
opened: ENHANCE_FILTER or SALVAGE_FILTER
|
||||
Keep this filter opened
|
||||
interval:
|
||||
|
||||
Returns:
|
||||
bool: If clicked
|
||||
"""
|
||||
# If filter opened, reset it
|
||||
if self.handle_filter_reset(SALVAGE_FILTER, interval=interval):
|
||||
self.interval_reset([SALVAGE_FILTER], interval=interval)
|
||||
return True
|
||||
if self.handle_filter_reset(ENHANCE_FILTER, interval=interval):
|
||||
self.interval_reset([ENHANCE_FILTER], interval=interval)
|
||||
return True
|
||||
# If filter opened, close it
|
||||
if opened != SALVAGE_FILTER:
|
||||
if self.handle_filter_confirm(SALVAGE_FILTER, interval=interval):
|
||||
self.interval_clear([FILTER_CONFIRM, SALVAGE_CHECK_OFF, SALVAGE_CHECK_ON], interval=interval)
|
||||
return True
|
||||
if opened != ENHANCE_FILTER:
|
||||
if self.handle_filter_confirm(ENHANCE_FILTER, interval=interval):
|
||||
self.interval_clear([FILTER_CONFIRM, ENHANCE_CHECK], interval=interval)
|
||||
return True
|
||||
# If filter activated, open it
|
||||
if self.is_filter_active(SALVAGE_FILTER, interval=interval):
|
||||
logger.info(f'is_filter_active -> {SALVAGE_FILTER}')
|
||||
self.device.click(SALVAGE_FILTER)
|
||||
self.interval_reset([FILTER_CONFIRM, SALVAGE_CHECK_OFF, SALVAGE_CHECK_ON], interval=interval)
|
||||
return True
|
||||
if self.is_filter_active(ENHANCE_FILTER, interval=interval):
|
||||
logger.info(f'is_filter_active -> {ENHANCE_FILTER}')
|
||||
self.device.click(ENHANCE_FILTER)
|
||||
self.interval_reset([FILTER_CONFIRM, ENHANCE_CHECK], interval=interval)
|
||||
return True
|
||||
return False
|
||||
|
||||
def relics_goto_salvage_filter(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Pages:
|
||||
in: page_item, any subpage of relics
|
||||
out: salvage filter, with filter reset
|
||||
"""
|
||||
logger.info('Relics goto salvage filter')
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
# End
|
||||
if self.is_filter_opened() and self.appear(SALVAGE_FILTER):
|
||||
logger.info('Arrive SALVAGE_FILTER')
|
||||
break
|
||||
|
||||
# Close filter
|
||||
if self.handle_filter_close(opened=SALVAGE_FILTER):
|
||||
continue
|
||||
# Open filter
|
||||
if not self.is_filter_opened():
|
||||
# if self.is_filter_appear(ENHANCE_FILTER, interval=2):
|
||||
# self.device.click(ENHANCE_FILTER)
|
||||
# continue
|
||||
if self.is_filter_appear(SALVAGE_FILTER, interval=2):
|
||||
self.device.click(SALVAGE_FILTER)
|
||||
continue
|
||||
# UI switch
|
||||
if self.is_in_relics_enhance(interval=2):
|
||||
self.device.click(ENHANCE_GOTO_SALVAGE)
|
||||
continue
|
||||
# if self.is_in_relics_salvage(interval=2):
|
||||
# logger.info(f'is_in_relics_salvage -> {CLOSE}')
|
||||
# self.device.click(CLOSE)
|
||||
# continue
|
||||
|
||||
def relics_goto_salvage(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Pages:
|
||||
in: page_item, any subpage of relics
|
||||
out: salvage, with filter reset
|
||||
"""
|
||||
logger.info('Relics goto salvage')
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
# End
|
||||
if self.is_in_relics_salvage() and self.appear(SALVAGE_FILTER):
|
||||
logger.info('Arrive is_in_relics_salvage')
|
||||
break
|
||||
|
||||
# Close filter
|
||||
if self.handle_filter_close():
|
||||
continue
|
||||
# UI switch
|
||||
if self.is_in_relics_enhance(interval=2):
|
||||
self.device.click(ENHANCE_GOTO_SALVAGE)
|
||||
continue
|
||||
|
||||
def relics_goto_enhance_filter(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Pages:
|
||||
in: page_item, any subpage of relics
|
||||
out: enhance filter, with filter reset
|
||||
"""
|
||||
logger.info('Relics goto enhance filter')
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
# End
|
||||
if self.is_filter_opened() and self.appear(ENHANCE_FILTER):
|
||||
logger.info('Arrive ENHANCE_FILTER')
|
||||
break
|
||||
|
||||
# Close filter
|
||||
if self.handle_filter_close(opened=ENHANCE_FILTER):
|
||||
continue
|
||||
# Open filter
|
||||
if not self.is_filter_opened():
|
||||
if self.is_filter_appear(ENHANCE_FILTER, interval=2):
|
||||
self.device.click(ENHANCE_FILTER)
|
||||
continue
|
||||
# UI switch
|
||||
if self.is_in_relics_salvage(interval=2):
|
||||
logger.info(f'is_in_relics_salvage -> {CLOSE}')
|
||||
self.device.click(CLOSE)
|
||||
continue
|
||||
|
||||
def relics_goto_enhance(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Pages:
|
||||
in: page_item, any subpage of relics
|
||||
out: enhance, with filter reset
|
||||
"""
|
||||
logger.info('Relics goto enhance')
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
# End
|
||||
if self.is_in_relics_enhance() and self.appear(ENHANCE_FILTER):
|
||||
logger.info('Arrive is_in_relics_enhance')
|
||||
break
|
||||
|
||||
# Close filter
|
||||
if self.handle_filter_close():
|
||||
continue
|
||||
# UI switch
|
||||
if self.is_in_relics_salvage(interval=2):
|
||||
logger.info(f'is_in_relics_salvage -> {CLOSE}')
|
||||
self.device.click(CLOSE)
|
||||
continue
|
||||
|
||||
def ui_goto_relics(self):
|
||||
self.ui_ensure(page_item)
|
||||
self.item_goto(KEYWORDS_ITEM_TAB.Relics, wait_until_stable=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
self = RelicsUI('src')
|
||||
self.device.screenshot()
|
||||
self.relics_goto_salvage_filter()
|