feat(loadout): add plate search button to each armor slot

- 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
This commit is contained in:
LemonNexus 2026-02-09 11:59:06 +00:00
parent 88a3c8b551
commit cf7c4ab5de
1 changed files with 50 additions and 1 deletions

View File

@ -25,7 +25,7 @@ from PyQt6.QtCore import Qt, pyqtSignal, QThread
from PyQt6.QtGui import QFont from PyQt6.QtGui import QFont
from core.nexus_api import EntropiaNexusAPI, WeaponStats, ArmorStats, FinderStats 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 ( from core.attachments import (
Attachment, WeaponAmplifier, WeaponScope, WeaponAbsorber, Attachment, WeaponAmplifier, WeaponScope, WeaponAbsorber,
ArmorPlating, Enhancer, can_attach, get_mock_attachments ArmorPlating, Enhancer, can_attach, get_mock_attachments
@ -409,6 +409,13 @@ class ArmorSlotWidget(QWidget):
self.plate_combo.currentTextChanged.connect(self._on_plate_changed) self.plate_combo.currentTextChanged.connect(self._on_plate_changed)
layout.addWidget(self.plate_combo) 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 # Total protection
self.total_label = QLabel("Total: 0") self.total_label = QLabel("Total: 0")
self.total_label.setStyleSheet("color: #4caf50; font-weight: bold;") self.total_label.setStyleSheet("color: #4caf50; font-weight: bold;")
@ -455,6 +462,48 @@ class ArmorSlotWidget(QWidget):
display = f"{plate.name} (+{plate.get_total_protection()})" display = f"{plate.name} (+{plate.get_total_protection()})"
self.plate_combo.addItem(display, plate) 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): def _on_piece_changed(self, text: str):
"""Handle armor piece selection.""" """Handle armor piece selection."""
if text == "-- Empty --": if text == "-- Empty --":