| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2004-2005 Artur Wiebe * |
| 3 | * [email protected] * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #ifndef _VIEW_H_ |
| 22 | #define _VIEW_H_ |
| 23 | |
| 24 | |
| 25 | #include <QFrame> |
| 26 | #include <QTextEdit> |
| 27 | #include <QLineEdit> |
| 28 | #include <QLabel> |
| 29 | |
| 30 | |
| 31 | #include "board.h" |
| 32 | #include "toplevel.h" |
| 33 | |
| 34 | |
| 35 | class Pdn; |
| 36 | class myPlayer; |
| 37 | class myHistory; |
| 38 | |
| 39 | |
| 40 | class myView : public QFrame |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | |
| 44 | public: |
| 45 | myView(myTopLevel* parent); |
| 46 | ~myView(); |
| 47 | |
| 48 | void newGame(int rules, bool free_place, |
| 49 | const QString& name, bool is_white, |
| 50 | int opponent, const QString& opp_name, int skill); |
| 51 | bool openPdn(const QString& fn); |
| 52 | bool savePdn(const QString& fn); |
| 53 | |
| 54 | void setTheme(const QString& theme_path); |
| 55 | |
| 56 | bool isAborted() const { return m_aborted; } |
| 57 | |
| 58 | void setNotation(bool enabled, bool show_above); |
| 59 | void setNotationFont(const QFont& f); |
| 60 | QFont notationFont() const { return m_board->font(); } |
| 61 | |
| 62 | public slots: |
| 63 | virtual void setEnabled(bool); |
| 64 | |
| 65 | void slotClearLog(bool b) { m_clear_log = b; } |
| 66 | |
| 67 | void slotStopGame(); |
| 68 | void slotNextRound(); |
| 69 | |
| 70 | signals: |
| 71 | void working(bool); |
| 72 | |
| 73 | private slots: |
| 74 | void slot_click(int); |
| 75 | |
| 76 | void slot_move_done(const QString& board_str); |
| 77 | void slot_move_done_step_two(); |
| 78 | |
| 79 | void slot_preview_game(int game_type); |
| 80 | void slot_apply_moves(const QString& moves); |
| 81 | void slot_new_mode(bool paused, bool freeplace); |
| 82 | |
| 83 | private: |
| 84 | void begin_game(unsigned int round, bool freeplacement); |
| 85 | |
| 86 | void perform_jumps(const QString& from_board, const QString& to_board); |
| 87 | bool extract_move(const QString& move, int* from_num, int* to_num); |
| 88 | |
| 89 | void stop_game(const QString&); |
| 90 | void you_won(bool really); |
| 91 | bool check_game_over(); |
| 92 | |
| 93 | enum LogType { |
| 94 | None, |
| 95 | Error, |
| 96 | Warning, |
| 97 | System, |
| 98 | User, |
| 99 | Opponent, |
| 100 | }; |
| 101 | void add_log(enum LogType type, const QString& text); |
| 102 | |
| 103 | myPlayer* get_first_player() const; |
| 104 | |
| 105 | private: |
| 106 | bool m_clear_log; |
| 107 | |
| 108 | bool m_game_over;// need this to avoid multiple calls to isGameOver() |
| 109 | bool m_aborted; |
| 110 | |
| 111 | myPlayer* m_player; |
| 112 | myPlayer* m_current; |
| 113 | myTopLevel* m_toplevel; |
| 114 | |
| 115 | myBoard* m_board; |
| 116 | |
| 117 | int m_freeplace_from; |
| 118 | }; |
| 119 | |
| 120 | |
| 121 | #endif |
| 122 |