1 | /* |
2 | Copyright (C) 2002-2005, Jason Katz-Brown <jasonkb@mit.edu> |
3 | Copyright 2010 Stefan Majewsky <majewsky@gmx.net> |
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 Free Software |
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | */ |
19 | |
20 | #ifndef NEWGAME_H |
21 | #define NEWGAME_H |
22 | |
23 | #include <QCheckBox> |
24 | #include <QWidget> |
25 | #include <KColorButton> |
26 | #include <KLineEdit> |
27 | #include <KPageDialog> |
28 | |
29 | class QLabel; |
30 | class QListWidget; |
31 | class QScrollArea; |
32 | class KPushButton; |
33 | class CourseInfo; |
34 | |
35 | class PlayerEditor : public QWidget |
36 | { |
37 | Q_OBJECT |
38 | |
39 | public: |
40 | explicit PlayerEditor(QString name = QString(), QColor = Qt::red, QWidget *parent = 0); |
41 | QColor color() { return colorButton->color(); } |
42 | QString name() { return editor->text(); } |
43 | void setColor(QColor col) { colorButton->setColor(col); } |
44 | void setName(const QString &newname) { editor->setText(newname); } |
45 | |
46 | signals: |
47 | void deleteEditor(PlayerEditor *editor); |
48 | |
49 | private slots: |
50 | void removeMe(); |
51 | |
52 | private: |
53 | KLineEdit *editor; |
54 | KColorButton *colorButton; |
55 | QPixmap grass; |
56 | }; |
57 | |
58 | class NewGameDialog : public KPageDialog |
59 | { |
60 | Q_OBJECT |
61 | |
62 | public: |
63 | NewGameDialog(bool enableCourses); |
64 | ~NewGameDialog(); |
65 | QList<PlayerEditor*> *players() { return &editors; } |
66 | bool competition() { return mode->isChecked(); } |
67 | QString course() { return currentCourse; } |
68 | |
69 | public slots: |
70 | void deleteEditor(PlayerEditor *); |
71 | |
72 | protected slots: |
73 | void slotOk(); |
74 | private slots: |
75 | void addPlayer(); |
76 | void courseSelected(int); |
77 | void addCourse(); |
78 | void removeCourse(); |
79 | void selectionChanged(); |
80 | void showHighscores(); |
81 | |
82 | private: |
83 | QWidget *playersWidget; |
84 | KPushButton *addButton; |
85 | QFrame *playerPage; |
86 | QScrollArea *scroller; |
87 | QFrame *coursePage; |
88 | QFrame *optionsPage; |
89 | QList<QColor> startColors; |
90 | QList<PlayerEditor*> editors; |
91 | KPushButton *remove; |
92 | QCheckBox *mode; |
93 | |
94 | QPixmap grass; |
95 | |
96 | QStringList names; |
97 | QStringList externCourses; |
98 | QMap<QString, CourseInfo> info; |
99 | |
100 | QStringList ; |
101 | |
102 | QListWidget *courseList; |
103 | QLabel *name; |
104 | QLabel *author; |
105 | QLabel *par; |
106 | QLabel *holes; |
107 | |
108 | QString currentCourse; |
109 | |
110 | void enableButtons(); |
111 | bool enableCourses; |
112 | }; |
113 | |
114 | #endif |
115 | |