add very big index card deck (known as mobile gui card deck before) to the list of distributed card decks and set this to default. For this style there is a new card deck file type needed because of the very big index symbols left top. Therefor #154 is implemented

This commit is contained in:
doitux
2012-11-10 02:02:25 +01:00
parent 59df9c0968
commit e8498d1338
15 changed files with 336 additions and 184 deletions
+180 -116
View File
@@ -21,11 +21,12 @@
#include <cstdlib>
#include <fstream>
#include "mymessagebox.h"
#include "mymessagedialogimpl.h"
#include "game_defs.h"
using namespace std;
CardDeckStyleReader::CardDeckStyleReader(ConfigFile *c, QWidget *w) : myConfig(c), myW(w), fallBack(0), loadedSuccessfull(0)
CardDeckStyleReader::CardDeckStyleReader(ConfigFile *c, QWidget *w) : myConfig(c), myW(w), fallBack(0), loadedSuccessfull(0), myState(CD_STYLE_UNDEFINED)
{
}
@@ -37,141 +38,204 @@ CardDeckStyleReader::~CardDeckStyleReader()
void CardDeckStyleReader::readStyleFile(QString file)
{
BigIndexesActionBottom = "";
#ifdef ANDROID
//on Android we use just the defaul style packed with the binary via qrc
//on Android we use just the defaul style packed with the binary via qrc
currentFileName = ":/android/android-data/gfx/cards/default_800x480/defaultdeckstyle_800x480.xml";
currentDir = ":/android/android-data/gfx/cards/default_800x480/";
#else
//if style file failed --> default style fallback
if(QFile(file).exists()) {
currentFileName = file;
} else {
currentFileName = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml";
fallBack = 1;
}
//if style file failed --> default style fallback
if(QFile(file).exists()) {
currentFileName = file;
} else {
currentFileName = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default_800x480/defaultdeckstyle_800x480.xml";
fallBack = 1;
}
QFileInfo info(currentFileName);
currentDir = info.absolutePath()+"/";
QFileInfo info(currentFileName);
currentDir = info.absolutePath()+"/";
#endif
QFile myFile(currentFileName);
myFile.open(QIODevice::ReadOnly);
fileContent = myFile.readAll();
QFile myFile(currentFileName);
myFile.open(QIODevice::ReadOnly);
fileContent = myFile.readAll();
//start reading the file and fill vars
string tempString1("");
//start reading the file and fill vars
string tempString1("");
TiXmlDocument doc;
doc.Parse(fileContent.constData());
TiXmlDocument doc;
doc.Parse(fileContent.constData());
if(doc.RootElement()) {
TiXmlHandle docHandle( &doc );
if(doc.RootElement()) {
TiXmlHandle docHandle( &doc );
TiXmlElement *GameTableElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).ToElement();
if(GameTableElement) {
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("A game table style was selected instead of a card deck style.\nPlease select a card deck style and try again!"),
QMessageBox::Ok);
} else {
TiXmlElement *GameTableElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).ToElement();
if(GameTableElement) {
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("A game table style was selected instead of a card deck style.\nPlease select a card deck style and try again!"),
QMessageBox::Ok);
} else {
TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).FirstChild().ToElement();
for( ; itemsList; itemsList=itemsList->NextSiblingElement()) {
const char *tmpStr1 = itemsList->Attribute("value");
if (tmpStr1) {
tempString1 = tmpStr1;
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() == "StyleMaintainerName") {
StyleMaintainerName = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "StyleMaintainerEMail") {
StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "StyleCreateDate") {
StyleCreateDate = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") {
PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str());
} else if (itemsList->ValueStr() == "Preview") {
Preview = currentDir+QString::fromUtf8(tempString1.c_str());
} else if (itemsList->ValueStr() == "BigIndexesActionBottom") {
BigIndexesActionBottom = QString::fromUtf8(tempString1.c_str());
}
}
}
//check if style items are left and show warning
leftItems.clear();
if(itemsList->ValueStr() == "StyleDescription") {
StyleDescription = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "StyleMaintainerName") {
StyleMaintainerName = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "StyleMaintainerEMail") {
StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "StyleCreateDate") {
StyleCreateDate = QString::fromUtf8(tempString1.c_str());
} else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") {
PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str());
} else if (itemsList->ValueStr() == "Preview") {
Preview = currentDir+QString::fromUtf8(tempString1.c_str());
}
}
}
//check if style items are left and show warning
leftItems.clear();
if(StyleDescription == "") {
leftItems << "StyleDescription";
}
if(StyleMaintainerName == "") {
leftItems << "StyleMaintainerName";
}
if(StyleMaintainerEMail == "") {
leftItems << "StyleMaintainerEMail";
}
if(StyleCreateDate == "") {
leftItems << "StyleCreateDate";
}
if(PokerTHStyleFileVersion == "") {
leftItems << "PokerTHStyleFileVersion";
}
if(BigIndexesActionBottom == "") {
//ATTENTION: no fallback action here because default position is mostly CENTER
BigIndexesActionBottom = "0";
leftItems << "BigIndexesActionBottom";
}
if(StyleDescription == "") {
leftItems << "StyleDescription";
}
if(StyleMaintainerName == "") {
leftItems << "StyleMaintainerName";
}
if(StyleMaintainerEMail == "") {
leftItems << "StyleMaintainerEMail";
}
if(StyleCreateDate == "") {
leftItems << "StyleCreateDate";
}
if(PokerTHStyleFileVersion == "") {
leftItems << "PokerTHStyleFileVersion";
}
//check if all files are there
cardsLeft.clear();
int i;
for(i=0; i<52; i++) {
QString cardString(QString::number(i)+".png");
if(!QDir(currentDir).exists(cardString)) {
cardsLeft << cardString;
}
}
if(!QDir(currentDir).exists("flipside.png")) {
cardsLeft << "flipside.png";
}
//check if all files are there
cardsLeft.clear();
int i;
for(i=0; i<52; i++) {
QString cardString(QString::number(i)+".png");
if(!QDir(currentDir).exists(cardString)) {
cardsLeft << cardString;
}
}
if(!QDir(currentDir).exists("flipside.png")) {
cardsLeft << "flipside.png";
}
// set loadedSuccessfull TRUE if everything works
if(leftItems.isEmpty() && cardsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_CD_STYLE_FILE_VERSION)
loadedSuccessfull = 1;
else
loadedSuccessfull = 0;
if(!leftItems.isEmpty() && myW != 0) showLeftItemsErrorMessage(StyleDescription, leftItems, StyleMaintainerEMail);
else {
if(!cardsLeft.isEmpty() && myW != 0) showCardsLeftErrorMessage(StyleDescription, cardsLeft, StyleMaintainerEMail);
//check for style file version
if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_CD_STYLE_FILE_VERSION) {
QString EMail;
if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail;
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("Selected card deck style \"%1\" seems to be outdated. \n The current PokerTH card deck style version is \"%2\", but this style has version \"%3\" set. \n\nPlease contact the card deck style builder %4.").arg(StyleDescription).arg(POKERTH_CD_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail),
QMessageBox::Ok);
}
}
}
} else {
loadedSuccessfull = 0;
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("Cannot load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName),
QMessageBox::Ok);
}
// set loadedSuccessfull TRUE if everything works
if(leftItems.isEmpty() && cardsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_CD_STYLE_FILE_VERSION) {
myState = CD_STYLE_OK;
}
else {
//check for style file version
if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_CD_STYLE_FILE_VERSION) {
myState = CD_STYLE_OUTDATED;
} else {
//if one or more items are left
if(!leftItems.isEmpty() && myW != 0) myState = CD_STYLE_FIELDS_EMPTY;
//if one or more pictures where not found
if(!cardsLeft.isEmpty() && myW != 0) myState = CD_STYLE_PICTURES_MISSING;
}
}
loadedSuccessfull = 1;
}
}
else {
loadedSuccessfull = 0;
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("Cannot load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName),
QMessageBox::Ok);
}
}
void CardDeckStyleReader::showLeftItemsErrorMessage(QString style, QStringList failedItems, QString email)
void CardDeckStyleReader::showErrorMessage()
{
QString items = failedItems.join(", ");
QString EMail;
if(email != "NULL") EMail = email;
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("Selected card deck style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of \"%2\" is/are missing. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail),
QMessageBox::Ok);
switch (myState) {
case CD_STYLE_PICTURES_MISSING:
showCardsLeftErrorMessage();
break;
case CD_STYLE_FIELDS_EMPTY:
showLeftItemsErrorMessage();
break;
case CD_STYLE_OUTDATED:
showOutdatedErrorMessage();
break;
default:
;
}
}
void CardDeckStyleReader::showCardsLeftErrorMessage(QString style, QStringList failedItems, QString email)
QString CardDeckStyleReader::getMyStateToolTipInfo()
{
QString items = failedItems.join(", ");
QString EMail;
if(email != "NULL") EMail = email;
switch (myState) {
case CD_STYLE_OK:
return QString(tr("Everything OK!"));
break;
case CD_STYLE_PICTURES_MISSING:
return QString(tr("Some cards pictures are missing, please contact style maintainer for this issue."));
break;
case CD_STYLE_FIELDS_EMPTY:
return QString(tr("Some style fields are missing, please contact style maintainer for this issue."));
break;
case CD_STYLE_OUTDATED:
return QString(tr("This style is outdated, please contact style maintainer for this issue."));
break;
default:
return QString("");
}
}
MyMessageBox::warning(myW, tr("Card Deck Style Error"),
tr("Selected card deck style \"%1\" seems to be incomplete or defective. \nThe card picture(s) \"%2\" is/are not available. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail),
QMessageBox::Ok);
void CardDeckStyleReader::showLeftItemsErrorMessage()
{
QString items = leftItems.join("\n");
QString EMail;
if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail;
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(CD_VALUES_MISSING)) {
dialog.exec(CD_VALUES_MISSING, tr("Selected card deck style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. \n\nAnyway you can play with this deck, because the missing content will be filled up by PokerTH default card deck. \n\nPlease contact the card deck style builder via \"%3\".").arg(StyleDescription).arg(items).arg(EMail), tr("Card Deck Style Error - Fields content missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
void CardDeckStyleReader::showCardsLeftErrorMessage()
{
QString pics = cardsLeft.join("\n");
QString EMail;
if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail;
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(CD_PICS_MISSING)) {
dialog.exec(CD_PICS_MISSING, tr("One or more pictures from current card deck style \"%1\" were not found: \n\n%2 \n\nPlease contact the card deck style builder via \"%3\".").arg(StyleDescription).arg(pics).arg(EMail), tr("Card Deck Style Error - Pictures missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
void CardDeckStyleReader::showOutdatedErrorMessage()
{
QString EMail;
if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail;
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(CD_OUTDATED)) {
dialog.exec(CD_OUTDATED, tr("Selected card deck style \"%1\" seems to be outdated. \nThe current PokerTH card deck style version is \"%2\", but this deck has version \"%3\" set. \n\nAnyway you can play with this deck, because the missing content will be filled up by PokerTH default card deck. \n\nPlease contact the card deck style builder via \"%4\".").arg(StyleDescription).arg(POKERTH_CD_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), tr("Card Deck Style Error - Outdated"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
+20 -5
View File
@@ -24,13 +24,14 @@
#include <QtCore>
#include <QtGui>
#define POKERTH_CD_STYLE_FILE_VERSION 1
#define POKERTH_CD_STYLE_FILE_VERSION 2
enum CdStyleState {
CD_STYLE_OK = 0,
CD_STYLE_OUTDATED,
CD_STYLE_FIELDS_EMPTY,
CD_STYLE_PICTURES_MISSING,
CD_STYLE_UNDEFINED
};
class CardDeckStyleReader : public QObject
@@ -66,15 +67,26 @@ public:
return Preview;
}
QString getBigIndexesActionBottom() const {
return BigIndexesActionBottom;
}
bool getFallBack() const {
return fallBack;
}
bool getLoadedSuccessfull() const {
return loadedSuccessfull;
}
}
void showLeftItemsErrorMessage(QString, QStringList, QString);
void showCardsLeftErrorMessage(QString, QStringList, QString);
CdStyleState getState() const {
return myState;
}
QString getMyStateToolTipInfo();
void showErrorMessage();
void showLeftItemsErrorMessage();
void showCardsLeftErrorMessage();
void showOutdatedErrorMessage();
private:
@@ -84,6 +96,7 @@ private:
QString StyleCreateDate;
QString PokerTHStyleFileVersion;
QString Preview;
QString BigIndexesActionBottom;
QString currentFileName;
QString currentDir;
@@ -96,7 +109,9 @@ private:
QWidget *myW;
bool fallBack;
bool loadedSuccessfull;
bool loadedSuccessfull;
CdStyleState myState;
};
#endif
+16 -25
View File
@@ -127,7 +127,6 @@ void GameTableStyleReader::readStyleFile(QString file)
if(doc.RootElement()) {
TiXmlHandle docHandle( &doc );
TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement();
if(CardDeckElement) {
MyMessageBox::warning(myW, tr("Game Table Style Error"),
@@ -1254,7 +1253,8 @@ void GameTableStyleReader::readStyleFile(QString file)
}
loadedSuccessfull = 1;
}
} else {
}
else {
loadedSuccessfull = 0;
MyMessageBox::warning(myW, tr("Game Table Style Error"),
tr("Cannot load game table style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName),
@@ -1287,8 +1287,8 @@ void GameTableStyleReader::showLeftItemsErrorMessage()
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(5)) {
dialog.exec(5, tr("Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(items).arg(EMail), tr("Game Table Style Error - Fields content missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
if(dialog.checkIfMesssageWillBeDisplayed(GT_VALUES_MISSING)) {
dialog.exec(GT_VALUES_MISSING, tr("Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(items).arg(EMail), tr("Game Table Style Error - Fields content missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
@@ -1301,8 +1301,8 @@ void GameTableStyleReader::showItemPicsLeftErrorMessage()
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(6)) {
dialog.exec(6, tr("One or more pictures from current game table style \"%1\" were not found: \n\n%2 \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(pics).arg(EMail), tr("Game Table Style Error - Pictures missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
if(dialog.checkIfMesssageWillBeDisplayed(GT_PICS_MISSING)) {
dialog.exec(GT_PICS_MISSING, tr("One or more pictures from current game table style \"%1\" were not found: \n\n%2 \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(pics).arg(EMail), tr("Game Table Style Error - Pictures missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
@@ -1313,8 +1313,8 @@ void GameTableStyleReader::showOutdatedErrorMessage()
myMessageDialogImpl dialog(myConfig, myW);
if(dialog.checkIfMesssageWillBeDisplayed(7)) {
dialog.exec(7, tr("Selected game table style \"%1\" seems to be outdated. \nThe current PokerTH game table style version is \"%2\", but this style has version \"%3\" set. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%4\".").arg(StyleDescription).arg(POKERTH_GT_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), tr("Game Table Style Error - Outdated"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
if(dialog.checkIfMesssageWillBeDisplayed(GT_OUTDATED)) {
dialog.exec(GT_OUTDATED, tr("Selected game table style \"%1\" seems to be outdated. \nThe current PokerTH game table style version is \"%2\", but this style has version \"%3\" set. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%4\".").arg(StyleDescription).arg(POKERTH_GT_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), tr("Game Table Style Error - Outdated"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true);
}
}
@@ -1693,27 +1693,18 @@ QString GameTableStyleReader::getFallBackFieldContent(QString field, int type)
if(doc.RootElement()) {
TiXmlHandle docHandle( &doc );
TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement();
if(CardDeckElement) {
MyMessageBox::warning(myW, tr("Game Table Style Error"),
tr("A card deck style was selected instead of a game table style.\nPlease select a game table style and try again!"),
QMessageBox::Ok);
} else {
TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement();
for( ; itemsList; itemsList=itemsList->NextSiblingElement()) {
const char *tmpStr1 = itemsList->Attribute("value");
if (tmpStr1) {
tempString1 = tmpStr1;
if(itemsList->ValueStr() == field.toStdString()) {
if(type == 1) return QString(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/"+QString::fromUtf8(tempString1.c_str()));
else return QString::fromUtf8(tempString1.c_str());
}
TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement();
for( ; itemsList; itemsList=itemsList->NextSiblingElement()) {
const char *tmpStr1 = itemsList->Attribute("value");
if (tmpStr1) {
tempString1 = tmpStr1;
if(itemsList->ValueStr() == field.toStdString()) {
if(type == 1) return QString(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/"+QString::fromUtf8(tempString1.c_str()));
else return QString::fromUtf8(tempString1.c_str());
}
}
}
}
return QString("");
}