all repos — mgba @ f3b66397a2a598e5cfb63acd0c0b84f5796d0802

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