mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Selection may have lost after setting rarity
This commit is contained in:
parent
a1bc3c94be
commit
287f51386e
@ -330,15 +330,17 @@ class InventoryManager:
|
||||
clicked = True
|
||||
continue
|
||||
|
||||
def wait_selected(self, skip_first_screenshot=True):
|
||||
def wait_selected(self, select_first=False, skip_first_screenshot=True):
|
||||
"""
|
||||
Args:
|
||||
select_first: True to click first item if no item was selected
|
||||
skip_first_screenshot:
|
||||
|
||||
Returns:
|
||||
bool: If success
|
||||
"""
|
||||
timeout = Timer(2, count=6).start()
|
||||
interval = Timer(1, count=3)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
@ -346,6 +348,8 @@ class InventoryManager:
|
||||
self.main.device.screenshot()
|
||||
|
||||
self.update()
|
||||
|
||||
# End
|
||||
if timeout.reached():
|
||||
logger.warning('Wait inventory selected timeout')
|
||||
return False
|
||||
@ -353,3 +357,12 @@ class InventoryManager:
|
||||
continue
|
||||
if self.selected is not None:
|
||||
return True
|
||||
|
||||
# Click
|
||||
if select_first:
|
||||
first = self.get_first()
|
||||
if first is None:
|
||||
logger.warning(f'No items detected, cannot select inventory')
|
||||
elif interval.reached():
|
||||
self.main.device.click(first)
|
||||
interval.reset()
|
||||
|
@ -213,7 +213,8 @@ class Synthesize(CombatObtain, ItemUI):
|
||||
if inv is not None:
|
||||
if inv.wait_selected():
|
||||
return True
|
||||
else:
|
||||
# Game bug that selection may have lost after setting rarity
|
||||
elif inv.wait_selected(select_first=True):
|
||||
continue
|
||||
else:
|
||||
logger.info('synthesize_rarity_reset ended without wait_selected()')
|
||||
|
Loading…
Reference in New Issue
Block a user