mirror of https://github.com/mgba-emu/mgba.git
Qt: Remove game DB downloader and just bundle it
This commit is contained in:
parent
dcbcae26da
commit
bbe10619ef
|
@ -70,7 +70,6 @@ set(SOURCE_FILES
|
||||||
CheatsModel.cpp
|
CheatsModel.cpp
|
||||||
CheatsView.cpp
|
CheatsView.cpp
|
||||||
ConfigController.cpp
|
ConfigController.cpp
|
||||||
DatDownloadView.cpp
|
|
||||||
Display.cpp
|
Display.cpp
|
||||||
DisplayGL.cpp
|
DisplayGL.cpp
|
||||||
DisplayQt.cpp
|
DisplayQt.cpp
|
||||||
|
@ -108,7 +107,6 @@ set(SOURCE_FILES
|
||||||
qt5_wrap_ui(UI_FILES
|
qt5_wrap_ui(UI_FILES
|
||||||
AboutScreen.ui
|
AboutScreen.ui
|
||||||
CheatsView.ui
|
CheatsView.ui
|
||||||
DatDownloadView.ui
|
|
||||||
GIFView.ui
|
GIFView.ui
|
||||||
IOViewer.ui
|
IOViewer.ui
|
||||||
LoadSaveState.ui
|
LoadSaveState.ui
|
||||||
|
@ -168,13 +166,14 @@ if(WIN32)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(SHADER_DIR Applications/${PROJECT_NAME}.app/Contents/Resources)
|
set(DATA_DIR Applications/${PROJECT_NAME}.app/Contents/Resources)
|
||||||
else()
|
else()
|
||||||
set(SHADER_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME})
|
set(DATA_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME})
|
||||||
endif()
|
endif()
|
||||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${SHADER_DIR} COMPONENT ${BINARY_NAME}-qt)
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${DATA_DIR} COMPONENT ${BINARY_NAME}-qt)
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATA_DIR} COMPONENT ${BINARY_NAME}-qt)
|
||||||
if(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
list(APPEND QT_DEFINES QT_SHADER_DIR="${SHADER_DIR}/shaders")
|
list(APPEND QT_DEFINES DATA_DIR="${DATA_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
|
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
/* Copyright (c) 2013-2015 Jeffrey Pfau
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
#include "DatDownloadView.h"
|
|
||||||
|
|
||||||
#include "GBAApp.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "gba/context/config.h"
|
|
||||||
#include "util/version.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace QGBA;
|
|
||||||
|
|
||||||
DatDownloadView::DatDownloadView(QWidget* parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, m_reply(nullptr)
|
|
||||||
{
|
|
||||||
m_ui.setupUi(this);
|
|
||||||
|
|
||||||
m_netman = new QNetworkAccessManager(this);
|
|
||||||
connect(m_netman, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
|
|
||||||
connect(m_ui.dialogButtonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonPressed(QAbstractButton*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatDownloadView::start() {
|
|
||||||
if (m_reply) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QNetworkRequest request(QUrl("https://raw.githubusercontent.com/mgba-emu/mgba/master/res/nointro.dat"));
|
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, QString("%1 %2").arg(projectName).arg(projectVersion));
|
|
||||||
m_reply = m_netman->get(request);
|
|
||||||
connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
|
|
||||||
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(errored(QNetworkReply::NetworkError)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatDownloadView::finished(QNetworkReply* reply) {
|
|
||||||
if (!m_reply) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
char path[PATH_MAX];
|
|
||||||
GBAConfigDirectory(path, sizeof(path));
|
|
||||||
QFile outfile(QString::fromUtf8(path) + "/nointro.dat");
|
|
||||||
outfile.open(QIODevice::WriteOnly);
|
|
||||||
outfile.write(m_reply->readAll());
|
|
||||||
GBAApp::app()->reloadGameDB();
|
|
||||||
|
|
||||||
m_reply->deleteLater();
|
|
||||||
m_reply = nullptr;
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatDownloadView::downloadProgress(qint64 read, qint64 size) {
|
|
||||||
if (size < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_ui.progressBar->setMaximum(size);
|
|
||||||
m_ui.progressBar->setValue(read);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatDownloadView::errored(QNetworkReply::NetworkError) {
|
|
||||||
m_ui.status->setText(tr("An error occurred"));
|
|
||||||
m_reply->deleteLater();
|
|
||||||
m_reply = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatDownloadView::buttonPressed(QAbstractButton* button) {
|
|
||||||
switch (m_ui.dialogButtonBox->standardButton(button)) {
|
|
||||||
case QDialogButtonBox::Cancel:
|
|
||||||
if (m_reply) {
|
|
||||||
m_reply->abort();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/* Copyright (c) 2013-2015 Jeffrey Pfau
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
#ifndef QGBA_DAT_DOWNLOAD_VIEW
|
|
||||||
#define QGBA_DAT_DOWNLOAD_VIEW
|
|
||||||
|
|
||||||
#include <QNetworkReply>
|
|
||||||
|
|
||||||
#include "ui_DatDownloadView.h"
|
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
|
||||||
|
|
||||||
namespace QGBA {
|
|
||||||
|
|
||||||
class DatDownloadView : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DatDownloadView(QWidget* parent = nullptr);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void start();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void finished(QNetworkReply*);
|
|
||||||
void downloadProgress(qint64, qint64);
|
|
||||||
void errored(QNetworkReply::NetworkError);
|
|
||||||
void buttonPressed(QAbstractButton* button);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::DatDownloadView m_ui;
|
|
||||||
QNetworkAccessManager* m_netman;
|
|
||||||
QNetworkReply* m_reply;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,99 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DatDownloadView</class>
|
|
||||||
<widget class="QDialog" name="DatDownloadView">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>274</width>
|
|
||||||
<height>101</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="sizeConstraint">
|
|
||||||
<enum>QLayout::SetFixedSize</enum>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="status">
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Downloading database…</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>250</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="dialogButtonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Close</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>dialogButtonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>DatDownloadView</receiver>
|
|
||||||
<slot>hide()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>dialogButtonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>DatDownloadView</receiver>
|
|
||||||
<slot>hide()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -174,11 +174,21 @@ QFileDialog* GBAApp::getSaveFileDialog(QWidget* owner, const QString& title, con
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GBAApp::dataDir() {
|
||||||
|
#ifdef DATA_DIR
|
||||||
|
QString path = QString::fromUtf8(DATA_DIR);
|
||||||
|
#else
|
||||||
|
QString path = QCoreApplication::applicationDirPath();
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
path += QLatin1String("/../Resources");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
bool GBAApp::reloadGameDB() {
|
bool GBAApp::reloadGameDB() {
|
||||||
NoIntroDB* db = nullptr;
|
NoIntroDB* db = nullptr;
|
||||||
char path[PATH_MAX];
|
VFile* vf = VFileDevice::open(dataDir() + "/nointro.dat", O_RDONLY);
|
||||||
GBAConfigDirectory(path, sizeof(path));
|
|
||||||
VFile* vf = VFileDevice::open(QString::fromUtf8(path) + "/nointro.dat", O_RDONLY);
|
|
||||||
if (vf) {
|
if (vf) {
|
||||||
db = NoIntroDBLoad(vf);
|
db = NoIntroDBLoad(vf);
|
||||||
vf->close(vf);
|
vf->close(vf);
|
||||||
|
@ -186,7 +196,11 @@ bool GBAApp::reloadGameDB() {
|
||||||
if (db && m_db) {
|
if (db && m_db) {
|
||||||
NoIntroDBDestroy(m_db);
|
NoIntroDBDestroy(m_db);
|
||||||
}
|
}
|
||||||
m_db = db;
|
if (db) {
|
||||||
|
m_db = db;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBAApp::FileDialog::FileDialog(GBAApp* app, QWidget* parent, const QString& caption, const QString& filter)
|
GBAApp::FileDialog::FileDialog(GBAApp* app, QWidget* parent, const QString& caption, const QString& filter)
|
||||||
|
|
|
@ -30,6 +30,8 @@ public:
|
||||||
GBAApp(int& argc, char* argv[]);
|
GBAApp(int& argc, char* argv[]);
|
||||||
static GBAApp* app();
|
static GBAApp* app();
|
||||||
|
|
||||||
|
static QString dataDir();
|
||||||
|
|
||||||
Window* newWindow();
|
Window* newWindow();
|
||||||
|
|
||||||
QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = QString());
|
QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = QString());
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ShaderSelector.h"
|
#include "ShaderSelector.h"
|
||||||
|
|
||||||
#include "ConfigController.h"
|
#include "ConfigController.h"
|
||||||
|
#include "GBAApp.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "VFileDevice.h"
|
#include "VFileDevice.h"
|
||||||
|
|
||||||
|
@ -57,16 +58,9 @@ void ShaderSelector::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderSelector::selectShader() {
|
void ShaderSelector::selectShader() {
|
||||||
#ifdef QT_SHADER_DIR
|
QString path(GBAApp::dataDir());
|
||||||
QFileDialog dialog(nullptr, tr("Load shader"), QT_SHADER_DIR, tr("%1 Shader (%.shader)").arg(projectName));
|
|
||||||
#else
|
|
||||||
QString path = QCoreApplication::applicationDirPath();
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
path += QLatin1String("/../Resources");
|
|
||||||
#endif
|
|
||||||
path += QLatin1String("/shaders");
|
path += QLatin1String("/shaders");
|
||||||
QFileDialog dialog(nullptr, tr("Load shader"), path, tr("%1 Shader (%.shader)").arg(projectName));
|
QFileDialog dialog(nullptr, tr("Load shader"), path, tr("%1 Shader (%.shader)").arg(projectName));
|
||||||
#endif
|
|
||||||
dialog.setFileMode(QFileDialog::Directory);
|
dialog.setFileMode(QFileDialog::Directory);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
QStringList names = dialog.selectedFiles();
|
QStringList names = dialog.selectedFiles();
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "AboutScreen.h"
|
#include "AboutScreen.h"
|
||||||
#include "CheatsView.h"
|
#include "CheatsView.h"
|
||||||
#include "ConfigController.h"
|
#include "ConfigController.h"
|
||||||
#include "DatDownloadView.h"
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
@ -408,12 +407,6 @@ void Window::openROMInfo() {
|
||||||
openView(romInfo);
|
openView(romInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::openDatDownloadWindow() {
|
|
||||||
DatDownloadView* datView = new DatDownloadView();
|
|
||||||
datView->show();
|
|
||||||
datView->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
void Window::openGamepadWindow() {
|
void Window::openGamepadWindow() {
|
||||||
const char* profile = m_inputController.profileForType(SDL_BINDING_BUTTON);
|
const char* profile = m_inputController.profileForType(SDL_BINDING_BUTTON);
|
||||||
|
@ -1194,10 +1187,6 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
addControlledAction(toolsMenu, gdbWindow, "gdbWindow");
|
addControlledAction(toolsMenu, gdbWindow, "gdbWindow");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QAction* updateDat = new QAction(tr("Update game database..."), toolsMenu);
|
|
||||||
connect(updateDat, SIGNAL(triggered()), this, SLOT(openDatDownloadWindow()));
|
|
||||||
addControlledAction(toolsMenu, updateDat, "updateDat");
|
|
||||||
|
|
||||||
toolsMenu->addSeparator();
|
toolsMenu->addSeparator();
|
||||||
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())),
|
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())),
|
||||||
"settings");
|
"settings");
|
||||||
|
|
|
@ -89,7 +89,6 @@ public slots:
|
||||||
|
|
||||||
void openAboutScreen();
|
void openAboutScreen();
|
||||||
void openROMInfo();
|
void openROMInfo();
|
||||||
void openDatDownloadWindow();
|
|
||||||
|
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
void openGamepadWindow();
|
void openGamepadWindow();
|
||||||
|
|
Loading…
Reference in New Issue