use mod console
This commit is contained in:
parent
957b03be31
commit
6ee9d62937
@ -211,7 +211,7 @@ class ClientWindow(Window):
|
||||
def start_game(self) -> None:
|
||||
self.set_icon(pyglet.image.load('./textures/icon.png'))
|
||||
self.run_input = True
|
||||
self.read_input()
|
||||
# self.read_input()
|
||||
try:
|
||||
pyglet.app.event_loop.run(1 / self.main_config['runtime']['fps'])
|
||||
except KeyboardInterrupt:
|
||||
@ -314,6 +314,7 @@ class ClientWindow(Window):
|
||||
self.logger.info(tr().window.command.text().format(command))
|
||||
if command.re_match('stop'):
|
||||
# self.dispatch_event('on_exit')
|
||||
print("command stop!")
|
||||
pyglet.app.platform_event_loop.stop()
|
||||
self.dispatch_event('on_close', 'command') # source = command
|
||||
elif command.re_match('fps'):
|
||||
@ -439,10 +440,13 @@ class ClientWindow(Window):
|
||||
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())
|
||||
self.fps_log.check_list = False
|
||||
# self.fps_log.check_list = False
|
||||
DR_runtime.running = False
|
||||
if self.run_input:
|
||||
self.run_input = False
|
||||
self.save_info()
|
||||
super().on_close()
|
||||
self.logger.info(tr().window.game.end())
|
||||
|
||||
|
||||
ClientWindow.register_event_type("on_command")
|
||||
|
@ -36,7 +36,7 @@ if TYPE_CHECKING:
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
from .Difficult_Rocket_rs import CenterCamera_rs, SR1PartList_rs
|
||||
from .Difficult_Rocket_rs import CenterCamera_rs, SR1PartList_rs, Console_rs
|
||||
|
||||
|
||||
logger = logging.getLogger('client')
|
||||
@ -135,6 +135,7 @@ class SR1ShipRender(BaseScreen):
|
||||
min_zoom=(1 / 2) ** 10, max_zoom=10)
|
||||
self.rust_parts = None
|
||||
self.part_list_rs = SR1PartList_rs('configs/PartList.xml', 'default_part_list')
|
||||
self.console = Console_rs()
|
||||
|
||||
def load_xml(self, file_path: str) -> bool:
|
||||
try:
|
||||
@ -270,6 +271,11 @@ class SR1ShipRender(BaseScreen):
|
||||
self.debug_mouse_label.draw()
|
||||
if SR1ShipRender_Option.debug_mouse_d_pos:
|
||||
self.debug_mouse_delta_line.draw()
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
read_input = self.console.get_command()
|
||||
if read_input:
|
||||
print(f"Rust console: |{read_input}|")
|
||||
window.dispatch_event("on_command", CommandText(read_input))
|
||||
|
||||
def on_resize(self, width: int, height: int, window: "ClientWindow"):
|
||||
if not self.rendered:
|
||||
@ -381,6 +387,9 @@ class SR1ShipRender(BaseScreen):
|
||||
if self.load_xml(path): # 加载成功一个就停下
|
||||
break
|
||||
self.render_ship()
|
||||
|
||||
def on_close(self, window: "ClientWindow"):
|
||||
self.console.stop_console()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user