File indexing completed on 2024-04-14 04:01:49

0001 /* This file is part of KsirK.
0002    Copyright (C) 2008 Guillaume Pelouas <pelouas@hotmail.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 /* begin                : Thu Nov 21 2007 */
0021 
0022 
0023 #ifndef FIGHTARENA_H
0024 #define FIGHTARENA_H
0025 
0026 #include "KsirkGlobalDefinitions.h"
0027 #include "GameLogic/onu.h"
0028 #include "GameLogic/country.h"
0029 #include "GameLogic/gameautomaton.h"
0030 #include "Sprites/backgnd.h"
0031 
0032 #include <stdlib.h>
0033 #include <QTimer>
0034 #include <QMouseEvent>
0035 #include <QGraphicsView>
0036 #include <QPixmap>
0037 #include <KConfig>
0038 #include <KConfigGroup>
0039 
0040 namespace Ksirk
0041 {
0042 
0043 namespace GameLogic
0044 {
0045   class ONU;
0046   class Country;
0047   class GameAutomaton;
0048 }
0049 
0050    /**
0051    * The FightArena class is the widget displayed while fights, and where
0052    * all the units sprites are displayed. It is linked to its parent 
0053    * widget (the main window)
0054    */
0055    class FightArena: public QGraphicsView
0056    {
0057       Q_OBJECT
0058       
0059       public:
0060       /**
0061       * Creates the frame, its timer and set some parameters
0062       * @param parent The parent widget, the main window
0063       * @param mapW The width of the arena. Will be the width given in size hint.
0064       * @param mapH The height of the arena. Will be the height given in size hint.
0065       * @param sceneArena where sprites will be added.
0066       * @param onuObject onuObject for getting map and country information
0067       * @param automaton automaton for the construction of countries
0068       */
0069       FightArena(QWidget* parent, unsigned int mapW, unsigned int mapH, QGraphicsScene* sceneArena, GameLogic::ONU* onuObject, GameLogic::GameAutomaton* automaton);
0070 
0071       /**
0072       * Destroy the frame : stops and deletes the timer
0073       */
0074       ~FightArena() override;
0075       
0076       /**
0077       * Returns the size given to the constructor.
0078       * @return The size given to the constructor.
0079       */
0080       QSize sizeHint() const override;
0081 
0082       /**
0083       * Initializes the fight arena with the two country which fight each other
0084       * @param countryA Country attacker
0085       * @param countryD Country defender
0086       * @param bg backgroud where to paint the elements
0087       */
0088       void initFightArena (GameLogic::Country* countryA, GameLogic::Country* countryD, BackGnd* bg);
0089 
0090       /**
0091         * Get the attacking arena country
0092         */
0093       inline GameLogic::Country* countryAttack () {return m_countryAttack;}
0094 
0095       /**
0096         * Get the defensing arena country
0097         */
0098       inline GameLogic::Country* countryDefense () {return m_countryDefense;}
0099 
0100       private:
0101       unsigned int m_mapW;
0102       unsigned int m_mapH;
0103 
0104       GameLogic::Country* m_countryAttack;
0105       GameLogic::Country* m_countryDefense;
0106       QGraphicsScene* m_scene;
0107       GameLogic::ONU* m_onu;
0108       GameLogic::GameAutomaton* m_automaton;
0109       QPixmap* m_bgImage;
0110    };
0111    
0112 }
0113 
0114 #endif // FIGHTARENA_H