diff --git a/CommonClient.py b/CommonClient.py index 884e9d37afc2..26d167d9ce07 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -318,16 +318,17 @@ def on_deathlink(self, data: dict): logger.info(f"DeathLink: Received from {data['source']}") async def send_death(self, death_text: str = ""): - logger.info("DeathLink: Sending death to your friends...") - self.last_death_link = time.time() - await self.send_msgs([{ - "cmd": "Bounce", "tags": ["DeathLink"], - "data": { - "time": self.last_death_link, - "source": self.player_names[self.slot], - "cause": death_text - } - }]) + if self.server and self.server.socket: + logger.info("DeathLink: Sending death to your friends...") + self.last_death_link = time.time() + await self.send_msgs([{ + "cmd": "Bounce", "tags": ["DeathLink"], + "data": { + "time": self.last_death_link, + "source": self.player_names[self.slot], + "cause": death_text + } + }]) async def update_death_link(self, death_link): old_tags = self.tags.copy() diff --git a/FactorioClient.py b/FactorioClient.py index d13078203eed..f1f6844b53e2 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -183,7 +183,7 @@ async def game_watcher(ctx: FactorioContext): }])) ctx.rcon_client.send_command( f"/ap-energylink -{value}") - logger.info(f"EnergyLink: Sent {value} Joules") + logger.info(f"EnergyLink: Sent {Utils.format_SI_prefix(value)}J") await asyncio.sleep(0.1) diff --git a/kvui.py b/kvui.py index 89c63639d6f4..80b02722567b 100644 --- a/kvui.py +++ b/kvui.py @@ -91,9 +91,9 @@ class ServerToolTip(Label): pass -class ServerLabel(HoverBehavior, Label): +class HovererableLabel(HoverBehavior, Label): def __init__(self, *args, **kwargs): - super(ServerLabel, self).__init__(*args, **kwargs) + super(HovererableLabel, self).__init__(*args, **kwargs) self.layout = FloatLayout() self.popuplabel = ServerToolTip(text="Test") self.layout.add_widget(self.popuplabel) @@ -105,6 +105,12 @@ def on_enter(self): def on_leave(self): App.get_running_app().root.remove_widget(self.layout) + @property + def ctx(self) -> context_type: + return App.get_running_app().ctx + + +class ServerLabel(HovererableLabel): def get_text(self): if self.ctx.server: ctx = self.ctx @@ -138,10 +144,6 @@ def get_text(self): else: return "No current server connection. \nPlease connect to an Archipelago server." - @property - def ctx(self) -> context_type: - return App.get_running_app().ctx - class MainLayout(GridLayout): pass