fix(ui): properly update ArmorSlotWidget UI when setting piece from API
- Fixed set_piece() to use protection_label instead of non-existent piece_name_label - Now updates protection display when piece is set - Adds piece to combo if not already present - Properly stores current_piece and calls _update_total()
This commit is contained in:
parent
a349a85cbe
commit
437f6b3027
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue