From cf7c4ab5de000e716f4a20ae354ce7e8b2727a62 Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Mon, 9 Feb 2026 11:59:06 +0000 Subject: [PATCH] feat(loadout): add plate search button to each armor slot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Each armor slot now has a 🔍 button for plate selection - Opens PlateSelectorDialog filtered by armor's highest protection type - Selected plates from API are added to the slot's combo box - Plates auto-selected after API selection --- ui/loadout_manager.py | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/ui/loadout_manager.py b/ui/loadout_manager.py index 13c5117..2ebe5a2 100644 --- a/ui/loadout_manager.py +++ b/ui/loadout_manager.py @@ -25,7 +25,7 @@ from PyQt6.QtCore import Qt, pyqtSignal, QThread from PyQt6.QtGui import QFont from core.nexus_api import EntropiaNexusAPI, WeaponStats, ArmorStats, FinderStats -from core.nexus_full_api import get_nexus_api, NexusArmor, NexusHealingTool +from core.nexus_full_api import get_nexus_api, NexusArmor, NexusHealingTool, NexusPlate from core.attachments import ( Attachment, WeaponAmplifier, WeaponScope, WeaponAbsorber, ArmorPlating, Enhancer, can_attach, get_mock_attachments @@ -409,6 +409,13 @@ class ArmorSlotWidget(QWidget): self.plate_combo.currentTextChanged.connect(self._on_plate_changed) layout.addWidget(self.plate_combo) + # Add plate search button + self.search_plate_btn = QPushButton("🔍") + self.search_plate_btn.setToolTip("Search plates from Nexus API") + self.search_plate_btn.setFixedWidth(40) + self.search_plate_btn.clicked.connect(self._on_search_plate) + layout.addWidget(self.search_plate_btn) + # Total protection self.total_label = QLabel("Total: 0") self.total_label.setStyleSheet("color: #4caf50; font-weight: bold;") @@ -455,6 +462,48 @@ class ArmorSlotWidget(QWidget): display = f"{plate.name} (+{plate.get_total_protection()})" self.plate_combo.addItem(display, plate) + def _on_search_plate(self): + """Open plate selector dialog from Nexus API.""" + from ui.plate_selector import PlateSelectorDialog + + # Get current piece's protection to suggest matching plates + preferred_type = "" + if self.current_piece: + # Find highest protection type + protections = { + 'impact': self.current_piece.protection.impact, + 'cut': self.current_piece.protection.cut, + 'stab': self.current_piece.protection.stab, + 'burn': self.current_piece.protection.burn, + 'cold': self.current_piece.protection.cold, + } + preferred_type = max(protections, key=protections.get) + + dialog = PlateSelectorDialog(self, damage_type=preferred_type) + dialog.plate_selected.connect(self._on_api_plate_selected) + dialog.exec() + + def _on_api_plate_selected(self, plate: NexusPlate): + """Handle plate selection from API.""" + # Add to combo if not exists + index = self.plate_combo.findText(plate.name) + if index < 0: + # Create ArmorPlate from NexusPlate + from core.armor_system import ArmorPlate as LocalArmorPlate + local_plate = LocalArmorPlate( + name=plate.name, + item_id=plate.item_id, + protection=plate.protection, + durability=plate.durability, + decay_per_hp=plate.decay_per_hp + ) + display = f"{plate.name} (+{plate.protection_impact + plate.protection_cut + plate.protection_stab} prot)" + self.plate_combo.addItem(display, local_plate) + index = self.plate_combo.count() - 1 + + self.plate_combo.setCurrentIndex(index) + self._update_total() + def _on_piece_changed(self, text: str): """Handle armor piece selection.""" if text == "-- Empty --":