fix: pass full loadout info to session and display gear names in HUD
- Updated loadout_selected signal to emit dict with full loadout info - _on_loadout_selected_for_session now extracts weapon/armor/healing names - HUD now shows gear names from selected loadout - Cost tracker skipped for JSON-based loadouts (need DB save first)
This commit is contained in:
parent
d7f1e61533
commit
ca8f9f8eb3
|
|
@ -24,7 +24,7 @@ class LoadoutSelectionDialog(QDialog):
|
||||||
Shows saved loadouts with their per-action cost metrics.
|
Shows saved loadouts with their per-action cost metrics.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
loadout_selected = pyqtSignal(int, str) # loadout_id, loadout_name
|
loadout_selected = pyqtSignal(dict) # loadout_info dict with id, name, source, data
|
||||||
|
|
||||||
def __init__(self, parent=None, db_manager: Optional[DatabaseManager] = None):
|
def __init__(self, parent=None, db_manager: Optional[DatabaseManager] = None):
|
||||||
"""
|
"""
|
||||||
|
|
@ -293,7 +293,23 @@ class LoadoutSelectionDialog(QDialog):
|
||||||
def _on_accept(self):
|
def _on_accept(self):
|
||||||
"""Handle OK button - start session with selected loadout."""
|
"""Handle OK button - start session with selected loadout."""
|
||||||
if self.selected_loadout_id:
|
if self.selected_loadout_id:
|
||||||
self.loadout_selected.emit(self.selected_loadout_id, self.selected_loadout_name or "")
|
# Find the full loadout info
|
||||||
|
loadout_info = None
|
||||||
|
for lo in self.all_loadouts:
|
||||||
|
if lo['id'] == self.selected_loadout_id:
|
||||||
|
loadout_info = lo
|
||||||
|
break
|
||||||
|
|
||||||
|
if loadout_info:
|
||||||
|
self.loadout_selected.emit(loadout_info)
|
||||||
|
else:
|
||||||
|
# Fallback
|
||||||
|
self.loadout_selected.emit({
|
||||||
|
'id': self.selected_loadout_id,
|
||||||
|
'name': self.selected_loadout_name or "Unknown",
|
||||||
|
'source': 'unknown',
|
||||||
|
'data': {}
|
||||||
|
})
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
def _on_no_loadout(self):
|
def _on_no_loadout(self):
|
||||||
|
|
@ -307,7 +323,12 @@ class LoadoutSelectionDialog(QDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
if reply == QMessageBox.StandardButton.Yes:
|
if reply == QMessageBox.StandardButton.Yes:
|
||||||
self.loadout_selected.emit(0, "No Loadout")
|
self.loadout_selected.emit({
|
||||||
|
'id': 0,
|
||||||
|
'name': 'No Loadout',
|
||||||
|
'source': 'none',
|
||||||
|
'data': {}
|
||||||
|
})
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -935,27 +935,34 @@ class MainWindow(QMainWindow):
|
||||||
|
|
||||||
# Show HUD and start session tracking
|
# Show HUD and start session tracking
|
||||||
self.hud.show()
|
self.hud.show()
|
||||||
weapon_name = self._selected_weapon or "Unknown"
|
|
||||||
|
# Get gear names from loadout selection if available, otherwise fall back to selected weapon
|
||||||
|
weapon_name = getattr(self, '_session_weapon_name', None) or self._selected_weapon or "Unknown"
|
||||||
|
armor_name = getattr(self, '_session_armor_name', None) or "None"
|
||||||
|
healing_name = getattr(self, '_session_healing_name', None) or "None"
|
||||||
|
|
||||||
weapon_stats = self._selected_weapon_stats or {}
|
weapon_stats = self._selected_weapon_stats or {}
|
||||||
weapon_dpp = Decimal(str(weapon_stats.get('dpp', 0)))
|
weapon_dpp = Decimal(str(weapon_stats.get('dpp', 0)))
|
||||||
weapon_cost_per_hour = Decimal(str(weapon_stats.get('cost_per_hour', 0)))
|
weapon_cost_per_hour = Decimal(str(weapon_stats.get('cost_per_hour', 0)))
|
||||||
|
|
||||||
# Get loadout name from session selection
|
# Get loadout name from session selection
|
||||||
loadout_name = getattr(self, '_session_loadout_name', None) or "Default"
|
loadout_info = getattr(self, '_session_loadout_info', None)
|
||||||
loadout_id = getattr(self, '_session_loadout_id', None)
|
loadout_name = loadout_info.get('name', 'Default') if loadout_info else "Default"
|
||||||
|
|
||||||
self.hud.start_session(
|
self.hud.start_session(
|
||||||
weapon=weapon_name,
|
weapon=weapon_name,
|
||||||
|
armor=armor_name,
|
||||||
|
fap=healing_name,
|
||||||
loadout=loadout_name,
|
loadout=loadout_name,
|
||||||
weapon_dpp=weapon_dpp,
|
weapon_dpp=weapon_dpp,
|
||||||
weapon_cost_per_hour=weapon_cost_per_hour
|
weapon_cost_per_hour=weapon_cost_per_hour
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up cost tracker if loadout selected
|
# Set up cost tracker if loadout selected
|
||||||
if loadout_id:
|
if loadout_info and loadout_info.get('id'):
|
||||||
self._setup_session_cost_tracker(loadout_id)
|
self._setup_session_cost_tracker(loadout_info)
|
||||||
|
|
||||||
self.log_info("HUD", f"HUD shown - Weapon: {weapon_name}, Loadout: {loadout_name} (DPP: {weapon_dpp:.2f}, Cost/h: {weapon_cost_per_hour:.2f} PED)")
|
self.log_info("HUD", f"HUD shown - Weapon: {weapon_name}, Armor: {armor_name}, Healing: {healing_name}, Loadout: {loadout_name}")
|
||||||
|
|
||||||
def _setup_log_watcher_callbacks(self):
|
def _setup_log_watcher_callbacks(self):
|
||||||
"""Setup LogWatcher event callbacks."""
|
"""Setup LogWatcher event callbacks."""
|
||||||
|
|
@ -1145,11 +1152,21 @@ class MainWindow(QMainWindow):
|
||||||
self._log_watcher_thread = None
|
self._log_watcher_thread = None
|
||||||
self.log_info("LogWatcher", "Stopped")
|
self.log_info("LogWatcher", "Stopped")
|
||||||
|
|
||||||
def _setup_session_cost_tracker(self, loadout_id: int):
|
def _setup_session_cost_tracker(self, loadout_info: dict):
|
||||||
"""Set up session cost tracker with selected loadout."""
|
"""Set up session cost tracker with selected loadout."""
|
||||||
from core.session_cost_tracker import SessionCostTracker
|
from core.session_cost_tracker import SessionCostTracker
|
||||||
from core.database import DatabaseManager
|
from core.database import DatabaseManager
|
||||||
|
|
||||||
|
loadout_id = loadout_info.get('id')
|
||||||
|
loadout_source = loadout_info.get('source')
|
||||||
|
|
||||||
|
# If JSON-based loadout, we need to save it to database first or handle differently
|
||||||
|
if loadout_source == 'json':
|
||||||
|
# For now, skip cost tracking for JSON loadouts
|
||||||
|
# TODO: Save JSON loadout to database first, then use its ID
|
||||||
|
self.log_warning("CostTracker", "Cost tracking not available for file-based loadouts. Save to database first.")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DatabaseManager()
|
db = DatabaseManager()
|
||||||
self._cost_tracker = SessionCostTracker(
|
self._cost_tracker = SessionCostTracker(
|
||||||
|
|
@ -1217,17 +1234,27 @@ class MainWindow(QMainWindow):
|
||||||
dialog.rejected.connect(lambda: self.log_info("Session", "Session start cancelled - no loadout selected"))
|
dialog.rejected.connect(lambda: self.log_info("Session", "Session start cancelled - no loadout selected"))
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
def _on_loadout_selected_for_session(self, loadout_id: int, loadout_name: str):
|
def _on_loadout_selected_for_session(self, loadout_info: dict):
|
||||||
"""Handle loadout selection and start session."""
|
"""Handle loadout selection and start session."""
|
||||||
|
loadout_id = loadout_info.get('id', 0)
|
||||||
|
loadout_name = loadout_info.get('name', 'No Loadout')
|
||||||
|
loadout_data = loadout_info.get('data', {})
|
||||||
|
|
||||||
if loadout_id > 0:
|
if loadout_id > 0:
|
||||||
self.log_info("Session", f"Starting session with loadout: {loadout_name} (ID: {loadout_id})")
|
self.log_info("Session", f"Starting session with loadout: {loadout_name} (ID: {loadout_id})")
|
||||||
# Store the selected loadout ID for use in start_session
|
# Store the selected loadout info for use in start_session
|
||||||
self._session_loadout_id = loadout_id
|
self._session_loadout_info = loadout_info
|
||||||
self._session_loadout_name = loadout_name
|
|
||||||
|
# Extract gear names from loadout data
|
||||||
|
self._session_weapon_name = loadout_data.get('weapon_name', 'Unknown')
|
||||||
|
self._session_armor_name = loadout_data.get('armor_set_name', 'Unknown')
|
||||||
|
self._session_healing_name = loadout_data.get('heal_name', 'Unknown')
|
||||||
else:
|
else:
|
||||||
self.log_info("Session", "Starting session without loadout")
|
self.log_info("Session", "Starting session without loadout")
|
||||||
self._session_loadout_id = None
|
self._session_loadout_info = None
|
||||||
self._session_loadout_name = None
|
self._session_weapon_name = None
|
||||||
|
self._session_armor_name = None
|
||||||
|
self._session_healing_name = None
|
||||||
|
|
||||||
# Now start the session
|
# Now start the session
|
||||||
if self.current_project:
|
if self.current_project:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue