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}
24
25void AssetView::updateTiles(bool force) {
26 if (!m_controller->thread() || !m_controller->thread()->core) {
27 return;
28 }
29
30 switch (m_controller->platform()) {
31#ifdef M_CORE_GBA
32 case PLATFORM_GBA:
33 updateTilesGBA(force);
34 break;
35#endif
36#ifdef M_CORE_GB
37 case PLATFORM_GB:
38 updateTilesGB(force);
39 break;
40#endif
41 default:
42 return;
43 }
44}
45
46void AssetView::resizeEvent(QResizeEvent*) {
47 updateTiles(true);
48}
49
50void AssetView::showEvent(QShowEvent*) {
51 updateTiles(true);
52}