all repos — mgba @ 19b164d560f6382b2e8ee55cc8a6eec22951ae29

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