PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/mainwindow.h

http://cutefootball.googlecode.com/
C++ Header | 171 lines | 123 code | 25 blank | 23 comment | 0 complexity | 7b056a67110bb654cc99146e90a0465e MD5 | raw file
  1/*
  2 * Copyright 2010,2011 Timothy Rochford
  3 *
  4 *    This file is part of CuteFootball.
  5 *
  6 *    CuteFootball is free software: you can redistribute it and/or modify
  7 *    it under the terms of the Lesser GNU General Public License as published by
  8 *    the Free Software Foundation, either version 3 of the License, or
  9 *    (at your option) any later version.
 10 *
 11 *    CuteFootball is distributed in the hope that it will be useful,
 12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 *    Lesser GNU General Public License for more details.
 15 *
 16 *    You should have received a copy of the Lesser GNU General Public License
 17 *    along with CuteFootball.  If not, see <http://www.gnu.org/licenses/>.
 18 *
 19 */
 20#ifndef MAINWINDOW_H
 21#define MAINWINDOW_H
 22
 23#include <QtGui>
 24#include <qmap.h>
 25class TeamSelectionFrame;
 26
 27class aboutFrame;
 28class Pitch;
 29class SoundEffects;
 30class settingsFrame;
 31class helpFrame;
 32class inputSettingsFrame;
 33class mainMenuFrame;
 34class HalfStatisticsFrame;
 35class InGameMenuFrame;
 36
 37namespace Ui {
 38    class MainWindow;
 39}
 40
 41class MWindow : public QMainWindow
 42{
 43    Q_OBJECT
 44
 45public:
 46    enum ScreenOrientation {
 47        ScreenOrientationLockPortrait,
 48        ScreenOrientationLockLandscape,
 49        ScreenOrientationAuto
 50    };
 51
 52    MWindow(QWidget *parent = 0);
 53    virtual ~MWindow();
 54
 55    void setOrientation(ScreenOrientation orientation);
 56    Pitch* pitch() { return m_pitch; }
 57
 58    enum Action {
 59        East = 0,
 60        SouthEast = -45,
 61        South = -90,
 62        SouthWest = -135,
 63        West = -180,
 64        NorthWest = -225,
 65        North = -270,
 66        NorthEast = -315,
 67
 68        Button,
 69        ButtonShortPress,
 70        ButtonLongPress,
 71
 72        Shot,
 73        Pass,
 74        Tackle,
 75
 76        TackleN,
 77        TackleNE,
 78        TackleE,
 79        TackleSE,
 80        TackleS,
 81        TackleSW,
 82        TackleW,
 83        TackleNW,
 84
 85        // Due to loosing a tackle
 86        FallenOver,
 87
 88// TODO        YellowCard,
 89// TODO        RedCard,
 90
 91        // goal keeper moves
 92      DiveEast = 1,
 93      DiveWest = -179,
 94
 95      Pause,
 96      NoAction
 97    };
 98
 99    enum Frame {
100        MainMenu,
101        Settings,
102        Help,
103        InputSettings,
104        TeamSelection,
105        HalfTimeStatistics,
106        GraphicsView,
107        InGameMenu,
108        About
109    };
110
111private:
112    void createConnections();
113    void removeContextMenus();
114
115signals:
116    void setFrame(MWindow::Frame f);
117
118public slots:
119    void showFrame(MWindow::Frame f);
120    void newGame();
121
122    inline void setComputerTeam(int index) { m_awayTeamIndex = index; }
123    inline int computerTeam() const { return m_awayTeamIndex; }
124    inline void setPlayerTeam(int index){ m_homeTeamIndex = index; }
125    inline int playerTeam() const { return m_homeTeamIndex; }
126    void hideInputSettingsFrame(){ emit setFrame(MWindow::MainMenu);}
127    void hideHelpFrame(){emit setFrame(MWindow::MainMenu);}
128    void hideSettingsFrame(){ emit setFrame(MWindow::MainMenu);}
129    void showSettingsFrame(){ emit setFrame(MWindow::Settings);}
130    void showMainMenuFrame(){ emit setFrame(MWindow::MainMenu);}
131    void hideTeamSelectionFrame(){ emit setFrame(MWindow::MainMenu);}
132    void showSingleGameTeamSelection();
133    void showInputSettingsFrame() { emit setFrame(MWindow::InputSettings);}
134    void showHelpFrame(){emit setFrame(MWindow::Help);}
135    void showStatisticsFrame(){emit setFrame(MWindow::HalfTimeStatistics);}
136    void hideStatisticsFrame();
137    void showAboutFrame(){emit setFrame(MWindow::About);}
138    void hideAboutFrame() { emit setFrame(MWindow::MainMenu);}
139    void showInGameMenu() { emit setFrame(MWindow::InGameMenu); }
140    void hideInGameMenu();
141    void displayHalfTimeStatistics(bool display);
142    void showGraphicsViewFrame() { emit setFrame(MWindow::GraphicsView); }
143    void showComputerTeamSelection();
144    void showCupTeamSelection();
145
146
147protected:
148    void resizeEvent(QResizeEvent *e);
149
150private slots:
151    void enableActions(bool gameInProgress);
152
153private:
154    int m_homeTeamIndex;
155    int m_awayTeamIndex;
156    Pitch *m_pitch;
157    settingsFrame* m_settingsFrame;
158    inputSettingsFrame* m_inputSettingsFrame;
159    HalfStatisticsFrame* m_halfStatisticsFrame;
160    helpFrame* m_helpFrame;
161    TeamSelectionFrame* m_teamSelectionFrame;
162    InGameMenuFrame* m_inGameMenuFrame;
163    mainMenuFrame* m_mainMenuFrame;
164    SoundEffects* m_soundEffects;
165    aboutFrame* m_aboutFrame;
166    bool m_gameInProgress;
167public:
168    Ui::MainWindow* uiMainWindow;
169    };
170
171#endif // MAINWINDOW_H