diff --git a/data/gfx/cards/default/defaultdeckstyle.xml b/data/gfx/cards/default/defaultdeckstyle.xml index 3562ddca..1a3bbf6c 100644 --- a/data/gfx/cards/default/defaultdeckstyle.xml +++ b/data/gfx/cards/default/defaultdeckstyle.xml @@ -1,11 +1,12 @@ - + - + + diff --git a/data/gfx/cards/default4c/default4cdeckstyle.xml b/data/gfx/cards/default4c/default4cdeckstyle.xml index 56df4618..5e1f103d 100644 --- a/data/gfx/cards/default4c/default4cdeckstyle.xml +++ b/data/gfx/cards/default4c/default4cdeckstyle.xml @@ -1,11 +1,12 @@ - + - + + diff --git a/data/gfx/cards/default_800x480/defaultdeckstyle_800x480.xml b/data/gfx/cards/default_800x480/defaultdeckstyle_800x480.xml index 02c89287..41dd1e1c 100644 --- a/data/gfx/cards/default_800x480/defaultdeckstyle_800x480.xml +++ b/data/gfx/cards/default_800x480/defaultdeckstyle_800x480.xml @@ -1,11 +1,12 @@ - + - + + diff --git a/data/gfx/cards/default_800x480/preview.png b/data/gfx/cards/default_800x480/preview.png new file mode 100644 index 00000000..db24cec8 Binary files /dev/null and b/data/gfx/cards/default_800x480/preview.png differ diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index 7c4b0247..31759bc1 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -50,7 +50,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) myConfigState = OK; // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 97; + configRev = 98; //standard defaults logOnOffDefault = "1"; @@ -555,12 +555,19 @@ void ConfigFile::updateConfig(ConfigState myConfigState) ///////// VERSION HACK SECTION /////////////////////// //this is the right place for special version depending config hacks: //0.9.1 - log interval needs to be set to 1 instead of 0 - if (configRev == 95 || configRev == 96) { // this means 0.9.1 or 0.9.2 + if (configRev > 94 || configRev < 99) { // this means 0.9.1 or 0.9.2 or 1.0 TiXmlElement * confElement2 = new TiXmlElement( "LogInterval" ); config->LinkEndChild( confElement2 ); confElement2->SetAttribute("value", 1); noUpdateElemtsList.push_back("LogInterval"); } + + if (configRev == 98) { // this means 1.0 + TiXmlElement * confElement3 = new TiXmlElement( "CurrentCardDeckStyle" ); + config->LinkEndChild( confElement3 ); + confElement3->SetAttribute("value", ""); + noUpdateElemtsList.push_back("CurrentCardDeckStyle"); + } ///////// VERSION HACK SECTION /////////////////////// TiXmlHandle oldDocHandle( &oldDoc ); diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index ea034687..1f94b4dc 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -1653,7 +1653,7 @@ void gameLobbyDialogImpl::showInfoMsgBox() switch(infoMsgToShowId) { case 2: { inviteOnlyInfoMsgBox->setModal(false); - inviteOnlyInfoMsgBox->show(2, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true); + inviteOnlyInfoMsgBox->show(INFO_AFTER_JOIN_INVITE_GAME, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true); } break; default: @@ -1672,7 +1672,7 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI inviteDialogIsCurrentlyShown = true; myMessageDialogImpl dialog(myConfig, this); - if(dialog.exec(3, tr("You have been invited to the game %1 by %2.
Would you like to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { + if(dialog.exec(JOIN_INVITE_GAME_QUESTION, tr("You have been invited to the game %1 by %2.
Would you like to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { mySession->acceptGameInvitation(gameId); inviteDialogIsCurrentlyShown = false; @@ -1726,7 +1726,7 @@ void gameLobbyDialogImpl::putPlayerOnIgnoreList() if(!playerIsOnIgnoreList(playerId)) { myMessageDialogImpl dialog(myConfig, this); - if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on your ignore list?").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { + if(dialog.exec(INGNORE_PLAYER_QUESTION, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on your ignore list?").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); playerIgnoreList.push_back(QString("%1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())).toUtf8().constData()); diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 670c9a6e..41c6761f 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -391,6 +391,10 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) textLabel_Status0->setMyW(this); + //check position depending on card deck type + checkActionLabelPosition(); + + // GroupBoxArray init groupBoxArray[0] = groupBox0; groupBoxArray[1] = groupBox1; @@ -689,9 +693,9 @@ void gameTableImpl::callSettingsDialog() void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) { - - //apply card deck style + //apply card deck style myCardDeckStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); + checkActionLabelPosition(); //apply game table style myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); @@ -3723,8 +3727,8 @@ void gameTableImpl::closeGameTable() bool close = true; - if(myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(6) && (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK ) && this->isVisible()) { - if (myUniversalMessageDialog->exec(6, tr("Really want to exit?"), tr("PokerTH - Close Table?"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Rejected) { + if(myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(CLOSE_GAMETABLE_QUESTION ) && (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK ) && this->isVisible()) { + if (myUniversalMessageDialog->exec(CLOSE_GAMETABLE_QUESTION , tr("Really want to exit?"), tr("PokerTH - Close Table?"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Rejected) { close = false; } } @@ -3804,12 +3808,12 @@ void gameTableImpl::leaveCurrentNetworkGame() if (myStartWindow->getSession()->isNetworkClientRunning()) { - if(!myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(1)) { + if(!myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(BACKTO_LOBBY_QUESTION)) { assert(myStartWindow->getSession()); myStartWindow->getSession()->sendLeaveCurrentGame(); } else { - if (myUniversalMessageDialog->exec(1, tr("Attention! Do you really want to leave the current game\nand go back to the lobby?"), tr("PokerTH - Internet Game Message"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Accepted) { + if (myUniversalMessageDialog->exec(BACKTO_LOBBY_QUESTION, tr("Attention! Do you really want to leave the current game\nand go back to the lobby?"), tr("PokerTH - Internet Game Message"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Accepted) { assert(myStartWindow->getSession()); myStartWindow->getSession()->sendLeaveCurrentGame(); } @@ -4389,3 +4393,38 @@ void gameTableImpl::tabsButtonClose() tabsDiag->close(); } #endif + + +void gameTableImpl::checkActionLabelPosition() { +#ifndef GUI_800x480 + int i; + if(myCardDeckStyle->getBigIndexesActionBottom() == "1") { + for (i=0; i=3 && i<=7) { + if(actionLabelArray[i]->y() == 56) { + actionLabelArray[i]->move(actionLabelArray[i]->x(), 80); + } + } + else { + if(actionLabelArray[i]->y() == 43) { + actionLabelArray[i]->move(actionLabelArray[i]->x(), 67); + } + } + } + } + else { + for (i=0; i=3 && i<=7) { + if(actionLabelArray[i]->y() == 80) { + actionLabelArray[i]->move(actionLabelArray[i]->x(), 56); + } + } + else { + if(actionLabelArray[i]->y() == 67) { + actionLabelArray[i]->move(actionLabelArray[i]->x(), 43); + } + } + } + } +#endif +} diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index c6997233..e77e9bd8 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -346,9 +346,10 @@ public slots: void sendShowMyCardsSignal(); void closeMessageBoxes(); - void hide(); + void hide(); void soundEvent_blindsWereSet(int); - void enableCallCheckPushButton(); + void enableCallCheckPushButton(); + void checkActionLabelPosition(); #ifdef GUI_800x480 void tabsButtonClicked(); diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index a6235569..6114935a 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -412,7 +412,7 @@ void MyAvatarLabel::putPlayerOnIgnoreList() if(!playerIsOnIgnoreList(list.at(myId))) { myMessageDialogImpl dialog(myW->getMyConfig(), this); - if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on ignore list?").arg(list.at(myId)), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { + if(dialog.exec(INGNORE_PLAYER_QUESTION, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on ignore list?").arg(list.at(myId)), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { std::list playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); playerIgnoreList.push_back(list.at(myId).toUtf8().constData()); diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h index da99e053..598a7556 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h @@ -24,6 +24,22 @@ #include "ui_mymessagedialog.h" #endif +enum MESSAGE_CONTENT { + NONE=0, //0: not set ;) + BACKTO_LOBBY_QUESTION, //1: leave lobby during online game: Question(Do you really wanna leave?) + INFO_AFTER_JOIN_INVITE_GAME, //2: join invite only game: Info(You can invite people with right click ...) + JOIN_INVITE_GAME_QUESTION, //3: reciev invite to game: Question(You've been invited to the game %1 by %2.
Do you want to join this game?) + INGNORE_PLAYER_QUESTION, //4: click ignore player: Question(Do you really want to put this player on ignore List?) + GT_VALUES_MISSING, //5: Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. + CLOSE_GAMETABLE_QUESTION, //6: close gametable: Do you really wanna quit? + GT_PICS_MISSING, //7: One or more pictures from current game table style \"%1\" were not found: + GT_OUTDATED, //8: Selected game table style \"%1\" seems to be outdated. \nThe current PokerTH game table style version is + CD_VALUES_MISSING, //9: + CD_PICS_MISSING, //10: + CD_OUTDATED //11: + +}; + class ConfigFile; class myMessageDialogImpl: public QDialog, public Ui::myMessageDialog @@ -52,10 +68,3 @@ private: #endif -// messages --> id: content -//1: leave lobby during online game: Question(Do you really wanna leave?) -//2: join invite only game: Info(You can invite people with right click ...) -//3: reciev invite to game: Question(You've been invited to the game %1 by %2.
Do you want to join this game?) -//4: click ignore player: Question(Do you really want to put this player on ignore List?) -//5: add a broken (fields missing) game table style: Info(Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of \"%2\" is/are missing. \n\nPlease contact the game table style builder %3.) -//6: close gametable: Do you really wanna quit? diff --git a/src/gui/qt/settingsdialog.ui b/src/gui/qt/settingsdialog.ui index 3a7270e4..1da41760 100644 --- a/src/gui/qt/settingsdialog.ui +++ b/src/gui/qt/settingsdialog.ui @@ -585,6 +585,11 @@ p, li { white-space: pre-wrap; } Maintainer + + + State + + diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp index 84802498..a6ae15d4 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp @@ -381,22 +381,23 @@ void settingsDialogImpl::prepareDialog() showCurrentGameTableStylePreview(); //CARDS -#ifdef GUI_800x480 - // define PokerTH default GameTableStyle for Maemo + // define PokerTH 1.0 default carddeck treeWidget_cardDeckStyles->clear(); - CardDeckStyleReader defaultCardStyle(myConfig, this); - defaultCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default_800x480/defaultdeckstyle_800x480.xml"); - if(defaultCardStyle.getLoadedSuccessfull()) { + CardDeckStyleReader defaultCardStyle10(myConfig, this); + defaultCardStyle10.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default_800x480/defaultdeckstyle_800x480.xml"); + if(defaultCardStyle10.getLoadedSuccessfull()) { QStringList tempStringList1; - tempStringList1 << defaultCardStyle.getStyleDescription() << defaultCardStyle.getStyleMaintainerName(); + tempStringList1 << defaultCardStyle10.getStyleDescription() << defaultCardStyle10.getStyleMaintainerName(); MyStyleListItem *defaultCardItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); defaultCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default_800x480/defaultdeckstyle_800x480.xml"); defaultCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); defaultCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default_800x480/defaultdeckstyle_800x480.xml"); + defaultCardItem->setData(2, Qt::ToolTipRole, defaultCardStyle10.getMyStateToolTipInfo()); + if(defaultCardStyle10.getState()) defaultCardItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else defaultCardItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); } -#else - //define PokerTH default CardDeck - treeWidget_cardDeckStyles->clear(); +#ifndef GUI_800x480 + //define PokerTH old default CardDeck CardDeckStyleReader defaultCardStyle(myConfig, this); defaultCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); if(defaultCardStyle.getLoadedSuccessfull()) { @@ -406,8 +407,11 @@ void settingsDialogImpl::prepareDialog() defaultCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); defaultCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); defaultCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); + defaultCardItem->setData(2, Qt::ToolTipRole, defaultCardStyle.getMyStateToolTipInfo()); + if(defaultCardStyle.getState()) defaultCardItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else defaultCardItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); } - //define PokerTH default CardDeck4c + //define PokerTH old default CardDeck4c CardDeckStyleReader default4cCardStyle(myConfig, this); default4cCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); if(default4cCardStyle.getLoadedSuccessfull()) { @@ -417,6 +421,9 @@ void settingsDialogImpl::prepareDialog() default4cCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); default4cCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); default4cCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); + default4cCardItem->setData(2, Qt::ToolTipRole, default4cCardStyle.getMyStateToolTipInfo()); + if(default4cCardStyle.getState()) default4cCardItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else default4cCardItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); } #endif //load secondary card styles into list (if fallback no entry) @@ -432,6 +439,9 @@ void settingsDialogImpl::prepareDialog() nextItem->setData(0, 15,QString::fromUtf8(it2->c_str())); nextItem->setData(0, 16, ADDITIONAL_STYLE); nextItem->setData(0, Qt::ToolTipRole,QString::fromUtf8(it2->c_str())); + nextItem->setData(2, Qt::ToolTipRole, nextStyle.getMyStateToolTipInfo()); + if(nextStyle.getState()) nextItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else nextItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); treeWidget_cardDeckStyles->addTopLevelItem(nextItem); } } @@ -1313,9 +1323,17 @@ void settingsDialogImpl::addCardDeckStyle() newItem->setData(0, 15,fileName); newItem->setData(0, 16, ADDITIONAL_STYLE); newItem->setData(0, Qt::ToolTipRole,fileName); - treeWidget_cardDeckStyles->addTopLevelItem(newItem); + newItem->setData(2, Qt::ToolTipRole, newStyle.getMyStateToolTipInfo()); + if(newStyle.getState() != CD_STYLE_OK) newItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else newItem->setIcon(2, QIcon(":/gfx/dialog-ok-apply.png")); + + qDebug() << "settings: " << newStyle.getStyleDescription() << newStyle.getState(); + if(newStyle.getState() != CD_STYLE_OK) newStyle.showErrorMessage(); + + treeWidget_cardDeckStyles->addTopLevelItem(newItem); treeWidget_cardDeckStyles->setCurrentItem(newItem); treeWidget_cardDeckStyles->sortItems(0, Qt::AscendingOrder); + } else { MyMessageBox::warning(this, tr("Card Deck Style File Error"), tr("Could not load card deck style file correctly. \nStyle will not be placed into list!"), diff --git a/src/gui/qt/styles/carddeckstylereader.cpp b/src/gui/qt/styles/carddeckstylereader.cpp index f9c45da1..c3621d41 100644 --- a/src/gui/qt/styles/carddeckstylereader.cpp +++ b/src/gui/qt/styles/carddeckstylereader.cpp @@ -21,11 +21,12 @@ #include #include #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); + } } diff --git a/src/gui/qt/styles/carddeckstylereader.h b/src/gui/qt/styles/carddeckstylereader.h index 132a01cd..ca7f7b82 100644 --- a/src/gui/qt/styles/carddeckstylereader.h +++ b/src/gui/qt/styles/carddeckstylereader.h @@ -24,13 +24,14 @@ #include #include -#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 diff --git a/src/gui/qt/styles/gametablestylereader.cpp b/src/gui/qt/styles/gametablestylereader.cpp index dc08b29a..af09a5d5 100644 --- a/src/gui/qt/styles/gametablestylereader.cpp +++ b/src/gui/qt/styles/gametablestylereader.cpp @@ -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(""); }