Skip to content

Commit

Permalink
Add: Double Break warning, "End Break" label
Browse files Browse the repository at this point in the history
1. If "Go to Break" is pressed, and a break is already scheduled for
   this round (or time has already been added, manually or in settings,
   with "invisible breaks"), a warning pops up saying so.  For 1/2 a
   second, so it doesn't stick around for ever.
2. During a visible break, the "End Round" button changes to
   "End Break".
3. Fixed sizing of "Round #" so that visible break text doesn't
   overflow.
  • Loading branch information
mycroftw committed Oct 3, 2024
1 parent 7a9993c commit 24b1a3d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bridge_clock_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def _next_round(self) -> None:
else:
self.round += 1
self._in_break = False
self.button_end_round.SetLabel("End Round")
self._update_round()
self._reset_clock()
if not self.settings.break_visible and self._break_this_round():
Expand All @@ -312,10 +313,11 @@ def _go_to_break(self) -> None:
self._in_break = True
self.label_clock.SetBackgroundColour(BREAK_COLOUR)
self.label_round.SetBackgroundColour(BREAK_COLOUR)
self.label_round.SetLabelText("TIME TO NEXT ROUND:")
self.label_round.SetLabelText("NEXT ROUND IN:")
self.round_end = wx.DateTime.Now() + wx.TimeSpan.Minutes(
self.settings.break_length
)
self.button_end_round.SetLabel("End Break")
self._update_clock()

def _game_over(self) -> None:
Expand Down Expand Up @@ -445,10 +447,7 @@ def on_resize(self, event) -> None:
"""Hack to resolve sizer not auto-sizing with panel on maximize/unmaximize."""
self.Layout()
self.sizer_1.SetDimension(self.panel_1.GetPosition(), self.panel_1.GetSize())
self._handle_resize(
self.label_round,
"ROUND 8" if self.settings.rounds < 10 else "ROUND 88",
)
self._handle_resize(self.label_round, "NEXT ROUND IN:")
self._handle_resize(
self.label_clock,
"88:88" if self.settings.round_length < 100 else "888:88",
Expand Down Expand Up @@ -523,6 +522,16 @@ def on_goto_break(self, event):
if not self.settings.break_visible: # treat as "add break minutes to clock"
self.round_end.Add(wx.TimeSpan.Minutes(self.settings.break_length))
self._update_clock()
else:
dlg = wx.GenericProgressDialog(
"",
"Break already scheduled for this round.",
style=wx.PD_AUTO_HIDE,
)
dlg.SetPosition( # show above "go to break" button)
self.button_break.GetScreenPosition() - (0, dlg.GetSize().GetHeight())
)
wx.CallLater(500, dlg.Update, 100)
event.Skip()

def on_button_end_round(self, event) -> None:
Expand Down

0 comments on commit 24b1a3d

Please sign in to comment.