File indexing completed on 2024-04-28 07:54:21

0001 /* This file is part of KsirK.
0002    Copyright (C) 2008 Gael de Chalendar <kleag@free.fr>
0003 
0004    KsirK is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, either version 2
0007    of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    General Public License for more details.
0013 
0014    You should have received a copy of the GNU General Public License
0015    along with this program; if not, write to the Free Software
0016    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017    02110-1301, USA
0018 */
0019 
0020 #ifndef MAINWINDOW_H
0021 #define MAINWINDOW_H
0022 
0023 #include "ksirkskineditorwidget.h"
0024 #include "onu.h"
0025 #include "spritetype.h"
0026 
0027 // include files for Qt
0028 
0029 #include <QPointF>
0030 #include <QLabel>
0031 #include <QPushButton>
0032 #include <QStackedWidget>
0033 #include <QGroupBox>
0034 #include <QSplitter>
0035 #include <QSlider>
0036 #include <QHBoxLayout>
0037 #include <QVBoxLayout>
0038 #include <QUrl>
0039 // include files for KDE
0040 #include <KSharedConfig>
0041 #include <KXmlGuiWindow>
0042 // include files for kde games
0043 
0044 class QAction;
0045 class KRecentFilesAction;
0046 
0047 class QGraphicsView;
0048 class QListWidgetItem;
0049 class QGraphicsPixmapItem;
0050 
0051 class KSirkSkinDefinitionWidget;
0052 class KsirkCountryDefinitionWidget;
0053 class KsirkContinentDefinitionWidget;
0054 class KsirkGoalDefinitionWidget;
0055 class KsirkSpritesDefinitionWidget;
0056 class KsirkNationalityDefinitionWidget;
0057 
0058 namespace KsirkSkinEditor
0059 {
0060   class PixmapItem;
0061   class Goal;
0062   class Scene;
0063   
0064 /**
0065   * This is the main window.
0066   *
0067   * @author Gael de Chalendar (aka Kleag)
0068   * @version $Id: $
0069   */
0070 class MainWindow : public KXmlGuiWindow
0071 {
0072   Q_OBJECT
0073 
0074 public:
0075   /**
0076     * Create the window and initializes its members
0077     */
0078   explicit MainWindow(QWidget* parent=nullptr);
0079   
0080   /**
0081     * Deletes the background and the pool
0082     */
0083   ~MainWindow() override;
0084     
0085 protected:
0086   /**
0087     * Add the main toolbar buttons
0088     */
0089   void initActions();
0090 
0091   /**
0092     * Prepares the status bar
0093     */
0094   void initStatusBar();
0095 
0096   /**
0097     * creates and display the main frame with the background
0098     */
0099   void initView();
0100 
0101   /**
0102     * Reimplementation of the inherited function called when a window close event arise
0103     */
0104   bool queryClose() override;
0105 
0106 public Q_SLOTS:
0107 
0108   /**
0109     * The standard slotShowAboutApplication slot
0110     */
0111   void slotShowAboutApplication();
0112 
0113 //   void slotZoomIn();
0114 //   void slotZoomOut();
0115 
0116 private Q_SLOTS:
0117   void optionsConfigure();
0118 
0119   void slotFlagButtonClicked();
0120   void slotInfantryButtonClicked();
0121   void slotCavalryButtonClicked();
0122   void slotCannonButtonClicked();
0123   void slotAnchorButtonClicked();
0124   void slotCenterButtonClicked();
0125   
0126   void slotPosition(const QPointF&);
0127   void slotPressPosition(const QPointF&);
0128 
0129   void slotCountrySelected(QListWidgetItem* item);
0130   void slotContinentSelected(QListWidgetItem* item);
0131   
0132   void slotItemPressed(QGraphicsItem*, const QPointF&);
0133   void slotItemPlaced(QGraphicsItem*, const QPointF&);
0134   
0135   void slotOpenSkin();
0136   void slotSaveSkin();
0137 
0138   void slotURLSelected(const QUrl&);
0139 
0140   void slotSkinNameEdited();
0141   void slotSkinWidthEdited(int);
0142   void slotSkinHeightEdited(int);
0143   void slotSkinDescriptionEdited();
0144 
0145   void slotSkinWidthDiffEdited();
0146 
0147   void slotNewCountry();
0148   void slotDeleteCountry();
0149 
0150   void slotNeighbours();
0151   void slotSkinPartTabChanged(int index);
0152   void slotContinentCountries();
0153   void slotContinentBonusEdited(int);
0154 
0155   void slotFlagWidthChanged(int);
0156   void slotFlagHeightChanged(int);
0157   void slotFlagFramesChanged(int);
0158   void slotFlagVersionsChanged(int);
0159   
0160   void slotInfantryWidthChanged(int);
0161   void slotInfantryHeightChanged(int);
0162   void slotInfantryFramesChanged(int);
0163   void slotInfantryVersionsChanged(int);
0164   
0165   void slotCavalryWidthChanged(int);
0166   void slotCavalryHeightChanged(int);
0167   void slotCavalryFramesChanged(int);
0168   void slotCavalryVersionsChanged(int);
0169   
0170   void slotCannonWidthChanged(int);
0171   void slotCannonHeightChanged(int);
0172   void slotCannonFramesChanged(int);
0173   void slotCannonVersionsChanged(int);
0174   
0175   void slotFiringWidthChanged(int);
0176   void slotFiringHeightChanged(int);
0177   void slotFiringFramesChanged(int);
0178   void slotFiringVersionsChanged(int);
0179   
0180   void slotExplodingWidthChanged(int);
0181   void slotExplodingHeightChanged(int);
0182   void slotExplodingFramesChanged(int);
0183   void slotExplodingVersionsChanged(int);
0184 
0185   void slotNewContinent();
0186   void slotDeleteContinent();
0187 
0188   void slotGoalSelected(QListWidgetItem* item);
0189 
0190   void slotGoalTypeWorldClicked();
0191   void slotGoalTypePlayerClicked();
0192   void slotGoalTypeCountriesClicked();
0193   void slotGoalTypeContinentsClicked();
0194   void slotGoalDescriptionEdited();
0195   void slotGoalNbCountriesChanged(int);
0196   void slotGoalNbArmiesByCountryChanged(int);
0197   void slotGoalAnyContinentChanged(int);
0198   void slotGoalContinents();
0199   void slotNewGoal();
0200   void slotDeleteGoal();
0201 
0202   void slotNationalitySelected(QListWidgetItem* item);
0203   void slotNationalityNameEdited();
0204   void slotNationalityLeaderNameEdited();
0205   void slotNationalityFlagEdited(int);
0206   void slotNewNationality();
0207   void slotDeleteNationality();
0208   
0209   void slotFontSelected(const QFont& font);
0210   void slotFgSelected(const QColor& color);
0211   void slotBgColorSelected(const QColor& color);
0212   void slotReleasePosition(const QPointF&);
0213 
0214   void slotFLagxValueChanged(int);
0215   void slotFLagyValueChanged(int v);
0216   void slotCenterxValueChanged(int);
0217   void slotCenteryValueChanged(int v);
0218   void slotAnchorxValueChanged(int);
0219   void slotAnchoryValueChanged(int v);
0220   void slotCavalryxValueChanged(int);
0221   void slotCavalryyValueChanged(int v);
0222   void slotCannonxValueChanged(int);
0223   void slotCannonyValueChanged(int v);
0224   void slotInfantryxValueChanged(int);
0225   void slotInfantryyValueChanged(int v);
0226   
0227 private:
0228   void initSpritesButtonsWith(const Country* country);
0229     
0230   void openSkin(const QString& skinDir);
0231   void initContinentWidgetWith(Continent* continent);
0232   void initGoalWidgetWith(Goal* continent);
0233   void initNationalityWidgetWith(Nationality* nationality);
0234   void updateSprites(SpriteType type);
0235   
0236   Country* currentCountry();
0237   void createPixmapFor(Country* country, SpriteType type);
0238 
0239   // the current saved game file name
0240   QString m_fileName;
0241 
0242   QAction * m_saveGameAction;
0243 
0244   QGraphicsView* m_mapView;
0245   Scene* m_mapScene;
0246   
0247   SpriteType m_selectedSprite;
0248 
0249   ONU* m_onu;
0250 
0251   KSirkSkinDefinitionWidget* m_skinDefWidget;
0252   KsirkCountryDefinitionWidget* m_countryDefWidget;
0253   KsirkContinentDefinitionWidget* m_continentDefWidget;
0254   KsirkGoalDefinitionWidget* m_goalDefWidget;
0255   KsirkSpritesDefinitionWidget* m_spritesDefWidget;
0256   KsirkNationalityDefinitionWidget* m_nationalityDefWidget;
0257   
0258   QPushButton* m_flagButton;
0259   QPushButton* m_infantryButton;
0260   QPushButton* m_cavalryButton;
0261   QPushButton* m_cannonButton;
0262   QPushButton* m_anchorButton;
0263   QPushButton* m_centerButton;
0264   
0265   KRecentFilesAction* m_rfa;
0266 
0267   QGraphicsPixmapItem* m_mapItem;
0268 
0269   bool m_updateHighlightPosition;
0270 };
0271 
0272 } // closing namespace KsirkSkinEditor
0273 
0274 #endif 
0275