diff --git a/projects/mtg/bin/Res/rules/modrules.xml b/projects/mtg/bin/Res/rules/modrules.xml index f214c6cb5..aceec2056 100644 --- a/projects/mtg/bin/Res/rules/modrules.xml +++ b/projects/mtg/bin/Res/rules/modrules.xml @@ -13,4 +13,32 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index dd3ebbcdc..5ddfb6885 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -71,7 +71,7 @@ private: if(s == "prex") { ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost()); - intValue = cX->getCost(Constants::MTG_NB_COLORS); + intValue = cX->getCost(Constants::NB_Colors); delete cX; } else if (s == "x" || s == "X") @@ -2533,7 +2533,7 @@ public: if(sabilities.find("battleready") != string::npos) battleReady = true; - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { size_t found = sabilities.find(Constants::MTGColorStrings[j]); if (found != string::npos) @@ -3834,7 +3834,9 @@ public: MTGAbility(observer, id, _source) { counters = 0; - int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 4 }; + std::vector _cost; + _cost.push_back(Constants::MTG_COLOR_ARTIFACT); + _cost.push_back(4); cost = ManaCost(_cost, 1); } @@ -3896,7 +3898,9 @@ public: MTGAbility(observer, _id, _source) { canprevent = 0; - int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 2 }; + std::vector _cost; + _cost.push_back(Constants::MTG_COLOR_ARTIFACT); + _cost.push_back(2); cost = ManaCost(_cost, 1); } @@ -3990,7 +3994,9 @@ public: AFarmstead(GameObserver* observer, int _id, MTGCardInstance * source, MTGCardInstance * _target) : ActivatedAbility(observer, _id, source, 0, 1) { - int8_t _cost[] = { Constants::MTG_COLOR_WHITE, 2 }; + std::vector _cost; + _cost.push_back(Constants::MTG_COLOR_WHITE); + _cost.push_back(2); setCost(NEW ManaCost(_cost, 1), true); target = _target; usedThisTurn = 0; diff --git a/projects/mtg/include/CardGui.h b/projects/mtg/include/CardGui.h index a03a3e95d..6692b3595 100644 --- a/projects/mtg/include/CardGui.h +++ b/projects/mtg/include/CardGui.h @@ -38,6 +38,7 @@ protected: static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal); static void AlternateRender(MTGCard * card, const Pos& pos); static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad); + static string FormattedData (string data, string replace, string value); public: static const float Width; diff --git a/projects/mtg/include/GameApp.h b/projects/mtg/include/GameApp.h index cbd7cca29..90554e82d 100644 --- a/projects/mtg/include/GameApp.h +++ b/projects/mtg/include/GameApp.h @@ -108,6 +108,6 @@ public: }; -extern JQuadPtr manaIcons[7]; +extern vector manaIcons; #endif diff --git a/projects/mtg/include/GameStateDeckViewer.h b/projects/mtg/include/GameStateDeckViewer.h index 4ca9c4a9d..81be26bb4 100644 --- a/projects/mtg/include/GameStateDeckViewer.h +++ b/projects/mtg/include/GameStateDeckViewer.h @@ -75,13 +75,13 @@ enum DECK_VIEWER_MENU_ITEMS #define MED_SPEED 5.0f #define LOW_SPEED 1.5 -#define MAX_SAVED_FILTERS 8 -#define CARDS_DISPLAYED 7 +#define MAX_SAVED_FILTERS Constants::NB_Colors + 1 +#define CARDS_DISPLAYED 10 class GameStateDeckViewer: public GameState, public JGuiListener { private: - JQuadPtr mIcons[CARDS_DISPLAYED]; + vector mIcons; JQuadPtr pspIcons[8]; JTexture * pspIconsTexture; float last_user_activity; diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index 62ade5a27..a18e3cd5b 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -99,7 +99,7 @@ private: protected: int conf_read_mode; - int colorsCount[Constants::MTG_NB_COLORS]; + vector colorsCount; int total_cards; void init(); void initCounters(); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 71e39a870..b3263480e 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -249,7 +249,7 @@ class Constants }; static char MTGColorChars[]; - static const char* MTGColorStrings[]; + static vector MTGColorStrings; static int _r[], _g[], _b[]; static map MTGBasicAbilitiesMap; @@ -259,7 +259,7 @@ class Constants static int GetBasicAbilityIndex(string mtgAbility); static int GetColorStringIndex(string mtgColor); - + static int NB_Colors; }; #endif diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index 7f8af7e0e..5be369854 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -23,7 +23,7 @@ class ManaCost friend std::ostream& operator<<(std::ostream& out, ManaCost m); protected: - int8_t cost[Constants::MTG_NB_COLORS+1]; + std::vector cost; std::vector hybrids; @@ -56,7 +56,7 @@ public: virtual void reinit(); void x(); int hasX(); - ManaCost(int8_t _cost[], int nb_elems = 1); + ManaCost(std::vector& _cost, int nb_elems = 1); ManaCost(); ~ManaCost(); ManaCost(ManaCost * _manaCost); @@ -83,8 +83,8 @@ public: int doPayExtra(); int addHybrid(int c1, int v1, int c2, int v2); - int tryToPayHybrids(std::vector& _hybrids, int _nbhybrids, int8_t diff[]); - void randomDiffHybrids(ManaCost * _cost, int8_t diff[]); + int tryToPayHybrids(std::vector& _hybrids, int _nbhybrids,std::vector& diff); + void randomDiffHybrids(ManaCost * _cost, std::vector& diff); int add(ManaCost * _cost); int remove(ManaCost * _cost); int removeAll(int color); diff --git a/projects/mtg/include/ModRules.h b/projects/mtg/include/ModRules.h index ff4b0a9f1..1cbfb3871 100644 --- a/projects/mtg/include/ModRules.h +++ b/projects/mtg/include/ModRules.h @@ -84,6 +84,42 @@ public: ~ModRulesMenu(); }; + +class ModRulesBackGroundCardGuiItem +{ +protected: + static int strToint(string str); +public: + int mColorId; + string MColorName; + string mDisplayImg; + string mDisplayThumb; + int mMenuIcon; + ModRulesBackGroundCardGuiItem(string ColorId,string ColorName, string DisplayImg, string DisplayThumb,string MenuIcon); +}; + +class ModRulesRenderCardGuiItem +{ +public: + string mName; + int mPosX; + int mPosY; + string mType; + string mFormattedData; + + ModRulesRenderCardGuiItem(string Name, string PosX, string PosY, string FormattedData, string Type); +}; + +class ModRulesCardGui +{ +public: + vector background; + vector renderbig; + vector rendertinycrop; + void parse(TiXmlElement* element); + ~ModRulesCardGui(); +}; + class ModRulesGame { public: @@ -123,7 +159,7 @@ public: ModRulesCards cards; ModRulesMenu menu; ModRulesGame game; - + ModRulesCardGui cardgui; bool load(string filename); static int getValueAsInt(TiXmlElement* element, string childName); diff --git a/projects/mtg/src/AIHints.cpp b/projects/mtg/src/AIHints.cpp index 19a93e2c2..ac5380149 100644 --- a/projects/mtg/src/AIHints.cpp +++ b/projects/mtg/src/AIHints.cpp @@ -187,7 +187,7 @@ string AIHints::constraintsNotFulfilled(AIAction * action, AIHint * hint, ManaCo { //Not enough Mana, try to find which mana we should get in priority ManaCost * diff = potentialMana->Diff(a->getCost()); - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { if(diff->getCost(i) < 0) { diff --git a/projects/mtg/src/AIMomirPlayer.cpp b/projects/mtg/src/AIMomirPlayer.cpp index 5eaa180c2..d4afd5e2a 100644 --- a/projects/mtg/src/AIMomirPlayer.cpp +++ b/projects/mtg/src/AIMomirPlayer.cpp @@ -52,7 +52,10 @@ int AIMomirPlayer::momir() if (efficiency >= chance) { - int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, converted }; + + std::vector _cost; + _cost.push_back(Constants::MTG_COLOR_ARTIFACT); + _cost.push_back(converted); ManaCost * cost = NEW ManaCost(_cost); MTGAbility * ability = getMomirAbility(); MTGCardInstance * card = game->hand->cards[0]; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 9750d9147..52dd247a9 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -773,7 +773,7 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect { used[card] = true; int doUse = 1; - for (int i = Constants::MTG_NB_COLORS - 1; i >= 0; i--) + for (int i = Constants::NB_Colors - 1; i >= 0; i--) { if (diff->getCost(i) && amp->output->getCost(i)) { @@ -908,7 +908,7 @@ vector AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * } else if (amp && canHandleCost(amp) && amp->isReactingToClick(amp->source,amp->getCost())) { - for (int k = Constants::MTG_NB_COLORS-1; k > 0 ; k--)//go backwards. + for (int k = Constants::NB_Colors-1; k > 0 ; k--)//go backwards. { if (cost->hasColor(k) && amp->output->hasColor(k) && result->getCost(k) < cost->getCost(k)) { @@ -993,7 +993,7 @@ vector AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * ManaCost * checkResult = NEW ManaCost(); check->init(); checkResult->init(); - for (int k = 1; k < Constants::MTG_NB_COLORS; k++) + for (int k = 1; k < Constants::NB_Colors; k++) { check->add(k,cost->getCost(k)); checkResult->add(k,result->getCost(k)); @@ -1056,7 +1056,7 @@ vector AIPlayerBaka::canPaySunBurst(ManaCost * cost) continue;//pentid prism, has no cost but contains a counter cost, without this check ai will think it can still use this mana. if (amp && canHandleCost(amp) && amp->isReactingToClick(amp->source,amp->getCost())) { - for (int k = Constants::MTG_NB_COLORS-1; k > 0 ; k--) + for (int k = Constants::NB_Colors-1; k > 0 ; k--) { if (amp->output->hasColor(k) && result->getCost(k) < 1 && result->getConvertedCost() < cost->getConvertedCost()) { diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 19311daa5..c11a8879a 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -240,7 +240,7 @@ Interruptible(observer, id), tc(tc), cost(_cost), payResult(payResult) int Spell::computeX(MTGCardInstance * card) { ManaCost * c = cost->Diff(card->getManaCost()); - int x = c->getCost(Constants::MTG_NB_COLORS); + int x = c->getCost(Constants::NB_Colors); delete c; return x; } diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 0594dfce1..e14fb8c07 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1952,7 +1952,7 @@ int AARemoveMana::resolve() { if (mManaDesc) // Remove all mana Matching a description { - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { if (mManaDesc->hasColor(i)) manaPool->removeAll(i); @@ -2635,7 +2635,7 @@ void AAlterCost::increaseTheCost(MTGCardInstance * card) { if(card->getIncreasedManaCost()->getConvertedCost()) { - for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::MTG_NB_COLORS;k++) + for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++) { card->getManaCost()->add(k,card->getIncreasedManaCost()->getCost(k)); if (card->getManaCost()->alternative) @@ -2655,7 +2655,7 @@ void AAlterCost::decreaseTheCost(MTGCardInstance * card) { if(card->getReducedManaCost()->getConvertedCost()) { - for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::MTG_NB_COLORS;k++) + for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++) { card->getManaCost()->remove(k,card->getReducedManaCost()->getCost(k)); if (card->getManaCost()->alternative) @@ -2739,7 +2739,7 @@ int ATransformer::addToGame() while (_target->next) _target = _target->next; - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { if (_target->hasColor(j)) oldcolors.push_back(j); @@ -4210,7 +4210,7 @@ void PopulateColorIndexVector(list& colors, const string& colorStringList, vector abilitiesList = split(colorStringList, delimiter); for (vector::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter) { - for (int colorIndex = Constants::MTG_COLOR_ARTIFACT; colorIndex < Constants::MTG_NB_COLORS; ++colorIndex) + for (int colorIndex = Constants::MTG_COLOR_ARTIFACT; colorIndex < Constants::NB_Colors; ++colorIndex) { // if the text is not a basic ability but contains a valid color add it to the color vector if ((Constants::GetBasicAbilityIndex(*iter) == -1) diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index ffa0787a2..193e06594 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -14,6 +14,7 @@ #include "GameObserver.h" #include #include "Counters.h" +#include "ModRules.h" const float CardGui::Width = 28.0; const float CardGui::Height = 40.0; @@ -247,7 +248,7 @@ void CardGui::Render() if (icon.get()) { icon->SetColor(ARGB(static_cast(actA),255,255,255)); - renderer->RenderQuad(icon.get(), actX, actY, 0); + renderer->RenderQuad(icon.get(), actX, actY, actT); icon->SetColor(ARGB(255,255,255,255)); //Putting color back as this quad is shared } @@ -336,41 +337,21 @@ void CardGui::Render() JQuadPtr CardGui::AlternateThumbQuad(MTGCard * card) { JQuadPtr q; - + vectoritems = gModRules.cardgui.background; + ModRulesBackGroundCardGuiItem * item; + int numItems = (int)items.size(); if (card->data->countColors() > 1) { - q = WResourceManager::Instance()->RetrieveTempQuad("gold_thumb.jpg"); + item = items[numItems-1]; } else { - switch (card->data->getColor()) - { - case Constants::MTG_COLOR_ARTIFACT: - q = WResourceManager::Instance()->RetrieveTempQuad("artifact_thumb.jpg"); - break; - case Constants::MTG_COLOR_GREEN: - q = WResourceManager::Instance()->RetrieveTempQuad("green_thumb.jpg"); - break; - case Constants::MTG_COLOR_BLUE: - q = WResourceManager::Instance()->RetrieveTempQuad("blue_thumb.jpg"); - break; - case Constants::MTG_COLOR_RED: - q = WResourceManager::Instance()->RetrieveTempQuad("red_thumb.jpg"); - break; - case Constants::MTG_COLOR_BLACK: - q = WResourceManager::Instance()->RetrieveTempQuad("black_thumb.jpg"); - break; - case Constants::MTG_COLOR_WHITE: - q = WResourceManager::Instance()->RetrieveTempQuad("white_thumb.jpg"); - break; - case Constants::MTG_COLOR_LAND: - q = WResourceManager::Instance()->RetrieveTempQuad("land_thumb.jpg"); - break; - default: - q = WResourceManager::Instance()->RetrieveTempQuad("gold_thumb.jpg"); - break; - } + item = items[card->data->getColor()]; } + + + q = WResourceManager::Instance()->RetrieveTempQuad(item->mDisplayThumb); + items.clear(); if (q && q->mTex) q->SetHotSpot(static_cast (q->mTex->mWidth / 2), static_cast (q->mTex->mHeight / 2)); return q; @@ -383,41 +364,22 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos) JQuadPtr q; float x = pos.actX; - + + vectoritems = gModRules.cardgui.background; + ModRulesBackGroundCardGuiItem * item; + int numItems = (int)items.size(); if (card->data->countColors() > 1) { - q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg", TEXTURE_SUB_5551); + item = items[numItems-1]; } else { - switch (card->data->getColor()) - { - case Constants::MTG_COLOR_ARTIFACT: - q = WResourceManager::Instance()->RetrieveTempQuad("artifact.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_GREEN: - q = WResourceManager::Instance()->RetrieveTempQuad("green.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_BLUE: - q = WResourceManager::Instance()->RetrieveTempQuad("blue.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_RED: - q = WResourceManager::Instance()->RetrieveTempQuad("red.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_BLACK: - q = WResourceManager::Instance()->RetrieveTempQuad("black.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_WHITE: - q = WResourceManager::Instance()->RetrieveTempQuad("white.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_LAND: - q = WResourceManager::Instance()->RetrieveTempQuad("land.jpg", TEXTURE_SUB_5551); - break; - default: - q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg", TEXTURE_SUB_5551); - break; - } + item = items[card->data->getColor()]; } + + q = WResourceManager::Instance()->RetrieveTempQuad(item->mDisplayImg,TEXTURE_SUB_5551); + + items.clear(); if (q.get() && q->mTex) { q->SetHotSpot(static_cast (q->mTex->mWidth / 2), static_cast (q->mTex->mHeight / 2)); @@ -426,180 +388,288 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos) q->SetColor(ARGB((int)pos.actA,255,255,255)); renderer->RenderQuad(q.get(), x, pos.actY, pos.actT, scale, scale); } - // Write the title + + vectorCarditems = gModRules.cardgui.renderbig; + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); float backup_scale = font->GetScale(); font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); - font->SetScale(kWidthScaleFactor * pos.actZ); - + string sFormattedData = ""; + for( size_t i =0 ; i < Carditems.size(); i ++) { - char name[4096]; - sprintf(name, "%s", _(card->data->getName()).c_str()); - float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ; - if (w > BigWidth - 30) - font->SetScale((BigWidth - 30) / w); - font->DrawString(name, x + (22 - BigWidth / 2) * pos.actZ, pos.actY + (25 - BigHeight / 2) * pos.actZ); - } - - // Write the description - { - font->SetScale(kWidthScaleFactor * pos.actZ); - - std::vector txt = card->data->getFormattedText(); - - unsigned i = 0; - unsigned h = neofont ? 14 : 11; - for (std::vector::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i) - font->DrawString(it->c_str(), x + (22 - BigWidth / 2) * pos.actZ, pos.actY + (-BigHeight / 2 + 80 + h * i) * pos.actZ); - } - - // Write the strength - if (card->data->isCreature()) - { - char buffer[32]; - sprintf(buffer, "%i/%i", card->data->power, card->data->toughness); - float w = font->GetStringWidth(buffer) * kWidthScaleFactor; - font->DrawString(buffer, x + (65 - w / 2) * pos.actZ, pos.actY + (106) * pos.actZ); - } - - // Mana - { - ManaCost* manacost = card->data->getManaCost(); - ManaCostHybrid* h; - unsigned int j = 0; - unsigned char t = (JGE::GetInstance()->GetTime() / 3) & 0xFF; - unsigned char v = t + 127; - float yOffset = -112; - while ((h = manacost->getHybridCost(j))) + ModRulesRenderCardGuiItem * Carditem = Carditems[i]; + if (Carditem->mType.length() == 0 || card->data->hasType(Carditem->mType.c_str())) { - float scale = pos.actZ * 0.05f * cosf(2 * M_PI * ((float) t) / 256.0f); - if (scale < 0) + if (Carditem->mName == "title") { - renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) t)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f - + scale); - renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) v)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f - - scale); - } - else - { - renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) v)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f - - scale); - renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) t)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f - + scale); - } - ++j; - } - for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i) - { - int cost; + // Write the title + + font->SetScale(kWidthScaleFactor * pos.actZ); - for (cost = manacost->getCost(i); cost > 0; --cost) - { - renderer->RenderQuad(manaIcons[i].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0.0f, 0.4f - * pos.actZ, 0.4f * pos.actZ); - ++j; + char name[4096]; + sprintf(name, FormattedData(Carditem->mFormattedData,"title","%s").c_str(), _(card->data->getName()).c_str()); + float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ; + if (w > BigWidth - 30) + font->SetScale((BigWidth - 30) / w); + font->DrawString(name, x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, pos.actY + (Carditem->mPosY - BigHeight / 2) * pos.actZ); + + } + else if (Carditem->mName == "description") + { + // Write the description + font->SetScale(kWidthScaleFactor * pos.actZ); + + std::vector txt = card->data->getFormattedText(); + + unsigned i = 0; + unsigned h = neofont ? 14 : 11; + for (std::vector::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i) + font->DrawString(it->c_str(), x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, pos.actY + (-BigHeight / 2 + Carditem->mPosY + h * i) * pos.actZ); + } + else if (Carditem->mName == "power") + { + // Write the strength + char buffer[32]; + sprintf(buffer, FormattedData(Carditem->mFormattedData,"power","%i").c_str(), card->data->power); + float w = font->GetStringWidth(buffer) * kWidthScaleFactor; + font->DrawString(buffer, x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + + } + else if (Carditem->mName == "life") + { + // Write the strength + if (card->data->hasType(Carditem->mType.c_str())) + { + char buffer[32]; + sprintf(buffer, FormattedData(Carditem->mFormattedData,"life","%i").c_str(), card->data->toughness); + float w = font->GetStringWidth(buffer) * kWidthScaleFactor; + font->DrawString(buffer, x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + } + } + else if (Carditem->mName == "mana") + { + // Mana + ManaCost* manacost = card->data->getManaCost(); + ManaCostHybrid* h; + unsigned int j = 0; + unsigned char t = (JGE::GetInstance()->GetTime() / 3) & 0xFF; + unsigned char v = t + 127; + float yOffset = (float)Carditem->mPosY; + while ((h = manacost->getHybridCost(j))) + { + float scale = pos.actZ * 0.05f * cosf(2 * M_PI * ((float) t) / 256.0f); + + if (scale < 0) + { + renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) t)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f + + scale); + renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) v)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f + - scale); + } + else + { + renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) v)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f + - scale); + renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) t)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f + + scale); + } + ++j; + } + for (int i = Constants::NB_Colors - 2; i >= 1; --i) + { + int cost; + for (cost = manacost->getCost(i); cost > 0; --cost) + { + renderer->RenderQuad(manaIcons[i].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f + * pos.actZ, 0.4f * pos.actZ); + ++j; + } + + } + // Colorless mana + if (int cost = manacost->getCost(0)) + { + char buffer[10]; + sprintf(buffer, "%d", cost); + renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, + 0.4f * pos.actZ); + float w = font->GetStringWidth(buffer); + font->DrawString(buffer, x + (-12 * j + (Carditem->mPosX +1) - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); + ++j; + } + //Has X? + if (manacost->hasX()) + { + char buffer[10]; + sprintf(buffer, "X"); + renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, + 0.4f * pos.actZ); + float w = font->GetStringWidth(buffer); + font->DrawString(buffer, x + (-12 * j + (Carditem->mPosX + 1) - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); + } + + } + else if (Carditem->mName == "types") + { + //types + string s = ""; + for (int i = card->data->types.size() - 1; i > 0; --i) + { + if (card->data->basicAbilities[(int)Constants::CHANGELING]) + {// this avoids drawing the list of subtypes on changeling cards. + s += _("Shapeshifter - "); + break; + } + else + { + s += _(Subtypes::subtypesList->find(card->data->types[i])); + s += _(" - "); + } + } + if (card->data->types.size()) + s += _(Subtypes::subtypesList->find(card->data->types[0])); + else + { + DebugTrace("Typeless card: " << setlist[card->setId].c_str() << card->data->getName() << card->getId()); + } + + font->DrawString(s.c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (Carditem->mPosY - BigHeight / 2)*pos.actZ); + + } + else if (Carditem->mName == "rarity") + { + font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); + + string sRarity; + switch(card->getRarity()) + { + case Constants::RARITY_M: + sRarity ="Mythic"; + break; + case Constants::RARITY_R: + sRarity ="Rare"; + break; + case Constants::RARITY_U: + sRarity ="Uncommon"; + break; + case Constants::RARITY_C: + sRarity ="Common"; + break; + case Constants::RARITY_L: + sRarity ="Land"; + break; + case Constants::RARITY_T: + sRarity ="Token"; + break; + default: + case Constants::RARITY_S: + sRarity ="Special"; + break; + } + + switch(card->data->getColor()) + { + case Constants::MTG_COLOR_BLACK: + case Constants::MTG_COLOR_GREEN: + case Constants::MTG_COLOR_BLUE: + case Constants::MTG_COLOR_LAND: + font->SetColor(ARGB((int)pos.actA,255,255,255)); + font->DrawString(FormattedData(Carditem->mFormattedData,"rarity",sRarity).c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - Carditem->mPosY)*pos.actZ); + break; + default: + font->DrawString(FormattedData(Carditem->mFormattedData,"rarity",sRarity).c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - Carditem->mPosY)*pos.actZ); + break; //Leave black + } + } + else if (Carditem->mName == "expansion") + { + string formattedfield = FormattedData(Carditem->mFormattedData, "expansion", setlist[card->setId].c_str()); + float w = font->GetStringWidth(formattedfield.c_str()) * kWidthScaleFactor; + font->DrawString(formattedfield.c_str(), x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + + } + else + { + string formattedfield = Carditem->mFormattedData; + + size_t found = Carditem->mName.find("title"); + if (found != string::npos) + { + stringstream st; + st << card->data->name; + formattedfield = FormattedData(formattedfield, "title", st.str()); + + } + + found = Carditem->mName.find("power"); + if (found != string::npos) + { + stringstream st; + st << card->data->power; + formattedfield = FormattedData(formattedfield, "power", st.str()); + } + found = Carditem->mName.find("life"); + if (found != string::npos) + { + stringstream st; + st << card->data->toughness; + formattedfield = FormattedData(formattedfield, "life", st.str()); + + } + + found = Carditem->mName.find("rarity"); + if (found != string::npos) + { + + string sRarity; + switch(card->getRarity()) + { + case Constants::RARITY_M: + sRarity ="Mythic"; + break; + case Constants::RARITY_R: + sRarity ="Rare"; + break; + case Constants::RARITY_U: + sRarity ="Uncommon"; + break; + case Constants::RARITY_C: + sRarity ="Common"; + break; + case Constants::RARITY_L: + sRarity ="Land"; + break; + case Constants::RARITY_T: + sRarity ="Token"; + break; + default: + case Constants::RARITY_S: + sRarity ="Special"; + break; + } + formattedfield = FormattedData(formattedfield, "rarity", sRarity); + } + + found = Carditem->mName.find("expansion"); + if (found != string::npos) + { + formattedfield = FormattedData(formattedfield, "expansion", setlist[card->setId].c_str()); + } + + float w = font->GetStringWidth(formattedfield.c_str()) * kWidthScaleFactor; + font->DrawString(formattedfield.c_str(), x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + } - } - // Colorless mana - if (int cost = manacost->getCost(0)) - { - char buffer[10]; - sprintf(buffer, "%d", cost); - renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, - 0.4f * pos.actZ); - float w = font->GetStringWidth(buffer); - font->DrawString(buffer, x + (-12 * j + 76 - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); - ++j; - } - //Has X? - if (manacost->hasX()) - { - char buffer[10]; - sprintf(buffer, "X"); - renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, - 0.4f * pos.actZ); - float w = font->GetStringWidth(buffer); - font->DrawString(buffer, x + (-12 * j + 76 - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); } } - //types - { - string s = ""; - for (int i = card->data->types.size() - 1; i > 0; --i) - { - if (card->data->basicAbilities[(int)Constants::CHANGELING]) - {// this avoids drawing the list of subtypes on changeling cards. - s += _("Shapeshifter - "); - break; - } - else - { - s += _(Subtypes::subtypesList->find(card->data->types[i])); - s += _(" - "); - } - } - if (card->data->types.size()) - s += _(Subtypes::subtypesList->find(card->data->types[0])); - else - { - DebugTrace("Typeless card: " << setlist[card->setId].c_str() << card->data->getName() << card->getId()); - } - - font->DrawString(s.c_str(), x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (49 - BigHeight / 2)*pos.actZ); - } - - //expansion and rarity - font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); - { - char buf[512]; - switch(card->getRarity()) - { - case Constants::RARITY_M: - sprintf(buf,_("%s Mythic").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_R: - sprintf(buf,_("%s Rare").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_U: - sprintf(buf,_("%s Uncommon").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_C: - sprintf(buf,_("%s Common").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_L: - sprintf(buf,_("%s Land").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_T: - sprintf(buf,_("%s Token").c_str(),setlist[card->setId].c_str()); - break; - default: - case Constants::RARITY_S: - sprintf(buf,_("%s Special").c_str(),setlist[card->setId].c_str()); - break; - } - - switch(card->data->getColor()) - { - case Constants::MTG_COLOR_BLACK: - case Constants::MTG_COLOR_GREEN: - case Constants::MTG_COLOR_BLUE: - case Constants::MTG_COLOR_LAND: - font->SetColor(ARGB((int)pos.actA,255,255,255)); - font->DrawString(buf, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - 30)*pos.actZ); - break; - default: - font->DrawString(buf, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - 30)*pos.actZ); - break; //Leave black - } - - } + font->SetScale(backup_scale); RenderCountersBig(card, pos, DrawMode::kText); @@ -615,41 +685,21 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) float x = pos.actX; float displayScale = 250 / BigHeight; - + + vectoritems = gModRules.cardgui.background; + ModRulesBackGroundCardGuiItem * item; + int numItems = (int)items.size(); if (card->data->countColors() > 1) { - q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg", TEXTURE_SUB_5551); + item = items[numItems-1]; } else { - switch (card->data->getColor()) - { - case Constants::MTG_COLOR_ARTIFACT: - q = WResourceManager::Instance()->RetrieveTempQuad("artifact.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_GREEN: - q = WResourceManager::Instance()->RetrieveTempQuad("green.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_BLUE: - q = WResourceManager::Instance()->RetrieveTempQuad("blue.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_RED: - q = WResourceManager::Instance()->RetrieveTempQuad("red.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_BLACK: - q = WResourceManager::Instance()->RetrieveTempQuad("black.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_WHITE: - q = WResourceManager::Instance()->RetrieveTempQuad("white.jpg", TEXTURE_SUB_5551); - break; - case Constants::MTG_COLOR_LAND: - q = WResourceManager::Instance()->RetrieveTempQuad("land.jpg", TEXTURE_SUB_5551); - break; - default: - q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg", TEXTURE_SUB_5551); - break; - } + item = items[card->data->getColor()]; } + + q = WResourceManager::Instance()->RetrieveTempQuad(item->mDisplayImg,TEXTURE_SUB_5551); + items.clear(); if (q.get() && q->mTex) { q->SetHotSpot(static_cast (q->mTex->mWidth / 2), static_cast (q->mTex->mHeight / 2)); @@ -658,7 +708,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) q->SetColor(ARGB((int)pos.actA,255,255,255)); renderer->RenderQuad(q.get(), x, pos.actY, pos.actT, scale, scale); } - + std::vector txt = card->data->getFormattedText(); size_t nbTextLines = txt.size(); @@ -673,168 +723,286 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) } renderer->RenderQuad(quad, x, imgY, pos.actT, imgScale, imgScale); - // Write the title + + + vectorCarditems = gModRules.cardgui.rendertinycrop; + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); float backup_scale = font->GetScale(); - font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); - font->SetScale(kWidthScaleFactor * pos.actZ); - + string sFormattedData = ""; + for( size_t i =0 ; i < Carditems.size(); i ++) { - char name[4096]; - sprintf(name, "%s", _(card->data->getName()).c_str()); - float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ; - if (w > BigWidth - 30) - font->SetScale((BigWidth - 30) / w); - font->DrawString(name, x + (22 - BigWidth / 2) * pos.actZ, pos.actY + (25 - BigHeight / 2) * pos.actZ); - } - - // Write the description - { - font->SetScale(kWidthScaleFactor * pos.actZ); - float imgBottom = imgY + (imgScale * quad->mHeight / 2); - unsigned i = 0; - unsigned h = neofont ? 14 : 11; - for (std::vector::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i) - font->DrawString(it->c_str(), x + (22 - BigWidth / 2) * pos.actZ, imgBottom + (h * i * pos.actZ)); - } - - // Write the strength - if (card->data->isCreature()) - { - char buffer[32]; - sprintf(buffer, "%i/%i", card->data->power, card->data->toughness); - float w = font->GetStringWidth(buffer) * kWidthScaleFactor; - font->DrawString(buffer, x + (65 - w / 2) * pos.actZ, pos.actY + (106) * pos.actZ); - } - - // Mana - { - ManaCost* manacost = card->data->getManaCost(); - ManaCostHybrid* h; - unsigned int j = 0; - unsigned char t = (JGE::GetInstance()->GetTime() / 3) & 0xFF; - unsigned char v = t + 127; - float yOffset = -112; - while ((h = manacost->getHybridCost(j))) + ModRulesRenderCardGuiItem * Carditem = Carditems[i]; + if (Carditem->mType.length() == 0 || card->data->hasType(Carditem->mType.c_str())) { - float scale = pos.actZ * 0.05f * cosf(2 * M_PI * ((float) t) / 256.0f); - if (scale < 0) + if (Carditem->mName == "title") { - renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) t)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f - + scale); - renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) v)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f - - scale); + // Write the title + font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); + font->SetScale(kWidthScaleFactor * pos.actZ); + + char name[4096]; + sprintf(name, FormattedData(Carditem->mFormattedData,"title","%s").c_str(), _(card->data->getName()).c_str()); + float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ; + if (w > BigWidth - 30) + font->SetScale((BigWidth - 30) / w); + font->DrawString(name, x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, pos.actY + (Carditem->mPosY - BigHeight / 2) * pos.actZ); + } - else + else if (Carditem->mName == "description") { - renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) v)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f - - scale); - renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + 75 + 3 * SineHelperFunction((float) t)) * pos.actZ, - pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f - + scale); + // Write the description + font->SetScale(kWidthScaleFactor * pos.actZ); + + float imgBottom = imgY + (imgScale * quad->mHeight / 2); + + unsigned i = 0; + unsigned h = neofont ? 14 : 11; + for (std::vector::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i) + font->DrawString(it->c_str(), x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, imgBottom + (-BigHeight / 2 + Carditem->mPosY + h * i) * pos.actZ); } - ++j; - } - for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i) - { - for (int cost = manacost->getCost(i); cost > 0; --cost) + else if (Carditem->mName == "power") { - renderer->RenderQuad(manaIcons[i].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f - * pos.actZ, 0.4f * pos.actZ); - ++j; + // Write the strength + char buffer[32]; + sprintf(buffer, FormattedData(Carditem->mFormattedData,"power","%s").c_str(), card->data->power); + float w = font->GetStringWidth(buffer) * kWidthScaleFactor; + font->DrawString(buffer, x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + + } + else if (Carditem->mName == "life") + { + // Write the strength + if (card->data->hasType(Carditem->mType.c_str())) + { + char buffer[32]; + sprintf(buffer, FormattedData(Carditem->mFormattedData,"life","%s").c_str(), card->data->toughness); + float w = font->GetStringWidth(buffer) * kWidthScaleFactor; + font->DrawString(buffer, x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + } + } + else if (Carditem->mName == "mana") + { + // Mana + ManaCost* manacost = card->data->getManaCost(); + ManaCostHybrid* h; + unsigned int j = 0; + unsigned char t = (JGE::GetInstance()->GetTime() / 3) & 0xFF; + unsigned char v = t + 127; + float yOffset = (float)Carditem->mPosY; + while ((h = manacost->getHybridCost(j))) + { + float scale = pos.actZ * 0.05f * cosf(2 * M_PI * ((float) t) / 256.0f); + + if (scale < 0) + { + renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) t)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f + + scale); + renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) v)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f + - scale); + } + else + { + renderer->RenderQuad(manaIcons[h->color2].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) v)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) v)) * pos.actZ, 0, 0.4f - scale, 0.4f + - scale); + renderer->RenderQuad(manaIcons[h->color1].get(), x + (-12 * j + Carditem->mPosX + 3 * SineHelperFunction((float) t)) * pos.actZ, + pos.actY + (yOffset + 3 * CosineHelperFunction((float) t)) * pos.actZ, 0, 0.4f + scale, 0.4f + + scale); + } + ++j; + } + for (int i = Constants::NB_Colors - 2; i >= 1; --i) + { + for (int cost = manacost->getCost(i); cost > 0; --cost) + { + renderer->RenderQuad(manaIcons[i].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f + * pos.actZ, 0.4f * pos.actZ); + ++j; + } + } + // Colorless mana + if (int cost = manacost->getCost(0)) + { + char buffer[10]; + sprintf(buffer, "%d", cost); + renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, + 0.4f * pos.actZ); + float w = font->GetStringWidth(buffer); + font->DrawString(buffer, x + (-12 * j + (Carditem->mPosX +1) - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); + ++j; + } + //Has X? + if (manacost->hasX()) + { + char buffer[10]; + sprintf(buffer, "X"); + renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + Carditem->mPosX) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, + 0.4f * pos.actZ); + float w = font->GetStringWidth(buffer); + font->DrawString(buffer, x + (-12 * j + (Carditem->mPosX + 1) - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); + } + + } + else if (Carditem->mName == "types") + { + //types + string s = ""; + for (int i = card->data->types.size() - 1; i > 0; --i) + { + if (card->data->basicAbilities[(int)Constants::CHANGELING]) + {// this avoids drawing the list of subtypes on changeling cards. + s += _("Shapeshifter - "); + break; + } + else + { + s += _(Subtypes::subtypesList->find(card->data->types[i])); + s += _(" - "); + } + } + if (card->data->types.size()) + s += _(Subtypes::subtypesList->find(card->data->types[0])); + else + { + DebugTrace("Typeless card: " << setlist[card->setId].c_str() << card->data->getName() << card->getId()); + } + + font->DrawString(s.c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (Carditem->mPosY - BigHeight / 2)*pos.actZ); + + } + else if (Carditem->mName == "rarity") + { + font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); + + string sRarity; + switch(card->getRarity()) + { + case Constants::RARITY_M: + sRarity ="Mythic"; + break; + case Constants::RARITY_R: + sRarity ="Rare"; + break; + case Constants::RARITY_U: + sRarity ="Uncommon"; + break; + case Constants::RARITY_C: + sRarity ="Common"; + break; + case Constants::RARITY_L: + sRarity ="Land"; + break; + case Constants::RARITY_T: + sRarity ="Token"; + break; + default: + case Constants::RARITY_S: + sRarity ="Special"; + break; + } + + switch(card->data->getColor()) + { + case Constants::MTG_COLOR_BLACK: + case Constants::MTG_COLOR_GREEN: + case Constants::MTG_COLOR_BLUE: + case Constants::MTG_COLOR_LAND: + font->SetColor(ARGB((int)pos.actA,255,255,255)); + font->DrawString(FormattedData(Carditem->mFormattedData,"rarity",sRarity).c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - Carditem->mPosY)*pos.actZ); + break; + default: + font->DrawString(FormattedData(Carditem->mFormattedData,"rarity",sRarity).c_str(), x + (Carditem->mPosX - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - Carditem->mPosY)*pos.actZ); + break; //Leave black + } + } + else if (Carditem->mName == "expansion") + { + string formattedfield = FormattedData(Carditem->mFormattedData, "expansion", setlist[card->setId].c_str()); + float w = font->GetStringWidth(formattedfield.c_str()) * kWidthScaleFactor; + font->DrawString(formattedfield.c_str(), x + (Carditem->mPosX - w / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + + } + else + { + string formattedfield = Carditem->mFormattedData; + + size_t found = Carditem->mName.find("title"); + if (found != string::npos) + { + stringstream st; + st << card->data->name; + formattedfield = FormattedData(formattedfield, "title", st.str()); + + } + + found = Carditem->mName.find("power"); + if (found != string::npos) + { + stringstream st; + st << card->data->power; + formattedfield = FormattedData(formattedfield, "power", st.str()); + } + found = Carditem->mName.find("life"); + if (found != string::npos) + { + stringstream st; + st << card->data->toughness; + formattedfield = FormattedData(formattedfield, "life", st.str()); + + } + + found = Carditem->mName.find("rarity"); + if (found != string::npos) + { + + string sRarity; + switch(card->getRarity()) + { + case Constants::RARITY_M: + sRarity ="Mythic"; + break; + case Constants::RARITY_R: + sRarity ="Rare"; + break; + case Constants::RARITY_U: + sRarity ="Uncommon"; + break; + case Constants::RARITY_C: + sRarity ="Common"; + break; + case Constants::RARITY_L: + sRarity ="Land"; + break; + case Constants::RARITY_T: + sRarity ="Token"; + break; + default: + case Constants::RARITY_S: + sRarity ="Special"; + break; + } + formattedfield = FormattedData(formattedfield, "rarity", sRarity); + } + + found = Carditem->mName.find("expansion"); + if (found != string::npos) + { + formattedfield = FormattedData(formattedfield, "expansion", setlist[card->setId].c_str()); + } + + float w = font->GetStringWidth(formattedfield.c_str()) * kWidthScaleFactor; + font->DrawString(formattedfield.c_str(), x + (Carditem->mPosX - BigWidth / 2) * pos.actZ, pos.actY + (Carditem->mPosY) * pos.actZ); + } } - // Colorless mana - if (int cost = manacost->getCost(0)) - { - char buffer[10]; - sprintf(buffer, "%d", cost); - renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, - 0.4f * pos.actZ); - float w = font->GetStringWidth(buffer); - font->DrawString(buffer, x + (-12 * j + 76 - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); - ++j; - } - //Has X? - if (manacost->hasX()) - { - char buffer[10]; - sprintf(buffer, "X"); - renderer->RenderQuad(manaIcons[0].get(), x + (-12 * j + 75) * pos.actZ, pos.actY + (yOffset) * pos.actZ, 0, 0.4f * pos.actZ, - 0.4f * pos.actZ); - float w = font->GetStringWidth(buffer); - font->DrawString(buffer, x + (-12 * j + 76 - w / 2) * pos.actZ, pos.actY + (yOffset - 5) * pos.actZ); - } } - //types - { - string s = ""; - for (int i = card->data->types.size() - 1; i > 0; --i) - { - s += _(Subtypes::subtypesList->find(card->data->types[i])); - s += _(" - "); - } - if (card->data->types.size()) - s += _(Subtypes::subtypesList->find(card->data->types[0])); - else - { - DebugTrace("Typeless card: " << setlist[card->setId].c_str() << card->data->getName() << card->getId()); - } - - font->DrawString(s.c_str(), x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (49 - BigHeight / 2)*pos.actZ); - } - - //expansion and rarity - font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); - { - char buf[512]; - switch(card->getRarity()) - { - case Constants::RARITY_M: - sprintf(buf,_("%s Mythic").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_R: - sprintf(buf,_("%s Rare").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_U: - sprintf(buf,_("%s Uncommon").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_C: - sprintf(buf,_("%s Common").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_L: - sprintf(buf,_("%s Land").c_str(),setlist[card->setId].c_str()); - break; - case Constants::RARITY_T: - sprintf(buf,_("%s Token").c_str(),setlist[card->setId].c_str()); - break; - default: - case Constants::RARITY_S: - sprintf(buf,_("%s Special").c_str(),setlist[card->setId].c_str()); - break; - } - - switch(card->data->getColor()) - { - case Constants::MTG_COLOR_BLACK: - case Constants::MTG_COLOR_GREEN: - case Constants::MTG_COLOR_BLUE: - case Constants::MTG_COLOR_LAND: - font->SetColor(ARGB((int)pos.actA,255,255,255)); - font->DrawString(buf, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - 30)*pos.actZ); - break; - default: - font->DrawString(buf, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (BigHeight / 2 - 30)*pos.actZ); - break; //Leave black - } - - } + font->SetScale(backup_scale); RenderCountersBig(card, pos); @@ -870,6 +1038,22 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos) AlternateRender(card, pos); } +string CardGui::FormattedData(string data, string replace, string value) +{ + size_t found = data.find(replace.c_str()); + if (found != string::npos) + { + size_t len = replace.length(); + string teste = data.replace(found,len,value); + return teste; + } + else + { + return value; + } + +} + void CardGui::RenderCountersBig(MTGCard * mtgcard, const Pos& pos, int drawMode) { MTGCardInstance * card = dynamic_cast (mtgcard); @@ -1033,3 +1217,4 @@ void SimpleCardEffectMask::undoEffect(Pos * card) { card->mask = 0; } + diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index b80f20a0d..e6b291879 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -132,16 +132,12 @@ const string CardPrimitive::getOtherRestrictions() void CardPrimitive::setColor(const string& _color, int removeAllOthers) { - if (_color.compare(Constants::kManaBlue) == 0) - return setColor(Constants::MTG_COLOR_BLUE, removeAllOthers); - if (_color.compare(Constants::kManaRed) == 0) - return setColor(Constants::MTG_COLOR_RED, removeAllOthers); - if (_color.compare(Constants::kManaGreen) == 0) - return setColor(Constants::MTG_COLOR_GREEN, removeAllOthers); - if (_color.compare(Constants::kManaBlack) == 0) - return setColor(Constants::MTG_COLOR_BLACK, removeAllOthers); - if (_color.compare(Constants::kManaWhite) == 0) - return setColor(Constants::MTG_COLOR_WHITE, removeAllOthers); + for( size_t i =0 ; i< Constants::MTGColorStrings.size(); i++) + { + if (_color.compare(Constants::MTGColorStrings._Myfirst[i]) == 0) + return setColor(i, removeAllOthers); + } + //Keep artifact compare, to Remove this we need change all MTG.txt if (_color.compare("artifact") == 0) return setColor(Constants::MTG_COLOR_ARTIFACT, removeAllOthers); } @@ -164,7 +160,7 @@ int CardPrimitive::getColor() { if (colors) { - for (int i = 1; i < Constants::MTG_NB_COLORS; i++) + for (int i = 1; i < Constants::NB_Colors; i++) if (hasColor(i)) return i; } diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index 911499be6..9bcc04c87 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -402,7 +402,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) this->countSpellsPerCost[i] = 0; } - for (int i = 0; i <= Constants::MTG_NB_COLORS; i++) + for (int i = 0; i <= Constants::NB_Colors; i++) { this->totalCostPerColor[i] = 0; this->countLandsPerColor[i] = 0; @@ -412,7 +412,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++) { - for (int k = 0; k <= Constants::MTG_NB_COLORS; k++) + for (int k = 0; k <= Constants::NB_Colors; k++) { this->countCardsPerCostAndColor[i][k] = 0; this->countCreaturesPerCostAndColor[i][k] = 0; @@ -481,7 +481,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) { s = s.substr(t + 3); ManaCost * mc = ManaCost::parseManaCost(s); - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { if (mc->hasColor(j)) { @@ -508,7 +508,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) // Add to the per color counters // a. regular costs - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { this->totalCostPerColor[j] += currentCost->getCost(j) * currentCount; if (current->data->hasColor(j)) @@ -539,7 +539,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) } this->totalColoredSymbols = 0; - for (int j = 1; j < Constants::MTG_NB_COLORS; j++) + for (int j = 1; j < Constants::NB_Colors; j++) { this->totalColoredSymbols += this->totalCostPerColor[j]; } diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index fb0c86a53..b93dd9401 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -39,7 +39,7 @@ JMusic * GameApp::music = NULL; string GameApp::currentMusicFile = ""; string GameApp::systemError = ""; -JQuadPtr manaIcons[7]; +vector manaIcons; GameState::GameState(GameApp* parent, string id) : mParent(parent), mStringID(id) @@ -161,22 +161,25 @@ void GameApp::Create() LOG("--Loading menuicons.png"); WResourceManager::Instance()->RetrieveTexture("menuicons.png", RETRIEVE_MANAGE); LOG("---Gettings menuicons.png quads"); - //Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id - manaIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 0 * 36, 38, 32, 32, "c_green", - RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 1 * 36, 38, 32, 32, "c_blue", - RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 3 * 36, 38, 32, 32, "c_red", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 2 * 36, 38, 32, 32, "c_black", - RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 4 * 36, 38, 32, 32, "c_white", - RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 5 * 36, 38, 32, 32, "c_land", - RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 6 * 36, 38, 32, 32, "c_artifact", - RETRIEVE_MANAGE); + + //Load all icons from gModRules and save in manaIcons -> todo. Change the icons positions on menuicons.png to avoid use item->mColorId + vectoritems = gModRules.cardgui.background; + for(size_t i= 0; i < items.size(); i ++) + { + + ModRulesBackGroundCardGuiItem * item = items[i]; + if (item->mMenuIcon == 1) + { + manaIcons.push_back(WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + (float)item->mColorId * 36, 38, 32, 32, "c_" + item->MColorName, RETRIEVE_MANAGE)); + Constants::MTGColorStrings.push_back(item->MColorName.c_str()); + } + } + Constants::NB_Colors = (int)Constants::MTGColorStrings.size(); + + items.erase(items.begin(),items.end()); + - for (int i = sizeof(manaIcons) / sizeof(manaIcons[0]) - 1; i >= 0; --i) + for (int i = manaIcons.size()-1; i >= 0; --i) if (manaIcons[i].get()) manaIcons[i]->SetHotSpot(16, 16); diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index 9ed3e6809..2e3c9bec5 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -225,14 +225,8 @@ void GameStateDeckViewer::Start() displayed_deck = myCollection; //Icons - mIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->GetQuad("c_artifact"); - mIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->GetQuad("c_land"); - mIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->GetQuad("c_white"); - mIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->GetQuad("c_red"); - mIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->GetQuad("c_black"); - mIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->GetQuad("c_blue"); - mIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->GetQuad("c_green"); - for (int i = 0; i < 7; i++) + mIcons = manaIcons; + for (int i = 0; i < Constants::NB_Colors; i++) { mIcons[i]->SetHotSpot(16, 16); } @@ -723,7 +717,7 @@ void GameStateDeckViewer::renderDeckBackground() int max2 = 0; int maxC2 = 4; - for (int i = 0; i < Constants::MTG_NB_COLORS - 1; i++) + for (int i = 0; i < Constants::NB_Colors - 1; i++) { int value = myDeck->getCount(i); if (value > max1) @@ -816,7 +810,7 @@ void GameStateDeckViewer::renderOnScreenMenu() //Your Deck Information char buffer[300]; int nb_letters = 0; - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { int value = myDeck->getCount(j); if (value > 0) @@ -890,7 +884,7 @@ void GameStateDeckViewer::renderOnScreenMenu() posY += 10; // Counts by color - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { int value = myDeck->getCount(j); if (value > 0) @@ -1008,7 +1002,7 @@ void GameStateDeckViewer::renderOnScreenMenu() posY = 70; // Column titles - for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++) + for (int j = 0; j < Constants::NB_Colors - 1; j++) { r->RenderQuad(mIcons[j].get(), 52 + j * 15 + leftTransition, posY - 10, 0, 0.5, 0.5); } @@ -1017,20 +1011,20 @@ void GameStateDeckViewer::renderOnScreenMenu() //font->DrawString(_("Ty"), 27 + leftTransition, posY-16); // Horizontal table lines - r->DrawLine(27 + leftTransition, posY - 20, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 20, + r->DrawLine(27 + leftTransition, posY - 20, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 20, ARGB(128, 255, 255, 255)); - r->DrawLine(27 + leftTransition, posY - 1, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 1, + r->DrawLine(27 + leftTransition, posY - 1, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 1, ARGB(128, 255, 255, 255)); - r->DrawLine(27 + leftTransition, 2 * 10 + posY + 12, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, 2 * 10 + r->DrawLine(27 + leftTransition, 2 * 10 + posY + 12, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, 2 * 10 + posY + 12, ARGB(128, 255, 255, 255)); - r->DrawLine(27 + leftTransition, 3 * 10 + posY + 14, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, 3 * 10 + r->DrawLine(27 + leftTransition, 3 * 10 + posY + 14, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255)); // Vertical table lines r->DrawLine(26 + leftTransition, posY - 20, 26 + leftTransition, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255)); r->DrawLine(43 + leftTransition, posY - 20, 43 + leftTransition, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255)); - r->DrawLine(60 + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15, posY - 20, 60 + leftTransition - + (Constants::MTG_NB_COLORS - 2) * 15, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255)); + r->DrawLine(60 + leftTransition + (Constants::NB_Colors - 2) * 15, posY - 20, 60 + leftTransition + + (Constants::NB_Colors - 2) * 15, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255)); font->DrawString(_("BL"), 27 + leftTransition, posY); font->DrawString(_("NB"), 27 + leftTransition, posY + 10); @@ -1039,7 +1033,7 @@ void GameStateDeckViewer::renderOnScreenMenu() int curCount; - for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++) + for (int j = 0; j < Constants::NB_Colors - 1; j++) { curCount = stw->countBasicLandsPerColor[j]; sprintf(buffer, (curCount == 0 ? "." : "%i"), curCount); @@ -1076,13 +1070,13 @@ void GameStateDeckViewer::renderOnScreenMenu() int totalProducedSymbols; totalProducedSymbols = 0; - for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++) + for (int i = 1; i < Constants::NB_Colors - 1; i++) { totalProducedSymbols += stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i]; //!! Move to updatestats! } posY = 50; - for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++) + for (int i = 1; i < Constants::NB_Colors - 1; i++) { if (stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i] > 0) { @@ -1154,7 +1148,7 @@ void GameStateDeckViewer::renderOnScreenMenu() posY = 70; // Column titles - for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++) + for (int j = 0; j < Constants::NB_Colors - 1; j++) { r->RenderQuad(mIcons[j].get(), 67 + j * 15 + leftTransition, posY - 10, 0, 0.5, 0.5); } @@ -1163,11 +1157,11 @@ void GameStateDeckViewer::renderOnScreenMenu() font->DrawString(_("#"), 45 + leftTransition, posY - 16); // Horizontal table lines - r->DrawLine(27 + leftTransition, posY - 20, 75 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 20, + r->DrawLine(27 + leftTransition, posY - 20, 75 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 20, ARGB(128, 255, 255, 255)); - r->DrawLine(27 + leftTransition, posY - 1, 75 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 1, + r->DrawLine(27 + leftTransition, posY - 1, 75 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 1, ARGB(128, 255, 255, 255)); - r->DrawLine(27 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, 75 + (Constants::MTG_NB_COLORS - 2) + r->DrawLine(27 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, 75 + (Constants::NB_Colors - 2) * 15 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, ARGB(128, 255, 255, 255)); // Vertical table lines @@ -1177,8 +1171,8 @@ void GameStateDeckViewer::renderOnScreenMenu() ARGB(128, 255, 255, 255)); r->DrawLine(58 + leftTransition, posY - 20, 58 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, ARGB(128, 255, 255, 255)); - r->DrawLine(75 + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15, posY - 20, 75 + leftTransition - + (Constants::MTG_NB_COLORS - 2) * 15, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, + r->DrawLine(75 + leftTransition + (Constants::NB_Colors - 2) * 15, posY - 20, 75 + leftTransition + + (Constants::NB_Colors - 2) * 15, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, ARGB(128, 255, 255, 255)); for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++) @@ -1187,12 +1181,12 @@ void GameStateDeckViewer::renderOnScreenMenu() font->DrawString(buffer, 30 + leftTransition, posY); sprintf(buffer, ((*countPerCost)[i] > 0) ? _("%i").c_str() : ".", (*countPerCost)[i]); font->DrawString(buffer, 45 + leftTransition, posY); - for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++) + for (int j = 0; j < Constants::NB_Colors - 1; j++) { sprintf(buffer, ((*countPerCostAndColor)[i][j] > 0) ? _("%i").c_str() : ".", (*countPerCostAndColor)[i][j]); font->DrawString(buffer, 64 + leftTransition + j * 15, posY); } - r->FillRect(77.f + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15.0f, posY + 2.0f, (*countPerCost)[i] * 5.0f, + r->FillRect(77.f + leftTransition + (Constants::NB_Colors - 2) * 15.0f, posY + 2.0f, (*countPerCost)[i] * 5.0f, 8.0f, graphColor); posY += 10; } @@ -1257,7 +1251,7 @@ void GameStateDeckViewer::renderOnScreenMenu() font->DrawString(_("Total colored manasymbols in cards' casting costs:"), 20 + leftTransition, 30); posY = 50; - for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++) + for (int i = 1; i < Constants::NB_Colors - 1; i++) { if (stw->totalCostPerColor[i] > 0) { diff --git a/projects/mtg/src/GuiMana.cpp b/projects/mtg/src/GuiMana.cpp index 8c986a76b..89dd55db1 100644 --- a/projects/mtg/src/GuiMana.cpp +++ b/projects/mtg/src/GuiMana.cpp @@ -240,11 +240,12 @@ GuiMana::~GuiMana() void GuiMana::RenderStatic() { - int values[Constants::MTG_NB_COLORS]; + vector values; + values.resize(Constants::NB_Colors); int totalColors = 0; WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * r = JRenderer::GetInstance(); - for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) + for (int i = 0; i < Constants::NB_Colors; ++i) values[i] = 0; for (vector::iterator it = manas.begin(); it != manas.end(); ++it) if (ManaIcon::ALIVE == (*it)->mode) @@ -263,7 +264,7 @@ void GuiMana::RenderStatic() r->FillRoundRect(x0, y - 5, static_cast (20 * totalColors + 5), 20, 2, ARGB(128,0,0,0)); int offset = 0; - for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) + for (int i = 0; i < Constants::NB_Colors; ++i) { if (values[i]) { @@ -273,7 +274,7 @@ void GuiMana::RenderStatic() } r->FillRoundRect(x0, y, static_cast (20 * totalColors + 5), 8, 2, ARGB(100,0,0,0)); offset = 0; - for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) + for (int i = 0; i < Constants::NB_Colors; ++i) { if (values[i]) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 44579432d..3c629dc0c 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2983,7 +2983,10 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) case 1103: //Crystal Rod { - int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 }; + + std::vector cost; + cost.push_back(Constants::MTG_COLOR_ARTIFACT); + cost.push_back(1); ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_BLUE, NEW ManaCost(cost, 1), 1); observer->addObserver(ability); break; @@ -3015,7 +3018,10 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) } case 1113: //Iron Star { - int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 }; + + std::vector cost; + cost.push_back(Constants::MTG_COLOR_ARTIFACT); + cost.push_back(1); ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_RED, NEW ManaCost(cost, 1), 1); observer->addObserver(ability); break; @@ -3027,7 +3033,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) } case 1114: //Ivory cup { - int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 }; + std::vector cost; + cost.push_back(Constants::MTG_COLOR_ARTIFACT); + cost.push_back(1); ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_WHITE, NEW ManaCost(cost, 1), 1); observer->addObserver(ability); break; @@ -3100,7 +3108,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) case 1140: //Throne of Bone { - int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 }; + std::vector cost; + cost.push_back(Constants::MTG_COLOR_ARTIFACT); + cost.push_back(1); ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_BLACK, NEW ManaCost(cost, 1), 1); observer->addObserver(ability); break; @@ -3108,7 +3118,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell) case 1142: //Wooden Sphere { - int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 }; + std::vector cost; + cost.push_back(Constants::MTG_COLOR_ARTIFACT); + cost.push_back(1); ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_GREEN, NEW ManaCost(cost, 1), 1); observer->addObserver(ability); break; diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 9c97e0dba..0c90fa45b 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -308,8 +308,9 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi void MTGAllCards::initCounters() { - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) - colorsCount[i] = 0; + colorsCount.erase(colorsCount.begin(),colorsCount.end()); + for (int i = 0; i < Constants::NB_Colors; i++) + colorsCount.push_back(0); } void MTGAllCards::init() @@ -480,7 +481,7 @@ int MTGAllCards::countByColor(int color) { if (colorsCount[color] == 0) { - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { colorsCount[i] = 0; } @@ -811,8 +812,9 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c { if (howmany <= 0) return 1; - int unallowedColors[Constants::MTG_NB_COLORS + 1]; - for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) + vector unallowedColors; + unallowedColors.resize(Constants::NB_Colors + 1); + for (int i = 0; i < Constants::NB_Colors; ++i) { if (nbcolors) unallowedColors[i] = 1; @@ -854,7 +856,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c if (ok) { - for (int j = 0; j < Constants::MTG_NB_COLORS; ++j) + for (int j = 0; j < Constants::NB_Colors; ++j) { if (unallowedColors[j] && card->data->hasColor(j)) { diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 564a91168..3cc48f00f 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -5,7 +5,7 @@ using std::string; #include "MTGDefinitions.h" char Constants::MTGColorChars[] = {'x','g','u','r','b','w','l'}; -const char* Constants::MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"}; +vector Constants::MTGColorStrings; const string Constants::kManaColorless = "colorless"; const string Constants::kManaGreen = "green"; @@ -26,6 +26,8 @@ const string Constants::kRetraceKeyword = "retrace"; const string Constants::kKickerKeyword = "kicker"; const string Constants::kMorphKeyword = "facedown"; +int Constants::NB_Colors; //Store de Max number of colors + const char* Constants::MTGBasicAbilities[] = { "trample", "forestwalk", @@ -141,7 +143,7 @@ int Constants::GetBasicAbilityIndex(string basicAbllity) int Constants::GetColorStringIndex(string mtgColor) { - for (int idx = 0; idx < Constants::MTG_NB_COLORS; ++idx) + for (int idx = 0; idx < Constants::NB_Colors; ++idx) { if (Constants::MTGColorStrings[idx]) return idx; diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 2269448dd..d7a7efb6f 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -208,7 +208,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan } else { - for (int j = 0; j < Constants::MTG_NB_COLORS; j++) + for (int j = 0; j < Constants::NB_Colors; j++) { if (c == Constants::MTGColorChars[j]) { @@ -245,12 +245,12 @@ ManaCost::ManaCost() init(); } -ManaCost::ManaCost(int8_t _cost[], int nb_elems) +ManaCost::ManaCost(vector& _cost, int nb_elems) { init(); for (int i = 0; i < nb_elems; i++) { - cost[_cost[i * 2]] = _cost[i * 2 + 1]; + cost[_cost._Myfirst[i * 2]] = _cost._Myfirst[i * 2 + 1]; } } @@ -262,7 +262,7 @@ ManaCost::ManaCost(ManaCost * manaCost) init(); if ( !manaCost ) return; - for (int i = 0; i <= Constants::MTG_NB_COLORS; i++) + for (int i = 0; i <= Constants::NB_Colors; i++) { cost[i] = manaCost->getCost(i); } @@ -288,9 +288,9 @@ ManaCost::ManaCost(const ManaCost& manaCost) : InstanceCounter(manaCost) #endif { - for (int i = 0; i <= Constants::MTG_NB_COLORS; i++) + for (int i = 0; i <= Constants::NB_Colors; i++) { - cost[i] = manaCost.cost[i]; + cost.push_back(manaCost.cost[i]); } hybrids = manaCost.hybrids; @@ -312,7 +312,7 @@ ManaCost & ManaCost::operator= (const ManaCost & manaCost) { if ( this != &manaCost ) { - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) cost[i] = manaCost.cost[i]; hybrids = manaCost.hybrids; @@ -338,24 +338,27 @@ ManaCost::~ManaCost() SAFE_DELETE(Retrace); SAFE_DELETE(morph); SAFE_DELETE(suspend); + + cost.erase(cost.begin() ,cost.end()); } void ManaCost::x() { - cost[Constants::MTG_NB_COLORS] = 1; + cost[Constants::NB_Colors] = 1; } int ManaCost::hasX() { - return cost[Constants::MTG_NB_COLORS]; + return cost[Constants::NB_Colors]; } void ManaCost::init() { int i; - for (i = 0; i <= Constants::MTG_NB_COLORS; i++) + cost.erase(cost.begin(),cost.end()); + for (i = 0; i <= Constants::NB_Colors; i++) { - cost[i] = 0; + cost.push_back(0); } extraCosts = NULL; kicker = NULL; @@ -371,9 +374,12 @@ void ManaCost::init() void ManaCost::reinit() { int i; - for (i = 0; i <= Constants::MTG_NB_COLORS; i++) + + cost.erase(cost.begin() ,cost.end()); + + for (i = 0; i <= Constants::NB_Colors; i++) { - cost[i] = 0; + cost.push_back(0); } SAFE_DELETE(extraCosts); SAFE_DELETE(kicker); @@ -389,9 +395,12 @@ void ManaCost::copy(ManaCost * _manaCost) { if (!_manaCost) return; - for (unsigned int i = 0; i <= Constants::MTG_NB_COLORS; i++) + + cost.erase(cost.begin() ,cost.end()); + + for (int i = 0; i <= Constants::NB_Colors; i++) { - cost[i] = _manaCost->getCost(i); + cost.push_back(_manaCost->getCost(i)); } hybrids = _manaCost->hybrids; @@ -483,7 +492,7 @@ int ManaCost::isNull() int ManaCost::getConvertedCost() { int result = 0; - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for ( int i = 0; i < Constants::NB_Colors; i++) { result += cost[i]; } @@ -524,7 +533,7 @@ int ManaCost::add(ManaCost * _cost) { if (!_cost) return 0; - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for ( int i = 0; i < Constants::NB_Colors; i++) { cost[i] += _cost->getCost(i); } @@ -538,7 +547,7 @@ int ManaCost::remove(ManaCost * _cost) { if (!_cost) return 0; - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for ( int i = 0; i < Constants::NB_Colors; i++) { int8_t toRemove = min(cost[i], (int8_t)_cost->getCost(i)); //we don't want to be negative cost[i] -= toRemove; @@ -601,7 +610,7 @@ int ManaCost::pay(ManaCost * _cost) ManaCost * toPay = NEW ManaCost(); toPay->copy(_cost); ManaCost * diff = Diff(toPay); - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { cost[i] = diff->getCost(i); } @@ -626,10 +635,10 @@ int ManaCost::canAfford(ManaCost * _cost) int ManaCost::isPositive() { - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { - if (cost[i] < 0) + if (cost._Myfirst[i] < 0) { return 0; } @@ -638,7 +647,7 @@ int ManaCost::isPositive() } -void ManaCost::randomDiffHybrids(ManaCost * _cost, int8_t diff[]) +void ManaCost::randomDiffHybrids(ManaCost * _cost, std::vector& diff) { for (size_t i = 0; i < _cost->hybrids.size(); i++) { @@ -650,7 +659,7 @@ void ManaCost::randomDiffHybrids(ManaCost * _cost, int8_t diff[]) /** starting from the end of the array (diff) */ -int ManaCost::tryToPayHybrids(std::vector& _hybrids, int _nbhybrids, int8_t diff[]) +int ManaCost::tryToPayHybrids(std::vector& _hybrids, int _nbhybrids, std::vector& diff) { if (!_nbhybrids) return 1; @@ -681,12 +690,13 @@ ManaCost * ManaCost::Diff(ManaCost * _cost) if (!_cost) return NEW ManaCost(*this); //diff with null is equivalent to diff with 0 - int8_t diff[(Constants::MTG_NB_COLORS + 1) * 2]; - diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS; - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + vector diff; + diff.resize((Constants::NB_Colors + 1) * 2); + diff[Constants::NB_Colors * 2] = Constants::NB_Colors; + for (int i = 0; i < Constants::NB_Colors; i++) { diff[i * 2] = i; - diff[i * 2 + 1] = cost[i] - _cost->getCost(i); + diff[i * 2 + 1] = cost._Myfirst[i] - _cost->getCost(i); } int hybridResult = tryToPayHybrids(_cost->hybrids, _cost->hybrids.size(), diff); if (!hybridResult) @@ -696,7 +706,7 @@ ManaCost * ManaCost::Diff(ManaCost * _cost) int colorless_idx = Constants::MTG_COLOR_ARTIFACT * 2 + 1; if (diff[colorless_idx] < 0) { - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { if (diff[i * 2 + 1] > 0) { @@ -718,18 +728,18 @@ ManaCost * ManaCost::Diff(ManaCost * _cost) //Cost X if (_cost->hasX()) { - diff[Constants::MTG_NB_COLORS * 2 + 1] = 0; - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + diff[Constants::NB_Colors * 2 + 1] = 0; + for (int i = 0; i < Constants::NB_Colors; i++) { if (diff[i * 2 + 1] > 0) { - diff[Constants::MTG_NB_COLORS * 2 + 1] += diff[i * 2 + 1]; + diff[Constants::NB_Colors * 2 + 1] += diff[i * 2 + 1]; diff[i * 2 + 1] = 0; } } } - ManaCost * result = NEW ManaCost(diff, Constants::MTG_NB_COLORS + 1); + ManaCost * result = NEW ManaCost(diff, Constants::NB_Colors + 1); return result; } @@ -737,7 +747,7 @@ ManaCost * ManaCost::Diff(ManaCost * _cost) string ManaCost::toString() { ostringstream oss; - for (int i = 0; i <= Constants::MTG_NB_COLORS; i++) + for (int i = 0; i <= Constants::NB_Colors; i++) { if (cost[i]) { @@ -828,7 +838,7 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source) if (!_cost) return 0; int result = ManaCost::add(_cost); - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { for (int j = 0; j < _cost->getCost(i); j++) { @@ -841,14 +851,14 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source) int ManaPool::pay(ManaCost * _cost) { - int current[Constants::MTG_NB_COLORS]; - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + vector current; + for (int i = 0; i < Constants::NB_Colors; i++) { - current[i] = cost[i]; + current.push_back(cost[i]); } int result = ManaCost::pay(_cost); - for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { int value = current[i] - cost[i]; for (int j = 0; j < value; j++) @@ -858,5 +868,6 @@ int ManaPool::pay(ManaCost * _cost) } } + current.erase(current.begin(),current.end()); return result; } diff --git a/projects/mtg/src/ModRules.cpp b/projects/mtg/src/ModRules.cpp index 2a935bd48..da62f6d12 100644 --- a/projects/mtg/src/ModRules.cpp +++ b/projects/mtg/src/ModRules.cpp @@ -41,6 +41,10 @@ bool ModRules::load(string filename) { game.parse(element); } + else if (strcmp(element->Value(), "cardgui") == 0) + { + cardgui.parse(element); + } } } return true; @@ -277,3 +281,82 @@ ModRulesCards::~ModRulesCards() { SAFE_DELETE(activateEffect); } + +ModRulesBackGroundCardGuiItem::ModRulesBackGroundCardGuiItem(string ColorId,string ColorName, string DisplayImg, string DisplayThumb,string MenuIcon) +{ + mColorId = atoi(ColorId.c_str()); + MColorName = ColorName; + mDisplayImg = DisplayImg; + mDisplayThumb = DisplayThumb; + mMenuIcon = atoi(MenuIcon.c_str()); +} + +ModRulesRenderCardGuiItem::ModRulesRenderCardGuiItem(string Name, string PosX, string PosY, string FormattedData, string Type) +{ + mName = Name; + mPosX = atoi(PosX.c_str()); + mPosY = atoi(PosY.c_str()); + mFormattedData = FormattedData; + mType = Type; +} + +void ModRulesCardGui::parse(TiXmlElement* element) +{ + TiXmlNode* mainNode = element->FirstChild("background"); + if (mainNode) { + for (TiXmlNode* node = mainNode->ToElement()->FirstChild("card"); node; node = node->NextSibling("card")) + { + TiXmlElement* element = node->ToElement(); + { + background.push_back(NEW ModRulesBackGroundCardGuiItem( + element->Attribute("id"), + element->Attribute("color"), + element->Attribute("img"), + element->Attribute("thumb"), + element->Attribute("menuicon"))); + } + } + } + mainNode = element->FirstChild("renderbig"); + if (mainNode) { + for (TiXmlNode* node = mainNode->ToElement()->FirstChild("item"); node; node = node->NextSibling("item")) + { + TiXmlElement* element = node->ToElement(); + { + renderbig.push_back(NEW ModRulesRenderCardGuiItem( + element->Attribute("name"), + element->Attribute("posx"), + element->Attribute("posy"), + element->Attribute("formattedtext"), + element->Attribute("type"))); + } + } + } + mainNode = element->FirstChild("rendertinycrop"); + if (mainNode) { + for (TiXmlNode* node = mainNode->ToElement()->FirstChild("item"); node; node = node->NextSibling("item")) + { + TiXmlElement* element = node->ToElement(); + { + renderbig.push_back(NEW ModRulesRenderCardGuiItem( + element->Attribute("name"), + element->Attribute("posx"), + element->Attribute("posy"), + element->Attribute("formattedtext"), + element->Attribute("type"))); + } + } + } +} + +ModRulesCardGui::~ModRulesCardGui() +{ + for (size_t i = 0; i < background.size(); ++i) + SAFE_DELETE(background[i]); + for (size_t i = 0; i < renderbig.size(); ++i) + SAFE_DELETE(renderbig[i]); + + background.clear(); + renderbig.clear(); + +} diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index cb66c2aea..82e570bf7 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -552,7 +552,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta { int attributefound = 0; //Colors - remove Artifact and Land from the loop - for (int cid = 1; cid < Constants::MTG_NB_COLORS - 1; cid++) + for (int cid = 1; cid < Constants::NB_Colors - 1; cid++) { if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos) { diff --git a/projects/mtg/src/Tasks.cpp b/projects/mtg/src/Tasks.cpp index f586fcf7d..674fea6c5 100644 --- a/projects/mtg/src/Tasks.cpp +++ b/projects/mtg/src/Tasks.cpp @@ -950,7 +950,7 @@ void TaskMassiveBurial::restoreCustomAttribs() void TaskMassiveBurial::randomize() { - color = rand() % (Constants::MTG_NB_COLORS - 1) + 1; + color = rand() % (Constants::NB_Colors - 1) + 1; bodyCount = 5 + ((Constants::MTG_COLOR_LAND == color) ? rand() % 10 : rand() % 20); Task::randomize(); } @@ -1044,7 +1044,7 @@ void TaskWisdom::restoreCustomAttribs() void TaskWisdom::randomize() { - color = rand() % (Constants::MTG_NB_COLORS - 1) + 1; + color = rand() % (Constants::NB_Colors - 1) + 1; cardCount = 2 + ((Constants::MTG_COLOR_LAND == color) ? rand() % 5 : rand() % 7); Task::randomize(); } diff --git a/projects/mtg/src/WFilter.cpp b/projects/mtg/src/WFilter.cpp index a67b5b379..0b3d96e4e 100644 --- a/projects/mtg/src/WFilter.cpp +++ b/projects/mtg/src/WFilter.cpp @@ -218,7 +218,7 @@ string WCFilterColor::getCode() { char buf[12]; char c = '?'; - if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color]; + if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color]; sprintf(buf, "color:%c;", c); return buf; } @@ -227,7 +227,7 @@ WCFilterColor::WCFilterColor(string arg) { color = -1; char c = tolower(arg[0]); - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { if (Constants::MTGColorChars[i] == c) { @@ -240,7 +240,7 @@ WCFilterColor::WCFilterColor(string arg) bool WCFilterOnlyColor::isMatch(MTGCard * c) { if (!c || !c->data) return false; - for (int i = 0; i < Constants::MTG_NB_COLORS; i++) + for (int i = 0; i < Constants::NB_Colors; i++) { if (i == color) continue; if (c->data->hasColor(i)) return false; @@ -251,7 +251,7 @@ string WCFilterOnlyColor::getCode() { char buf[12]; char c = '?'; - if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color]; + if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color]; sprintf(buf, "xcolor:%c;", c); return buf; } @@ -290,7 +290,7 @@ string WCFilterProducesColor::getCode() { char buf[12]; char c = '?'; - if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color]; + if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color]; sprintf(buf, "produces:%c;", c); return buf; } diff --git a/projects/mtg/src/WFont.cpp b/projects/mtg/src/WFont.cpp index c40c775c6..e8fd26481 100644 --- a/projects/mtg/src/WFont.cpp +++ b/projects/mtg/src/WFont.cpp @@ -516,7 +516,7 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO mRenderer->RenderQuad(manaIcons[mana].get(), xx + 3 * sinf(2 * M_PI * ((float) t) / 256.0f), yy + 3 * cosf(2 * M_PI * ((float) (t - 35)) / 256.0f), 0, 0.5f * mScale, 0.5f * mScale); } - mana = Constants::MTG_NB_COLORS + 1; // do not draw colorless cost in hybrid mana cost + mana = Constants::NB_Colors + 1; // do not draw colorless cost in hybrid mana cost } else mRenderer->RenderQuad(manaIcons[mana].get(), xx, yy, 0, 0.5f * mScale, 0.5f * mScale); @@ -935,7 +935,7 @@ void WGBKFont::DrawString(const char *s, float x, float y, int align, float left mRenderer->RenderQuad(manaIcons[mana].get(), xx + 3 * sinf(2 * M_PI * ((float) t) / 256.0f), yy + 3 * cosf(2 * M_PI * ((float) (t - 35)) / 256.0f), 0, 0.5f * mScale, 0.5f * mScale); } - mana = Constants::MTG_NB_COLORS + 1; // donot draw colorless cost in hybrid mana cost + mana = Constants::NB_Colors + 1; // donot draw colorless cost in hybrid mana cost } else mRenderer->RenderQuad(manaIcons[mana].get(), xx, yy, 0, 0.5f * mScale, 0.5f * mScale); diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index fef1e8b79..d608fe266 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -1686,7 +1686,7 @@ bool WGuiFilters::Finish(bool emptyset) { WCFilterFactory * wc = WCFilterFactory::GetInstance(); WCardFilter * f = wc->Construct(src); - if (recolorTo > -1 && recolorTo < Constants::MTG_NB_COLORS) + if (recolorTo > -1 && recolorTo < Constants::NB_Colors) { f = NEW WCFilterAND(f, NEW WCFilterColor(recolorTo)); } @@ -1694,7 +1694,7 @@ bool WGuiFilters::Finish(bool emptyset) } else { - if (recolorTo > -1 && recolorTo < Constants::MTG_NB_COLORS) + if (recolorTo > -1 && recolorTo < Constants::NB_Colors) { WCardFilter * f = NEW WCFilterColor(recolorTo); source->addFilter(f);