mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Chore: [ALAS] Add Button.is_offset_in()
This commit is contained in:
parent
4d086d1753
commit
97dd0f6324
@ -34,6 +34,23 @@ class Button(Resource):
|
|||||||
def clear_offset(self):
|
def clear_offset(self):
|
||||||
self._button_offset = (0, 0)
|
self._button_offset = (0, 0)
|
||||||
|
|
||||||
|
def is_offset_in(self, x=0, y=0):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
x:
|
||||||
|
y:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: If _button_offset is in (-x, -y, x, y)
|
||||||
|
"""
|
||||||
|
if x:
|
||||||
|
if self._button_offset[0] < -x or self._button_offset[0] > x:
|
||||||
|
return False
|
||||||
|
if y:
|
||||||
|
if self._button_offset[1] < -y or self._button_offset[1] > y:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def image(self):
|
def image(self):
|
||||||
return load_image(self.file, self.area)
|
return load_image(self.file, self.area)
|
||||||
@ -295,6 +312,17 @@ class ButtonWrapper(Resource):
|
|||||||
for b in self.iter_buttons():
|
for b in self.iter_buttons():
|
||||||
b.clear_offset()
|
b.clear_offset()
|
||||||
|
|
||||||
|
def is_offset_in(self, x=0, y=0):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
x:
|
||||||
|
y:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: If _button_offset is in (-x, -y, x, y)
|
||||||
|
"""
|
||||||
|
return self.matched_button.is_offset_in(x=x, y=y)
|
||||||
|
|
||||||
def load_search(self, area):
|
def load_search(self, area):
|
||||||
"""
|
"""
|
||||||
Set `search` attribute.
|
Set `search` attribute.
|
||||||
|
Loading…
Reference in New Issue
Block a user