1 /* Copyright (c) 2013-2019 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 "BattleChipModel.h"
9 
10 #include <QDialog>
11 
12 #include <memory>
13 
14 #include <mgba/core/interface.h>
15 
16 #include "ui_BattleChipView.h"
17 
18 namespace QGBA {
19 
20 class CoreController;
21 class Window;
22 
23 class BattleChipView : public QDialog {
24 Q_OBJECT
25 
26 public:
27 	BattleChipView(std::shared_ptr<CoreController> controller, Window* window, QWidget* parent = nullptr);
28 	~BattleChipView();
29 
30 public slots:
31 	void setFlavor(int);
32 	void insertChip(bool);
33 	void reinsert();
34 	void resort();
35 
36 private slots:
37 	void advanceFrameCounter();
38 	void addChip();
39 	void removeChip();
40 
41 	void saveDeck();
42 	void loadDeck();
43 
44 	void updateData();
45 
46 private:
47 	static const int UNINSERTED_TIME = 10;
48 
49 	void loadChipNames(int);
50 
51 	Ui::BattleChipView m_ui;
52 
53 	BattleChipModel m_model;
54 	std::shared_ptr<CoreController> m_controller;
55 
56 	int m_frameCounter = -1;
57 	bool m_next = false;
58 
59 	Window* m_window;
60 
61 	BattleChipUpdater* m_updater = nullptr;
62 };
63 
64 }
65