mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2026-10-10 04:52:05 +00:00
fix: copy raw attributes of first frame to all
This commit is contained in:
+24
-12
@@ -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
|
for frame in frames.values():
|
||||||
first = frames[1]
|
# Generate `search` from `area`
|
||||||
if first.search:
|
if not frame.has_raw_search:
|
||||||
for frame in frames.values():
|
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
|
frame.search = first.search
|
||||||
else:
|
if not frame.has_raw_color and first.has_raw_color:
|
||||||
for frame in frames.values():
|
frame.color = first.color
|
||||||
if frame.search:
|
if not frame.has_raw_button and first.has_raw_button:
|
||||||
# Follow frame specific `search`
|
frame.button = first.button
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Generate `search` from `area`
|
|
||||||
frame.search = DataAssets.area_to_search(frame.area)
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user