diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 8878d6b8b..688935c57 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -886,14 +886,15 @@ public: JQuad * mBg[9]; bool mUserCloseRequest, mDontShow; bool mIsImage; + int mLimit; - ATutorialMessage(MTGCardInstance * source, string message); + ATutorialMessage(MTGCardInstance * source, string message, int limit = 1); void Update(float dt); bool CheckUserInput(JButton key); void Render(); string getOptionName(); - bool alreadyShown(); + int alreadyShown(); ATutorialMessage * clone() const; ~ATutorialMessage(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index be94518d3..f6449cee7 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -3616,7 +3616,7 @@ ABlinkGeneric::~ABlinkGeneric() ATutorialMessage * ATutorialMessage::Current = NULL; -ATutorialMessage::ATutorialMessage(MTGCardInstance * source, string message) : MTGAbility(0, source), IconButtonsController(0, 0) +ATutorialMessage::ATutorialMessage(MTGCardInstance * source, string message, int limit) : MTGAbility(0, source), IconButtonsController(0, 0), mLimit(limit) { mBgTex = NULL; @@ -3649,7 +3649,7 @@ ATutorialMessage::ATutorialMessage(MTGCardInstance * source, string message) : M mX = 0; mY = -SCREEN_HEIGHT_F - 0.1f; //Offscreen } - mDontShow = mUserCloseRequest = alreadyShown(); + mDontShow = mUserCloseRequest = (mLimit > 0) && (alreadyShown() >= mLimit); if(mDontShow) forceDestroy = 1; @@ -3664,9 +3664,9 @@ string ATutorialMessage::getOptionName() return out.str(); } -bool ATutorialMessage::alreadyShown() +int ATutorialMessage::alreadyShown() { - return options[getOptionName()].number ? true : false; + return options[getOptionName()].number; } bool ATutorialMessage::CheckUserInput(JButton key) @@ -3726,8 +3726,12 @@ void ATutorialMessage::Update(float dt) void ATutorialMessage::ButtonPressed(int controllerId, int controlId) { //TODO : cancel ALL tips/tutorials for JGE_BTN_SEC? - options[getOptionName()].number = 1; - options.save(); //TODO: if we experience I/O slowness in tutorials, move this save at the end of a turn, or at the end of the game. + if (mLimit) + { + string optionName = getOptionName(); + options[optionName].number = options[optionName].number + 1; + options.save(); //TODO: if we experience I/O slowness in tutorials, move this save at the end of a turn, or at the end of the game. + } mElapsed = 0; mUserCloseRequest = true; } @@ -3876,7 +3880,7 @@ void ATutorialMessage::Render() ATutorialMessage * ATutorialMessage::clone() const { ATutorialMessage * copy = NEW ATutorialMessage(*this); - copy->mUserCloseRequest = copy->alreadyShown(); + copy->mUserCloseRequest = (copy->alreadyShown() > 0); return copy; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index cab069c6e..4a3fe5e89 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -737,11 +737,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG //This one is not a real ability, it displays a message on the screen. We use this for tutorials // Triggers need to be checked above this one, as events are usuallly what will trigger (...) these messages - vector splitMsg = parseBetween(s, "tutorial(", ")"); - if (splitMsg.size()) { - string msg = splitMsg[1]; - return NEW ATutorialMessage(card, msg); + vector splitMsg = parseBetween(s, "tutorial(", ")"); + if (splitMsg.size()) + { + string msg = splitMsg[1]; + return NEW ATutorialMessage(card, msg); + } + + splitMsg = parseBetween(s, "message(", ")"); + if (splitMsg.size()) + { + string msg = splitMsg[1]; + return NEW ATutorialMessage(card, msg, 0); + } } int restrictions = parseRestriction(s);