mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +00:00
Chore: Add SEARCH attribute to SWITCH_ITEM_TAB to be reused in synthesize
This commit is contained in:
parent
46ee9b1524
commit
2fd074efae
BIN
assets/share/item/ui/SWITCH_SEARCH.png
Normal file
BIN
assets/share/item/ui/SWITCH_SEARCH.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
@ -36,8 +36,8 @@ class Switch:
|
||||
"""
|
||||
Args:
|
||||
state (str):
|
||||
check_button (Button):
|
||||
click_button (Button):
|
||||
check_button (ButtonWrapper):
|
||||
click_button (ButtonWrapper):
|
||||
"""
|
||||
self.state_list.append({
|
||||
'state': state,
|
||||
|
@ -103,6 +103,16 @@ RELICS_CLICK = ButtonWrapper(
|
||||
button=(36, 298, 78, 319),
|
||||
),
|
||||
)
|
||||
SWITCH_SEARCH = ButtonWrapper(
|
||||
name='SWITCH_SEARCH',
|
||||
share=Button(
|
||||
file='./assets/share/item/ui/SWITCH_SEARCH.png',
|
||||
area=(22, 60, 94, 672),
|
||||
search=(2, 40, 114, 692),
|
||||
color=(77, 81, 88),
|
||||
button=(22, 60, 94, 672),
|
||||
),
|
||||
)
|
||||
UPGRADE_MATERIAL_CHECK = ButtonWrapper(
|
||||
name='UPGRADE_MATERIAL_CHECK',
|
||||
share=Button(
|
||||
|
@ -1,6 +1,7 @@
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
from tasks.base.assets.assets_base_page import CLOSE
|
||||
from tasks.base.page import page_item
|
||||
from tasks.item.assets.assets_item_relics import *
|
||||
from tasks.item.keywords import KEYWORDS_ITEM_TAB
|
||||
from tasks.item.ui import ItemUI
|
||||
@ -48,6 +49,7 @@ class RelicsUI(ItemUI):
|
||||
out: page_item, GOTO_SALVAGE
|
||||
"""
|
||||
logger.hr('Salvage Relic', level=2)
|
||||
self.ui_ensure(page_item)
|
||||
self.item_goto(KEYWORDS_ITEM_TAB.Relics, wait_until_stable=False)
|
||||
while 1: # relic tab -> salvage
|
||||
if skip_first_screenshot:
|
||||
|
@ -1,12 +1,32 @@
|
||||
from module.logger import logger
|
||||
from module.ui.switch import Switch
|
||||
from tasks.base.page import page_item
|
||||
from tasks.base.ui import UI
|
||||
from tasks.item.assets.assets_item_consumable_usage import SIMPLE_PROTECTIVE_GEAR
|
||||
from tasks.item.assets.assets_item_ui import *
|
||||
from tasks.item.keywords import KEYWORDS_ITEM_TAB
|
||||
|
||||
SWITCH_ITEM_TAB = Switch('ItemTab', is_selector=True)
|
||||
|
||||
class SwitchItemTab(Switch):
|
||||
def add_state(self, state, check_button, click_button=None):
|
||||
# Load search
|
||||
if check_button is not None:
|
||||
check_button.load_search(SWITCH_SEARCH.area)
|
||||
if click_button is not None:
|
||||
click_button.load_search(SWITCH_SEARCH.area)
|
||||
return super().add_state(state, check_button, click_button)
|
||||
|
||||
def click(self, state, main):
|
||||
"""
|
||||
Args:
|
||||
state (str):
|
||||
main (ModuleBase):
|
||||
"""
|
||||
button = self.get_data(state)['click_button']
|
||||
_ = button.match_template_luma(main.device.image) # Search button to load offset
|
||||
main.device.click(button)
|
||||
|
||||
|
||||
SWITCH_ITEM_TAB = SwitchItemTab('ItemTab', is_selector=True)
|
||||
SWITCH_ITEM_TAB.add_state(
|
||||
KEYWORDS_ITEM_TAB.UpgradeMaterials,
|
||||
check_button=UPGRADE_MATERIAL_CHECK,
|
||||
@ -53,16 +73,20 @@ class ItemUI(UI):
|
||||
inside the tab, wait_until_stable should set to True
|
||||
|
||||
Returns:
|
||||
bool: If switched
|
||||
|
||||
Examples:
|
||||
self = ItemUI('alas')
|
||||
self.device.screenshot()
|
||||
self.item_goto(KEYWORDS_ITEM_TAB.Relics)
|
||||
self.item_goto(KEYWORDS_ITEM_TAB.Consumables)
|
||||
"""
|
||||
logger.hr('Item tab goto', level=2)
|
||||
self.ui_ensure(page_item)
|
||||
SWITCH_ITEM_TAB.set(state, main=self)
|
||||
if SWITCH_ITEM_TAB.set(state, main=self):
|
||||
if wait_until_stable:
|
||||
logger.info(f'Tab goto {state}, wait until loaded')
|
||||
self.wait_until_stable(SIMPLE_PROTECTIVE_GEAR)
|
||||
else:
|
||||
logger.info(f'Tab goto {state}')
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user