From 64ad73c9f9c32334e117ff4fc6c930f981ec07db Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 21 Feb 2019 18:18:52 -0800 Subject: [PATCH] Qt: Add placeholders, minor revamps --- res/{chip-names-4.txt => exe4/chip-names.txt} | 0 res/exe4/placeholder.png | Bin 0 -> 483 bytes res/{chip-names-5.txt => exe5/chip-names.txt} | 0 res/exe5/placeholder.png | Bin 0 -> 475 bytes res/{chip-names-6.txt => exe6/chip-names.txt} | 0 res/exe6/placeholder.png | Bin 0 -> 476 bytes src/platform/qt/BattleChipView.cpp | 16 ++++++++++++++-- src/platform/qt/BattleChipView.ui | 4 ++-- src/platform/qt/resources.qrc | 9 ++++++--- 9 files changed, 22 insertions(+), 7 deletions(-) rename res/{chip-names-4.txt => exe4/chip-names.txt} (100%) create mode 100644 res/exe4/placeholder.png rename res/{chip-names-5.txt => exe5/chip-names.txt} (100%) create mode 100644 res/exe5/placeholder.png rename res/{chip-names-6.txt => exe6/chip-names.txt} (100%) create mode 100644 res/exe6/placeholder.png diff --git a/res/chip-names-4.txt b/res/exe4/chip-names.txt similarity index 100% rename from res/chip-names-4.txt rename to res/exe4/chip-names.txt diff --git a/res/exe4/placeholder.png b/res/exe4/placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..f057bb2492d68c79ce533643aaee068278c11ed7 GIT binary patch literal 483 zcmV<90UZ8`P)|uP87m5D2<6)s*kkDKPX9OTb#_3c3x% zE8q#HBcBfnget?fv)|mXgmP&S2cZFoQ9! zU>SVbLy1Kx1&nnqhrCcq2_ve1iUJKS;Ly{@Awrc?i{7wSA0YUh_{@p_d{$Gj6G57~9R%DGK zVU8EX_a1mrMP`#4n8Xw3u?ghRZ^Eu>s z+6bG2lHb)bq6E)M`E$gzdLDYxSaL%+7G8|f2>_L~F@*bb#D!wK5zic`tc}MpKgr1{ z_cT^GxU4AjTR$T{GvP4ixaQ~KzG;#QVKR6C9l-k*hT~{%NCA=qTyky3p6YidFvi;2 zr2DGxVJsmN-#;vdFy3KSGJtWMe}EIYusKt=tM?6c$u+mRk?sDWy|FF_%^$v+Nj+2L R&XNEC002ovPDHLkV1mLO)nfnv literal 0 HcmV?d00001 diff --git a/res/chip-names-6.txt b/res/exe6/chip-names.txt similarity index 100% rename from res/chip-names-6.txt rename to res/exe6/chip-names.txt diff --git a/res/exe6/placeholder.png b/res/exe6/placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..7873bb227f646c31efbc299850301fe5bb83c0ed GIT binary patch literal 476 zcmV<20VDp2P)A@Bg@m%DohDB&X3VbAJ9-L?_P863jLz^%cUX#&AeRTzpo< zil10z#jh;UEeP8XwjpdoXrW?W6{Lxj*g#HpFeXZAt<<-ae$f^&k)uQprIxsOY8g3BtSZ1(W*Dz>PQ;IR6rCgo z)BMbd&J{U@@rjTVopbt?N=>2h2;0et)<m!+Bj(7$Zw!f%C)| zS@-C|$YYN)XxhZw;_BkW$Yvb6{O!} #include +#include #include #include @@ -32,6 +33,13 @@ BattleChipView::BattleChipView(std::shared_ptr controller, QWidg core->getGameCode(core, title); QString qtitle(title); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + int size = QFontMetrics(QFont()).height() / ((int) ceil(devicePixelRatioF()) * 16); +#else + int size = QFontMetrics(QFont()).height() / (devicePixelRatio() * 16); +#endif + m_ui.chipList->setGridSize(m_ui.chipList->gridSize() * size); + m_ui.chipList->setIconSize(m_ui.chipList->iconSize() * size); connect(m_ui.chipId, static_cast(&QSpinBox::valueChanged), m_ui.inserted, [this]() { m_ui.inserted->setChecked(Qt::Unchecked); @@ -124,7 +132,11 @@ void BattleChipView::addChip() { } QListWidgetItem* add = new QListWidgetItem(m_chipIdToName[insertedChip]); add->setData(Qt::UserRole, insertedChip); - add->setIcon(QIcon(QString(":/res/exe%1/%2.png").arg(m_flavor).arg(insertedChip, 3, 10, QLatin1Char('0')))); + QString path = QString(":/res/exe%1/%2.png").arg(m_flavor).arg(insertedChip, 3, 10, QLatin1Char('0')); + if (!QFile(path).exists()) { + path = QString(":/res/exe%1/placeholder.png").arg(m_flavor); + } + add->setIcon(QIcon(path)); m_ui.chipList->addItem(add); } @@ -143,7 +155,7 @@ void BattleChipView::loadChipNames(int flavor) { } m_flavor = flavor; - QFile file(QString(":/res/chip-names-%1.txt").arg(flavor)); + QFile file(QString(":/res/exe%1/chip-names.txt").arg(flavor)); file.open(QIODevice::ReadOnly | QIODevice::Text); int id = 0; while (true) { diff --git a/src/platform/qt/BattleChipView.ui b/src/platform/qt/BattleChipView.ui index 14ce62c55..10e8000d8 100644 --- a/src/platform/qt/BattleChipView.ui +++ b/src/platform/qt/BattleChipView.ui @@ -151,8 +151,8 @@ - 160 - 128 + 80 + 72 diff --git a/src/platform/qt/resources.qrc b/src/platform/qt/resources.qrc index ea08c5e39..990203809 100644 --- a/src/platform/qt/resources.qrc +++ b/src/platform/qt/resources.qrc @@ -4,8 +4,11 @@ ../../../res/keymap.qpic ../../../res/patrons.txt ../../../res/no-cam.png - ../../../res/chip-names-4.txt - ../../../res/chip-names-5.txt - ../../../res/chip-names-6.txt + ../../../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