all repos — mgba @ 2743905845e0e3bc7bbb56f34bbc1be06d84ebaa

mGBA Game Boy Advance Emulator

src/platform/qt/AssetView.h (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#pragma once
 7
 8#include <QTimer>
 9#include <QWidget>
10
11#include <mgba/core/cache-set.h>
12
13#include <memory>
14
15struct mMapCacheEntry;
16
17namespace QGBA {
18
19class CoreController;
20
21class AssetView : public QWidget {
22Q_OBJECT
23
24public:
25	AssetView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
26
27protected slots:
28	void updateTiles();
29	void updateTiles(bool force);
30
31protected:
32#ifdef M_CORE_GBA
33	virtual void updateTilesGBA(bool force) = 0;
34#endif
35#ifdef M_CORE_GB
36	virtual void updateTilesGB(bool force) = 0;
37#endif
38
39	void resizeEvent(QResizeEvent*) override;
40	void showEvent(QShowEvent*) override;
41
42	mCacheSet* const m_cacheSet;
43	std::shared_ptr<CoreController> m_controller;
44
45protected:
46	struct ObjInfo {
47		unsigned tile;
48		unsigned width;
49		unsigned height;
50		unsigned stride;
51		unsigned paletteId;
52		unsigned paletteSet;
53		unsigned bits;
54
55		bool enabled : 1;
56		unsigned priority : 2;
57		unsigned x : 9;
58		unsigned y : 9;
59		bool hflip : 1;
60		bool vflip : 1;
61
62		bool operator!=(const ObjInfo&) const;
63	};
64
65	static void compositeTile(const void* tile, void* image, size_t stride, size_t x, size_t y, int depth = 8);
66	QImage compositeMap(int map, mMapCacheEntry*);
67	QImage compositeObj(const ObjInfo&);
68
69	bool lookupObj(int id, struct ObjInfo*);
70
71private:
72#ifdef M_CORE_GBA
73	bool lookupObjGBA(int id, struct ObjInfo*);
74#endif
75#ifdef M_CORE_GB
76	bool lookupObjGB(int id, struct ObjInfo*);
77#endif
78
79	QTimer m_updateTimer;
80};
81
82}