From a6d78d9af7c8162f9be18aa7d5ea9c74c87c2fd3 Mon Sep 17 00:00:00 2001 From: jtoyoda Date: Tue, 22 Feb 2022 11:12:37 -0700 Subject: [PATCH] Adding in the ability to disable messages in the client --- FF1Client.py | 15 ++++++++++++++- host.yaml | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/FF1Client.py b/FF1Client.py index 23e2a8be..c4044968 100644 --- a/FF1Client.py +++ b/FF1Client.py @@ -18,6 +18,8 @@ CONNECTION_TENTATIVE_STATUS = "Initial Connection Made" CONNECTION_CONNECTED_STATUS = "Connected" CONNECTION_INITIAL_STATUS = "Connection has not been initiated" +DISPLAY_MSGS = True + class FF1CommandProcessor(ClientCommandProcessor): def __init__(self, ctx: CommonContext): @@ -28,6 +30,12 @@ class FF1CommandProcessor(ClientCommandProcessor): if isinstance(self.ctx, FF1Context): logger.info(f"NES Status: {self.ctx.nes_status}") + def _cmd_toggle_msgs(self): + """Toggle displaying messages in bizhawk""" + global DISPLAY_MSGS + DISPLAY_MSGS = not DISPLAY_MSGS + logger.info(f"Messages are now {'enabled' if DISPLAY_MSGS else 'disabled'}") + class FF1Context(CommonContext): command_processor = FF1CommandProcessor @@ -42,6 +50,7 @@ class FF1Context(CommonContext): self.nes_status = CONNECTION_INITIAL_STATUS self.game = 'Final Fantasy' self.awaiting_rom = False + self.display_msgs = True async def server_auth(self, password_requested: bool = False): if password_requested and not self.password: @@ -54,7 +63,8 @@ class FF1Context(CommonContext): await self.send_connect() def _set_message(self, msg: str, msg_id: int): - self.messages[(time.time(), msg_id)] = msg + if DISPLAY_MSGS: + self.messages[(time.time(), msg_id)] = msg def on_package(self, cmd: str, args: dict): if cmd == 'Connected': @@ -215,6 +225,9 @@ if __name__ == '__main__': # Text Mode to use !hint and such with games that have no text entry Utils.init_logging("FF1Client") + options = Utils.get_options() + DISPLAY_MSGS = options["ffr_options"]["display_msgs"] + async def main(args): ctx = FF1Context(args.connect, args.password) ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop") diff --git a/host.yaml b/host.yaml index 1b2e6a53..46fdd741 100644 --- a/host.yaml +++ b/host.yaml @@ -102,12 +102,14 @@ sm_options: rom_start: true factorio_options: executable: "factorio\\bin\\x64\\factorio" -minecraft_options: +minecraft_options: forge_directory: "Minecraft Forge server" max_heap_size: "2G" -oot_options: +oot_options: # File name of the OoT v1.0 ROM rom_file: "The Legend of Zelda - Ocarina of Time.z64" soe_options: # File name of the SoE US ROM rom_file: "Secret of Evermore (USA).sfc" +ffr_options: + display_msgs: true