1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-18 21:53:33 +08:00

Opt: Add load_offset method to Button class

It will be useful in the future
This commit is contained in:
LmeSzinc
2021-04-04 22:27:36 +08:00
parent 25830dff67
commit 59e723dcf0
2 changed files with 15 additions and 6 deletions

View File

@@ -88,6 +88,16 @@ class Button:
self.image = np.array(image.crop(self.area)) self.image = np.array(image.crop(self.area))
return self.color return self.color
def load_offset(self, button):
"""
Load offset from another button.
Args:
button (Button):
"""
offset = np.subtract(button.button, button._button)[:2]
self._button_offset = area_offset(self._button, offset=offset)
def ensure_template(self): def ensure_template(self):
""" """
Load asset image. Load asset image.

View File

@@ -18,13 +18,12 @@ class GlobeOperation(MapEventHandler):
Returns: Returns:
Button: Button:
""" """
for button in ZONE_TYPES: for zone in ZONE_TYPES:
if self.appear(button, offset=(20, 20)): if self.appear(zone, offset=(20, 20)):
offset = np.subtract(button.button, button._button)[:2] for button in ASSETS_PINNED_ZONE:
for change in ASSETS_PINNED_ZONE: button.load_offset(zone)
change._button_offset = area_offset(change._button, offset=offset)
return button return zone
return None return None