mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 08:37:42 +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] = ()
|
||||
button: t.Tuple[int, int, int, int] = ()
|
||||
|
||||
has_raw_area = False
|
||||
has_raw_search = False
|
||||
has_raw_color = False
|
||||
has_raw_button = False
|
||||
|
||||
@staticmethod
|
||||
def area_to_search(area):
|
||||
area = area_pad(area, pad=-20)
|
||||
@ -131,12 +136,16 @@ class DataAssets:
|
||||
self.button = image.bbox
|
||||
elif image.attr == 'AREA':
|
||||
self.area = image.bbox
|
||||
self.has_raw_area = True
|
||||
elif image.attr == 'SEARCH':
|
||||
self.search = image.bbox
|
||||
self.has_raw_search = True
|
||||
elif image.attr == 'COLOR':
|
||||
self.color = image.mean
|
||||
self.has_raw_color = True
|
||||
elif image.attr == 'BUTTON':
|
||||
self.button = image.bbox
|
||||
self.has_raw_button = True
|
||||
else:
|
||||
logger.warning(f'Trying to load an image with unknown attribute: {image}')
|
||||
|
||||
@ -182,19 +191,22 @@ def iter_assets():
|
||||
# Set `search`
|
||||
for path, frames in deep_iter(data, depth=3):
|
||||
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():
|
||||
# Generate `search` from `area`
|
||||
if not frame.has_raw_search:
|
||||
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
|
||||
else:
|
||||
for frame in frames.values():
|
||||
if frame.search:
|
||||
# Follow frame specific `search`
|
||||
pass
|
||||
else:
|
||||
# Generate `search` from `area`
|
||||
frame.search = DataAssets.area_to_search(frame.area)
|
||||
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
|
||||
|
||||
|
@ -29,6 +29,13 @@ class GamePageUnknownError(Exception):
|
||||
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):
|
||||
# Request human takeover
|
||||
# Alas is unable to handle such error, probably because of wrong settings.
|
||||
|
@ -62,7 +62,7 @@ GET_REWARD = ButtonWrapper(
|
||||
area=(625, 144, 655, 168),
|
||||
search=(605, 124, 675, 188),
|
||||
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'
|
||||
self = Minimap()
|
||||
# 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.device.disable_stuck_detection()
|
||||
# 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.
|
||||
# self.init_position((337, 480))
|
||||
self.init_position((227.7, 425.5), locked=True)
|
||||
while 1:
|
||||
ui.device.screenshot()
|
||||
self.update(ui.device.image)
|
||||
|
Loading…
Reference in New Issue
Block a user