all repos — mgba @ fc905657adeba406a2c280bbb94b09533a89e3f8

mGBA Game Boy Advance Emulator

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	GBA* gba = controller->thread()->gba;
30	char title[13] = {};
31	GBAGetGameCode(gba, title);
32	m_ui.id->setText(QLatin1String(title));
33	GBAGetGameTitle(gba, title);
34	m_ui.title->setText(QLatin1String(title));
35	m_ui.size->setText(QString::number(gba->pristineRomSize));
36	m_ui.crc->setText(QString::number(gba->romCrc32, 16));
37	if (db) {
38		NoIntroGame game;
39		if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) {
40			m_ui.name->setText(game.name);
41		} else {
42			m_ui.name->setText(tr("(unknown)"));
43		}
44	} else {
45		m_ui.name->setText(tr("(no database present)"));
46	}
47	controller->threadContinue();
48}