File indexing completed on 2024-12-22 03:51:29
0001 /* 0002 Copyright (C) 2002-2005, Jason Katz-Brown <jasonkb@mit.edu> 0003 Copyright 2010 Stefan Majewsky <majewsky@gmx.net> 0004 0005 This program is free software; you can redistribute it and/or modify 0006 it under the terms of the GNU General Public License as published by 0007 the Free Software Foundation; either version 2 of the License, or 0008 (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 */ 0019 0020 #ifndef NEWGAME_H 0021 #define NEWGAME_H 0022 0023 #include <QCheckBox> 0024 #include <QWidget> 0025 #include <KColorButton> 0026 #include <KLineEdit> 0027 #include <KPageDialog> 0028 0029 class QLabel; 0030 class QListWidget; 0031 class QScrollArea; 0032 class QPushButton; 0033 struct CourseInfo; 0034 0035 class PlayerEditor : public QWidget 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit PlayerEditor(const QString &name = QString(), QColor = Qt::red, QWidget *parent = nullptr); 0041 QColor color() { return colorButton->color(); } 0042 QString name() { return editor->text(); } 0043 void setColor(QColor col) { colorButton->setColor(col); } 0044 void setName(const QString &newname) { editor->setText(newname); } 0045 0046 Q_SIGNALS: 0047 void deleteEditor(PlayerEditor *editor); 0048 0049 private Q_SLOTS: 0050 void removeMe(); 0051 0052 private: 0053 KLineEdit *editor; 0054 KColorButton *colorButton; 0055 QPixmap grass; 0056 }; 0057 0058 class NewGameDialog : public KPageDialog 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 explicit NewGameDialog(bool enableCourses); 0064 ~NewGameDialog() override; 0065 QList<PlayerEditor*> *players() { return &editors; } 0066 bool competition() { return mode->isChecked(); } 0067 QString course() { return currentCourse; } 0068 0069 public Q_SLOTS: 0070 void deleteEditor(PlayerEditor *); 0071 0072 protected Q_SLOTS: 0073 void slotOk(); 0074 private Q_SLOTS: 0075 void addPlayer(); 0076 void courseSelected(int); 0077 void addCourse(); 0078 void removeCourse(); 0079 void selectionChanged(); 0080 void showHighscores(); 0081 0082 private: 0083 QWidget *playersWidget; 0084 QPushButton *addButton; 0085 QFrame *playerPage; 0086 QScrollArea *scroller; 0087 QFrame *coursePage; 0088 QFrame *optionsPage; 0089 QList<QColor> startColors; 0090 QList<PlayerEditor*> editors; 0091 QPushButton *remove; 0092 QCheckBox *mode; 0093 0094 QPixmap grass; 0095 0096 QStringList names; 0097 QStringList externCourses; 0098 QMap<QString, CourseInfo> info; 0099 0100 QStringList extraCourses; 0101 0102 QListWidget *courseList; 0103 QLabel *name; 0104 QLabel *author; 0105 QLabel *par; 0106 QLabel *holes; 0107 0108 QString currentCourse; 0109 0110 void enableButtons(); 0111 bool enableCourses; 0112 }; 0113 0114 #endif