From 19f6d5307fcf5a9f1565cec81ff7e45e99587675 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 28 Aug 2022 16:11:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20py=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8A=A0=E8=BD=BD=E5=A4=96=E6=9C=8D=E5=A2=9E?= =?UTF-8?q?=E9=87=8F=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Python/asst.py | 11 ++++++++--- src/Python/sample.py | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Python/asst.py b/src/Python/asst.py index 68836a0e52..8468acf737 100644 --- a/src/Python/asst.py +++ b/src/Python/asst.py @@ -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): """ diff --git a/src/Python/sample.py b/src/Python/sample.py index 1fd847aae7..d7ccbe65b4 100644 --- a/src/Python/sample.py +++ b/src/Python/sample.py @@ -18,6 +18,8 @@ if __name__ == "__main__": # 请设置为存放 dll 文件及资源的路径 path = pathlib.Path.cwd().parent + # 外服需要再额外传入增量资源路径,例如 + # incremental_path=path / 'resource' / 'global' / 'YoStarEN' Asst.load(path=path) # 若需要获取详细执行信息,请传入 callback 参数