mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 18:05:26 +00:00
Fix: Copy raw attributes of the first frame to all
This commit is contained in:
parent
cfde77f7ef
commit
f374e8fa69
@ -108,6 +108,11 @@ class DataAssets:
|
|||||||
color: t.Tuple[int, int, int] = ()
|
color: t.Tuple[int, int, int] = ()
|
||||||
button: t.Tuple[int, int, int, int] = ()
|
button: t.Tuple[int, int, int, int] = ()
|
||||||
|
|
||||||
|
has_raw_area = False
|
||||||
|
has_raw_search = False
|
||||||
|
has_raw_color = False
|
||||||
|
has_raw_button = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def area_to_search(area):
|
def area_to_search(area):
|
||||||
area = area_pad(area, pad=-20)
|
area = area_pad(area, pad=-20)
|
||||||
@ -131,12 +136,16 @@ class DataAssets:
|
|||||||
self.button = image.bbox
|
self.button = image.bbox
|
||||||
elif image.attr == 'AREA':
|
elif image.attr == 'AREA':
|
||||||
self.area = image.bbox
|
self.area = image.bbox
|
||||||
|
self.has_raw_area = True
|
||||||
elif image.attr == 'SEARCH':
|
elif image.attr == 'SEARCH':
|
||||||
self.search = image.bbox
|
self.search = image.bbox
|
||||||
|
self.has_raw_search = True
|
||||||
elif image.attr == 'COLOR':
|
elif image.attr == 'COLOR':
|
||||||
self.color = image.mean
|
self.color = image.mean
|
||||||
|
self.has_raw_color = True
|
||||||
elif image.attr == 'BUTTON':
|
elif image.attr == 'BUTTON':
|
||||||
self.button = image.bbox
|
self.button = image.bbox
|
||||||
|
self.has_raw_button = True
|
||||||
else:
|
else:
|
||||||
logger.warning(f'Trying to load an image with unknown attribute: {image}')
|
logger.warning(f'Trying to load an image with unknown attribute: {image}')
|
||||||
|
|
||||||
@ -182,19 +191,22 @@ def iter_assets():
|
|||||||
# Set `search`
|
# Set `search`
|
||||||
for path, frames in deep_iter(data, depth=3):
|
for path, frames in deep_iter(data, depth=3):
|
||||||
print(path, frames)
|
print(path, frames)
|
||||||
# If `search` attribute is set in the first frame, apply to all
|
|
||||||
first = frames[1]
|
|
||||||
if first.search:
|
|
||||||
for frame in frames.values():
|
for frame in frames.values():
|
||||||
frame.search = first.search
|
|
||||||
else:
|
|
||||||
for frame in frames.values():
|
|
||||||
if frame.search:
|
|
||||||
# Follow frame specific `search`
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Generate `search` from `area`
|
# Generate `search` from `area`
|
||||||
|
if not frame.has_raw_search:
|
||||||
frame.search = DataAssets.area_to_search(frame.area)
|
frame.search = DataAssets.area_to_search(frame.area)
|
||||||
|
# If an attribute is set in the first frame, apply to all
|
||||||
|
first: DataAssets = frames[1]
|
||||||
|
for frame in frames.values():
|
||||||
|
# frame: DataAssets = frame
|
||||||
|
if not frame.has_raw_area and first.has_raw_area:
|
||||||
|
frame.area = first.area
|
||||||
|
if not frame.has_raw_search and first.has_raw_search:
|
||||||
|
frame.search = first.search
|
||||||
|
if not frame.has_raw_color and first.has_raw_color:
|
||||||
|
frame.color = first.color
|
||||||
|
if not frame.has_raw_button and first.has_raw_button:
|
||||||
|
frame.button = first.button
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -29,6 +29,13 @@ class GamePageUnknownError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TaskError(Exception):
|
||||||
|
# An error occurred in task,
|
||||||
|
# task itself should have error handled before raising TaskError,
|
||||||
|
# then task will be re-scheduled
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RequestHumanTakeover(Exception):
|
class RequestHumanTakeover(Exception):
|
||||||
# Request human takeover
|
# Request human takeover
|
||||||
# Alas is unable to handle such error, probably because of wrong settings.
|
# Alas is unable to handle such error, probably because of wrong settings.
|
||||||
|
@ -62,7 +62,7 @@ GET_REWARD = ButtonWrapper(
|
|||||||
area=(625, 144, 655, 168),
|
area=(625, 144, 655, 168),
|
||||||
search=(605, 124, 675, 188),
|
search=(605, 124, 675, 188),
|
||||||
color=(226, 0, 0),
|
color=(226, 0, 0),
|
||||||
button=(625, 144, 655, 168),
|
button=(741, 495, 1071, 644),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -438,13 +438,13 @@ if __name__ == '__main__':
|
|||||||
# MapResource.SRCMAP = '../srcmap/srcmap'
|
# MapResource.SRCMAP = '../srcmap/srcmap'
|
||||||
self = Minimap()
|
self = Minimap()
|
||||||
# Set plane, assume starting from Jarilo_AdministrativeDistrict
|
# Set plane, assume starting from Jarilo_AdministrativeDistrict
|
||||||
self.set_plane('Jarilo_BackwaterPass', floor='F1')
|
self.set_plane('Jarilo_SilvermaneGuardRestrictedZone', floor='F1')
|
||||||
|
|
||||||
ui = UI('src')
|
ui = UI('src')
|
||||||
ui.device.disable_stuck_detection()
|
ui.device.disable_stuck_detection()
|
||||||
# Set starter point. Starter point will be calculated if it's missing but may contain errors.
|
# Set starter point. Starter point will be calculated if it's missing but may contain errors.
|
||||||
# With starter point set, position is only searched around starter point and new position becomes new starter point.
|
# With starter point set, position is only searched around starter point and new position becomes new starter point.
|
||||||
# self.init_position((337, 480))
|
self.init_position((227.7, 425.5), locked=True)
|
||||||
while 1:
|
while 1:
|
||||||
ui.device.screenshot()
|
ui.device.screenshot()
|
||||||
self.update(ui.device.image)
|
self.update(ui.device.image)
|
||||||
|
Loading…
Reference in New Issue
Block a user