mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 10:57:45 +08:00
feat: py接口新增支持加载外服增量资源
This commit is contained in:
@@ -4,7 +4,7 @@ import pathlib
|
||||
import platform
|
||||
import json
|
||||
|
||||
from typing import Union, Dict, List, Any, Type
|
||||
from typing import Union, Dict, List, Any, Type, Optional
|
||||
from enum import Enum, unique, auto
|
||||
|
||||
JSON = Union[Dict[str, Any], List[Any], int, str, float, bool, Type[None]]
|
||||
@@ -23,7 +23,7 @@ class Asst:
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def load(path: Union[pathlib.Path, str]) -> bool:
|
||||
def load(path: Union[pathlib.Path, str], incremental_path: Optional[Union[pathlib.Path, str]] = None) -> bool:
|
||||
"""
|
||||
加载 dll 及资源
|
||||
|
||||
@@ -40,7 +40,12 @@ class Asst:
|
||||
Asst.__lib = ctypes.CDLL(str(Asst.__libpath))
|
||||
Asst.__set_lib_properties()
|
||||
|
||||
return Asst.__lib.AsstLoadResource(str(path).encode('utf-8'))
|
||||
ret: bool = Asst.__lib.AsstLoadResource(str(path).encode('utf-8'))
|
||||
if incremental_path:
|
||||
ret &= Asst.__lib.AsstLoadResource(
|
||||
str(incremental_path).encode('utf-8'))
|
||||
|
||||
return ret
|
||||
|
||||
def __init__(self, callback: CallBackType = None, arg=None):
|
||||
"""
|
||||
|
||||
@@ -18,6 +18,8 @@ if __name__ == "__main__":
|
||||
# 请设置为存放 dll 文件及资源的路径
|
||||
path = pathlib.Path.cwd().parent
|
||||
|
||||
# 外服需要再额外传入增量资源路径,例如
|
||||
# incremental_path=path / 'resource' / 'global' / 'YoStarEN'
|
||||
Asst.load(path=path)
|
||||
|
||||
# 若需要获取详细执行信息,请传入 callback 参数
|
||||
|
||||
Reference in New Issue
Block a user