File indexing completed on 2024-04-28 04:03:50
0001 /*************************************************************************** 0002 kdialogsetupjoueur.cpp - 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 #include "kwaitedplayersetupdialog.h" 0024 #include "GameLogic/gameautomaton.h" 0025 #include "kgamewin.h" 0026 #include "GameLogic/onu.h" 0027 #include "Sprites/skinSpritesData.h" 0028 0029 #include <QString> 0030 #include <QLabel> 0031 #include <QLineEdit> 0032 #include <QCheckBox> 0033 #include <QComboBox> 0034 #include <QPixmap> 0035 0036 #include <KLocalizedString> 0037 #include "ksirk_debug.h" 0038 0039 #define _XOPEN_SOURCE_ 0040 #include <unistd.h> 0041 0042 namespace Ksirk 0043 { 0044 using namespace GameLogic; 0045 0046 KWaitedPlayerSetupDialog::KWaitedPlayerSetupDialog( 0047 GameLogic::GameAutomaton* automaton, 0048 QString& password, 0049 int& result, 0050 QWidget *parent) : 0051 QDialog(parent), QWaitedPlayerSetupDialog(), 0052 m_automaton(automaton), 0053 m_password(password), m_result(result) 0054 { 0055 setupUi(this); 0056 qCDebug(KSIRK_LOG) << "KWaitedPlayerSetupDialog constructor"; 0057 fillWaitedPlayersCombo(); 0058 0059 connect(PushButton1, &QAbstractButton::clicked, this, &KWaitedPlayerSetupDialog::slotOK); 0060 } 0061 0062 KWaitedPlayerSetupDialog::~KWaitedPlayerSetupDialog(){ 0063 } 0064 0065 void KWaitedPlayerSetupDialog::slotOK() 0066 { 0067 qCDebug(KSIRK_LOG) << "slotOk"; 0068 // toport 0069 // m_password = QString(crypt(passwordEdit->password(),"T6")); 0070 m_result = waitedPlayersCombo->currentIndex(); 0071 close(); 0072 } 0073 0074 void KWaitedPlayerSetupDialog::fillWaitedPlayersCombo() 0075 { 0076 qCDebug(KSIRK_LOG) << "Filling nations combo"; 0077 0078 QList<PlayerMatrix>::iterator it, it_end; 0079 it = m_automaton->game()->waitedPlayers().begin(); 0080 it_end = m_automaton->game()->waitedPlayers().end(); 0081 for (; it != it_end; it++) 0082 { 0083 qCDebug(KSIRK_LOG) << "Adding waited player " << (*it).name ; 0084 QString imgName = m_automaton->game()->theWorld()->nationNamed((*it).nation)->flagFileName(); 0085 // load image 0086 QPixmap flag; 0087 QSize size(flag.width()/Sprites::SkinSpritesData::single().intData("flag-frames"),flag.height()); 0088 QPixmap allpm(size); 0089 allpm.fill(Qt::transparent); 0090 QPainter p(&allpm); 0091 QSvgRenderer renderer; 0092 renderer.load(imgName); 0093 renderer.render(&p/*, svgid*/); 0094 flag = allpm.copy(0, 0, size.width(), size.height()); 0095 0096 // get name 0097 QString name = (*it).name; 0098 name += QString(" ("); 0099 name += (i18n((*it).nation.toUtf8().data())); 0100 name += QString(")"); 0101 // fill a combo entry 0102 waitedPlayersCombo->addItem(QIcon(flag),name); 0103 } 0104 0105 } 0106 0107 } 0108 0109 #include "moc_kwaitedplayersetupdialog.cpp"