try mod loading
This commit is contained in:
parent
9183e56a2d
commit
82df6e52e6
@ -155,26 +155,26 @@ class _DR_runtime(Options):
|
|||||||
mods = []
|
mods = []
|
||||||
paths = Path(self.mod_path).iterdir()
|
paths = Path(self.mod_path).iterdir()
|
||||||
sys.path.append(self.mod_path)
|
sys.path.append(self.mod_path)
|
||||||
# for mod_path in paths:
|
for mod_path in paths:
|
||||||
# try:
|
try:
|
||||||
# if mod_path.is_dir() and mod_path.name != '__pycache__': # 处理文件夹 mod
|
if mod_path.is_dir() and mod_path.name != '__pycache__': # 处理文件夹 mod
|
||||||
# if importlib.util.find_spec(mod_path.name) is not None:
|
if importlib.util.find_spec(mod_path.name) is not None:
|
||||||
# mods.append(mod_path.name)
|
mods.append(mod_path.name)
|
||||||
# else:
|
else:
|
||||||
# print(f'can not import mod {mod_path} because importlib can not find spec')
|
print(f'can not import mod {mod_path} because importlib can not find spec')
|
||||||
# elif mod_path.suffix in ('.pyz', '.zip'): # 处理压缩包 mod
|
elif mod_path.suffix in ('.pyz', '.zip'): # 处理压缩包 mod
|
||||||
# if importlib.util.find_spec(mod_path.name) is not None:
|
if importlib.util.find_spec(mod_path.name) is not None:
|
||||||
# mods.append(mod_path.name)
|
mods.append(mod_path.name)
|
||||||
# elif mod_path.suffix == '.pyd': # pyd 扩展 mod
|
elif mod_path.suffix == '.pyd': # pyd 扩展 mod
|
||||||
# if importlib.util.find_spec(mod_path.name) is not None:
|
if importlib.util.find_spec(mod_path.name) is not None:
|
||||||
# mods.append(mod_path.name)
|
mods.append(mod_path.name)
|
||||||
# elif mod_path.suffix == '.py': # 处理单文件 mod
|
elif mod_path.suffix == '.py': # 处理单文件 mod
|
||||||
# print(f'importing mod {mod_path=} {mod_path.stem}')
|
print(f'importing mod {mod_path=} {mod_path.stem}')
|
||||||
# if importlib.util.find_spec(mod_path.stem) is not None:
|
if importlib.util.find_spec(mod_path.stem) is not None:
|
||||||
# mods.append(mod_path.stem)
|
mods.append(mod_path.stem)
|
||||||
# except ImportError:
|
except ImportError:
|
||||||
# print(f'ImportError when loading mod {mod_path}')
|
print(f'ImportError when loading mod {mod_path}')
|
||||||
# traceback.print_exc()
|
traceback.print_exc()
|
||||||
return mods
|
return mods
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,8 +195,8 @@ class ClientWindow(Window):
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.set_icon(pyglet.image.load('./textures/icon.png'))
|
self.set_icon(pyglet.image.load('./textures/icon.png'))
|
||||||
# self.logger.info(f"=== finding mods from {DR_runtime.mod_path} ===")
|
self.logger.info(f"=== finding mods from {DR_runtime.mod_path} ===")
|
||||||
# self.logger.info(f'find mods: {DR_runtime.find_mods()}')
|
self.logger.info(f'find mods: {DR_runtime.find_mods()}')
|
||||||
self.load_fonts()
|
self.load_fonts()
|
||||||
# TODO 读取配置文件,加载不同的屏幕,解耦
|
# TODO 读取配置文件,加载不同的屏幕,解耦
|
||||||
self.screen_list.append(DRDEBUGScreen(self))
|
self.screen_list.append(DRDEBUGScreen(self))
|
||||||
|
@ -110,7 +110,7 @@ class Game:
|
|||||||
def setup(self) -> None:
|
def setup(self) -> None:
|
||||||
self.client = client.Client(net_mode='local')
|
self.client = client.Client(net_mode='local')
|
||||||
self.server = server.Server(net_mode='local')
|
self.server = server.Server(net_mode='local')
|
||||||
# self.load_mods()
|
self.load_mods()
|
||||||
|
|
||||||
def python_version_check(self) -> None: # best 3.8+ and write at 3.8.10
|
def python_version_check(self) -> None: # best 3.8+ and write at 3.8.10
|
||||||
self.logger.info(f"{tr().main.version.now_on()} {self.on_python_v}")
|
self.logger.info(f"{tr().main.version.now_on()} {self.on_python_v}")
|
||||||
|
Loading…
Reference in New Issue
Block a user