diff --git a/ui/loadout_manager.py b/ui/loadout_manager.py index a5db499..f965185 100644 --- a/ui/loadout_manager.py +++ b/ui/loadout_manager.py @@ -651,16 +651,37 @@ class ArmorSlotWidget(QWidget): """Set selected armor piece.""" if piece is None: self.piece_combo.setCurrentIndex(0) + self.current_piece = None + self.protection_label.setText("-") + self._update_total() return - # Find and select the piece + # Store the piece + self.current_piece = piece + + # Update protection display + prot_parts = [] + if piece.protection.impact > 0: + prot_parts.append(f"Imp:{piece.protection.impact}") + if piece.protection.cut > 0: + prot_parts.append(f"Cut:{piece.protection.cut}") + if piece.protection.stab > 0: + prot_parts.append(f"Stab:{piece.protection.stab}") + self.protection_label.setText(", ".join(prot_parts) if prot_parts else "-") + + # Try to find and select the piece in combo for i in range(self.piece_combo.count()): data = self.piece_combo.itemData(i) - if data and data.item_id == piece.item_id: + if data and hasattr(data, 'item_id') and data.item_id == piece.item_id: self.piece_combo.setCurrentIndex(i) + self._update_total() return - - self.piece_combo.setCurrentIndex(0) + + # Piece not in combo - add it + display = f"{piece.name} (API)" + self.piece_combo.addItem(display, piece) + self.piece_combo.setCurrentIndex(self.piece_combo.count() - 1) + self._update_total() def set_plate(self, plate: Optional[ArmorPlate]): """Set selected plate."""