all repos — mgba @ bb7d85698bd863d1108af18f93efc72a91560858

mGBA Game Boy Advance Emulator

src/platform/qt/AssetView.cpp (view raw)

 1/* Copyright (c) 2013-2016 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 "AssetView.h"
 7
 8#include <QTimer>
 9
10extern "C" {
11#ifdef M_CORE_GBA
12#include "gba/gba.h"
13#endif
14}
15
16using namespace QGBA;
17
18AssetView::AssetView(GameController* controller, QWidget* parent)
19	: QWidget(parent)
20	, m_controller(controller)
21	, m_tileCache(controller->tileCache())
22{
23	m_updateTimer.setSingleShot(true);
24	m_updateTimer.setInterval(1);
25	connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateTiles()));
26
27	connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), &m_updateTimer, SLOT(start()));
28	connect(m_controller, SIGNAL(gameStopped(mCoreThread*)), this, SLOT(close()));
29}
30
31void AssetView::updateTiles(bool force) {
32	if (!m_controller->thread() || !m_controller->thread()->core) {
33		return;
34	}
35
36	switch (m_controller->platform()) {
37#ifdef M_CORE_GBA
38	case PLATFORM_GBA:
39		updateTilesGBA(force);
40		break;
41#endif
42#ifdef M_CORE_GB
43	case PLATFORM_GB:
44		updateTilesGB(force);
45		break;
46#endif
47	default:
48		return;
49	}
50}
51
52void AssetView::resizeEvent(QResizeEvent*) {
53	updateTiles(true);
54}
55
56void AssetView::showEvent(QShowEvent*) {
57	updateTiles(true);
58}