diff --git a/JGE/src/JLBFont.cpp b/JGE/src/JLBFont.cpp index 005fb753a..1cdeec5dd 100644 --- a/JGE/src/JLBFont.cpp +++ b/JGE/src/JLBFont.cpp @@ -102,23 +102,31 @@ JLBFont::~JLBFont() void JLBFont::DrawString(const char *string, float x, float y, int align, float leftOffset, float displayWidth) { char *p = (char*)string; - float dx = x, dy = y; + float dx0 = x, dy = y; if (mQuad == NULL) return; float width = GetStringWidth(string); if (align == JGETEXT_RIGHT) - dx -= width; + dx0 -= width; else if (align == JGETEXT_CENTER) - dx -= width/2; + dx0 -= width/2; - dx = floorf(dx); + float dx = floorf(dx0); dy = floorf(dy); float x0 = dx; int index; while (*p) { + if (*p == '\n') { + p++; + dy += (mHeight * 1.1 * mScale); + dy = floorf(dy); + dx = dx0; + continue; + } + index = (*p - 32)+mBase; float charWidth = mCharWidth[index]; float delta = (charWidth + mTracking) * mScale; diff --git a/projects/mtg/bin/Res/ai/baka/deck15.txt b/projects/mtg/bin/Res/ai/baka/deck15.txt index dbcdebfc0..e90f48851 100644 --- a/projects/mtg/bin/Res/ai/baka/deck15.txt +++ b/projects/mtg/bin/Res/ai/baka/deck15.txt @@ -1,3 +1,14 @@ +#NAME:Rats! +#DESC:"They fought the dogs, and killed the cats, +#DESC:And bit the babies in the cradles, +#DESC:And ate the cheeses out of the vats +#DESC:And licked the soup from the cook's own ladles, +#DESC:Split open the kegs of salted sprats, +#DESC:Made nests inside men's Sunday hats, +#DESC:And even spoiled the women's chats, +#DESC:By drowning their speaking +#DESC:With shrieking and squeaking +#DESC:In fifty different sharps and flats." #Black Deck, Rats #26 Swamps 157886 diff --git a/projects/mtg/bin/Res/ai/baka/deck17.txt b/projects/mtg/bin/Res/ai/baka/deck17.txt index 782074486..95127bb03 100644 --- a/projects/mtg/bin/Res/ai/baka/deck17.txt +++ b/projects/mtg/bin/Res/ai/baka/deck17.txt @@ -1,3 +1,6 @@ +#NAME:Faeries +#DESC:Be warned, those are not butterflies... +#DESC:Or the dangerous kind. #Plain blue deck #4 x Control Magic, {2}{U}{U}, Enchant creature 1194 diff --git a/projects/mtg/bin/Res/ai/baka/deck19.txt b/projects/mtg/bin/Res/ai/baka/deck19.txt index cf0b8e0f9..e8b5248cc 100644 --- a/projects/mtg/bin/Res/ai/baka/deck19.txt +++ b/projects/mtg/bin/Res/ai/baka/deck19.txt @@ -1,4 +1,8 @@ -#Plain Green Elf deck +#NAME:Elves +#DESC:And here you thought you would enjoy +#DESC:a little trip in the forest... +#DESC: +#DESC:Who said only Goblins were nasty? #4x Elvish Archers,{1}{G},2/1,Creature Elf,first strike 1242 1242 diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index 94fba37b0..2b899bd65 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -79,8 +79,11 @@ class MTGDeck:public MTGAllCards{ protected: string filename; MTGAllCards * allcards; + public: - MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards); + string meta_desc; + string meta_name; + MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0); int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL); int add(int cardid); int remove(int cardid); diff --git a/projects/mtg/include/SimpleMenu.h b/projects/mtg/include/SimpleMenu.h index e956b40de..a987f4429 100644 --- a/projects/mtg/include/SimpleMenu.h +++ b/projects/mtg/include/SimpleMenu.h @@ -47,7 +47,7 @@ class SimpleMenu:public JGuiController{ SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7); void Render(); void Update(float dt); - void Add(int id, const char * Text); + void Add(int id, const char * Text,string desc = ""); void Close(); float selectionTargetY; diff --git a/projects/mtg/include/SimpleMenuItem.h b/projects/mtg/include/SimpleMenuItem.h index 7da901824..17937c550 100644 --- a/projects/mtg/include/SimpleMenuItem.h +++ b/projects/mtg/include/SimpleMenuItem.h @@ -24,6 +24,7 @@ class SimpleMenuItem: public JGuiObject float mTargetScale; public: + string desc; SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false); int mX; diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 5bbe19b73..9b99d4381 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -272,22 +272,24 @@ void GameStateDuel::Update(float dt) char deckDesc[512]; sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1); if(fileExists(buffer)){ - found = 1; - nbAIDecks++; - sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks); - DeckStats * stats = DeckStats::GetInstance(); - stats->load(mPlayers[0]); - int percentVictories = stats->percentVictories(string(aiSmallDeckName)); - string difficulty; - if (percentVictories < 34){ - difficulty = "(hard)"; - }else if (percentVictories < 67){ - difficulty = ""; - }else{ - difficulty = "(easy)"; - } - sprintf(deckDesc, "Deck %i %s",nbAIDecks, _(difficulty).c_str()); - opponentMenu->Add(nbAIDecks,deckDesc); + MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,NULL,1); + found = 1; + nbAIDecks++; + sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks); + DeckStats * stats = DeckStats::GetInstance(); + stats->load(mPlayers[0]); + int percentVictories = stats->percentVictories(string(aiSmallDeckName)); + string difficulty; + if (percentVictories < 34){ + difficulty = "(hard)"; + }else if (percentVictories < 67){ + difficulty = ""; + }else{ + difficulty = "(easy)"; + } + sprintf(deckDesc, "%s %s",mtgd->meta_name.c_str(), _(difficulty).c_str()); + opponentMenu->Add(nbAIDecks,deckDesc,mtgd->meta_desc); + delete mtgd; } } } diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 057344640..066d0199d 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -327,16 +327,35 @@ MTGCard * MTGAllCards::getCardByName(string name){ -MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards){ +MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){ mCache = cache; total_cards = 0; allcards = _allcards; filename = config_file; + size_t slash = filename.find_last_of("/"); + size_t dot = filename.find("."); + meta_name = filename.substr(slash+1,dot-slash-1); std::ifstream file(config_file); std::string s; if(file){ while(std::getline(file,s)){ + if (!s.size()) continue; + if (s[0] == '#'){ + size_t found = s.find("NAME:"); + if ( found != string::npos){ + meta_name = s.substr(found+5); + continue; + } + found = s.find("DESC:"); + if ( found != string::npos){ + if (meta_desc.size()) meta_desc.append("\n"); + meta_desc.append(s.substr(found+5)); + continue; + } + continue; + } + if (meta_only) break; int cardnb = atoi(s.c_str()); if (cardnb){ add(cardnb); diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 7e6e28b8d..dd3f92617 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -134,8 +134,10 @@ void SimpleMenu::Render(){ if (i > mCount-1) break; if ((static_cast(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) { - if (static_cast(mObjects[i])->hasFocus()) - mFont->SetColor(ARGB(255,255,255,0)); + if (static_cast(mObjects[i])->hasFocus()){ + GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast(mObjects[i])->desc.c_str(),mX+mWidth+20,mY+15); + mFont->SetColor(ARGB(255,255,255,0)); + } else mFont->SetColor(ARGB(255,255,255,255)); (static_cast(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId); @@ -168,8 +170,10 @@ void SimpleMenu::Update(float dt){ } } -void SimpleMenu::Add(int id, const char * text){ - JGuiController::Add(NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0))); +void SimpleMenu::Add(int id, const char * text,string desc){ + SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0)); + smi->desc = desc; + JGuiController::Add(smi); if (mCount <= maxItems) mHeight += LINE_HEIGHT; } diff --git a/projects/mtg/tools/gatherer/gatherer-builder.py b/projects/mtg/tools/gatherer/gatherer-builder.py index 12bed5011..77d41cbc8 100644 --- a/projects/mtg/tools/gatherer/gatherer-builder.py +++ b/projects/mtg/tools/gatherer/gatherer-builder.py @@ -19,7 +19,7 @@ import os import os.path from mtgCommon import * -setinfo=sets['OD'] +setinfo=sets['UZ'] stripReminderText = False conffile = open(setinfo['dir'] + ".conf", 'w') diff --git a/projects/mtg/tools/gatherer/mtgCommon.py b/projects/mtg/tools/gatherer/mtgCommon.py index 07df7eaef..be2b804c6 100644 --- a/projects/mtg/tools/gatherer/mtgCommon.py +++ b/projects/mtg/tools/gatherer/mtgCommon.py @@ -16,6 +16,13 @@ sets ={'BE':{'name':'Beta', 'gathabbrev': '3E', 'gathname':'RevisedEdition' }, + 'ARB':{'name':'Alara Reborn', + 'dir':'ARB', + 'abbrev':'ARB', + 'gathdirs':['ARB/en-us'], + 'gathabbrev': 'ARB', + 'gathname':'Alara%20Reborn' + }, '4E':{'name':'4th Edition', 'dir':'4E', 'abbrev':'4E', @@ -229,10 +236,11 @@ sets ={'BE':{'name':'Beta', 'gathabbrev': 'EX', 'gathname':'Exodus', }, - 'US':{'name':'Urza\'s Saga', - 'dir':'US', - 'abbrev':'US', + 'UZ':{'name':'Urza\'s Saga', + 'dir':'UZ', + 'abbrev':'UZ', 'gathabbrev': 'UZ', + 'gathdirs':['UZ/en-us'], 'gathname':'UrzasSaga', }, 'UL':{'name':'Urza\'s Legacy', @@ -250,7 +258,7 @@ sets ={'BE':{'name':'Beta', 'MM':{'name':'Mercadian Masques', 'dir':'MM', 'abbrev':'MM', - 'gathdirs':['MM/en-us'], + 'gathdirs':['MM/en-us'], 'gathabbrev': 'MM', 'gathname':'MercadianMasques', }, @@ -360,10 +368,11 @@ sets ={'BE':{'name':'Beta', 'gathabbrev': 'SOK', 'gathname':'SaviorsofKamigawa', }, - 'RA':{'name':'Ravnica: City of Guilds', - 'dir':'RA', - 'abbrev':'RA', + 'RAV':{'name':'Ravnica: City of Guilds', + 'dir':'RAV', + 'abbrev':'RAV', 'gathabbrev': 'RAV', + 'gathdirs':['RAV/en-us'], 'gathname':'RavnicaCityofGuilds', }, 'GP':{'name':'Guildpact',