1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/*
This file is part of StroQ, Copyright (C) 2005 Luc Vo Van
StroQ is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
StroQ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with StroQ; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Class : MainWindow
Author : Luc Vo Van
Original Date : 18.05.2005
Description : The main game window.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qcanvas.h>
#include <qtoolbutton.h>
#include <qhttp.h>
#include "playarea.h"
class QLabel;
class QProgressBar;
class QPopupMenu;
class QAction;
class QBuffer;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* Creates the main window, with no border
*/
MainWindow(QWidget *parent = 0, const char *name = 0);
~MainWindow();
public slots:
/**
* Called when the puzzle is changed, usually after a call to
* PlayArea.loadPuzzle()
* @param puzzle The puzzle that was just loaded
* @param canvasSize Size of the canvas used to display the puzzle
*/
void puzzleChanged(Puzzle* puzzle, QSize canvasSize);
/**
* Called when the player is moving to the next puzzle
*/
void loadNextPuzzle();
/**
* Called when the stroke changes its length
* @param length New length of the stroke
*/
void strokeLengthChanged(int length);
protected:
void resizeEvent(QResizeEvent *);
void closeEvent(QCloseEvent *event);
private slots:
// Puzzle stuff
/**
* To be called when a the player wants to select a new puzzle
*/
void selectPuzzle();
/**
* To be called when the player wants to enter a puzzle code
*/
void enterPuzzleCode();
/**
* To be called when the player wants to download a puzzle from
* the Internet
*/
void downloadPuzzleOfTheDay();
/**
* To be called when switching from/to puzzle edit mode
*/
void toggleEditMode();
/**
* To be called to copy the current puzzle's code to the system's
* clipboard
*/
void copyPuzzleCode();
/**
* To be called to quit the game
*/
void quit();
// About stuff
/**
* To be called to display StroQ's about window
*/
void about();
/**
* To be called to displays Qt's about window
*/
void aboutQt();
/**
* Slot called when the transfer from the web server is finished
*/
void downloadPuzzleOfTheDayFinished(bool error);
/**
* Sets the number of the current puzzle
* @param puzzlenumber Number of the puzzle currently loaded
*/
void setPuzzleNumber(int puzzlenumber);
/**
* Returns the number of the current puzzle
* @return the number of the current puzzle
*/
int getPuzzleNumber();
private:
void createActions();
void createMenus();
void createGameArea();
/**
* Loads the first puzzle into the PlayArea
*/
void loadFirstPuzzle();
// About menu
QPopupMenu *aboutMenu;
QAction *aboutStroQAct;
QAction *aboutQtAct;
// Puzzle menu
QPopupMenu *puzzleMenu;
QAction *selectPuzzleAct;
QAction *enterPuzzleCodeAct;
QAction *downloadPuzzleOfTheDayAct;
QAction *editPuzzleAct;
QAction *quitAct;
// Play menu
QPopupMenu *playMenu;
QAction *resetPuzzleAct;
QAction *runPuzzleAct;
QAction *copyPuzzleCodeAct;
// Edit menu
QPopupMenu *editMenu;
QAction *newEditPuzzleAct;
QAction *invertPuzzleAct;
// Game area
QCanvas *mainCanvas;
PlayArea *playArea;
// Game Toolbar
QLabel *m_lPuzzleNumber;
QLabel *m_lCurrentStrokeLength;
QToolButton *m_bNextPuzzle;
QString m_sCurrentCode;
int m_iPuzzleNumber;
int m_iBestStrokeLength;
bool m_bFirstDisplay; /**< used to resize the window properly */
QBuffer *potdBuffer;
QHttp potdHttp;
};
#endif
|