mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 05:08:19 +08:00
Opt: Release cached assets
This commit is contained in:
@@ -6,10 +6,11 @@ from PIL import ImageDraw
|
||||
|
||||
import module.config.server as server
|
||||
from module.base.decorator import cached_property
|
||||
from module.base.resource import Resource
|
||||
from module.base.utils import *
|
||||
|
||||
|
||||
class Button:
|
||||
class Button(Resource):
|
||||
def __init__(self, area, color, button, file=None, name=None):
|
||||
"""Initialize a Button instance.
|
||||
|
||||
@@ -50,6 +51,8 @@ class Button:
|
||||
else:
|
||||
self.is_gif = False
|
||||
|
||||
self.resource_add(key=self.file)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@@ -131,6 +134,10 @@ class Button:
|
||||
self.image = load_image(self.file, self.area)
|
||||
self._match_init = True
|
||||
|
||||
def resource_release(self):
|
||||
self.image = None
|
||||
self._match_init = False
|
||||
|
||||
def match(self, image, offset=30, threshold=0.85):
|
||||
"""Detects button by template matching. To Some button, its location may not be static.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user