From cd6b6862ff51b3d9435ba0546f7129b515da6b72 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 20 Dec 2015 02:44:19 -0800 Subject: [PATCH] Qt: Start work on ROM information view --- CHANGES | 1 + src/platform/qt/CMakeLists.txt | 2 + src/platform/qt/ROMInfo.cpp | 29 +++++++++++ src/platform/qt/ROMInfo.h | 33 ++++++++++++ src/platform/qt/ROMInfo.ui | 95 ++++++++++++++++++++++++++++++++++ src/platform/qt/Window.cpp | 11 ++++ src/platform/qt/Window.h | 1 + 7 files changed, 172 insertions(+) create mode 100644 src/platform/qt/ROMInfo.cpp create mode 100644 src/platform/qt/ROMInfo.h create mode 100644 src/platform/qt/ROMInfo.ui diff --git a/CHANGES b/CHANGES index 4f86b5601..b13d91035 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Features: - Customization of GIF recording - Libretro: Cheat code support - Support for GLSL shaders + - ROM information view Bugfixes: - Util: Fix PowerPC PNG read/write pixel order - VFS: Fix VFileReadline and remove _vfdReadline diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index 579115c3d..4b4547c75 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -91,6 +91,7 @@ set(SOURCE_FILES MultiplayerController.cpp OverrideView.cpp PaletteView.cpp + ROMInfo.cpp SavestateButton.cpp SensorView.cpp SettingsView.cpp @@ -112,6 +113,7 @@ qt5_wrap_ui(UI_FILES MemoryView.ui OverrideView.ui PaletteView.ui + ROMInfo.ui SensorView.ui SettingsView.ui ShaderSelector.ui diff --git a/src/platform/qt/ROMInfo.cpp b/src/platform/qt/ROMInfo.cpp new file mode 100644 index 000000000..ec918cebc --- /dev/null +++ b/src/platform/qt/ROMInfo.cpp @@ -0,0 +1,29 @@ +/* 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 "ROMInfo.h" + +#include "GameController.h" + +using namespace QGBA; + +ROMInfo::ROMInfo(GameController* controller, QWidget* parent) { + m_ui.setupUi(this); + + if (!controller->isLoaded()) { + return; + } + + controller->threadInterrupt(); + GBA* gba = controller->thread()->gba; + char title[13] = {}; + GBAGetGameCode(gba, title); + m_ui.id->setText(QLatin1String(title)); + GBAGetGameTitle(gba, title); + m_ui.title->setText(QLatin1String(title)); + m_ui.size->setText(QString::number(gba->pristineRomSize)); + m_ui.crc->setText(QString::number(gba->romCrc32, 16)); + controller->threadContinue(); +} diff --git a/src/platform/qt/ROMInfo.h b/src/platform/qt/ROMInfo.h new file mode 100644 index 000000000..bfe08b171 --- /dev/null +++ b/src/platform/qt/ROMInfo.h @@ -0,0 +1,33 @@ +/* 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_ROM_INFO +#define QGBA_ROM_INFO + +#include + +#include "ui_ROMInfo.h" + +extern "C" { +#include "gba/supervisor/thread.h" +} + +namespace QGBA { + +class GameController; + +class ROMInfo : public QDialog { +Q_OBJECT + +public: + ROMInfo(GameController* controller, QWidget* parent = nullptr); + +private: + Ui::ROMInfo m_ui; +}; + +} + +#endif diff --git a/src/platform/qt/ROMInfo.ui b/src/platform/qt/ROMInfo.ui new file mode 100644 index 000000000..08211a68e --- /dev/null +++ b/src/platform/qt/ROMInfo.ui @@ -0,0 +1,95 @@ + + + ROMInfo + + + + 0 + 0 + 236 + 142 + + + + ROM Info + + + + QLayout::SetFixedSize + + + QFormLayout::FieldsStayAtSizeHint + + + + + Game ID: + + + + + + + {ID} + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Internal name: + + + + + + + {TITLE} + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + File size: + + + + + + + {SIZE} + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + CRC32: + + + + + + + {CRC} + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 0a3130e11..0fb1577a0 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -31,6 +31,7 @@ #include "MemoryView.h" #include "OverrideView.h" #include "PaletteView.h" +#include "ROMInfo.h" #include "SensorView.h" #include "SettingsView.h" #include "ShaderSelector.h" @@ -400,6 +401,11 @@ void Window::openAboutScreen() { openView(about); } +void Window::openROMInfo() { + ROMInfo* romInfo = new ROMInfo(m_controller); + openView(romInfo); +} + #ifdef BUILD_SDL void Window::openGamepadWindow() { const char* profile = m_inputController.profileForType(SDL_BINDING_BUTTON); @@ -767,6 +773,11 @@ void Window::setupMenu(QMenuBar* menubar) { addControlledAction(fileMenu, fileMenu->addAction(tr("Replace ROM..."), this, SLOT(replaceROM())), "replaceROM"); + QAction* romInfo = new QAction(tr("ROM &info..."), fileMenu); + connect(romInfo, SIGNAL(triggered()), this, SLOT(openROMInfo())); + m_gameActions.append(romInfo); + addControlledAction(fileMenu, romInfo, "romInfo"); + m_mruMenu = fileMenu->addMenu(tr("Recent")); fileMenu->addSeparator(); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 7772811dd..32a8f459a 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -88,6 +88,7 @@ public slots: void openIOViewer(); void openAboutScreen(); + void openROMInfo(); #ifdef BUILD_SDL void openGamepadWindow();