diff --git a/src/platform/qt/BattleChipView.cpp b/src/platform/qt/BattleChipView.cpp index 2e00ac47b..42cca1fc4 100644 --- a/src/platform/qt/BattleChipView.cpp +++ b/src/platform/qt/BattleChipView.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -21,12 +23,12 @@ using namespace QGBA; BattleChipView::BattleChipView(std::shared_ptr controller, Window* window, QWidget* parent) - : QDialog(parent) + : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint) , m_controller(controller) , m_window(window) { - QResource::registerResource(GBAApp::dataDir() + "/chips.rcc"); - QResource::registerResource(ConfigController::configDir() + "/chips.rcc"); + QResource::registerResource(GBAApp::dataDir() + "/chips.rcc", "/exe"); + QResource::registerResource(ConfigController::configDir() + "/chips.rcc", "/exe"); m_ui.setupUi(this); @@ -38,12 +40,12 @@ BattleChipView::BattleChipView(std::shared_ptr controller, Windo QString qtitle(title); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - int size = QFontMetrics(QFont()).height() / ((int) ceil(devicePixelRatioF()) * 16); + int size = QFontMetrics(QFont()).height() / ((int) ceil(devicePixelRatioF()) * 12); #else - int size = QFontMetrics(QFont()).height() / (devicePixelRatio() * 16); + int size = QFontMetrics(QFont()).height() / (devicePixelRatio() * 12); #endif - m_ui.chipList->setGridSize(m_ui.chipList->gridSize() * size); m_ui.chipList->setIconSize(m_ui.chipList->iconSize() * size); + m_ui.chipList->setGridSize(m_ui.chipList->gridSize() * size); connect(m_ui.chipId, static_cast(&QSpinBox::valueChanged), m_ui.inserted, [this]() { m_ui.inserted->setChecked(Qt::Unchecked); @@ -59,6 +61,7 @@ BattleChipView::BattleChipView(std::shared_ptr controller, Windo connect(controller.get(), &CoreController::stopping, this, &QWidget::close); connect(m_ui.save, &QAbstractButton::clicked, this, &BattleChipView::saveDeck); connect(m_ui.load, &QAbstractButton::clicked, this, &BattleChipView::loadDeck); + connect(m_ui.buttonBox->button(QDialogButtonBox::Reset), &QAbstractButton::clicked, m_ui.chipList, &QListWidget::clear); connect(m_ui.gateBattleChip, &QAbstractButton::toggled, this, [this](bool on) { if (on) { @@ -144,11 +147,11 @@ void BattleChipView::addChip() { void BattleChipView::addChipId(int id) { QListWidgetItem* add = new QListWidgetItem(m_chipIdToName[id]); add->setData(Qt::UserRole, id); - QString path = QString(":/res/exe%1/%2.png").arg(m_flavor).arg(id, 3, 10, QLatin1Char('0')); + QString path = QString(":/exe/exe%1/%2.png").arg(m_flavor).arg(id, 3, 10, QLatin1Char('0')); if (!QFile(path).exists()) { - path = QString(":/res/exe%1/placeholder.png").arg(m_flavor); + path = QString(":/exe/exe%1/placeholder.png").arg(m_flavor); } - add->setIcon(QIcon(path)); + add->setIcon(QPixmap(path).scaled(m_ui.chipList->iconSize())); m_ui.chipList->addItem(add); } @@ -167,7 +170,7 @@ void BattleChipView::loadChipNames(int flavor) { } m_flavor = flavor; - QFile file(QString(":/res/exe%1/chip-names.txt").arg(flavor)); + QFile file(QString(":/exe/exe%1/chip-names.txt").arg(flavor)); file.open(QIODevice::ReadOnly | QIODevice::Text); int id = 0; while (true) { @@ -227,12 +230,17 @@ void BattleChipView::loadDeck() { ini.beginGroup("BattleChipDeck"); int flavor = ini.value("version").toInt(); if (flavor != m_flavor) { + QMessageBox* error = new QMessageBox(this); + error->setIcon(QMessageBox::Warning); + error->setStandardButtons(QMessageBox::Ok); + error->setWindowTitle(tr("Incompatible deck")); + error->setText(tr("The selected deck is not compatible with this Chip Gate")); + error->setAttribute(Qt::WA_DeleteOnClose); + error->show(); return; } - - while (m_ui.chipList->count()) { - delete m_ui.chipList->takeItem(m_ui.chipList->count() - 1); - } + + m_ui.chipList->clear(); QStringList deck = ini.value("deck").toString().split(','); for (const auto& item : deck) { bool ok; @@ -241,4 +249,4 @@ void BattleChipView::loadDeck() { addChipId(id); } } -} \ No newline at end of file +} diff --git a/src/platform/qt/BattleChipView.h b/src/platform/qt/BattleChipView.h index ca6dfb942..88a24d8a3 100644 --- a/src/platform/qt/BattleChipView.h +++ b/src/platform/qt/BattleChipView.h @@ -57,4 +57,4 @@ private: Window* m_window; }; -} \ No newline at end of file +} diff --git a/src/platform/qt/BattleChipView.ui b/src/platform/qt/BattleChipView.ui index a31513ced..f379a3bdc 100644 --- a/src/platform/qt/BattleChipView.ui +++ b/src/platform/qt/BattleChipView.ui @@ -13,7 +13,7 @@ BattleChip Gate - + @@ -35,7 +35,7 @@ - QListView::Snap + QListView::Static true @@ -45,13 +45,19 @@ - 80 + 120 72 QListView::IconMode + + false + + + true + @@ -174,10 +180,10 @@ - - + + - Chip ID + Inserted @@ -188,10 +194,10 @@ - - + + - Inserted + Chip ID @@ -200,19 +206,19 @@ + + + + Show advanced + + + - - - - Show advanced - - - - QDialogButtonBox::Close + QDialogButtonBox::Close|QDialogButtonBox::Reset @@ -222,6 +228,22 @@ + + buttonBox + rejected() + BattleChipView + reject() + + + 416 + 690 + + + 314 + 360 + + + showAdvanced toggled(bool) @@ -239,18 +261,18 @@ - buttonBox - rejected() - BattleChipView - reject() + chipList + indexesMoved(QModelIndexList) + chipList + doItemsLayout() - 416 - 690 + 314 + 203 314 - 360 + 203 diff --git a/src/platform/qt/resources.qrc b/src/platform/qt/resources.qrc index 990203809..bfc5235cc 100644 --- a/src/platform/qt/resources.qrc +++ b/src/platform/qt/resources.qrc @@ -1,14 +1,17 @@ - + + - ../../../res/mgba-1024.png - ../../../res/keymap.qpic - ../../../res/patrons.txt - ../../../res/no-cam.png - ../../../res/exe4/chip-names.txt - ../../../res/exe4/placeholder.png - ../../../res/exe5/chip-names.txt - ../../../res/exe5/placeholder.png - ../../../res/exe6/chip-names.txt - ../../../res/exe6/placeholder.png + ../../../res/mgba-1024.png + ../../../res/keymap.qpic + ../../../res/patrons.txt + ../../../res/no-cam.png - + + ../../../res/exe4/chip-names.txt + ../../../res/exe4/placeholder.png + ../../../res/exe5/chip-names.txt + ../../../res/exe5/placeholder.png + ../../../res/exe6/chip-names.txt + ../../../res/exe6/placeholder.png + +