Adding in the ability to disable messages in the client
This commit is contained in:
parent
48669e96d1
commit
a6d78d9af7
13
FF1Client.py
13
FF1Client.py
|
@ -18,6 +18,8 @@ CONNECTION_TENTATIVE_STATUS = "Initial Connection Made"
|
||||||
CONNECTION_CONNECTED_STATUS = "Connected"
|
CONNECTION_CONNECTED_STATUS = "Connected"
|
||||||
CONNECTION_INITIAL_STATUS = "Connection has not been initiated"
|
CONNECTION_INITIAL_STATUS = "Connection has not been initiated"
|
||||||
|
|
||||||
|
DISPLAY_MSGS = True
|
||||||
|
|
||||||
|
|
||||||
class FF1CommandProcessor(ClientCommandProcessor):
|
class FF1CommandProcessor(ClientCommandProcessor):
|
||||||
def __init__(self, ctx: CommonContext):
|
def __init__(self, ctx: CommonContext):
|
||||||
|
@ -28,6 +30,12 @@ class FF1CommandProcessor(ClientCommandProcessor):
|
||||||
if isinstance(self.ctx, FF1Context):
|
if isinstance(self.ctx, FF1Context):
|
||||||
logger.info(f"NES Status: {self.ctx.nes_status}")
|
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):
|
class FF1Context(CommonContext):
|
||||||
command_processor = FF1CommandProcessor
|
command_processor = FF1CommandProcessor
|
||||||
|
@ -42,6 +50,7 @@ class FF1Context(CommonContext):
|
||||||
self.nes_status = CONNECTION_INITIAL_STATUS
|
self.nes_status = CONNECTION_INITIAL_STATUS
|
||||||
self.game = 'Final Fantasy'
|
self.game = 'Final Fantasy'
|
||||||
self.awaiting_rom = False
|
self.awaiting_rom = False
|
||||||
|
self.display_msgs = True
|
||||||
|
|
||||||
async def server_auth(self, password_requested: bool = False):
|
async def server_auth(self, password_requested: bool = False):
|
||||||
if password_requested and not self.password:
|
if password_requested and not self.password:
|
||||||
|
@ -54,6 +63,7 @@ class FF1Context(CommonContext):
|
||||||
await self.send_connect()
|
await self.send_connect()
|
||||||
|
|
||||||
def _set_message(self, msg: str, msg_id: int):
|
def _set_message(self, msg: str, msg_id: int):
|
||||||
|
if DISPLAY_MSGS:
|
||||||
self.messages[(time.time(), msg_id)] = msg
|
self.messages[(time.time(), msg_id)] = msg
|
||||||
|
|
||||||
def on_package(self, cmd: str, args: dict):
|
def on_package(self, cmd: str, args: dict):
|
||||||
|
@ -215,6 +225,9 @@ if __name__ == '__main__':
|
||||||
# Text Mode to use !hint and such with games that have no text entry
|
# Text Mode to use !hint and such with games that have no text entry
|
||||||
Utils.init_logging("FF1Client")
|
Utils.init_logging("FF1Client")
|
||||||
|
|
||||||
|
options = Utils.get_options()
|
||||||
|
DISPLAY_MSGS = options["ffr_options"]["display_msgs"]
|
||||||
|
|
||||||
async def main(args):
|
async def main(args):
|
||||||
ctx = FF1Context(args.connect, args.password)
|
ctx = FF1Context(args.connect, args.password)
|
||||||
ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop")
|
ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop")
|
||||||
|
|
Loading…
Reference in New Issue