Qt: Start work on ROM information view
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Dec 2015 02:44:19 -0800
7 files changed,
172 insertions(+),
0 deletions(-)
M
src/platform/qt/CMakeLists.txt
→
src/platform/qt/CMakeLists.txt
@@ -91,6 +91,7 @@ MessagePainter.cpp
MultiplayerController.cpp OverrideView.cpp PaletteView.cpp + ROMInfo.cpp SavestateButton.cpp SensorView.cpp SettingsView.cpp@@ -112,6 +113,7 @@ LogView.ui
MemoryView.ui OverrideView.ui PaletteView.ui + ROMInfo.ui SensorView.ui SettingsView.ui ShaderSelector.ui
A
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(); +}
A
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 <QWidget> + +#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
A
src/platform/qt/ROMInfo.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ROMInfo</class> + <widget class="QDialog" name="ROMInfo"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>236</width> + <height>142</height> + </rect> + </property> + <property name="windowTitle"> + <string>ROM Info</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::FieldsStayAtSizeHint</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Game ID:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="id"> + <property name="text"> + <string>{ID}</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Internal name:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="title"> + <property name="text"> + <string>{TITLE}</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>File size:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="size"> + <property name="text"> + <string>{SIZE}</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>CRC32:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="crc"> + <property name="text"> + <string>{CRC}</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui>
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -31,6 +31,7 @@ #include "MultiplayerController.h"
#include "MemoryView.h" #include "OverrideView.h" #include "PaletteView.h" +#include "ROMInfo.h" #include "SensorView.h" #include "SettingsView.h" #include "ShaderSelector.h"@@ -398,6 +399,11 @@
void Window::openAboutScreen() { AboutScreen* about = new AboutScreen(); openView(about); +} + +void Window::openROMInfo() { + ROMInfo* romInfo = new ROMInfo(m_controller); + openView(romInfo); } #ifdef BUILD_SDL@@ -766,6 +772,11 @@ addControlledAction(fileMenu, fileMenu->addAction(tr("Load &patch..."), this, SLOT(selectPatch())), "loadPatch");
addControlledAction(fileMenu, fileMenu->addAction(tr("Boot BIOS"), m_controller, SLOT(bootBIOS())), "bootBIOS"); 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"));
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -88,6 +88,7 @@ void openMemoryWindow();
void openIOViewer(); void openAboutScreen(); + void openROMInfo(); #ifdef BUILD_SDL void openGamepadWindow();