src/platform/qt/ROMInfo.cpp (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "ROMInfo.h"
7
8#include "GBAApp.h"
9#include "GameController.h"
10
11extern "C" {
12#include "util/nointro.h"
13}
14
15using namespace QGBA;
16
17ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
18 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
19{
20 m_ui.setupUi(this);
21
22 if (!controller->isLoaded()) {
23 return;
24 }
25
26 const NoIntroDB* db = GBAApp::app()->gameDB();
27
28 controller->threadInterrupt();
29 mCore* core = controller->thread()->core;
30 GBA* gba = static_cast<GBA*>(core->board);
31 char title[17] = {};
32 GBAGetGameCode(gba, title);
33 m_ui.id->setText(QLatin1String(title));
34 core->getGameTitle(core, title);
35 m_ui.title->setText(QLatin1String(title));
36 m_ui.size->setText(QString::number(gba->pristineRomSize));
37 m_ui.crc->setText(QString::number(gba->romCrc32, 16));
38 if (db) {
39 NoIntroGame game;
40 if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) {
41 m_ui.name->setText(game.name);
42 } else {
43 m_ui.name->setText(tr("(unknown)"));
44 }
45 } else {
46 m_ui.name->setText(tr("(no database present)"));
47 }
48 controller->threadContinue();
49}