2007-01-17 01:22:55 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2006 by FThauer FHammer *
|
|
|
|
|
* f.thauer@web.de *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#include "settingsdialogimpl.h"
|
2007-01-17 23:57:41 +00:00
|
|
|
#include "configfile.h"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2007-01-17 01:22:55 +00:00
|
|
|
|
|
|
|
|
settingsDialogImpl::settingsDialogImpl(QWidget *parent, const char *name)
|
|
|
|
|
: QDialog(parent, name)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
setupUi(this);
|
2007-01-17 23:57:41 +00:00
|
|
|
|
2007-01-28 14:48:18 +00:00
|
|
|
playerNickIsChanged = FALSE;
|
|
|
|
|
|
2007-01-17 23:57:41 +00:00
|
|
|
//Formulare Füllen
|
2007-01-22 22:25:58 +00:00
|
|
|
ConfigFile myConfig;
|
2007-01-17 23:57:41 +00:00
|
|
|
|
|
|
|
|
//Player Nicks
|
2007-01-22 22:25:58 +00:00
|
|
|
lineEdit_humanPlayerName->setText(QString::fromStdString(myConfig.readConfigString("MyName", "Human Player")));
|
|
|
|
|
lineEdit_Opponent1Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent1Name", "Player 1")));
|
|
|
|
|
lineEdit_Opponent2Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent2Name", "Player 2")));
|
|
|
|
|
lineEdit_Opponent3Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent3Name", "Player 3")));
|
|
|
|
|
lineEdit_Opponent4Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent4Name", "Player 4")));
|
2007-01-17 23:57:41 +00:00
|
|
|
|
|
|
|
|
//Game Settings
|
2007-01-22 22:25:58 +00:00
|
|
|
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers", 5));
|
|
|
|
|
spinBox_startCash->setValue(myConfig.readConfigInt("StartCash", 2000));
|
|
|
|
|
spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind", 10));
|
2007-01-23 19:20:18 +00:00
|
|
|
spinBox_handsBeforeRaiseSmallBlind->setValue(myConfig.readConfigInt("HandsBeforeRaiseSmallBlind", 9));
|
2007-01-22 22:25:58 +00:00
|
|
|
spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed", 4));
|
2007-01-28 14:48:18 +00:00
|
|
|
checkBox_pauseBetweenHands->setChecked(myConfig.readConfigInt("PauseBetweenHands", 0));
|
2007-01-22 22:25:58 +00:00
|
|
|
checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig.readConfigInt("ShowGameSettingsDialogOnNewGame", 1));
|
2007-01-28 14:48:18 +00:00
|
|
|
|
2007-01-20 01:38:40 +00:00
|
|
|
//Interface
|
2007-01-22 22:25:58 +00:00
|
|
|
checkBox_showToolbox->setChecked(myConfig.readConfigInt("ShowToolBox", 1));
|
2007-01-26 08:59:40 +00:00
|
|
|
checkBox_showIntro->setChecked(myConfig.readConfigInt("ShowIntro", 1));
|
2007-01-28 14:48:18 +00:00
|
|
|
checkBox_showFadeOutCardsAnimation->setChecked(myConfig.readConfigInt("ShowFadeOutCardsAnimation", 1));
|
2007-01-31 01:17:13 +00:00
|
|
|
checkBox_showFlipCardsAnimation->setChecked(myConfig.readConfigInt("ShowFlipCardsAnimation", 1));
|
2007-01-28 23:33:48 +00:00
|
|
|
radioButton_flipsideTux->setChecked(myConfig.readConfigInt("FlipsideTux", 1));
|
|
|
|
|
radioButton_flipsideOwn->setChecked(myConfig.readConfigInt("FlipsideOwn", 0));
|
2007-01-29 00:53:20 +00:00
|
|
|
if(radioButton_flipsideOwn->isChecked()) {
|
|
|
|
|
lineEdit_OwnFlipsideFilename->setEnabled(TRUE);
|
|
|
|
|
pushButton_openFlipsidePicture->setEnabled(TRUE);
|
|
|
|
|
}
|
2007-01-28 23:33:48 +00:00
|
|
|
lineEdit_OwnFlipsideFilename->setText(QString::fromStdString(myConfig.readConfigString("FlipsideOwnFile", "")));
|
2007-01-17 01:22:55 +00:00
|
|
|
|
2007-01-20 01:38:40 +00:00
|
|
|
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) );
|
2007-01-28 14:48:18 +00:00
|
|
|
connect( lineEdit_humanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) );
|
|
|
|
|
connect( lineEdit_Opponent1Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) );
|
|
|
|
|
connect( lineEdit_Opponent2Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) );
|
|
|
|
|
connect( lineEdit_Opponent3Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) );
|
|
|
|
|
connect( lineEdit_Opponent4Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) );
|
2007-01-28 23:33:48 +00:00
|
|
|
connect( pushButton_openFlipsidePicture, SIGNAL( clicked() ), this, SLOT( setFlipsidePicFileName()) );
|
|
|
|
|
|
2007-01-17 23:57:41 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-20 01:38:40 +00:00
|
|
|
void settingsDialogImpl::isAccepted() {
|
2007-01-17 23:57:41 +00:00
|
|
|
|
|
|
|
|
//Daten speichern
|
2007-01-22 22:25:58 +00:00
|
|
|
ConfigFile myConfig;
|
2007-01-17 23:57:41 +00:00
|
|
|
|
2007-01-22 22:25:58 +00:00
|
|
|
// Player Nicks
|
|
|
|
|
myConfig.writeConfigString("MyName", lineEdit_humanPlayerName->text().toStdString());
|
|
|
|
|
myConfig.writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toStdString());
|
|
|
|
|
myConfig.writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toStdString());
|
|
|
|
|
myConfig.writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toStdString());
|
|
|
|
|
myConfig.writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toStdString());
|
2007-01-17 23:57:41 +00:00
|
|
|
|
2007-01-22 22:25:58 +00:00
|
|
|
// Game Settings
|
|
|
|
|
myConfig.writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value());
|
|
|
|
|
myConfig.writeConfigInt("StartCash", spinBox_startCash->value());
|
|
|
|
|
myConfig.writeConfigInt("SmallBlind", spinBox_smallBlind->value());
|
2007-01-23 19:20:18 +00:00
|
|
|
myConfig.writeConfigInt("HandsBeforeRaiseSmallBlind", spinBox_handsBeforeRaiseSmallBlind->value());
|
2007-01-22 22:25:58 +00:00
|
|
|
myConfig.writeConfigInt("GameSpeed", spinBox_gameSpeed->value());
|
2007-01-28 14:48:18 +00:00
|
|
|
myConfig.writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked());
|
2007-01-22 22:25:58 +00:00
|
|
|
myConfig.writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked());
|
2007-01-17 23:57:41 +00:00
|
|
|
|
2007-01-22 22:25:58 +00:00
|
|
|
// Interface
|
|
|
|
|
myConfig.writeConfigInt("ShowToolBox", checkBox_showToolbox->isChecked());
|
2007-01-26 08:59:40 +00:00
|
|
|
myConfig.writeConfigInt("ShowIntro", checkBox_showIntro->isChecked());
|
2007-01-28 14:48:18 +00:00
|
|
|
myConfig.writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked());
|
2007-01-31 01:17:13 +00:00
|
|
|
myConfig.writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked());
|
2007-01-28 23:33:48 +00:00
|
|
|
myConfig.writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked());
|
|
|
|
|
myConfig.writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked());
|
|
|
|
|
myConfig.writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toStdString());
|
2007-01-20 01:38:40 +00:00
|
|
|
|
2007-01-17 01:22:55 +00:00
|
|
|
}
|
2007-01-28 23:33:48 +00:00
|
|
|
|
|
|
|
|
void settingsDialogImpl::setFlipsidePicFileName()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Select your Flipside Picture"),
|
|
|
|
|
QDir::homePath(),
|
2007-01-29 21:25:33 +00:00
|
|
|
tr("Images (*.bmp *.png *.xpm)"));
|
2007-01-28 23:33:48 +00:00
|
|
|
|
|
|
|
|
if (!fileName.isEmpty())
|
|
|
|
|
lineEdit_OwnFlipsideFilename->setText(fileName);
|
2007-01-29 00:53:20 +00:00
|
|
|
}
|