DR -> DR SDK #16

Merged
shenjackyuanjie merged 41 commits from feature/dr-sdk into main 2023-05-03 00:40:53 +08:00
3 changed files with 13 additions and 5 deletions
Showing only changes of commit db962e4fc5 - Show all commits

View File

@ -60,6 +60,14 @@ class ModInfo(Options):
print(f'Mod {self.mod_id} loaded') print(f'Mod {self.mod_id} loaded')
return True return True
def on_client_start(self, game: Game, client: ClientWindow):
""" 客户端启动时调用 """
print(f'Mod {self.mod_id} client start')
def on_client_stop(self, game: Game, client: ClientWindow, source: str = 'window'):
""" 客户端停止时调用 """
print(f'Mod {self.mod_id} client stop')
def on_server_start(self, game: Game): def on_server_start(self, game: Game):
""" 服务器启动时调用 """ """ 服务器启动时调用 """
print(f'Mod {self.mod_id} server start') print(f'Mod {self.mod_id} server start')
@ -68,10 +76,6 @@ class ModInfo(Options):
""" 服务器停止时调用 """ """ 服务器停止时调用 """
print(f'Mod {self.mod_id} server stop') print(f'Mod {self.mod_id} server stop')
def on_client_start(self, game: Game, client: ClientWindow):
""" 客户端启动时调用 """
print(f'Mod {self.mod_id} client start')
def on_unload(self, game: Game): def on_unload(self, game: Game):
""" 卸载时调用 """ """ 卸载时调用 """
print(f'Mod {self.mod_id} unloaded') print(f'Mod {self.mod_id} unloaded')

View File

@ -271,7 +271,6 @@ class ClientWindow(Window):
for command in self.command_list: for command in self.command_list:
self.on_command(line.CommandText(command)) self.on_command(line.CommandText(command))
self.command_list.pop(0) self.command_list.pop(0)
# self.logger.debug('on_draw call dt: {}'.format(dt))
pyglet.gl.glClearColor(0.1, 0, 0, 0.0) pyglet.gl.glClearColor(0.1, 0, 0, 0.0)
self.clear() self.clear()
self.draw_update(float(self.SPF)) self.draw_update(float(self.SPF))
@ -438,6 +437,7 @@ class ClientWindow(Window):
@_call_screen_before @_call_screen_before
def on_close(self, source: str = 'window') -> None: def on_close(self, source: str = 'window') -> None:
self.game.dispatch_event('on_close', game=self.game, client=self, source=source)
self.logger.info(tr().window.game.stop_get().format(tr().game[source]())) self.logger.info(tr().window.game.stop_get().format(tr().game[source]()))
self.logger.info(tr().window.game.stop()) self.logger.info(tr().window.game.stop())
self.fps_log.check_list = False self.fps_log.check_list = False

View File

@ -39,6 +39,10 @@
- `on_client_start(game: Game, client: ClientWindow) -> None` - `on_client_start(game: Game, client: ClientWindow) -> None`
- `game`: Game 对象 用于存储 DR SDK 的信息 - `game`: Game 对象 用于存储 DR SDK 的信息
- `client`: ClientWindow 对象 用于传递客户端状态 - `client`: ClientWindow 对象 用于传递客户端状态
- `on_client_stop(game: Game, client: ClientWindow, source: str = 'window')`
- `game`: Game 对象 用于存储 DR SDK 的信息
- `client`: ClientWindow 对象 用于传递客户端状态
- `source`: 关闭调用的来源
### DR_rs `0.2.7.0` ### DR_rs `0.2.7.0`