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)
|
- 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: 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: 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)
|
0.7.3: (2019-09-15)
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
#include <QListWidgetItem>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "LogController.h"
|
#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.exportButton, &QAbstractButton::clicked, this, &ObjView::exportObj);
|
||||||
connect(m_ui.copyButton, &QAbstractButton::clicked, this, &ObjView::copyObj);
|
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);
|
QAction* exportAction = new QAction(this);
|
||||||
exportAction->setShortcut(QKeySequence::Save);
|
exportAction->setShortcut(QKeySequence::Save);
|
||||||
connect(exportAction, &QAction::triggered, this, &ObjView::exportObj);
|
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) {
|
void ObjView::selectObj(int obj) {
|
||||||
m_objId = 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);
|
updateTiles(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +100,8 @@ void ObjView::updateTilesGBA(bool force) {
|
||||||
const GBA* gba = static_cast<const GBA*>(m_controller->thread()->core->board);
|
const GBA* gba = static_cast<const GBA*>(m_controller->thread()->core->board);
|
||||||
const GBAObj* obj = &gba->video.oam.obj[m_objId];
|
const GBAObj* obj = &gba->video.oam.obj[m_objId];
|
||||||
|
|
||||||
|
updateObjList(128);
|
||||||
|
|
||||||
ObjInfo newInfo;
|
ObjInfo newInfo;
|
||||||
lookupObj(m_objId, &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 GB* gb = static_cast<const GB*>(m_controller->thread()->core->board);
|
||||||
const GBObj* obj = &gb->video.oam.obj[m_objId];
|
const GBObj* obj = &gb->video.oam.obj[m_objId];
|
||||||
|
|
||||||
|
updateObjList(40);
|
||||||
|
|
||||||
ObjInfo newInfo;
|
ObjInfo newInfo;
|
||||||
lookupObj(m_objId, &newInfo);
|
lookupObj(m_objId, &newInfo);
|
||||||
|
|
||||||
|
@ -213,6 +233,26 @@ void ObjView::updateTilesGB(bool force) {
|
||||||
}
|
}
|
||||||
#endif
|
#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() {
|
void ObjView::exportObj() {
|
||||||
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export sprite"),
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export sprite"),
|
||||||
tr("Portable Network Graphics (*.png)"));
|
tr("Portable Network Graphics (*.png)"));
|
||||||
|
|
|
@ -9,8 +9,12 @@
|
||||||
|
|
||||||
#include "ui_ObjView.h"
|
#include "ui_ObjView.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
#include <mgba/core/tile-cache.h>
|
#include <mgba/core/tile-cache.h>
|
||||||
|
|
||||||
|
class QListWidgetItem;
|
||||||
|
|
||||||
namespace QGBA {
|
namespace QGBA {
|
||||||
|
|
||||||
class CoreController;
|
class CoreController;
|
||||||
|
@ -37,6 +41,8 @@ private:
|
||||||
void updateTilesGB(bool force) override;
|
void updateTilesGB(bool force) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void updateObjList(int maxObj);
|
||||||
|
|
||||||
Ui::ObjView m_ui;
|
Ui::ObjView m_ui;
|
||||||
|
|
||||||
std::shared_ptr<CoreController> m_controller;
|
std::shared_ptr<CoreController> m_controller;
|
||||||
|
@ -44,6 +50,8 @@ private:
|
||||||
int m_objId = 0;
|
int m_objId = 0;
|
||||||
ObjInfo m_objInfo = {};
|
ObjInfo m_objInfo = {};
|
||||||
|
|
||||||
|
QList<QListWidgetItem*> m_objs;
|
||||||
|
|
||||||
int m_tileOffset;
|
int m_tileOffset;
|
||||||
int m_boundary;
|
int m_boundary;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,14 +6,21 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>641</width>
|
<width>800</width>
|
||||||
<height>470</height>
|
<height>730</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Sprites</string>
|
<string>Sprites</string>
|
||||||
</property>
|
</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">
|
<item row="2" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -155,6 +162,43 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="0" column="1" rowspan="5">
|
||||||
<widget class="QGBA::AssetTile" name="tile">
|
<widget class="QGBA::AssetTile" name="tile">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -540,48 +584,35 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="3">
|
<item row="5" column="0" colspan="4">
|
||||||
<widget class="QPushButton" name="copyButton">
|
<widget class="QListWidget" name="objList">
|
||||||
<property name="text">
|
<property name="iconSize">
|
||||||
<string>Copy</string>
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="flow">
|
||||||
</item>
|
<enum>QListView::LeftToRight</enum>
|
||||||
<item row="0" column="2" rowspan="4" colspan="2">
|
</property>
|
||||||
<widget class="QFrame" name="frame">
|
<property name="resizeMode">
|
||||||
<property name="frameShape">
|
<enum>QListView::Adjust</enum>
|
||||||
<enum>QFrame::StyledPanel</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>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in New Issue