mirror of https://github.com/mgba-emu/mgba.git
Qt: Expose e-Reader parsing
This commit is contained in:
parent
a0360ec936
commit
e84db73f31
2
CHANGES
2
CHANGES
|
@ -1,4 +1,6 @@
|
||||||
0.10.0: (Future)
|
0.10.0: (Future)
|
||||||
|
Features:
|
||||||
|
- Tool for converting scanned pictures of e-Reader cards to raw dotcode data
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
- Core: Fix first event scheduling after loading savestate
|
- Core: Fix first event scheduling after loading savestate
|
||||||
- GB Serialize: Fix switching speed modes when loading a state (fixes mgba.io/i/2097)
|
- GB Serialize: Fix switching speed modes when loading a state (fixes mgba.io/i/2097)
|
||||||
|
|
|
@ -76,6 +76,8 @@
|
||||||
#include <mgba/feature/commandline.h>
|
#include <mgba/feature/commandline.h>
|
||||||
#include <mgba-util/vfs.h>
|
#include <mgba-util/vfs.h>
|
||||||
|
|
||||||
|
#include <mgba-util/convolve.h>
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWidget* parent)
|
Window::Window(CoreManager* manager, ConfigController* config, int playerId, QWidget* parent)
|
||||||
|
@ -424,6 +426,53 @@ void Window::scanCard() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::parseCard() {
|
||||||
|
#ifdef USE_FFMPEG
|
||||||
|
QStringList filenames = GBAApp::app()->getOpenFileNames(this, tr("Select e-Reader card images"), tr("Image file (*.png *.jpg *.jpeg)"));
|
||||||
|
QMessageBox* dialog = new QMessageBox(QMessageBox::Information, tr("Conversion finished"),
|
||||||
|
QString("oh"), QMessageBox::Ok);
|
||||||
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
auto status = std::make_shared<QPair<int, int>>(0, filenames.size());
|
||||||
|
GBAApp::app()->submitWorkerJob([filenames, dialog, status]() {
|
||||||
|
int success = 0;
|
||||||
|
for (QString filename : filenames) {
|
||||||
|
if (filename.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QImage image(filename);
|
||||||
|
if (image.isNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EReaderScan* scan;
|
||||||
|
switch (image.depth()) {
|
||||||
|
case 8:
|
||||||
|
scan = EReaderScanLoadImage8(image.constBits(), image.width(), image.height(), image.bytesPerLine());
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
scan = EReaderScanLoadImage(image.constBits(), image.width(), image.height(), image.bytesPerLine());
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
scan = EReaderScanLoadImageA(image.constBits(), image.width(), image.height(), image.bytesPerLine());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QFileInfo ofile(filename);
|
||||||
|
if (EReaderScanCard(scan)) {
|
||||||
|
QString ofilename = ofile.path() + QDir::separator() + ofile.baseName() + ".raw";
|
||||||
|
EReaderScanSaveRaw(scan, ofilename.toUtf8().constData(), false);
|
||||||
|
++success;
|
||||||
|
}
|
||||||
|
EReaderScanDestroy(scan);
|
||||||
|
}
|
||||||
|
status->first = success;
|
||||||
|
}, [dialog, status]() {
|
||||||
|
dialog->setText(tr("%1 of %2 e-Reader cards converted successfully.").arg(status->first).arg(status->second));
|
||||||
|
dialog->show();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Window::openView(QWidget* widget) {
|
void Window::openView(QWidget* widget) {
|
||||||
connect(this, &Window::shutdown, widget, &QWidget::close);
|
connect(this, &Window::shutdown, widget, &QWidget::close);
|
||||||
widget->setAttribute(Qt::WA_DeleteOnClose);
|
widget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -1121,6 +1170,10 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
Action* scanCard = addGameAction(tr("Scan e-Reader dotcodes..."), "scanCard", this, &Window::scanCard, "file");
|
Action* scanCard = addGameAction(tr("Scan e-Reader dotcodes..."), "scanCard", this, &Window::scanCard, "file");
|
||||||
m_platformActions.insert(mPLATFORM_GBA, scanCard);
|
m_platformActions.insert(mPLATFORM_GBA, scanCard);
|
||||||
|
|
||||||
|
#ifdef USE_FFMPEG
|
||||||
|
m_actions.addAction(tr("Convert e-Reader card image to raw..."), "parseCard", this, &Window::parseCard, "file");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addGameAction(tr("ROM &info..."), "romInfo", openControllerTView<ROMInfo>(), "file");
|
addGameAction(tr("ROM &info..."), "romInfo", openControllerTView<ROMInfo>(), "file");
|
||||||
|
|
|
@ -82,6 +82,7 @@ public slots:
|
||||||
void selectState(bool load);
|
void selectState(bool load);
|
||||||
void selectPatch();
|
void selectPatch();
|
||||||
void scanCard();
|
void scanCard();
|
||||||
|
void parseCard();
|
||||||
void enterFullScreen();
|
void enterFullScreen();
|
||||||
void exitFullScreen();
|
void exitFullScreen();
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
|
|
Loading…
Reference in New Issue