128 lines
3.8 KiB
Python
128 lines
3.8 KiB
Python
# Description: Test script for HUD Overlay
|
|
# Run this to verify the HUD works correctly with mock data
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
try:
|
|
from PyQt6.QtWidgets import QApplication
|
|
from PyQt6.QtCore import QTimer
|
|
except ImportError as e:
|
|
print("❌ PyQt6 is not installed.")
|
|
print(" Install with: pip install PyQt6")
|
|
sys.exit(1)
|
|
|
|
from decimal import Decimal
|
|
from ui.hud_overlay import HUDOverlay, HUDStats
|
|
|
|
|
|
def test_hud():
|
|
"""Test the HUD overlay with mock data."""
|
|
app = QApplication(sys.argv)
|
|
app.setQuitOnLastWindowClosed(False)
|
|
|
|
print("\n" + "="*60)
|
|
print("🍋 LEMONTROPIA HUD OVERLAY - TEST MODE")
|
|
print("="*60)
|
|
|
|
# Create HUD
|
|
hud = HUDOverlay()
|
|
hud.show()
|
|
|
|
print("✅ HUD created and shown")
|
|
print(f" Position: ({hud.x()}, {hud.y()})")
|
|
print(f" Size: {hud.width()}x{hud.height()}")
|
|
|
|
# Start session
|
|
hud.start_session()
|
|
print("✅ Session started")
|
|
|
|
# Test initial stats
|
|
hud.update_stats({
|
|
'weapon': 'Omegaton M2100',
|
|
'loadout': 'Test Loadout',
|
|
})
|
|
print("✅ Initial stats set")
|
|
|
|
# Simulate events
|
|
import random
|
|
|
|
event_count = [0]
|
|
|
|
def simulate():
|
|
event_count[0] += 1
|
|
|
|
# Simulate various events
|
|
event_type = random.choice([
|
|
'loot', 'damage', 'kill', 'global', 'hof'
|
|
])
|
|
|
|
if event_type == 'loot':
|
|
value = Decimal(str(random.uniform(0.5, 25.0)))
|
|
hud.update_stats({'loot_delta': value})
|
|
print(f" 💰 Loot: +{value:.2f} PED")
|
|
|
|
elif event_type == 'damage':
|
|
damage = random.randint(10, 75)
|
|
hud.update_stats({'damage_dealt_add': damage})
|
|
print(f" ⚔️ Damage dealt: +{damage}")
|
|
|
|
elif event_type == 'kill':
|
|
hud.update_stats({'kills_add': 1})
|
|
current = hud.get_stats().kills
|
|
print(f" 💀 Kill! Total: {current}")
|
|
|
|
elif event_type == 'global':
|
|
hud.update_stats({'globals_add': 1})
|
|
print(f" 🌍 GLOBAL!!!")
|
|
|
|
elif event_type == 'hof':
|
|
hud.update_stats({'hofs_add': 1})
|
|
print(f" 🏆 HALL OF FAME!")
|
|
|
|
# Stop after 10 events
|
|
if event_count[0] >= 10:
|
|
timer.stop()
|
|
print("\n" + "="*60)
|
|
print("✅ TEST COMPLETE")
|
|
print("="*60)
|
|
|
|
final_stats = hud.get_stats()
|
|
print(f"\nFinal Stats:")
|
|
print(f" Session time: {final_stats.session_time}")
|
|
print(f" Total loot: {final_stats.loot_total:.2f} PED")
|
|
print(f" Kills: {final_stats.kills}")
|
|
print(f" Globals: {final_stats.globals_count}")
|
|
print(f" HoFs: {final_stats.hofs_count}")
|
|
print(f" Damage dealt: {final_stats.damage_dealt}")
|
|
|
|
hud.end_session()
|
|
print("\n Closing in 3 seconds...")
|
|
QTimer.singleShot(3000, app.quit)
|
|
|
|
# Run simulation every 2 seconds
|
|
timer = QTimer()
|
|
timer.timeout.connect(simulate)
|
|
timer.start(2000)
|
|
|
|
print("\n📋 FEATURES TO VERIFY:")
|
|
print(" 1. HUD appears on screen (top-right default)")
|
|
print(" 2. Frameless window with gold border")
|
|
print(" 3. Semi-transparent background")
|
|
print(" 4. Stats update automatically")
|
|
print(" 5. Session timer counts up")
|
|
print(" 6. Hold Ctrl to drag the HUD")
|
|
print(" 7. Click-through works (clicks pass to window below)")
|
|
print("\n Close window or wait for auto-close...")
|
|
print("="*60 + "\n")
|
|
|
|
sys.exit(app.exec())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_hud()
|