next steps skinning implementation (config ready)

This commit is contained in:
doitux
2009-03-30 13:12:44 +00:00
parent a2827fb4bc
commit da05707b26
13 changed files with 425 additions and 136 deletions
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<PokerTH>
<CardDeck>
<StyleDescription value="default card deck" />
<PreviewPicture value="preview.png" />
</CardDeck>
</PokerTH>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<PokerTH>
<CardDeck>
<StyleDescription value="PokerTH default card deck" />
<StyleMaintainerEMail value="webmaster@pokerth.net" />
<Preview value="preview.png" />
</CardDeck>
</PokerTH>
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+2
View File
@@ -178,6 +178,7 @@ HEADERS += \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \ src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h \
src/gui/qt/startwindow/startwindowimpl.h \ src/gui/qt/startwindow/startwindowimpl.h \
src/gui/qt/styles/gametablestylereader.h \ src/gui/qt/styles/gametablestylereader.h \
src/gui/qt/styles/carddeckstylereader.h \
src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.h \ src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.h \
src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h \ src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h \
src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h \ src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h \
@@ -242,6 +243,7 @@ SOURCES += \
src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \ src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp \
src/gui/qt/startwindow/startwindowimpl.cpp \ src/gui/qt/startwindow/startwindowimpl.cpp \
src/gui/qt/styles/gametablestylereader.cpp \ src/gui/qt/styles/gametablestylereader.cpp \
src/gui/qt/styles/carddeckstylereader.cpp \
src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.cpp \ src/gui/qt/changehumanplayernamedialog/changehumanplayernamedialogimpl.cpp \
src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp \ src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp \
src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp \ src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp \
+3 -3
View File
@@ -48,7 +48,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
myQtToolsInterface = CreateQtToolsWrapper(); myQtToolsInterface = CreateQtToolsWrapper();
// !!!! Revisionsnummer der Configdefaults !!!!! // !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 61; configRev = 62;
//standard defaults //standard defaults
logOnOffDefault = "1"; logOnOffDefault = "1";
@@ -148,8 +148,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("FlipsideOwnFile", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("FlipsideOwnFile", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("GameTableStylesList", CONFIG_TYPE_STRING_LIST, "GameTableStyles")); configList.push_back(ConfigInfo("GameTableStylesList", CONFIG_TYPE_STRING_LIST, "GameTableStyles"));
configList.push_back(ConfigInfo("CurrentGameTableStyle", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("CurrentGameTableStyle", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("CardDecksList", CONFIG_TYPE_STRING_LIST, "CardDecks")); configList.push_back(ConfigInfo("CardDeckStylesList", CONFIG_TYPE_STRING_LIST, "CardDeckStyles"));
configList.push_back(ConfigInfo("CurrentCardDeck", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("CurrentCardDeckStyle", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("PlaySoundEffects", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("PlaySoundEffects", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("SoundVolume", CONFIG_TYPE_INT, "8")); configList.push_back(ConfigInfo("SoundVolume", CONFIG_TYPE_INT, "8"));
configList.push_back(ConfigInfo("PlayGameActions", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("PlayGameActions", CONFIG_TYPE_INT, "1"));
+2 -2
View File
@@ -3496,7 +3496,7 @@
</property> </property>
<widget class="QMenu" name="menuView"> <widget class="QMenu" name="menuView">
<property name="title"> <property name="title">
<string>View</string> <string>&amp;View</string>
</property> </property>
<addaction name="actionFullScreen"/> <addaction name="actionFullScreen"/>
<addaction name="actionShowHideChat"/> <addaction name="actionShowHideChat"/>
@@ -3508,7 +3508,7 @@
</widget> </widget>
<widget class="QMenu" name="menuSettings"> <widget class="QMenu" name="menuSettings">
<property name="title"> <property name="title">
<string>Settings</string> <string>&amp;Settings</string>
</property> </property>
<addaction name="actionConfigure_PokerTH"/> <addaction name="actionConfigure_PokerTH"/>
</widget> </widget>
+6 -6
View File
@@ -481,13 +481,13 @@ p, li { white-space: pre-wrap; }
<item row="3" column="0"> <item row="3" column="0">
<widget class="QGroupBox" name="groupBox_12"> <widget class="QGroupBox" name="groupBox_12">
<property name="title"> <property name="title">
<string>Card Decks</string> <string>Card Deck Styles</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_14"> <layout class="QGridLayout" name="gridLayout_14">
<item row="0" column="1"> <item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QPushButton" name="pushButton_activateCardDeck"> <widget class="QPushButton" name="pushButton_activateCardDeckStyle">
<property name="text"> <property name="text">
<string>Activate</string> <string>Activate</string>
</property> </property>
@@ -507,14 +507,14 @@ p, li { white-space: pre-wrap; }
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_addCardDeck"> <widget class="QPushButton" name="pushButton_addCardDeckStyle">
<property name="text"> <property name="text">
<string>Add ...</string> <string>Add ...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_removeCardDeck"> <widget class="QPushButton" name="pushButton_removeCardDeckStyle">
<property name="text"> <property name="text">
<string>Remove</string> <string>Remove</string>
</property> </property>
@@ -529,7 +529,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
<layout class="QGridLayout" name="gridLayout_16"> <layout class="QGridLayout" name="gridLayout_16">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_cardDeckPreview"> <widget class="QLabel" name="label_cardDeckStylePreview">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>160</width> <width>160</width>
@@ -551,7 +551,7 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QListWidget" name="listWidget_2"/> <widget class="QListWidget" name="listWidget_cardDeckStyles"/>
</item> </item>
</layout> </layout>
</widget> </widget>
+154 -11
View File
@@ -20,11 +20,13 @@
#include "settingsdialogimpl.h" #include "settingsdialogimpl.h"
#include "myavatarlistitem.h" #include "myavatarlistitem.h"
#include "gametablestylereader.h" #include "gametablestylereader.h"
#include "carddeckstylereader.h"
#include "configfile.h" #include "configfile.h"
#include <net/socket_startup.h> #include <net/socket_startup.h>
#define POKERTH_DISTRIBUTED_GAME_TABLE_STYLES 1 #define POKERTH_DISTRIBUTED_GAME_TABLE_STYLES 1
#define POKERTH_DISTRIBUTED_CARD_DECK_STYLES 1
using namespace std; using namespace std;
@@ -110,8 +112,10 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAva
connect( pushButton_addGameTableStyle, SIGNAL( clicked() ), this, SLOT( addGameTableStyle()) ); connect( pushButton_addGameTableStyle, SIGNAL( clicked() ), this, SLOT( addGameTableStyle()) );
connect( pushButton_removeGameTableStyle, SIGNAL( clicked() ), this, SLOT( removeGameTableStyle()) ); connect( pushButton_removeGameTableStyle, SIGNAL( clicked() ), this, SLOT( removeGameTableStyle()) );
connect( listWidget_cardDeckStyles, SIGNAL( currentItemChanged(QListWidgetItem*, QListWidgetItem*) ), this, SLOT ( showCurrentCardDeckStylePreview() ));
connect( pushButton_activateCardDeckStyle, SIGNAL( clicked() ), this, SLOT( setSelectedCardDeckStyleActivated()) );
connect( pushButton_addCardDeckStyle, SIGNAL( clicked() ), this, SLOT( addCardDeckStyle()) );
connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) );
} }
void settingsDialogImpl::exec() { void settingsDialogImpl::exec() {
@@ -235,13 +239,14 @@ void settingsDialogImpl::exec() {
lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()));
//S t y l e //S t y l e
//TABLE
// define PokerTH default GameTableStyle // define PokerTH default GameTableStyle
listWidget_gameTableStyles->clear(); listWidget_gameTableStyles->clear();
GameTableStyleReader defaultStyle(myConfig); GameTableStyleReader defaultTableStyle(myConfig);
defaultStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/table/default/defaulttablestyle.xml"); defaultTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/table/default/defaulttablestyle.xml");
QListWidgetItem *defaultItem = new QListWidgetItem(defaultStyle.getStyleDescription(),listWidget_gameTableStyles); QListWidgetItem *defaultTableItem = new QListWidgetItem(defaultTableStyle.getStyleDescription(),listWidget_gameTableStyles);
defaultItem->setData(15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/table/default/defaulttablestyle.xml"); defaultTableItem->setData(15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/table/default/defaulttablestyle.xml");
//load secondary styles into list (if fallback no entry) //load secondary styles into list (if fallback no entry)
myGameTableStylesList = myConfig->readConfigStringList("GameTableStylesList"); myGameTableStylesList = myConfig->readConfigStringList("GameTableStylesList");
@@ -260,17 +265,17 @@ void settingsDialogImpl::exec() {
GameTableStyleReader currentGameTableStyle(myConfig); GameTableStyleReader currentGameTableStyle(myConfig);
currentGameTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); currentGameTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str()));
int i; int i;
bool currentFound(FALSE); bool currentGameTableFound(FALSE);
for(i=0; i < listWidget_gameTableStyles->count(); i++) { for(i=0; i < listWidget_gameTableStyles->count(); i++) {
QListWidgetItem *item = listWidget_gameTableStyles->item(i); QListWidgetItem *item = listWidget_gameTableStyles->item(i);
if(item->data(15) == currentGameTableStyle.getCurrentFileName()) { if(item->data(15) == currentGameTableStyle.getCurrentFileName()) {
item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
listWidget_gameTableStyles->setCurrentItem(item); listWidget_gameTableStyles->setCurrentItem(item);
currentFound=TRUE; currentGameTableFound=TRUE;
} }
else item->setIcon(QIcon()); else item->setIcon(QIcon());
} }
if(!currentFound) { if(!currentGameTableFound) {
qDebug() << "Config ERROR: current game table style file not found in List. Mark default as selected."; qDebug() << "Config ERROR: current game table style file not found in List. Mark default as selected.";
QListWidgetItem *item = listWidget_gameTableStyles->item(0); QListWidgetItem *item = listWidget_gameTableStyles->item(0);
item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
@@ -280,10 +285,50 @@ void settingsDialogImpl::exec() {
//refresh Game Table Style Preview //refresh Game Table Style Preview
showCurrentGameTableStylePreview(); showCurrentGameTableStylePreview();
//CARDS
//define PokerTH default CardDeck //define PokerTH default CardDeck
// defaultCardDeck = myQtToolsInterface->getDataPathStdString(myArgv0)+"gfx/cards/default/defaultcarddeck.xml"; listWidget_cardDeckStyles->clear();
CardDeckStyleReader defaultCardStyle(myConfig);
defaultCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/cards/default/defaultdeckstyle.xml");
QListWidgetItem *defaultCardItem = new QListWidgetItem(defaultCardStyle.getStyleDescription(),listWidget_cardDeckStyles);
defaultCardItem->setData(15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/cards/default/defaultdeckstyle.xml");
//load secondary card styles into list (if fallback no entry)
myCardDeckStylesList = myConfig->readConfigStringList("CardDeckStylesList");
list<std::string>::iterator it2;
for(it2= myCardDeckStylesList.begin(); it2 != myCardDeckStylesList.end(); it2++) {
CardDeckStyleReader nextStyle(myConfig);
nextStyle.readStyleFile(QString::fromUtf8(it2->c_str()));
if(!nextStyle.getFallBack()) {
QListWidgetItem *nextItem = new QListWidgetItem(nextStyle.getStyleDescription());
nextItem->setData(15,QString::fromUtf8(it2->c_str()));
listWidget_cardDeckStyles->addItem(nextItem);
}
}
//set current card deck style from config file
CardDeckStyleReader currentCardDeckStyle(myConfig);
currentCardDeckStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str()));
int j;
bool currentCardDeckFound(FALSE);
for(j=0; j < listWidget_cardDeckStyles->count(); j++) {
QListWidgetItem *item = listWidget_cardDeckStyles->item(j);
if(item->data(15) == currentCardDeckStyle.getCurrentFileName()) {
item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
listWidget_cardDeckStyles->setCurrentItem(item);
currentCardDeckFound=TRUE;
}
else item->setIcon(QIcon());
}
if(!currentCardDeckFound) {
qDebug() << "Config ERROR: current card deck style file not found in List. Mark default as selected.";
QListWidgetItem *item = listWidget_cardDeckStyles->item(0);
item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
listWidget_cardDeckStyles->setCurrentItem(item);
}
// refresh Card Deck Style Preview
showCurrentCardDeckStylePreview();
//Sound //Sound
groupBox_playSoundEffects->setChecked(myConfig->readConfigInt("PlaySoundEffects")); groupBox_playSoundEffects->setChecked(myConfig->readConfigInt("PlaySoundEffects"));
@@ -469,6 +514,7 @@ void settingsDialogImpl::isAccepted() {
} }
//S T Y L E //S T Y L E
// TABLE
//save game table styles list //save game table styles list
myGameTableStylesList.clear(); myGameTableStylesList.clear();
int i; int i;
@@ -483,6 +529,21 @@ void settingsDialogImpl::isAccepted() {
if(!item->icon().isNull()) if(!item->icon().isNull())
myConfig->writeConfigString("CurrentGameTableStyle", item->data(15).toString().toUtf8().constData()); myConfig->writeConfigString("CurrentGameTableStyle", item->data(15).toString().toUtf8().constData());
} }
// CARDS
//save card deck styles list
myCardDeckStylesList.clear();
int j;
for(j=POKERTH_DISTRIBUTED_CARD_DECK_STYLES; j < listWidget_cardDeckStyles->count(); j++) {
QListWidgetItem *item = listWidget_cardDeckStyles->item(j);
myCardDeckStylesList.push_back(item->data(15).toString().toUtf8().constData());
}
myConfig->writeConfigStringList("CardDeckStylesList", myCardDeckStylesList);
//save current card deck style
for(j=0; j < listWidget_cardDeckStyles->count(); j++) {
QListWidgetItem *item = listWidget_cardDeckStyles->item(j);
if(!item->icon().isNull())
myConfig->writeConfigString("CurrentCardDeckStyle", item->data(15).toString().toUtf8().constData());
}
//Sound //Sound
myConfig->writeConfigInt("PlaySoundEffects", groupBox_playSoundEffects->isChecked()); myConfig->writeConfigInt("PlaySoundEffects", groupBox_playSoundEffects->isChecked());
@@ -865,3 +926,85 @@ void settingsDialogImpl::removeGameTableStyle()
} }
} }
void settingsDialogImpl::showCurrentCardDeckStylePreview()
{
QListWidgetItem* item = listWidget_cardDeckStyles->currentItem();
if(item) {
CardDeckStyleReader style(myConfig);
style.readStyleFile(item->data(15).toString());
QPixmap preview(style.getPreview());
if(preview.height() > 160 || preview.width() > 120) label_cardDeckStylePreview->setPixmap(preview.scaled(160,120,Qt::KeepAspectRatio,Qt::SmoothTransformation));
else label_cardDeckStylePreview->setPixmap(preview);
}
}
void settingsDialogImpl::setSelectedCardDeckStyleActivated()
{
QListWidgetItem* selectedItem = listWidget_cardDeckStyles->currentItem();
if(selectedItem) {
int i;
for(i=0; i < listWidget_cardDeckStyles->count(); i++) {
QListWidgetItem *item = listWidget_cardDeckStyles->item(i);
if(item == selectedItem) {
item->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
}
else item->setIcon(QIcon());
}
}
}
void settingsDialogImpl::addCardDeckStyle()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Please select your card deck style"),
QDir::home().absolutePath(),
tr("PokerTH card deck styles (*.xml)"));
if (!fileName.isEmpty()) {
int i;
bool fileNameAlreadyFound(FALSE);
for(i=0; i < listWidget_cardDeckStyles->count(); i++) {
QListWidgetItem *item = listWidget_cardDeckStyles->item(i);
if(item->data(15).toString() == fileName)
fileNameAlreadyFound = TRUE;
}
if(fileNameAlreadyFound) {
QMessageBox::warning(this, tr("Card Deck Style Error"),
tr("Selected card deck style file is already in the list. \nPlease select another one to add!"),
QMessageBox::Ok);
}
else {
CardDeckStyleReader newStyle(myConfig);
newStyle.readStyleFile(fileName);
if(!newStyle.getFallBack()) {
QListWidgetItem *newItem = new QListWidgetItem(newStyle.getStyleDescription());
newItem->setData(15,fileName);
listWidget_cardDeckStyles->addItem(newItem);
}
else {
QMessageBox::warning(this, tr("Card Deck Style File Error"),
tr("Could not read card deck style file. \nStyle will not be placed into list!"),
QMessageBox::Ok);
}
}
}
}
void settingsDialogImpl::removeCardDeckStyle()
{
//never delete PokerTH defaullt Styles
if(listWidget_cardDeckStyles->currentRow() >= POKERTH_DISTRIBUTED_CARD_DECK_STYLES) {
QListWidgetItem* selectedItem = listWidget_cardDeckStyles->currentItem();
if(selectedItem) {
// if selected is activated --> swith activation to first default
if(!selectedItem->icon().isNull()) {
QListWidgetItem* firstItem = listWidget_cardDeckStyles->item(0);
firstItem->setIcon(QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png"));
}
//remove from List
listWidget_cardDeckStyles->takeItem(listWidget_cardDeckStyles->currentRow());
}
}
}
@@ -85,6 +85,11 @@ public slots:
void addGameTableStyle(); void addGameTableStyle();
void removeGameTableStyle(); void removeGameTableStyle();
void setSelectedCardDeckStyleActivated();
void showCurrentCardDeckStylePreview();
void addCardDeckStyle();
void removeCardDeckStyle();
private: private:
bool playerNickIsChanged; bool playerNickIsChanged;
@@ -101,7 +106,7 @@ private:
std::list<int> myManualBlindsList; std::list<int> myManualBlindsList;
std::list<int> myNetManualBlindsList; std::list<int> myNetManualBlindsList;
std::list<std::string> myGameTableStylesList; std::list<std::string> myGameTableStylesList;
std::list<std::string> myCardDecksList; std::list<std::string> myCardDeckStylesList;
ConfigFile* myConfig; ConfigFile* myConfig;
boost::shared_ptr<selectAvatarDialogImpl> mySelectAvatarDialogImpl; boost::shared_ptr<selectAvatarDialogImpl> mySelectAvatarDialogImpl;
+4 -3
View File
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>startWindow</class> <class>startWindow</class>
<widget class="QMainWindow" name="startWindow"> <widget class="QMainWindow" name="startWindow">
@@ -173,12 +174,12 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>450</width> <width>450</width>
<height>23</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuPokerTH"> <widget class="QMenu" name="menuPokerTH">
<property name="title"> <property name="title">
<string>PokerTH</string> <string>&amp;PokerTH</string>
</property> </property>
<widget class="QMenu" name="menuNetwork_Game"> <widget class="QMenu" name="menuNetwork_Game">
<property name="title"> <property name="title">
@@ -195,7 +196,7 @@
</widget> </widget>
<widget class="QMenu" name="menuSettings"> <widget class="QMenu" name="menuSettings">
<property name="title"> <property name="title">
<string>Settings</string> <string>&amp;Settings</string>
</property> </property>
<addaction name="actionConfigure_PokerTH"/> <addaction name="actionConfigure_PokerTH"/>
</widget> </widget>
+82
View File
@@ -0,0 +1,82 @@
/***************************************************************************
* Copyright (C) 2006 by Felix Hammer *
* f.hammer@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 "carddeckstylereader.h"
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <fstream>
using namespace std;
CardDeckStyleReader::CardDeckStyleReader(ConfigFile *c, gameTableImpl *w) : myConfig(c), myW(w), fallBack(0)
{
}
CardDeckStyleReader::~CardDeckStyleReader()
{
}
void CardDeckStyleReader::readStyleFile(QString file) {
string tinyFileName;
//if style file failed --> default style fallback
if(QFile(file).exists()) {
currentFileName = QFile(file).fileName();
tinyFileName = currentFileName.toUtf8().constData();
}
else {
currentFileName = QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/cards/default/defaultdeckstyle.xml").fileName();
tinyFileName = currentFileName.toUtf8().constData();
fallBack = 1;
}
QFileInfo info(currentFileName);
currentFileDir = info.absolutePath();
//start reading the file and fill vars
string tempString1("");
TiXmlDocument doc(tinyFileName);
if(doc.LoadFile()) {
TiXmlHandle docHandle( &doc );
TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).FirstChild().ToElement();
for( ; itemsList; itemsList=itemsList->NextSiblingElement()) {
const char *tmpStr1 = itemsList->Attribute("value");
if (tmpStr1) {
tempString1 = tmpStr1;
if(itemsList->ValueStr() == "StyleDescription") { StyleDescription = QString::fromUtf8(tempString1.c_str()); }
else if (itemsList->ValueStr() == "Preview") { Preview = QString::fromUtf8(tempString1.c_str()); }
}
}
}
else { qDebug() << "could not load card deck file: " << tinyFileName.c_str(); }
}
QString CardDeckStyleReader::getPreview()
{
return QString(currentFileDir+"/"+Preview);
}
+58
View File
@@ -0,0 +1,58 @@
/***************************************************************************
* Copyright (C) 2009 by Felix Hammer *
* f.hammer@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. *
***************************************************************************/
#ifndef CARDDECKSTYLEREADER_H
#define CARDDECKSTYLEREADER_H
#include "tinyxml.h"
#include "gametableimpl.h"
#include "configfile.h"
#include <string>
#include <QtCore>
#include <QtGui>
class CardDeckStyleReader : public QObject {
Q_OBJECT
public:
CardDeckStyleReader(ConfigFile *c, gameTableImpl *w =0 );
~CardDeckStyleReader();
void readStyleFile(QString);
QString getStyleDescription() const { return StyleDescription; }
QString getCurrentFileName() const { return currentFileName; }
QString getPreview();
bool getFallBack() const { return fallBack; }
private:
QString StyleDescription;
QString Preview;
QString currentFileName;
QString currentFileDir;
ConfigFile *myConfig;
gameTableImpl *myW;
bool fallBack;
};
#endif
-3
View File
@@ -43,9 +43,6 @@ public:
bool getFallBack() const { return fallBack; } bool getFallBack() const { return fallBack; }
private: private:
QString StyleDescription; QString StyleDescription;