File indexing completed on 2024-04-14 04:01:09

0001 /***************************************************************************
0002                           kdialogsetupjoueur.h  -  description
0003                              -------------------
0004     begin                : Thu Jul 19 2001
0005     copyright            : (C) 2001 by Gaƫl de Chalendar
0006     email                : Gael.de.Chalendar@free.fr
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either either version 2
0014    of the License, or (at your option) any later version.of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License
0018  *   along with this program; if not, write to the Free Software
0019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020  *   02110-1301, USA
0021  ***************************************************************************/
0022 
0023 #ifndef KPLAYERSETUPWIDGET_H
0024 #define KPLAYERSETUPWIDGET_H
0025 
0026 #include "ui_qplayersetupdialog.h"
0027 
0028 #include <QWidget>
0029 
0030 #include <QMap>
0031 
0032 class KPlayer;
0033 class NewGameSetup;
0034 
0035 namespace Ksirk
0036 {
0037   class NewPlayerData;
0038 namespace GameLogic
0039 {
0040   class ONU;
0041   class GameAutomaton;
0042 }
0043 
0044 /**
0045   * This is the implementation of the player configuration dialog made with
0046   * QT Designer
0047   * @author Gael de Chalendar
0048   */
0049 class KPlayerSetupWidget : public QWidget, public Ui::QPlayerSetupWidget
0050 {
0051   Q_OBJECT
0052 public:
0053   explicit KPlayerSetupWidget(QWidget *parent=nullptr);
0054   
0055   ~KPlayerSetupWidget() override;
0056 
0057   void init(GameLogic::GameAutomaton* automaton,
0058                       GameLogic::ONU* onu,
0059                       unsigned int playerNumber,
0060                       QString &playerName,
0061                       QString& password,
0062                       bool computerPlayer,
0063                       QMap< QString, QString >& nations,
0064                       QString & nationName,
0065                       NewGameSetup* newGameSetup);
0066 
0067   void init(NewPlayerData* player = nullptr);
0068   
0069 Q_SIGNALS:
0070   void next();
0071   void previous();
0072   void cancel();
0073   
0074 public Q_SLOTS:
0075   void slotNext();
0076   void slotPrevious();
0077   void slotCancel();
0078   void slotPlayerJoinedGame(KPlayer* player);
0079   void slotNationChanged();
0080   void slotNameEdited (const QString& text);
0081   
0082 private:
0083   /** Fills the nations combo with nations names and flag images */
0084   void fillNationsCombo();
0085   
0086   bool isAvailable(QString nationName);
0087   void setLabelText();
0088 
0089   GameLogic::GameAutomaton* m_automaton;
0090   QString m_name;
0091   bool m_computer;
0092   QString m_nationName;
0093   /** list of nation name , flag file name pairs */
0094   QMap< QString, QString > m_nations;
0095   GameLogic::ONU* m_onu;
0096   
0097   /** list of internationalized nations names. Used to retrive the internal name after choice in UI */
0098   QMap< QString, QString > m_nationsNames;
0099   unsigned int m_number;
0100   
0101   QString m_password;
0102   NewGameSetup* m_newGameSetup;
0103 };
0104 
0105 }
0106 
0107 #endif // KPLAYERSETUPWIDGET_H