Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hidden overlay #28

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/params.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[general]
; How many tabs should be checked for items in chest. Note: All 5 Tabs must be unlocked!
check_chest_tabs=2
; Transparancy of the overlay when not hovering it (has a 3 second dealy after hovering); The "shown" transparncy is 0.89
hidden_transparency=0.35
; Which additional scripts should be run. Seperated by comma
; Currently available:
; 1920x1080: rogue_tb
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def load_data(self):
self.general = {
"check_chest_tabs": int(self._select_val("general", "check_chest_tabs")),
"run_scripts": run_scripts_str.split(",") if run_scripts_str else [],
"hidden_transparency": max(0.01, float(self._select_val("general", "hidden_transparency"))),
}

for key in self.configs["params"]["parser"]["char"]:
Expand Down
20 changes: 19 additions & 1 deletion src/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def __init__(self):
self.is_minimized = True
self.root = tk.Tk()
self.root.title("LootFilter Overlay")
self.root.attributes("-alpha", 0.89)
self.root.attributes("-alpha", 0.87)
self.hide_id = self.root.after(15000, lambda: self.root.attributes("-alpha", Config().general["hidden_transparency"]))
self.root.overrideredirect(True)
# self.root.wm_attributes("-transparentcolor", "white")
self.root.wm_attributes("-topmost", True)
Expand All @@ -49,6 +50,8 @@ def __init__(self):
f"{self.initial_width}x{self.initial_height}+{self.screen_width//2 - self.initial_width//2 + self.screen_off_x}+{self.screen_height - self.initial_height + self.screen_off_y}"
)
self.canvas.pack()
self.root.bind("<Enter>", self.show_canvas)
self.root.bind("<Leave>", self.hide_canvas)

self.toggle_button = tk.Button(
self.root,
Expand Down Expand Up @@ -109,6 +112,21 @@ def __init__(self):
listbox_handler.setLevel(Logger._logger_level)
Logger.logger.addHandler(listbox_handler)

def show_canvas(self, event):
# Cancel the pending hide if it exists
if self.hide_id:
self.root.after_cancel(self.hide_id)
self.hide_id = None
# Make the window visible
self.root.attributes("-alpha", 0.89)

def hide_canvas(self, event):
# Reset the hide timer
if self.is_minimized:
if self.hide_id is not None:
self.root.after_cancel(self.hide_id)
self.hide_id = self.root.after(3000, lambda: self.root.attributes("-alpha", Config().general["hidden_transparency"]))

def toggle_size(self):
if not self.is_minimized:
self.canvas.config(height=self.initial_height, width=self.initial_width)
Expand Down