fix(hud): disable auto-hide by default, add debug mode
- Auto-hide feature disabled by default (was causing issues) - Add debug mode to see detected window titles - Add get_foreground_window_title() for troubleshooting - Case-insensitive window title matching
This commit is contained in:
parent
6ed97f3ffa
commit
6155aad694
|
|
@ -146,10 +146,11 @@ class HUDOverlay(QWidget):
|
||||||
self._drag_offset = QPoint()
|
self._drag_offset = QPoint()
|
||||||
self._modifier_pressed = False
|
self._modifier_pressed = False
|
||||||
|
|
||||||
# Game window detection
|
# Game window detection (disabled by default - enable after testing)
|
||||||
self._auto_hide_with_game = True # Auto-hide when game not focused
|
self._auto_hide_with_game = False # Auto-hide when game not focused
|
||||||
self._game_window_title = "Entropia Universe" # Window title to track
|
self._game_window_title = "Entropia Universe" # Window title to track
|
||||||
self._was_visible_before_unfocus = False
|
self._was_visible_before_unfocus = False
|
||||||
|
self._debug_window_detection = False # Set to True to debug
|
||||||
|
|
||||||
# Timer for session time updates
|
# Timer for session time updates
|
||||||
self._timer = QTimer(self)
|
self._timer = QTimer(self)
|
||||||
|
|
@ -660,24 +661,56 @@ class HUDOverlay(QWidget):
|
||||||
GetWindowTextW(hwnd, buffer, length + 1)
|
GetWindowTextW(hwnd, buffer, length + 1)
|
||||||
title = buffer.value
|
title = buffer.value
|
||||||
|
|
||||||
# Check if game is in foreground
|
if self._debug_window_detection:
|
||||||
is_game_focused = self._game_window_title in title
|
print(f"[HUD DEBUG] Foreground window: '{title}'")
|
||||||
|
|
||||||
|
# Check if game is in foreground (case insensitive)
|
||||||
|
is_game_focused = self._game_window_title.lower() in title.lower()
|
||||||
|
|
||||||
if is_game_focused:
|
if is_game_focused:
|
||||||
# Game is focused - show HUD if it was hidden
|
# Game is focused - show HUD if needed
|
||||||
if self._was_visible_before_unfocus and not self.isVisible():
|
if not self.isVisible():
|
||||||
self.show()
|
self.show()
|
||||||
|
if self._debug_window_detection:
|
||||||
|
print(f"[HUD DEBUG] Game focused - showing HUD")
|
||||||
else:
|
else:
|
||||||
# Game not focused - hide HUD if visible
|
# Game not focused - hide HUD if visible
|
||||||
if self.isVisible():
|
if self.isVisible():
|
||||||
self._was_visible_before_unfocus = True
|
|
||||||
self.hide()
|
self.hide()
|
||||||
else:
|
if self._debug_window_detection:
|
||||||
self._was_visible_before_unfocus = False
|
print(f"[HUD DEBUG] Game unfocused - hiding HUD")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
# Silently ignore errors (e.g., Windows API issues)
|
if self._debug_window_detection:
|
||||||
|
print(f"[HUD DEBUG] Error: {e}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_foreground_window_title(self) -> Optional[str]:
|
||||||
|
"""
|
||||||
|
Get the title of the current foreground window.
|
||||||
|
Useful for debugging window detection.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Window title string or None if unavailable
|
||||||
|
"""
|
||||||
|
if sys.platform != 'win32':
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
hwnd = GetForegroundWindow()
|
||||||
|
if hwnd:
|
||||||
|
length = GetWindowTextLengthW(hwnd)
|
||||||
|
if length > 0:
|
||||||
|
buffer = ctypes.create_unicode_buffer(length + 1)
|
||||||
|
GetWindowTextW(hwnd, buffer, length + 1)
|
||||||
|
return buffer.value
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
|
def set_debug_window_detection(self, enabled: bool) -> None:
|
||||||
|
"""Enable/disable debug output for window detection."""
|
||||||
|
self._debug_window_detection = enabled
|
||||||
|
|
||||||
def set_auto_hide_with_game(self, enabled: bool) -> None:
|
def set_auto_hide_with_game(self, enabled: bool) -> None:
|
||||||
"""
|
"""
|
||||||
Enable/disable auto-hide when game not focused.
|
Enable/disable auto-hide when game not focused.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue