mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
Suit: Implement auto-toggle of Suit line based on CAPI data
* There's a 'visible' argument to force it, default None to ignore. That flag is checked first in the function, and then it sets the 'current' state to the opposite so the following conditional will do the right thing. * Toggling is triggered in AppWindow.getandsend().
This commit is contained in:
parent
3baf92706d
commit
9ca55e7af7
@ -599,22 +599,28 @@ class AppWindow(object):
|
||||
|
||||
self.postprefs(False) # Companion login happens in callback from monitor
|
||||
|
||||
def toggle_suit_row(self, visible=True) -> None:
|
||||
def toggle_suit_row(self, visible: Optional[bool] = None) -> None:
|
||||
"""
|
||||
Toggle the visibility of the 'Suit' row.
|
||||
|
||||
:param visible: UNIMPLEMENTED
|
||||
:param visible: Force visibility to this.
|
||||
"""
|
||||
if visible is True:
|
||||
self.suit_shown = False
|
||||
|
||||
elif visible is False:
|
||||
self.suit_shown = True
|
||||
|
||||
if not self.suit_shown:
|
||||
self.suit_label.grid(row=self.suit_grid_row, column=0, sticky=tk.W)
|
||||
self.suit.grid(row=self.suit_grid_row, column=1, sticky=tk.EW)
|
||||
self.suit_shown = True
|
||||
|
||||
else:
|
||||
# Hide the Suit row
|
||||
self.suit_label.grid_forget()
|
||||
self.suit.grid_forget()
|
||||
|
||||
self.suit_shown = not self.suit_shown
|
||||
self.suit_shown = False
|
||||
|
||||
def postprefs(self, dologin: bool = True):
|
||||
"""Perform necessary actions after the Preferences dialog is applied."""
|
||||
@ -883,6 +889,12 @@ class AppWindow(object):
|
||||
if monitor.state['Modules']:
|
||||
self.ship.configure(state=True)
|
||||
|
||||
if monitor.state.get('SuitCurrent') is not None:
|
||||
self.toggle_suit_row(visible=True)
|
||||
|
||||
else:
|
||||
self.toggle_suit_row(visible=False)
|
||||
|
||||
if data['commander'].get('credits') is not None:
|
||||
monitor.state['Credits'] = data['commander']['credits']
|
||||
monitor.state['Loan'] = data['commander'].get('debt', 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user