Merge pull request #940 from kevlahnota/master

Booster Shop
This commit is contained in:
Anthony Calosa
2017-02-24 22:21:22 +08:00
committed by GitHub
7 changed files with 85 additions and 27 deletions

View File

@@ -165,7 +165,7 @@ typedef uint32_t u32;
#if defined (ABGR8888)
#ifndef ARGB
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (r << 16) | (g << 8) | b) // macro to assemble pixels in correct format
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (b << 16) | (g << 8) | r) // macro to assemble pixels in correct format
#endif
#define MAKE_COLOR(a, c) (a << 24 | c)
#define MASK_ALPHA 0xFF000000 // masks for accessing individual pixels

View File

@@ -23,7 +23,7 @@ public:
void rotateRight();
bool CheckUserInput(JButton key);
virtual void Update(float dt);
void Render();
void Render(bool norect = false);
void init(MTGGameZone * zone);
virtual ostream& toString(ostream& out) const;
};

View File

@@ -98,7 +98,7 @@ public:
int has(int ability);
void setText(const string& value);
const vector<string>& getFormattedText();
const vector<string>& getFormattedText(bool noremove = false);
void addMagicText(string value);
void addMagicText(string value, string zone);

View File

@@ -234,11 +234,34 @@ bool CardDisplay::CheckUserInput(JButton key)
return false;
}
void CardDisplay::Render()
void CardDisplay::Render(bool norect)
{
//norect - code shop
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
r->DrawRect(static_cast<float> (x), static_cast<float> (y), static_cast<float> (nb_displayed_items * 30 + 20), 50,
//if(norect)
// r->FillRect(0,0,SCREEN_WIDTH_F,SCREEN_HEIGHT_F,ARGB(180,5,5,5));
if(norect)
{
//info
r->FillRect(static_cast<float> (x), static_cast<float> (10), static_cast<float> (nb_displayed_items * 30 + 20), 192,
ARGB(200,5,5,5));
r->DrawRect(static_cast<float> (x), static_cast<float> (10), static_cast<float> (nb_displayed_items * 30 + 20), 192,
ARGB(255,240,240,240));
r->DrawRect(static_cast<float> (x)+1, static_cast<float> (10)+1, static_cast<float> (nb_displayed_items * 30 + 20)-2, 192-2,
ARGB(255,89,89,89));
//navi
r->FillRect(static_cast<float> (x), static_cast<float> (y), static_cast<float> (nb_displayed_items * 30 + 20), 50,
ARGB(200,5,5,5));
r->DrawRect(static_cast<float> (x), static_cast<float> (y), static_cast<float> (nb_displayed_items * 30 + 20), 50,
ARGB(255,240,240,240));
r->DrawRect(static_cast<float> (x)+1, static_cast<float> (y)+1, static_cast<float> (nb_displayed_items * 30 + 20)-2, 50-2,
ARGB(255,89,89,89));
}
else
r->DrawRect(static_cast<float> (x), static_cast<float> (y), static_cast<float> (nb_displayed_items * 30 + 20), 50,
ARGB(255,255,255,255));
if (!mObjects.size()) return;
for (int i = start_item; i < start_item + nb_displayed_items && i < (int)(mObjects.size()); i++)
@@ -268,6 +291,10 @@ void CardDisplay::Render()
CardGui * cardg = ((CardGui *) mObjects[mCurr]);
//Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 1.0, 0.0, 220);
Pos pos = Pos((CardGui::BigWidth / 2), CardGui::BigHeight / 2 - 10, 0.80f, 0.0, 220);
if(norect)
pos = Pos((CardGui::BigWidth / 2), CardGui::BigHeight / 2 - 7, 1.0, 0.0, 220);
int drawMode = DrawMode::kNormal;
if (observer)
{
@@ -276,7 +303,23 @@ void CardDisplay::Render()
if (x < (CardGui::BigWidth / 2)) pos.actX = SCREEN_WIDTH - 10 - CardGui::BigWidth / 2;
drawMode = observer->getCardSelector()->GetDrawMode();
}
if(norect)
{
mFont->SetColor(ARGB(255,240,230,140));
mFont->SetScale(1.5f);
mFont->DrawString(cardg->card->data->name.c_str(),SCREEN_WIDTH_F/2,20);
mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(1.0f);
string details = "";
std::vector<string> txt = cardg->card->data->getFormattedText(true);
for (std::vector<string>::const_iterator it = txt.begin(); it != txt.end(); ++it)
{
details.append("\n");
details.append(it->c_str());
}
mFont->DrawString(details.c_str(),SCREEN_WIDTH_F/2,25);
}
cardg->DrawCard(pos, drawMode);
}
}

View File

@@ -254,11 +254,17 @@ void CardGui::Render()
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
if(fakeborder)
{
if((card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO))||
((card->has(Constants::CANPLAYFROMGRAVEYARD) || card->has(Constants::TEMPFLASHBACK) || card->getManaCost()->getFlashback()) && game->isInGrave(card)))
fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border
if(game)
{
if((card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO))||
((card->has(Constants::CANPLAYFROMGRAVEYARD) || card->has(Constants::TEMPFLASHBACK) || card->getManaCost()->getFlashback()) && game->isInGrave(card)))
fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border
else
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
}
else
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16);
}
//draw border for highlighting
@@ -530,18 +536,22 @@ void CardGui::Render()
}
//for necro
if (!shadow)
shadow = card->getObserver()->getResourceManager()->GetQuad("shadow");
if (shadow)
if(game)
{
int myA = 0;
if(game && card->has(Constants::NECROED))//no peeking...
myA = 255;
else
myA = 0;
if (!shadow)
shadow = card->getObserver()->getResourceManager()->GetQuad("shadow");
if (shadow)
{
int myA = 0;
if(game && card->has(Constants::NECROED))//no peeking...
myA = 255;
else
myA = 0;
shadow->SetColor(ARGB(myA,255,255,255));
renderer->RenderQuad(shadow.get(), actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16);
shadow->SetColor(ARGB(myA,255,255,255));
if(myA > 0)
renderer->RenderQuad(shadow.get(), actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16);
}
}
PlayGuiObject::Render();

View File

@@ -298,16 +298,19 @@ void CardPrimitive::setText(const string& value)
* Instead, we format when requested, but only once, and cache the result.
* To avoid memory to blow up, in exchange of the cached result, we erase the original string
*/
const vector<string>& CardPrimitive::getFormattedText()
const vector<string>& CardPrimitive::getFormattedText(bool noremove)
{
if (!text.size())
return formattedText;
std::string::size_type found = text.find_first_of("{}");
while (found != string::npos)
if(!noremove)
{
text[found] = '/';
found = text.find_first_of("{}", found + 1);
while (found != string::npos)
{
text[found] = '/';
found = text.find_first_of("{}", found + 1);
}
}
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT);
mFont->FormatText(text, formattedText);

View File

@@ -308,7 +308,7 @@ void GameStateShop::purchaseBooster(int controlId)
SAFE_DELETE(booster);
deleteDisplay();
booster = NEW MTGDeck(MTGCollection());
boosterDisplay = NEW BoosterDisplay(12, NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT / 2, this, NULL, 5);
boosterDisplay = NEW BoosterDisplay(12, NULL, SCREEN_WIDTH - 255, SCREEN_HEIGHT-65, this, NULL, 7);
mBooster[controlId].addToDeck(booster, srcCards);
string sort = mBooster[controlId].getSort();
@@ -726,7 +726,7 @@ void GameStateShop::Render()
else
{
if (boosterDisplay)
boosterDisplay->Render();
boosterDisplay->Render(true);
else if (bigDisplay)
{
if (bigDisplay->mOffset.getPos() >= 0)
@@ -743,7 +743,9 @@ void GameStateShop::Render()
{
alpha = static_cast<int> (800 * (elp - LIST_FADEIN));
}
r->FillRoundRect(300, 10, 160, SHOP_SLOTS * 20 + 15, 5, ARGB(alpha,0,0,0));
//r->FillRoundRect(300, 10, 160, SHOP_SLOTS * 20 + 15, 5, ARGB(alpha,0,0,0));
r->FillRect(297, 9.5f, 175, SHOP_SLOTS * 20 + 31, ARGB(alpha,0,0,0));
r->DrawRect(297, 9.5f, 175, SHOP_SLOTS * 20 + 31, ARGB(alpha,20,20,20));
alpha += 55;
for (int i = 0; i < SHOP_SLOTS; i++)
{
@@ -788,7 +790,7 @@ void GameStateShop::Render()
if (menu)
menu->Render();
if (!filterMenu || (filterMenu && filterMenu->isFinished()))
if ((!filterMenu || (filterMenu && filterMenu->isFinished()))&&!boosterDisplay)
renderButtons();
}