Skip to content

Commit

Permalink
Merge pull request #138 from demon5760/tick_overlay_position
Browse files Browse the repository at this point in the history
Allow show / hide for the tick overlay message
  • Loading branch information
aussig authored Sep 14, 2023
2 parents 6218eea + 941238d commit 14bd90b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bgstally/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def load(self):
self.DiscordPostStyle:tk.StringVar = tk.StringVar(value=config.get_str('XDiscordPostStyle', default=DiscordPostStyle.EMBED))
self.DiscordActivity:tk.StringVar = tk.StringVar(value=config.get_str('XDiscordActivity', default=DiscordActivity.BOTH))
self.EnableOverlay:tk.StringVar = tk.StringVar(value=config.get_str('XEnableOverlay', default=CheckStates.STATE_ON))
self.EnableOverlayCurrentTick:tk.StringVar = tk.StringVar(value=config.get_str('BGST_EnableOverlayCurrentTick', default=CheckStates.STATE_ON))
self.EnableSystemActivityByDefault:tk.StringVar = tk.StringVar(value=config.get_str('BGST_EnableSystemActivityByDefault', default=CheckStates.STATE_ON))

# Persistent values
Expand All @@ -56,7 +57,6 @@ def refresh(self):
"""
self.enable_overlay:bool = (self.EnableOverlay.get() == CheckStates.STATE_ON)


def save(self):
"""
Save our state
Expand All @@ -76,6 +76,7 @@ def save(self):
config.set('XDiscordPostStyle', self.DiscordPostStyle.get())
config.set('XDiscordActivity', self.DiscordActivity.get())
config.set('XEnableOverlay', self.EnableOverlay.get())
config.set('BGST_EnableOverlayCurrentTick', self.EnableOverlayCurrentTick.get())
config.set('BGST_EnableSystemActivityByDefault', self.EnableSystemActivityByDefault.get())

# Persistent values
Expand Down
28 changes: 25 additions & 3 deletions bgstally/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,21 @@ def get_prefs_frame(self, parent_frame: tk.Frame):
EntryPlus(frame, textvariable=self.bgstally.state.DiscordUsername).grid(row=current_row, column=1, padx=10, pady=1, sticky=tk.W); current_row += 1

ttk.Separator(frame, orient=tk.HORIZONTAL).grid(row=current_row, columnspan=2, padx=10, pady=1, sticky=tk.EW); current_row += 1
nb.Label(frame, text="In-game Overlay", font=FONT_HEADING).grid(row=current_row, column=0, padx=10, sticky=tk.NW)
nb.Checkbutton(frame, text="Show In-game Overlay", variable=self.bgstally.state.EnableOverlay, state="disabled" if self.bgstally.overlay.edmcoverlay == None else "enabled", onvalue=CheckStates.STATE_ON, offvalue=CheckStates.STATE_OFF, command=self.bgstally.state.refresh).grid(row=current_row, column=1, padx=10, sticky=tk.W); current_row += 1
nb.Label(frame, text="In-game Overlay", font=FONT_HEADING).grid(row=current_row, column=0, padx=10, sticky=tk.NW); current_row += 1
nb.Checkbutton(frame, text="Show In-game Overlay",
variable=self.bgstally.state.EnableOverlay,
state=self._overlay_options_state(),
onvalue=CheckStates.STATE_ON,
offvalue=CheckStates.STATE_OFF,
command=self.bgstally.state.refresh
).grid(row=current_row, column=1, padx=10, sticky=tk.W); current_row += 1
nb.Checkbutton(frame, text="Show 'Curr Tick' Overlay",
variable=self.bgstally.state.EnableOverlayCurrentTick,
state=self._overlay_options_state(),
onvalue=CheckStates.STATE_ON,
offvalue=CheckStates.STATE_OFF,
).grid(row=current_row, column=1, padx=10, sticky=tk.W); current_row += 1

if self.bgstally.overlay.edmcoverlay == None:
nb.Label(frame, text="In-game overlay support requires the separate EDMCOverlay plugin to be installed - see the instructions for more information.").grid(columnspan=2, padx=10, sticky=tk.W); current_row += 1

Expand Down Expand Up @@ -198,7 +211,9 @@ def _worker(self) -> None:
current_activity:Activity = self.bgstally.activity_manager.get_current_activity()

# Current Tick Time
self.bgstally.overlay.display_message("tick", f"Curr Tick: {self.bgstally.tick.get_formatted(DATETIME_FORMAT_OVERLAY)}", True)
if self.bgstally.state.EnableOverlayCurrentTick.get() == CheckStates.STATE_ON:
self.bgstally.overlay.display_message("tick", f"Curr Tick: {self.bgstally.tick.get_formatted(DATETIME_FORMAT_OVERLAY)}", True)

minutes_delta:int = int((datetime.utcnow() - self.bgstally.tick.next_predicted()) / timedelta(minutes=1))

# Activity Indicator
Expand Down Expand Up @@ -290,3 +305,10 @@ def _confirm_force_tick(self):
"""
answer = askyesno(title="Confirm FORCE a New Tick", message="This will move your current activity into the previous tick, and clear activity for the current tick.\n\nWARNING: It is not usually necessary to force a tick. Only do this if you know FOR CERTAIN there has been a tick but BGS-Tally is not showing it.\n\nAre you sure that you want to do this?", default="no")
if answer: self.bgstally.new_tick(True, UpdateUIPolicy.IMMEDIATE)

def _overlay_options_state(self):
"""
If the overlay plugin is not available, we want to disable the options so users are not interacting
with them expecting results
"""
"disabled" if self.bgstally.overlay.edmcoverlay == None else "enabled"

0 comments on commit 14bd90b

Please sign in to comment.