forked from EasyRPG/Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.h
More file actions
160 lines (127 loc) · 3.6 KB
/
core.h
File metadata and controls
160 lines (127 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* This file is part of EasyRPG Editor.
*
* EasyRPG Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Editor. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "defines.h"
#ifdef Q_OS_WIN
#define PLAYER "Player.exe"
#else
#define PLAYER "easyrpg-player"
#endif
#include <QPixmap>
#include <QPainter>
#include <QListWidget>
#include <QQmlApplicationEngine>
#include <lcf/rpg/map.h>
#include <lcf/rpg/chipset.h>
#include "ui/other/run_game_dialog.h"
#include "model/project.h"
class Core : public QObject
{
Q_OBJECT
public:
enum Layer
{
LOWER,
UPPER,
EVENT
};
enum Tool
{
ZOOM,
PENCIL,
RECTANGLE,
CIRCLE,
FILL
};
Core();
static Core* getCore();
void LoadChipset(int n_chipsetid);
void LoadBackground(QString name);
int tileSize();
void setTileSize(int tileSize);
QString rtpPath(const QString &folder, const QString &filename = QString()) const;
Layer layer();
void setLayer(const Layer &layer);
Tool tool();
void setTool(const Tool &tool);
QString gameTitle();
void setGameTitle(const QString &gameTitle);
void beginPainting(QPixmap &dest);
void renderTile(const short &tile_id, const QRect &dest_rect);
void renderEvent(const lcf::rpg::Event& event, const QRect &dest_rect);
void endPainting();
QColor keycolor();
short translate(int terrain_id, int _code = 0, int _scode = 0);
int translate(short tile_id);
inline bool chipsetIsNull() {return m_tileCache[0].isNull();}
QPixmap createDummyPixmap(int width, int height);
bool isWater(int terrain_id);
bool isABWater(int terrain_id);
bool isDWater(int terrain_id);
bool isAnimation(int terrain_id);
bool isDblock(int terrain_id);
bool isEblock(int terrain_id);
bool isFblock(int terrain_id);
QString defDir() const;
void setDefDir(const QString &defDir);
void setRtpDir(const QString &n_path);
short selection(int off_x, int off_y);
int selWidth();
int selHeight();
void setSelection(std::vector<short> n_sel, int n_w, int n_h);
lcf::rpg::Event *currentMapEvent(int eventID);
void setCurrentMapEvents(QMap<int, lcf::rpg::Event *> *events);
void runGame();
void runGameHere(int map_id, int x, int y);
void runBattleTest(int troop_id);
std::shared_ptr<Project>& project();
const std::shared_ptr<Project>& project() const;
QQmlApplicationEngine* qmlEngine();
signals:
void toolChanged();
void layerChanged();
void chipsetChanged();
private:
lcf::rpg::Map *m_map;
lcf::rpg::Chipset m_chipset;
int m_tileSize;
QPainter m_painter;
QString m_defDir;
QString m_rtpDir;
QColor m_keycolor;
Layer m_layer;
Tool m_tool;
QPixmap m_background;
QMap<int, QPixmap> m_tileCache;
QMap<int, QPixmap> m_eventCache;
QMap<int, short> m_dictionary;
QMap<int, lcf::rpg::Map> m_maps;
QMap<int, QWidget*> m_mapTabs;
std::vector<short> m_lowerSel;
std::vector<short> m_upperSel;
short m_eventSel;
int m_lowerSelW;
int m_lowerSelH;
int m_upperSelW;
int m_upperSelH;
static Core *core_instance;
QMap<int, lcf::rpg::Event*> *m_currentMapEvents;
RunGameDialog *m_runGameDialog;
std::shared_ptr<Project> m_project;
QQmlApplicationEngine* m_qml_engine = nullptr;
};
Core& core();