author | unc0rr |
Wed, 01 Jan 2014 13:42:38 +0400 | |
changeset 9900 | 34ba1d8e0e9a |
parent 9744 | 1ee4842a9c86 |
child 9998 | 736015b847e3 |
permissions | -rw-r--r-- |
164 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com> |
9080 | 4 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
164 | 5 |
* |
184 | 6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
164 | 9 |
* |
184 | 10 |
* This program is distributed in the hope that it will be useful, |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
164 | 14 |
* |
184 | 15 |
* You should have received a copy of the GNU General Public License |
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
164 | 18 |
*/ |
19 |
||
20 |
#ifndef _HWMAP_CONTAINER_INCLUDED |
|
21 |
#define _HWMAP_CONTAINER_INCLUDED |
|
22 |
||
23 |
#include <QWidget> |
|
1209 | 24 |
#include <QGridLayout> |
8377 | 25 |
#include <QVBoxLayout> |
249 | 26 |
#include <QComboBox> |
1802 | 27 |
#include <QLabel> |
4489 | 28 |
#include <QByteArray> |
4519 | 29 |
#include <QLineEdit> |
164 | 30 |
|
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
31 |
#include "DataManager.h" |
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
32 |
|
1210 | 33 |
#include "hwmap.h" |
4520
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
34 |
#include "drawmapscene.h" |
7258 | 35 |
#include "MapModel.h" |
1210 | 36 |
|
164 | 37 |
class QPushButton; |
1209 | 38 |
class IconedGroupBox; |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
4976
diff
changeset
|
39 |
class QListView; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
40 |
class SeparatorPainter; |
8377 | 41 |
class QListWidget; |
164 | 42 |
|
249 | 43 |
class MapFileErrorException |
44 |
{ |
|
45 |
}; |
|
46 |
||
164 | 47 |
class HWMapContainer : public QWidget |
48 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
49 |
Q_OBJECT |
320 | 50 |
|
8377 | 51 |
Q_PROPERTY(bool master READ isMaster WRITE setMaster) |
52 |
||
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
53 |
public: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
54 |
HWMapContainer(QWidget * parent=0); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
55 |
QString getCurrentSeed() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
56 |
QString getCurrentMap() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
57 |
QString getCurrentTheme() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
58 |
int getCurrentHHLimit() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
59 |
QString getCurrentScheme() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
60 |
QString getCurrentWeapons() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
61 |
quint32 getTemplateFilter() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
62 |
MapGenerator get_mapgen(void) const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
63 |
int getMazeSize(void) const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
64 |
bool getCurrentIsMission() const; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
65 |
QByteArray getDrawnMapData(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
66 |
DrawMapScene * getDrawMapScene(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
67 |
void mapDrawingFinished(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
68 |
QLineEdit* seedEdit; |
8377 | 69 |
bool isMaster(); |
164 | 70 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
71 |
public slots: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
72 |
void askForGeneratedPreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
73 |
void setSeed(const QString & seed); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
74 |
void setMap(const QString & map); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
75 |
void setTheme(const QString & theme); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
76 |
void setTemplateFilter(int); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
77 |
void setMapgen(MapGenerator m); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
78 |
void setMazeSize(int size); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
79 |
void setDrawnMapData(const QByteArray & ar); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
80 |
void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
81 |
void updateModelViews(); |
7008
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6960
diff
changeset
|
82 |
void onPreviewMapDestroyed(QObject * map); |
8377 | 83 |
void setMaster(bool master); |
164 | 84 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
85 |
signals: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
86 |
void seedChanged(const QString & seed); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
87 |
void mapChanged(const QString & map); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
88 |
void themeChanged(const QString & theme); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
89 |
void newTemplateFilter(int filter); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
90 |
void mapgenChanged(MapGenerator m); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
91 |
void mazeSizeChanged(int s); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
92 |
void drawMapRequested(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
93 |
void drawnMapChanged(const QByteArray & data); |
325 | 94 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
95 |
private slots: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
96 |
void setImage(const QImage newImage); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
97 |
void setHHLimit(int hhLimit); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
98 |
void setRandomSeed(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
99 |
void setRandomTheme(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
100 |
void setRandomMap(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
101 |
void addInfoToPreview(QPixmap image); |
8377 | 102 |
void setNewSeed(const QString & newSeed); |
103 |
void mapTypeChanged(int); |
|
104 |
void showThemePrompt(); |
|
105 |
void updateTheme(const QModelIndex & current); |
|
106 |
void staticMapChanged(const QModelIndex & map, const QModelIndex & old = QModelIndex()); |
|
107 |
void missionMapChanged(const QModelIndex & map, const QModelIndex & old = QModelIndex()); |
|
108 |
void loadDrawing(); |
|
109 |
void showSeedPrompt(); |
|
8467 | 110 |
void previewClicked(); |
164 | 111 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
112 |
protected: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
113 |
virtual void resizeEvent ( QResizeEvent * event ); |
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
114 |
virtual void showEvent ( QShowEvent * event ); |
164 | 115 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
116 |
private: |
8377 | 117 |
QVBoxLayout mainLayout; |
8467 | 118 |
QPushButton* mapPreview; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
119 |
QComboBox* chooseMap; |
8377 | 120 |
MapModel * m_staticMapModel; |
121 |
MapModel * m_missionMapModel; |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
122 |
IconedGroupBox* gbThemes; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
123 |
QListView* lvThemes; |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
124 |
ThemeModel * m_themeModel; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
125 |
HWMap* pMap; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
126 |
QString m_seed; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
127 |
QPushButton* seedSet; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
128 |
QLabel* seedLabel; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
129 |
int hhLimit; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
130 |
int templateFilter; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
131 |
QPixmap hhSmall; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
132 |
QLabel* lblFilter; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
133 |
QComboBox* cbTemplateFilter; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
134 |
QLabel *maze_size_label; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
135 |
QComboBox *cbMazeSize; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
136 |
MapGenerator mapgen; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
137 |
DrawMapScene drawMapScene; |
8377 | 138 |
QComboBox * cType; |
139 |
QListView * staticMapList; |
|
140 |
QListView * missionMapList; |
|
141 |
QListWidget * generationStyles; |
|
142 |
QListWidget * mazeStyles; |
|
143 |
QLabel * lblMapList; |
|
144 |
QLabel * lblDesc; |
|
145 |
QPushButton * btnTheme; |
|
146 |
QPushButton * btnLoadMap; |
|
147 |
QPushButton * btnEditMap; |
|
148 |
QPushButton * btnRandomize; |
|
149 |
QString selectedTheme; |
|
150 |
QPushButton * btnSeed; |
|
151 |
bool m_master; |
|
152 |
QList<QWidget *> m_childWidgets; |
|
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
153 |
bool m_previewEnabled; |
9744 | 154 |
bool m_missionsViewSetup; |
155 |
bool m_staticViewSetup; |
|
331 | 156 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
157 |
void intSetSeed(const QString & seed); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
158 |
void intSetMap(const QString & map); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
159 |
void intSetMapgen(MapGenerator m); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
160 |
void intSetTemplateFilter(int); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
161 |
void intSetMazeSize(int size); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
162 |
void intSetIconlessTheme(const QString & name); |
8377 | 163 |
void mapChanged(const QModelIndex & map, int type, const QModelIndex & old = QModelIndex()); |
164 |
void setMapInfo(MapModel::MapInfo mapInfo); |
|
165 |
void changeMapType(MapModel::MapType type, const QModelIndex & newMap = QModelIndex()); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
166 |
void updatePreview(); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
167 |
void updateThemeButtonSize(); |
9744 | 168 |
void setupMissionMapsView(); |
169 |
void setupStaticMapsView(); |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
170 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
171 |
MapModel::MapInfo m_mapInfo; |
8475
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
172 |
int m_themeID; |
6940
211aca8c1f4f
decouple current theme from map theme (fixes theme confusion bugs of last commit)
sheepluva
parents:
6938
diff
changeset
|
173 |
QString m_theme; |
6960
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6952
diff
changeset
|
174 |
QString m_curMap; |
7017
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7008
diff
changeset
|
175 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7008
diff
changeset
|
176 |
QLinearGradient linearGrad; ///< for preview background |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7008
diff
changeset
|
177 |
QSize m_previewSize; |
164 | 178 |
}; |
179 |
||
180 |
#endif // _HWMAP_CONTAINER_INCLUDED |