mirror of https://github.com/mgba-emu/mgba.git
Qt: Show list of all sprites in sprite view
This commit is contained in:
parent
ecf01ca258
commit
e576f23fc4
1
CHANGES
1
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:
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
#include <QFontDatabase>
|
||||
#include <QListWidgetItem>
|
||||
#include <QTimer>
|
||||
|
||||
#include "LogController.h"
|
||||
|
@ -56,6 +57,13 @@ ObjView::ObjView(std::shared_ptr<CoreController> 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<CoreController> 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<const GBA*>(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<const GB*>(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)"));
|
||||
|
|
|
@ -9,8 +9,12 @@
|
|||
|
||||
#include "ui_ObjView.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include <mgba/core/tile-cache.h>
|
||||
|
||||
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<CoreController> m_controller;
|
||||
|
@ -44,6 +50,8 @@ private:
|
|||
int m_objId = 0;
|
||||
ObjInfo m_objInfo = {};
|
||||
|
||||
QList<QListWidgetItem*> m_objs;
|
||||
|
||||
int m_tileOffset;
|
||||
int m_boundary;
|
||||
};
|
||||
|
|
|
@ -6,14 +6,21 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>641</width>
|
||||
<height>470</height>
|
||||
<width>800</width>
|
||||
<height>730</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Sprites</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1,1">
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,1" columnstretch="0,0,1,1">
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="copyButton">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
|
@ -155,6 +162,43 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="4" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||
<widget class="QGBA::TilePainter" name="tiles" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="5">
|
||||
<widget class="QGBA::AssetTile" name="tile">
|
||||
<property name="title">
|
||||
|
@ -540,48 +584,35 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="copyButton">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="QListWidget" name="objList">
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="4" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<property name="flow">
|
||||
<enum>QListView::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="gridSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>96</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="itemAlignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||
<widget class="QGBA::TilePainter" name="tiles" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue