This commit is contained in:
doitux
2007-01-22 22:25:58 +00:00
parent ff0881df3e
commit e67c72e010
11 changed files with 65 additions and 73 deletions
-2
View File
@@ -52,8 +52,6 @@ ConfigFile::ConfigFile()
TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ createDefaultConfig(); }
// cout << "readConfigString Value: " << readConfigString("Opponent1Name", "doitux") << "\n";
writeConfigString(string("MyName"), string("Ret"));
}
+1 -4
View File
@@ -32,10 +32,7 @@ LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bo
// cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl;
myCardsValue = new CardsValue;
/*
ostringstream temp;
temp << "Player " << myID;
myName = temp.str();*/
}
+15 -3
View File
@@ -27,10 +27,11 @@
#include "playerinterface.h"
#include "handinterface.h"
#include "configfile.h"
using namespace std;
Game::Game(GuiInterface* g, int qP, int sC, int sB) : myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0)
{
int i;
@@ -56,9 +57,20 @@ Game::Game(GuiInterface* g, int qP, int sC, int sB) : myGui(g), actualHand(0), a
PlayerInterface *tempPlayer;
for(i=0; i<myGui->getMaxQuantityPlayers(); i++) {
// cout << myGui->getPlayerName(i) << "\n";
//Namen abfragen
ostringstream myName;
ostringstream myDefaultName;
if (i==0) {
myName << "MyName";
myDefaultName << "Human Player";
}
else {
myName << "Opponent" << i << "Name";
myDefaultName << "Player " << i << "Name";
}
tempPlayer = myFactory->createPlayer(actualBoard, i, myGui->getPlayerName(i), startCash, startQuantityPlayers > i, 0);
//PlayerObjekte erzeugen
tempPlayer = myFactory->createPlayer(actualBoard, i, myConfig->readConfigString(myName.str(),myDefaultName.str()), startCash, startQuantityPlayers > i, 0);
playerArray[i] = tempPlayer;
}
actualBoard->setPlayer(playerArray);
+7 -1
View File
@@ -21,18 +21,21 @@
#define GAME_H
#include <iostream>
#include <string>
#include <sstream>
class GuiInterface;
class HandInterface;
class PlayerInterface;
class BoardInterface;
class EngineFactory;
class ConfigFile;
class Game {
public:
Game(GuiInterface*, int, int, int);
Game(ConfigFile*, GuiInterface*, int, int, int);
~Game();
@@ -73,11 +76,14 @@ public:
private:
EngineFactory *myFactory;
ConfigFile *myConfig;
GuiInterface *myGui;
HandInterface *actualHand;
BoardInterface *actualBoard;
PlayerInterface *playerArray[5];
//Startvariablen
int startQuantityPlayers;
int startCash;
+1 -4
View File
@@ -40,10 +40,7 @@ public:
//get
virtual int getMaxQuantityPlayers() const=0;
virtual std::string getPlayerName(int) const=0;
//refresh-Funktionen
virtual void refreshSet() const=0;
virtual void refreshChangePlayer() const=0;
-9
View File
@@ -47,15 +47,6 @@ void GuiWrapper::setHand(HandInterface *lh) { myW->setHand(lh); }
void GuiWrapper::setSession(Session *s) { myW->setSession(s); }
int GuiWrapper::getMaxQuantityPlayers() const { return myW->getMaxQuantityPlayers(); }
std::string GuiWrapper::getPlayerName(int id) const {
// if(id==0) {
// return myConfig->readConfigString("MyName", "Human Player") ;
// }
// else { return myConfig->readConfigString("Opponent"+QString::number(id)+"Name", "Player "+QString::number(id)) ; }
}
void GuiWrapper::refreshSet() const { myW->refreshSet(); }
void GuiWrapper::refreshChangePlayer() const { myW->refreshChangePlayer(); }
+1 -4
View File
@@ -45,8 +45,7 @@ public:
void setSession(Session*);
int getMaxQuantityPlayers() const;
std::string getPlayerName(int) const;
void refreshSet() const;
void refreshChangePlayer() const;
void refreshPot() const;
@@ -85,12 +84,10 @@ public:
void showPlayerActionLogMsg(std::string playerName, int action, int setValue) const;
private:
Log *myLog;
mainWindowImpl *myW;
ConfigFile *myConfig;
};
+7 -8
View File
@@ -66,7 +66,7 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent, const char *name)
int i;
//Toolbox verstecken?
// if (!myConfig->readConfigInt("ShowToolBox", 1)) { groupBox_tools->hide(); }
if (!myConfig->readConfigInt("ShowToolBox", 1)) { groupBox_tools->hide(); }
pushButton_raise->setDisabled(TRUE);
@@ -196,7 +196,7 @@ void mainWindowImpl::callNewGameDialog() {
//wenn Dialogfenster gezeigt werden soll
// if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame", 1)){
if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame", 1)){
newGameDialogImpl *v = new newGameDialogImpl();
v->exec();
@@ -254,7 +254,7 @@ void mainWindowImpl::callNewGameDialog() {
label_Pot->setText("<p align='center'><span style='font-size:x-large; font-weight:bold'>Pot Total</span></p>");
label_Sets->setText("<p align='center'><span style='font-size:medium; font-weight:bold'>Sets:</span></p>");
guiGameSpeed = 4/*myConfig->readConfigInt("GameSpeed",4)*/;
guiGameSpeed = myConfig->readConfigInt("GameSpeed",4);
// debugMode = v->checkBox_debugMode->isChecked();
//Tools und Board aufhellen und enablen
@@ -271,11 +271,10 @@ void mainWindowImpl::callNewGameDialog() {
//Start Game!!!
// mySession->startGame(myConfig->readConfigInt("NumberOfPlayers",5), myConfig->readConfigInt("StartCash",2000), myConfig->readConfigInt("SmallBlind",10));
mySession->startGame(5, 2000, 10);
mySession->startGame(myConfig->readConfigInt("NumberOfPlayers",5), myConfig->readConfigInt("StartCash",2000), myConfig->readConfigInt("SmallBlind",10));
// }
}
}
@@ -293,8 +292,8 @@ void mainWindowImpl::callSettingsDialog() {
if (v->result()) {
//Toolbox verstecken?
// if (!myConfig->readConfigInt("ShowToolBox", 1)) { groupBox_tools->hide(); }
// else { groupBox_tools->show(); }
if (!myConfig->readConfigInt("ShowToolBox", 1)) { groupBox_tools->hide(); }
else { groupBox_tools->show(); }
}
}
+5 -7
View File
@@ -27,15 +27,13 @@ newGameDialogImpl::newGameDialogImpl(QWidget *parent, const char *name)
setupUi(this);
//Formulare Füllen
ConfigFile config;
bool ok=TRUE;
ConfigFile myConfig;
//Game Settings
// spinBox_quantityPlayers->setValue(config.readConfig("numberofplayers", "5").toInt(&ok,10));
// spinBox_startCash->setValue(config.readConfig("startcash", "2000").toInt(&ok,10));
// spinBox_smallBlind->setValue(config.readConfig("smallblind", "10").toInt(&ok,10));
// spinBox_gameSpeed->setValue(config.readConfig("gamespeed", "4").toInt(&ok,10));
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers", 5));
spinBox_startCash->setValue(myConfig.readConfigInt("StartCash", 2000));
spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind", 10));
spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed", 4));
}
+27 -30
View File
@@ -29,28 +29,25 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, const char *name)
setupUi(this);
//Formulare Füllen
ConfigFile config;
bool ok=TRUE;
ConfigFile myConfig;
//Player Nicks
// lineEdit_humanPlayerName->setText(config.readConfig("myname", "Human Player"));
// lineEdit_Opponent1Name->setText(config.readConfig("opponent1name", "Player 1"));
// lineEdit_Opponent2Name->setText(config.readConfig("opponent2name", "Player 2"));
// lineEdit_Opponent3Name->setText(config.readConfig("opponent3name", "Player 3"));
// lineEdit_Opponent4Name->setText(config.readConfig("opponent4name", "Player 4"));
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")));
//Game Settings
// spinBox_quantityPlayers->setValue(config.readConfig("numberofplayers", "5").toInt(&ok,10));
// spinBox_startCash->setValue(config.readConfig("startcash", "2000").toInt(&ok,10));
// spinBox_smallBlind->setValue(config.readConfig("smallblind", "10").toInt(&ok,10));
// spinBox_gameSpeed->setValue(config.readConfig("gamespeed", "4").toInt(&ok,10));
// checkBox_showGameSettingsDialogOnNewGame->setChecked(config.readConfig("showgamesettingsdialogonnewgame", "1").toInt(&ok,10));
spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers", 5));
spinBox_startCash->setValue(myConfig.readConfigInt("StartCash", 2000));
spinBox_smallBlind->setValue(myConfig.readConfigInt("SmallBlind", 10));
spinBox_gameSpeed->setValue(myConfig.readConfigInt("GameSpeed", 4));
checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig.readConfigInt("ShowGameSettingsDialogOnNewGame", 1));
//Interface
// checkBox_showToolbox->setChecked(config.readConfig("showtoolbox", "1").toInt(&ok,10));
checkBox_showToolbox->setChecked(myConfig.readConfigInt("ShowToolBox", 1));
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) );
}
@@ -59,23 +56,23 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, const char *name)
void settingsDialogImpl::isAccepted() {
//Daten speichern
ConfigFile config;
ConfigFile myConfig;
//Player Nicks
// config.writeConfig("myname", lineEdit_humanPlayerName->text());
// config.writeConfig("opponent1name", lineEdit_Opponent1Name->text());
// config.writeConfig("opponent2name", lineEdit_Opponent2Name->text());
// config.writeConfig("opponent3name", lineEdit_Opponent3Name->text());
// config.writeConfig("opponent4name", lineEdit_Opponent4Name->text());
// 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());
//Game Settings
// config.writeConfig("numberofplayers", QString::number(spinBox_quantityPlayers->value(),10));
// config.writeConfig("startcash", QString::number(spinBox_startCash->value(),10));
// config.writeConfig("smallblind", QString::number(spinBox_smallBlind->value(),10));
// config.writeConfig("gamespeed", QString::number(spinBox_gameSpeed->value(),10));
// config.writeConfig("showgamesettingsdialogonnewgame", QString::number(checkBox_showGameSettingsDialogOnNewGame->isChecked(),10));
// Game Settings
myConfig.writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value());
myConfig.writeConfigInt("StartCash", spinBox_startCash->value());
myConfig.writeConfigInt("SmallBlind", spinBox_smallBlind->value());
myConfig.writeConfigInt("GameSpeed", spinBox_gameSpeed->value());
myConfig.writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked());
//Interface
// config.writeConfig("showtoolbox", QString::number(checkBox_showToolbox->isChecked(),10));
// Interface
myConfig.writeConfigInt("ShowToolBox", checkBox_showToolbox->isChecked());
}
+1 -1
View File
@@ -45,7 +45,7 @@ Session::~Session()
void Session::startGame(int qP, int sC, int sB) {
actualGame = new Game(myGui, qP, sC, sB);
actualGame = new Game(myConfig, myGui, qP, sC, sB);
}