Fixed primitives, improved background images management for game settings, deck selection, deck editor background, post-match credits, deck editor selection and trophies room (now it's possibile to randomly use up to 3 background images and if the chosen image is not available, it will be rendered the default one).

This commit is contained in:
Vittorio Alfieri
2021-11-14 14:24:27 +01:00
parent 96f7072a77
commit c55c9c2507
9 changed files with 144 additions and 19 deletions
+24 -2
View File
@@ -142,6 +142,8 @@ void CreditBonus::Render(float x, float y, WFont * font)
font->DrawString(buffer, x, y);
}
static std::string kBgFile = "";
Credits::Credits()
{
unlocked = -1;
@@ -163,6 +165,7 @@ Credits::~Credits()
if (bonus[i])
delete bonus[i];
bonus.clear();
kBgFile = ""; //Reset the chosen backgorund.
}
void Credits::compute(GameObserver* g, GameApp * _app)
@@ -514,10 +517,29 @@ void Credits::Render()
return;
JRenderer * r = JRenderer::GetInstance();
#if !defined (PSP)
JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture("bgdeckeditor.jpg");
//Now it's possibile to randomly use up to 3 background images for post-match credits (if random index is 0, it will be rendered the default "bgdeckeditor.jpg" image).
JTexture * wpTex = NULL;
if(kBgFile == ""){
char temp[4096];
sprintf(temp, "bgdeckeditor%i.jpg", std::rand() % 3);
kBgFile.assign(temp);
wpTex = WResourceManager::Instance()->RetrieveTexture(kBgFile);
if (wpTex) {
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad(kBgFile);
if (wpQuad.get())
r->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
else {
kBgFile = "bgdeckeditor.jpg"; //Fallback to default background image for post-match credits.
wpTex = NULL;
}
} else
kBgFile = "bgdeckeditor.jpg"; //Fallback to default background image for post-match credits.
}
if(!wpTex)
wpTex = WResourceManager::Instance()->RetrieveTexture(kBgFile);
if (wpTex)
{
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad("bgdeckeditor.jpg");
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad(kBgFile);
r->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}
#else