diff --git a/ui/hud_overlay_clean.py b/ui/hud_overlay_clean.py index d24dcfd..cb28290 100644 --- a/ui/hud_overlay_clean.py +++ b/ui/hud_overlay_clean.py @@ -839,6 +839,7 @@ class HUDOverlay(QWidget): def update_loot(self, value_ped: Decimal, is_shrapnel: bool = False): """Update loot value - tracks per-kill totals for highest loot.""" + logger.debug(f"[HUD] update_loot called: value={value_ped}, is_shrapnel={is_shrapnel}, session_active={self.session_active}") if self.session_active: now = datetime.now() @@ -868,6 +869,7 @@ class HUDOverlay(QWidget): self._stats.recalculate() self._refresh_display() + logger.debug(f"[HUD] update_loot complete: shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}") def update_shrapnel(self, amount: Decimal): """Update shrapnel amount (convenience method).""" @@ -875,6 +877,7 @@ class HUDOverlay(QWidget): def update_weapon_cost(self, cost_ped: Decimal): """Update weapon cost.""" + logger.debug(f"[HUD] update_weapon_cost called: cost={cost_ped}, session_active={self.session_active}") if self.session_active: self._stats.weapon_cost_total += cost_ped self._stats.cost_total += cost_ped @@ -883,6 +886,7 @@ class HUDOverlay(QWidget): def update_armor_cost(self, cost_ped: Decimal): """Update armor cost.""" + logger.debug(f"[HUD] update_armor_cost called: cost={cost_ped}, session_active={self.session_active}") if self.session_active: self._stats.armor_cost_total += cost_ped self._stats.cost_total += cost_ped @@ -891,6 +895,7 @@ class HUDOverlay(QWidget): def update_healing_cost(self, cost_ped: Decimal): """Update healing cost.""" + logger.debug(f"[HUD] update_healing_cost called: cost={cost_ped}, session_active={self.session_active}") if self.session_active: self._stats.healing_cost_total += cost_ped self._stats.cost_total += cost_ped @@ -899,6 +904,7 @@ class HUDOverlay(QWidget): def update_kills(self, count: int = 1): """Update kill count.""" + logger.debug(f"[HUD] update_kills called: count={count}, session_active={self.session_active}") if self.session_active: self._stats.kills += count self._refresh_display() diff --git a/ui/main_window.py b/ui/main_window.py index 42a796e..e4b0e85 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -279,6 +279,18 @@ class MainWindow(QMainWindow): self._selected_medical_tool: Optional[str] = None self._selected_medical_tool_stats: Optional[dict] = None self._selected_loadout: Optional[Any] = None + + # Session cost tracking (initialized empty, populated by loadout selection) + self._session_costs: dict = { + 'cost_per_shot': Decimal('0'), + 'cost_per_hit': Decimal('0'), + 'cost_per_heal': Decimal('0'), + } + self._session_display: dict = { + 'weapon_name': 'None', + 'armor_name': 'None', + 'healing_name': 'None', + } # Setup UI self.setup_ui() @@ -1004,6 +1016,7 @@ class MainWindow(QMainWindow): Calculates healing cost based on FAP decay and updates HUD. """ heal_amount = event.data.get('heal_amount', Decimal('0')) + logger.debug(f"[EVENT] on_heal: heal_amount={heal_amount}") # Calculate heal cost based on selected medical tool decay # Get decay per heal from loadout or use default @@ -1021,16 +1034,23 @@ class MainWindow(QMainWindow): # Update HUD with heal event try: + logger.debug(f"[DEBUG] _session_costs={self._session_costs}") # Track healing cost if self._session_costs: cost_per_heal = self._session_costs.get('cost_per_heal', Decimal('0')) + logger.debug(f"[DEBUG] cost_per_heal={cost_per_heal}") if cost_per_heal > 0: + logger.debug(f"[HUD] update_healing_cost({cost_per_heal})") self.hud.update_healing_cost(cost_per_heal) # Track heal amount (as event dict for new HUD) + logger.debug(f"[HUD] on_heal_event({{'heal_amount': {heal_amount}}})") self.hud.on_heal_event({'heal_amount': heal_amount}) + logger.debug(f"[HUD] Heal update successful") except Exception as e: - logger.error(f"Error updating HUD heal: {e}") + logger.error(f"[ERROR] Error updating HUD heal: {e}") + import traceback + logger.error(traceback.format_exc()) # Log to UI self.log_info("Heal", f"Healed {heal_amount} HP (Cost: {decay_cost:.4f} PED)") @@ -1042,20 +1062,28 @@ class MainWindow(QMainWindow): item_name = event.data.get('item_name', 'Unknown') value_ped = event.data.get('value_ped', Decimal('0.0')) quantity = event.data.get('quantity', 1) + + logger.debug(f"[EVENT] on_loot: item={item_name}, value={value_ped}, qty={quantity}") # Skip Universal Ammo if item_name == 'Universal Ammo': + logger.debug("[EVENT] on_loot: skipped Universal Ammo") return try: # Update kill count (each loot event = 1 kill) + logger.debug(f"[HUD] update_kills(1)") self.hud.update_kills(1) # Update loot value is_shrapnel = 'shrapnel' in item_name.lower() + logger.debug(f"[HUD] update_loot({value_ped}, is_shrapnel={is_shrapnel})") self.hud.update_loot(value_ped, is_shrapnel=is_shrapnel) + logger.debug(f"[HUD] Loot update successful") except Exception as e: - logger.error(f"Error updating HUD loot: {e}") + logger.error(f"[ERROR] Error updating HUD loot: {e}") + import traceback + logger.error(traceback.format_exc()) # Queue database write for main thread (SQLite thread safety) if self._current_db_session_id: @@ -1114,17 +1142,24 @@ class MainWindow(QMainWindow): from decimal import Decimal try: damage = event.data.get('damage', 0) + logger.debug(f"[EVENT] on_damage_dealt: damage={damage}") if damage: # Track damage amount + logger.debug(f"[HUD] on_damage_dealt({damage})") self.hud.on_damage_dealt(Decimal(str(damage))) # Track weapon cost per shot + logger.debug(f"[DEBUG] _session_costs={self._session_costs}") if self._session_costs: cost_per_shot = self._session_costs.get('cost_per_shot', Decimal('0')) + logger.debug(f"[DEBUG] cost_per_shot={cost_per_shot}") if cost_per_shot > 0: + logger.debug(f"[HUD] update_weapon_cost({cost_per_shot})") self.hud.update_weapon_cost(cost_per_shot) except Exception as e: - logger.error(f"Error in on_damage_dealt: {e}") + logger.error(f"[ERROR] Error in on_damage_dealt: {e}") + import traceback + logger.error(traceback.format_exc()) def on_critical_hit(event): """Handle critical hit - same as damage dealt.""" @@ -1138,17 +1173,24 @@ class MainWindow(QMainWindow): from decimal import Decimal try: damage = event.data.get('damage', 0) + logger.debug(f"[EVENT] on_damage_taken: damage={damage}") if damage: # Track damage amount + logger.debug(f"[HUD] on_damage_taken({damage})") self.hud.on_damage_taken(Decimal(str(damage))) # Track armor cost per hit + logger.debug(f"[DEBUG] _session_costs={self._session_costs}") if self._session_costs: cost_per_hit = self._session_costs.get('cost_per_hit', Decimal('0')) + logger.debug(f"[DEBUG] cost_per_hit={cost_per_hit}") if cost_per_hit > 0: + logger.debug(f"[HUD] update_armor_cost({cost_per_hit})") self.hud.update_armor_cost(cost_per_hit) except Exception as e: - logger.error(f"Error in on_damage_taken: {e}") + logger.error(f"[ERROR] Error in on_damage_taken: {e}") + import traceback + logger.error(traceback.format_exc()) def on_evade(event): """Handle evade."""