Fixed deck selection in Deck Editor Menu (now it shows both Classical Decks and Commander Decks using a CMD suffix) and fixed deck selection in Demo Mode (now it filters decks according to game mode as it happens in normal game mode).

This commit is contained in:
Vittorio Alfieri
2021-02-05 11:25:04 +01:00
parent 8c031585cf
commit f1ee227b84
5 changed files with 15 additions and 12 deletions

View File

@@ -73,11 +73,11 @@ public:
// it makes it easier to manipulate the deck information menus.
// generate the Deck Meta Data and build the menu items of the menu given
// Will display up to maxDecks if maxDecks is non 0,all decks in path otherwise and it will show or not commander decks according to the current game type
static vector<DeckMetaData *> fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0, GameType type = GAME_TYPE_CLASSIC);
// Will display up to maxDecks if maxDecks is non 0, all decks in path otherwise and it will show or not commander decks according to the current game type or according to "showall" option (e.g. DeckEditorMenu)
static vector<DeckMetaData *> fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0, GameType type = GAME_TYPE_CLASSIC, bool showall = false);
// build a vector of decks with the information passsed in.
static vector<DeckMetaData *> BuildDeckList(const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0, GameType type = GAME_TYPE_CLASSIC);
static vector<DeckMetaData *> BuildDeckList(const string& path, const string& smallDeckPrefix = "", Player * statsPlayer = NULL, int maxDecks = 0, GameType type = GAME_TYPE_CLASSIC, bool showall = false);
// build menu items based on the vector<DeckMetaData *>
static void renderDeckMenu(SimpleMenu * _menu, const vector<DeckMetaData *>& deckMetaDataList);

View File

@@ -445,7 +445,10 @@ void DeckMenu::Add(int id, const string& text, const string& desc, bool forceFoc
deckDescription = it->second;
else
deckDescription = deckMetaData ? deckMetaData->getDescription() : desc;
if(deckMetaData && deckMetaData->isCommanderDeck)
deckDescription = deckDescription + " (" + _("CMD") + ")"; // It will show a CMD suffix for Commander Decks.
menuItem->setDescription(deckDescription);
JGuiController::Add(menuItem);

View File

@@ -15,16 +15,16 @@
// sortByName to do the sorting. This was done since the menu item display is done in insertion order.
vector<DeckMetaData *> GameState::fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix,
Player * statsPlayer, int maxDecks, GameType type)
Player * statsPlayer, int maxDecks, GameType type, bool showall)
{
vector<DeckMetaData *> deckMetaDataVector = BuildDeckList(path, smallDeckPrefix, statsPlayer, maxDecks, type);
vector<DeckMetaData *> deckMetaDataVector = BuildDeckList(path, smallDeckPrefix, statsPlayer, maxDecks, type, showall);
renderDeckMenu(_menu, deckMetaDataVector);
return deckMetaDataVector;
}
vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string& smallDeckPrefix, Player * statsPlayer, int maxDecks, GameType type)
vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string& smallDeckPrefix, Player * statsPlayer, int maxDecks, GameType type, bool showall)
{
vector<DeckMetaData*> retList;
@@ -42,7 +42,7 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
if (meta)
{
found = 1;
if((meta->isCommanderDeck && type != GAME_TYPE_COMMANDER) || (!meta->isCommanderDeck && type == GAME_TYPE_COMMANDER)){
if(!showall && ((meta->isCommanderDeck && type != GAME_TYPE_COMMANDER) || (!meta->isCommanderDeck && type == GAME_TYPE_COMMANDER))){
meta = NULL; // It will show commander decks only in commander mode and it will hide them in other modes.
nbDecks++;
continue;

View File

@@ -172,7 +172,7 @@ void GameStateDeckViewer::updateDecks()
{
SAFE_DELETE(welcome_menu);
welcome_menu = NEW DeckEditorMenu(MENU_DECK_SELECTION, this, Fonts::OPTION_FONT, "Choose Deck To Edit");
vector<DeckMetaData *> playerDeckList = fillDeckMenu(welcome_menu, options.profileFile());
vector<DeckMetaData *> playerDeckList = fillDeckMenu(welcome_menu, options.profileFile(), "", NULL, 0, GAME_TYPE_CLASSIC, true); // Show all decks in deck editor menu...
newDeckname = "";
welcome_menu->Add(MENU_ITEM_NEW_DECK, "--NEW--");

View File

@@ -274,7 +274,7 @@ void GameStateDuel::Start()
deckmenu->Add(MENUITEM_NEW_DECK, _("Create your Deck!").c_str(), desc);
}
premadeDeck = true;
fillDeckMenu(deckmenu, _("player/premade").c_str());
fillDeckMenu(deckmenu, _("player/premade").c_str(), "", NULL, 0, mParent->gameType);
}
else if (gModRules.general.hasDeckEditor())
{
@@ -299,9 +299,9 @@ void GameStateDuel::Start()
DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> playerDeckList;
playerDeckList = fillDeckMenu(deckmenu, "ai/baka","ai_baka",NULL,nmbDecks);
playerDeckList = fillDeckMenu(deckmenu, "ai/baka", "ai_baka", NULL, nmbDecks, mParent->gameType);
//printf("nmbDecks %i\n",playerDeckList.size());
renderDeckMenu(deckmenu, playerDeckList);
//renderDeckMenu(deckmenu, playerDeckList);
// save the changes to the player deck list maintained in DeckManager
deckManager->updateMetaDataList(&playerDeckList, true);
//save the real number of available decks