mirror of
https://github.com/onyx-and-iris/q3rcon-tui.git
synced 2026-02-26 03:09:09 +00:00
prevent keypresses from ConfigScreen propogating to the mainframe
improve the error message should a command execution fail.
This commit is contained in:
parent
086eeba916
commit
ab4898dac3
@ -26,6 +26,10 @@ class RconApp(App):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def on_key(self, event) -> None:
|
async def on_key(self, event) -> None:
|
||||||
|
# prevent keypresses from ConfigScreen from triggering actions in RconApp
|
||||||
|
if self.screen and isinstance(self.screen, ConfigScreen):
|
||||||
|
return
|
||||||
|
|
||||||
match event.key:
|
match event.key:
|
||||||
case 'enter' if self.query_one('#command', Input).has_focus:
|
case 'enter' if self.query_one('#command', Input).has_focus:
|
||||||
self.query_one('#send', Button).press()
|
self.query_one('#send', Button).press()
|
||||||
@ -64,9 +68,14 @@ class RconApp(App):
|
|||||||
self.query_one('#response', RichLog).write(
|
self.query_one('#response', RichLog).write(
|
||||||
self.writable.parse(cmd, response)
|
self.writable.parse(cmd, response)
|
||||||
)
|
)
|
||||||
except RCONError as e:
|
except RCONError:
|
||||||
|
output = (
|
||||||
|
'Unable to execute command.',
|
||||||
|
'It may be due to a map change or a server restart.',
|
||||||
|
'If the problem persists, please check your connection settings and ensure the server is running.',
|
||||||
|
)
|
||||||
self.query_one('#response', RichLog).write(
|
self.query_one('#response', RichLog).write(
|
||||||
f'{type(e).__name__}: Unable to connect to server: is the server running and are the host, port, and password correct? ({e})'
|
self.writable.error('\n'.join(output))
|
||||||
)
|
)
|
||||||
|
|
||||||
self.query_one('#command', Input).value = ''
|
self.query_one('#command', Input).value = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user