1 /* This file is part of KsirK.
2    Copyright (C) 2008 Gael de Chalendar <kleag@free.fr>
3 
4    KsirK is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public
6    License as published by the Free Software Foundation, either version 2
7    of the License, or (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA
18 */
19 
20 #ifndef MAINWINDOW_H
21 #define MAINWINDOW_H
22 
23 #include "ksirkskineditorwidget.h"
24 #include "onu.h"
25 #include "spritetype.h"
26 
27 // include files for Qt
28 
29 #include <QPointF>
30 #include <QPixmap>
31 #include <QLabel>
32 #include <QPushButton>
33 #include <QStackedWidget>
34 #include <QGroupBox>
35 #include <QSplitter>
36 #include <QSlider>
37 #include <QHBoxLayout>
38 #include <QVBoxLayout>
39 #include <QUrl>
40 // include files for KDE
41 #include <KSharedConfig>
42 #include <KXmlGuiWindow>
43 // include files for kde games
44 
45 class QAction;
46 class KRecentFilesAction;
47 
48 class QGraphicsScene;
49 class QGraphicsView;
50 class QListWidgetItem;
51 class QGraphicsPixmapItem;
52 
53 class KSirkSkinDefinitionWidget;
54 class KsirkCountryDefinitionWidget;
55 class KsirkContinentDefinitionWidget;
56 class KsirkGoalDefinitionWidget;
57 class KsirkSpritesDefinitionWidget;
58 class KsirkNationalityDefinitionWidget;
59 
60 namespace Phonon
61 {
62   class MediaObject;
63 }
64 
65 namespace KsirkSkinEditor
66 {
67   class PixmapItem;
68   class Goal;
69 
70 /**
71   * This is the main window.
72   *
73   * @author Gael de Chalendar (aka Kleag)
74   * @version $Id: $
75   */
76 class MainWindow : public KXmlGuiWindow
77 {
78   Q_OBJECT
79 
80 public:
81   /**
82     * Create the window and initializes its members
83     */
84   explicit MainWindow(QWidget* parent=0);
85 
86   /**
87     * Deletes the background and the pool
88     */
89   ~MainWindow() override;
90 
91 protected:
92   /**
93     * Add the main toolbar buttons
94     */
95   void initActions();
96 
97   /**
98     * Prepares the status bar
99     */
100   void initStatusBar();
101 
102   /**
103     * creates and display the main frame with the background
104     */
105   void initView();
106 
107   /**
108     * Reimplementation of the inherited function called when a window close event arise
109     */
110   bool queryClose() override;
111 
112 public Q_SLOTS:
113 
114   /**
115     * The standard slotShowAboutApplication slot
116     */
117   void slotShowAboutApplication();
118 
119 //   void slotZoomIn();
120 //   void slotZoomOut();
121 
122 private Q_SLOTS:
123   void optionsConfigure();
124 
125   void slotFlagButtonClicked();
126   void slotInfantryButtonClicked();
127   void slotCavalryButtonClicked();
128   void slotCannonButtonClicked();
129   void slotAnchorButtonClicked();
130   void slotCenterButtonClicked();
131 
132   void slotPosition(const QPointF&);
133   void slotPressPosition(const QPointF&);
134 
135   void slotCountrySelected(QListWidgetItem* item);
136   void slotContinentSelected(QListWidgetItem* item);
137 
138   void slotItemPressed(QGraphicsItem*, const QPointF&);
139   void slotItemPlaced(QGraphicsItem*, const QPointF&);
140 
141   void slotOpenSkin(const QString& dir = QString());
142   void slotSaveSkin();
143 
144   void slotURLSelected(const QUrl&);
145 
146   void slotSkinNameEdited();
147   void slotSkinWidthEdited(int);
148   void slotSkinHeightEdited(int);
149   void slotSkinDescriptionEdited();
150 
151   void slotSkinWidthDiffEdited();
152 
153   void slotNewCountry();
154   void slotDeleteCountry();
155 
156   void slotNeighbours();
157   void slotSkinPartTabChanged(int index);
158   void slotContinentCountries();
159   void slotContinentBonusEdited(int);
160 
161   void slotFlagWidthChanged(int);
162   void slotFlagHeightChanged(int);
163   void slotFlagFramesChanged(int);
164   void slotFlagVersionsChanged(int);
165 
166   void slotInfantryWidthChanged(int);
167   void slotInfantryHeightChanged(int);
168   void slotInfantryFramesChanged(int);
169   void slotInfantryVersionsChanged(int);
170 
171   void slotCavalryWidthChanged(int);
172   void slotCavalryHeightChanged(int);
173   void slotCavalryFramesChanged(int);
174   void slotCavalryVersionsChanged(int);
175 
176   void slotCannonWidthChanged(int);
177   void slotCannonHeightChanged(int);
178   void slotCannonFramesChanged(int);
179   void slotCannonVersionsChanged(int);
180 
181   void slotFiringWidthChanged(int);
182   void slotFiringHeightChanged(int);
183   void slotFiringFramesChanged(int);
184   void slotFiringVersionsChanged(int);
185 
186   void slotExplodingWidthChanged(int);
187   void slotExplodingHeightChanged(int);
188   void slotExplodingFramesChanged(int);
189   void slotExplodingVersionsChanged(int);
190 
191   void slotNewContinent();
192   void slotDeleteContinent();
193 
194   void slotGoalSelected(QListWidgetItem* item);
195 
196   void slotGoalTypeWorldClicked();
197   void slotGoalTypePlayerClicked();
198   void slotGoalTypeCountriesClicked();
199   void slotGoalTypeContinentsClicked();
200   void slotGoalDescriptionEdited();
201   void slotGoalNbCountriesChanged(int);
202   void slotGoalNbArmiesByCountryChanged(int);
203   void slotGoalAnyContinentChanged(int);
204   void slotGoalContinents();
205   void slotNewGoal();
206   void slotDeleteGoal();
207 
208   void slotNationalitySelected(QListWidgetItem* item);
209   void slotNationalityNameEdited();
210   void slotNationalityLeaderNameEdited();
211   void slotNationalityFlagEdited(int);
212   void slotNewNationality();
213   void slotDeleteNationality();
214 
215   void slotFontSelected(const QFont& font);
216   void slotFgSelected(const QColor& color);
217   void slotBgColorSelected(const QColor& color);
218   void slotReleasePosition(const QPointF&);
219 
220   void slotFLagxValueChanged(int);
221   void slotFLagyValueChanged(int v);
222   void slotCenterxValueChanged(int);
223   void slotCenteryValueChanged(int v);
224   void slotAnchorxValueChanged(int);
225   void slotAnchoryValueChanged(int v);
226   void slotCavalryxValueChanged(int);
227   void slotCavalryyValueChanged(int v);
228   void slotCannonxValueChanged(int);
229   void slotCannonyValueChanged(int v);
230   void slotInfantryxValueChanged(int);
231   void slotInfantryyValueChanged(int v);
232 
233 private:
234   void initSpritesButtonsWith(const Country* country);
235 
236   void initContinentWidgetWith(Continent* continent);
237   void initGoalWidgetWith(Goal* continent);
238   void initNationalityWidgetWith(Nationality* nationality);
239   void updateSprites(SpriteType type);
240 
241   Country* currentCountry();
242   void createPixmapFor(Country* country, SpriteType type);
243 
244   /**
245     * Audio player object: play all the sounds of the game.
246     */
247   Phonon::MediaObject* m_audioPlayer;
248 
249   // the current saved game file name
250   QString m_fileName;
251 
252   QAction * m_saveGameAction;
253 
254   QGraphicsView* m_mapView;
255   QGraphicsScene* m_mapScene;
256 
257   SpriteType m_selectedSprite;
258 
259   ONU* m_onu;
260 
261   KSirkSkinDefinitionWidget* m_skinDefWidget;
262   KsirkCountryDefinitionWidget* m_countryDefWidget;
263   KsirkContinentDefinitionWidget* m_continentDefWidget;
264   KsirkGoalDefinitionWidget* m_goalDefWidget;
265   KsirkSpritesDefinitionWidget* m_spritesDefWidget;
266   KsirkNationalityDefinitionWidget* m_nationalityDefWidget;
267 
268   QPushButton* m_flagButton;
269   QPushButton* m_infantryButton;
270   QPushButton* m_cavalryButton;
271   QPushButton* m_cannonButton;
272   QPushButton* m_anchorButton;
273   QPushButton* m_centerButton;
274 
275   KRecentFilesAction* m_rfa;
276 
277   QGraphicsPixmapItem* m_mapItem;
278 
279   bool m_updateHighlightPosition;
280 };
281 
282 } // closing namespace KsirkSkinEditor
283 
284 #endif
285 
286