all repos — mgba @ a75c019fab24f045069cb9a923d02795f4d6f564

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 "core/core.h"
13#include "gba/gba.h"
14#include "util/nointro.h"
15}
16
17using namespace QGBA;
18
19ROMInfo::ROMInfo(GameController* controller, QWidget* parent)
20	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
21{
22	m_ui.setupUi(this);
23
24	if (!controller->isLoaded()) {
25		return;
26	}
27
28	const NoIntroDB* db = GBAApp::app()->gameDB();
29
30	controller->threadInterrupt();
31	mCore* core = controller->thread()->core;
32	GBA* gba = static_cast<GBA*>(core->board);
33	char title[17] = {};
34	GBAGetGameCode(gba, title);
35	m_ui.id->setText(QLatin1String(title));
36	core->getGameTitle(core, title);
37	m_ui.title->setText(QLatin1String(title));
38	m_ui.size->setText(QString::number(gba->pristineRomSize));
39	m_ui.crc->setText(QString::number(gba->romCrc32, 16));
40	if (db) {
41		NoIntroGame game;
42		if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) {
43			m_ui.name->setText(game.name);
44		} else {
45			m_ui.name->setText(tr("(unknown)"));
46		}
47	} else {
48		m_ui.name->setText(tr("(no database present)"));
49	}
50	controller->threadContinue();
51}