diff --git a/CHANGES b/CHANGES index a6475479e..38407c923 100644 --- a/CHANGES +++ b/CHANGES @@ -82,6 +82,7 @@ Misc: - CMake: Don't use libzip on embedded platforms (fixes mgba.io/i/1527) - Qt: Printer quality of life improvements (fixes mgba.io/i/1540) - Qt: Add copy and QoL improvements to graphic views (closes mgba.io/i/1541) + - Qt: Show list of all sprites in sprite view 0.7.3: (2019-09-15) Emulation fixes: diff --git a/src/platform/qt/ObjView.cpp b/src/platform/qt/ObjView.cpp index 373e0ef16..fbbfdf309 100644 --- a/src/platform/qt/ObjView.cpp +++ b/src/platform/qt/ObjView.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "LogController.h" @@ -56,6 +57,13 @@ ObjView::ObjView(std::shared_ptr controller, QWidget* parent) connect(m_ui.exportButton, &QAbstractButton::clicked, this, &ObjView::exportObj); connect(m_ui.copyButton, &QAbstractButton::clicked, this, &ObjView::copyObj); + connect(m_ui.objList, &QListWidget::currentItemChanged, [this]() { + QListWidgetItem* item = m_ui.objList->currentItem(); + if (item) { + selectObj(item->data(Qt::UserRole).toInt()); + } + }); + QAction* exportAction = new QAction(this); exportAction->setShortcut(QKeySequence::Save); connect(exportAction, &QAction::triggered, this, &ObjView::exportObj); @@ -69,6 +77,14 @@ ObjView::ObjView(std::shared_ptr controller, QWidget* parent) void ObjView::selectObj(int obj) { m_objId = obj; + bool blocked = m_ui.objId->blockSignals(true); + m_ui.objId->setValue(m_objId); + m_ui.objId->blockSignals(blocked); + if (m_objs.size() > obj) { + blocked = m_ui.objList->blockSignals(true); + m_ui.objList->setCurrentItem(m_objs[obj]); + m_ui.objList->blockSignals(blocked); + } updateTiles(true); } @@ -84,6 +100,8 @@ void ObjView::updateTilesGBA(bool force) { const GBA* gba = static_cast(m_controller->thread()->core->board); const GBAObj* obj = &gba->video.oam.obj[m_objId]; + updateObjList(128); + ObjInfo newInfo; lookupObj(m_objId, &newInfo); @@ -166,6 +184,8 @@ void ObjView::updateTilesGB(bool force) { const GB* gb = static_cast(m_controller->thread()->core->board); const GBObj* obj = &gb->video.oam.obj[m_objId]; + updateObjList(40); + ObjInfo newInfo; lookupObj(m_objId, &newInfo); @@ -213,6 +233,26 @@ void ObjView::updateTilesGB(bool force) { } #endif +void ObjView::updateObjList(int maxObj) { + for (int i = 0; i < maxObj; ++i) { + if (m_objs.size() <= i) { + QListWidgetItem* item = new QListWidgetItem; + item->setText(QString::number(i)); + item->setData(Qt::UserRole, i); + item->setSizeHint(QSize(64, 96)); + if (m_objId == i) { + item->setSelected(true); + } + m_objs.append(item); + m_ui.objList->addItem(item); + } + QListWidgetItem* item = m_objs[i]; + ObjInfo info; + lookupObj(i, &info); + item->setIcon(QPixmap::fromImage(std::move(compositeObj(info)))); + } +} + void ObjView::exportObj() { QString filename = GBAApp::app()->getSaveFileName(this, tr("Export sprite"), tr("Portable Network Graphics (*.png)")); diff --git a/src/platform/qt/ObjView.h b/src/platform/qt/ObjView.h index 1ceef7417..c10d661c3 100644 --- a/src/platform/qt/ObjView.h +++ b/src/platform/qt/ObjView.h @@ -9,8 +9,12 @@ #include "ui_ObjView.h" +#include + #include +class QListWidgetItem; + namespace QGBA { class CoreController; @@ -37,6 +41,8 @@ private: void updateTilesGB(bool force) override; #endif + void updateObjList(int maxObj); + Ui::ObjView m_ui; std::shared_ptr m_controller; @@ -44,6 +50,8 @@ private: int m_objId = 0; ObjInfo m_objInfo = {}; + QList m_objs; + int m_tileOffset; int m_boundary; }; diff --git a/src/platform/qt/ObjView.ui b/src/platform/qt/ObjView.ui index 5585b6393..3385b80b2 100644 --- a/src/platform/qt/ObjView.ui +++ b/src/platform/qt/ObjView.ui @@ -6,14 +6,21 @@ 0 0 - 641 - 470 + 800 + 730 Sprites - + + + + + Copy + + + @@ -155,6 +162,43 @@ + + + + QFrame::StyledPanel + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 8 + 8 + + + + + + + @@ -540,48 +584,35 @@ - - - - Copy + + + + + 64 + 64 + - - - - - - QFrame::StyledPanel + + QListView::LeftToRight + + + QListView::Adjust + + + + 64 + 96 + + + + QListView::IconMode + + + true + + + Qt::AlignBottom|Qt::AlignHCenter - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 8 - 8 - - - - -