all repos — mgba @ c69c34ab2d419fa5ca605094e4afbb8f9e406a47

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	m_ui.setupUi(this);
19
20	if (!controller->isLoaded()) {
21		return;
22	}
23
24	const NoIntroDB* db = GBAApp::app()->gameDB();
25
26	controller->threadInterrupt();
27	GBA* gba = controller->thread()->gba;
28	char title[13] = {};
29	GBAGetGameCode(gba, title);
30	m_ui.id->setText(QLatin1String(title));
31	GBAGetGameTitle(gba, title);
32	m_ui.title->setText(QLatin1String(title));
33	m_ui.size->setText(QString::number(gba->pristineRomSize));
34	m_ui.crc->setText(QString::number(gba->romCrc32, 16));
35	if (db) {
36		NoIntroGame game;
37		if (NoIntroDBLookupGameByCRC(db, gba->romCrc32, &game)) {
38			m_ui.name->setText(game.name);
39		} else {
40			m_ui.name->setText(tr("(unknown)"));
41		}
42	} else {
43		m_ui.name->setText(tr("(no database present)"));
44	}
45	controller->threadContinue();
46}