Fixed primitives, improved background images management, now it's possbile to add a different background for opponent deck choosing (menupanel2.jpg) and added a new sub-folder "background" for custom themes where it will be possbile to store up to six new background images for battlefield (from "backdrop1.jpg" to "backdrop6.jpg") that will be randomly choosen when match starts.

This commit is contained in:
Vittorio Alfieri
2021-09-20 15:36:42 +02:00
parent e2a1705b3f
commit 832d033488
8 changed files with 46 additions and 16 deletions
+17 -5
View File
@@ -5,9 +5,10 @@
#include "GameObserver.h"
#include "Rules.h"
const std::string kBackdropFile = "backdrop.jpg";
const std::string kBackdropFrameFile = "backdropframe.png";
const std::string kPspBackdropFile = "pspbackdrop.jpg";
static std::string kBackdropFile = "";
static std::string kBackdropFrameFile = "backdropframe.png";
static std::string kPspBackdropFile = "pspbackdrop.jpg";
static std::string kPspBackdropFrameFile = "pspbackdropframe.png";
GuiBackground::GuiBackground(GameObserver* observer)
: GuiLayer(observer)
@@ -22,7 +23,11 @@ void GuiBackground::Render()
{
JRenderer* renderer = JRenderer::GetInstance();
JQuadPtr quad;
#if !defined (PSP)
JQuadPtr quadframe = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFrameFile);
#else
JQuadPtr quadframe = WResourceManager::Instance()->RetrieveTempQuad(kPspBackdropFrameFile);
#endif
if (observer && observer->mRules && observer->mRules->bg.size())
{
quad = WResourceManager::Instance()->RetrieveTempQuad(observer->mRules->bg);
@@ -30,6 +35,15 @@ void GuiBackground::Render()
if (!quad.get())
{
#if !defined (PSP)
//Now it's possibile to randomly use up to 6 new background images for match (if random index is 0, it will be rendered the default "backdrop.jpg" image).
if(kBackdropFile == ""){
char temp[4096];
sprintf(temp, "background/backdrop%i.jpg", std::rand() % 7);
kBackdropFile.assign(temp);
quad = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFile);
if (!quad.get())
kBackdropFile = "backdrop.jpg"; //Fallback to default background image for match.
}
quad = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFile);
#else
quad = WResourceManager::Instance()->RetrieveTempQuad(kPspBackdropFile);
@@ -39,10 +53,8 @@ void GuiBackground::Render()
{
renderer->RenderQuad(quad.get(), 0, 0, 0, SCREEN_WIDTH_F / quad->mWidth, SCREEN_HEIGHT_F / quad->mHeight);
}
#if !defined (PSP)
if (quadframe.get())
{
renderer->RenderQuad(quadframe.get(), 0, 0, 0, SCREEN_WIDTH_F / quadframe->mWidth, SCREEN_HEIGHT_F / quadframe->mHeight);
}
#endif
}