Skip to content

Commit

Permalink
Fixed primitives, improved background images management for game sett…
Browse files Browse the repository at this point in the history
…ings, 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).
  • Loading branch information
Vitty85 committed Nov 14, 2021
1 parent 96f7072 commit c55c9c2
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 19 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

## [master] (https://github.com/WagicProject/wagic/tree/master)

### 14/11/21
- *Committed:* 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). ([Vitty85](https://github.com/Vitty85))

- *Committed:* Fixed primitives, several bugs and crashes. https://github.com/WagicProject/wagic/commit/96f7072a77f566718fc49c2bfe3b0b192452faf6 ([EduardoMunozGomez](https://github.com/EduardoMunozGomez))

### 13/11/21
- *Committed:* Fixed VOW set, added new AI deck, improved Android downloader for VOC and VOW sets. ([Vitty85](https://github.com/Vitty85))
- *Committed:* Fixed VOW set, added new AI deck, improved Android downloader for VOC and VOW sets. https://github.com/WagicProject/wagic/commit/9957719e0c3e2467fd12039c213d54f151664fdd ([Vitty85](https://github.com/Vitty85))

### 11/11/21
- *Committed:* Fixed VOW and VOC sets, improved Android downloader for VOC and VOW sets. https://github.com/WagicProject/wagic/commit/8b91048d124be38bbb845c47c00857ce5a32cdac ([Vitty85](https://github.com/Vitty85))
Expand Down
6 changes: 3 additions & 3 deletions projects/mtg/bin/Res/sets/primitives/mtg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53740,8 +53740,8 @@ toughness=0
[card]
name=Helix Pinnacle
abilities=shroud
auto={X}:thisforeach(X) all(this) counter(0/0,1,Tower)
auto=@each my upkeep restriction{{type(helix pinnacle[counter{0/0.100.Tower}]|myBattlefield)~morethan~0}}:winGame
auto={X}:name(Put X counters) thisforeach(X) all(this) counter(0/0,1,Tower)
auto=@each my upkeep restriction{compare(hascnttower)~morethan~99}:name(You win the game) winGame controller
text=Shroud -- {X}: Put X tower counters on Helix Pinnacle. -- At the beginning of your upkeep, if there are 100 or more tower counters on Helix Pinnacle, you win the game.
mana={G}
type=Enchantment
Expand Down Expand Up @@ -125390,7 +125390,7 @@ toughness=6
[card]
name=Ulrich's Kindred
abilities=trample
auto={3}{G}:target(*[wolf;werewolf;attacking]) indestructible ueot
auto={3}{G}:name(Gains indestructible) target(*[wolf;werewolf;attacking]) indestructible ueot
text=Trample -- {3}{G}: Target attacking Wolf or Werewolf gains indestructible until end of turn.
mana={2}{R}
type=Creature
Expand Down
26 changes: 24 additions & 2 deletions projects/mtg/src/Credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions projects/mtg/src/DeckEditorMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const string& _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{
#if !defined (PSP)
//Now it's possibile to randomly use up to 3 background images for deck editor selection (if random index is 0, it will be rendered the default "menubgdeckeditor.jpg" image).
ostringstream bgFilename;
char temp[4096];
sprintf(temp, "menubgdeckeditor%i", std::rand() % 3);
backgroundName.assign(temp);
bgFilename << backgroundName << ".jpg";
JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
if (!background.get()){
backgroundName = "menubgdeckeditor"; //Fallback to default background image for deck editor selection.
}
#else
backgroundName = "menubgdeckeditor";
#endif

mShowDetailsScreen = false;
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";

Expand Down
2 changes: 1 addition & 1 deletion projects/mtg/src/DeckMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void DeckMenu::RenderBackground()
{
ostringstream bgFilename;
#if !defined (PSP)
if(backgroundName == "menubgdeckeditor")
if(backgroundName.find("menubgdeckeditor") != string::npos) //Now it's possibile to randomly use up to 3 background images for deck editor selection.
bgFilename << backgroundName << ".jpg";
else
bgFilename << backgroundName << ".png";
Expand Down
19 changes: 17 additions & 2 deletions projects/mtg/src/GameStateAwards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace GameStateAwardsConst
const int kBackToMainMenuID = 1;
}

static std::string kAwardFile = "";

GameStateAwards::GameStateAwards(GameApp* parent) :
GameState(parent, "trophies")
{
Expand All @@ -35,7 +37,7 @@ GameStateAwards::GameStateAwards(GameApp* parent) :

GameStateAwards::~GameStateAwards()
{

kAwardFile = ""; //Reset the chosen backgorund.
}

void GameStateAwards::End()
Expand All @@ -47,6 +49,8 @@ void GameStateAwards::End()

if (saveMe)
options.save();

kAwardFile = ""; //Reset the chosen backgorund.
}
void GameStateAwards::Start()
{
Expand Down Expand Up @@ -168,7 +172,18 @@ void GameStateAwards::Render()
#if defined (PSP)
JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad("pspawardback.jpg", TEXTURE_SUB_5551);
#else
JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad("awardback.jpg", TEXTURE_SUB_5551);
//Now it's possibile to randomly use up to 3 background images for trophies room (if random index is 0, it will be rendered the default "awardback.jpg" image).
JQuadPtr background;
if(kAwardFile == ""){
char temp[4096];
sprintf(temp, "awardback%i.jpg", std::rand() % 3);
kAwardFile.assign(temp);
JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad(kAwardFile);
if (!background.get())
kAwardFile = "awardback.jpg"; //Fallback to default background image for trophies room.
}
background = WResourceManager::Instance()->RetrieveTempQuad(kAwardFile, TEXTURE_SUB_5551);
//JQuadPtr background = WResourceManager::Instance()->RetrieveTempQuad("awardback.jpg", TEXTURE_SUB_5551);
#endif

if (background.get())
Expand Down
35 changes: 29 additions & 6 deletions projects/mtg/src/GameStateDeckViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#define NO_USER_ACTIVITY_HELP_DELAY 10

static std::string kBgFile = "";

GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
GameState(parent, "deckeditor"), mView(NULL), mCurrentView(CAROUSEL_VIEW)
{
Expand Down Expand Up @@ -102,6 +104,7 @@ GameStateDeckViewer::~GameStateDeckViewer()
SAFE_DELETE(myCollection);
}
SAFE_DELETE(filterMenu);
kBgFile = ""; //Reset the chosen backgorund.
}

void GameStateDeckViewer::rebuildFilters()
Expand Down Expand Up @@ -303,6 +306,7 @@ void GameStateDeckViewer::End()
SAFE_DELETE(playerdata);
SAFE_DELETE(filterMenu);
SAFE_DELETE(source);
kBgFile = ""; //Reset the chosen backgorund.
}

void GameStateDeckViewer::addRemove(MTGCard * card)
Expand Down Expand Up @@ -1570,22 +1574,41 @@ void GameStateDeckViewer::Render()
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
#if !defined (PSP)
JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture("bgdeckeditor.jpg");
//Now it's possibile to randomly use up to 3 background images for deck editor background (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())
JRenderer::GetInstance()->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 deck editor background.
wpTex = NULL;
}
} else
kBgFile = "bgdeckeditor.jpg"; //Fallback to default background image for deck editor background.
}
if(!wpTex)
wpTex = WResourceManager::Instance()->RetrieveTexture(kBgFile);
if (wpTex)
{
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad("bgdeckeditor.jpg");
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad(kBgFile);
JRenderer::GetInstance()->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}/*
if (mView->deck() == myDeck && mStage != STAGE_MENU)
}
/*if (mView->deck() == myDeck && mStage != STAGE_MENU)
renderDeckBackground();*/
#else
JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture("pspbgdeckeditor.jpg");
if (wpTex)
{
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad("pspbgdeckeditor.jpg");
JRenderer::GetInstance()->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}/*
if (mView->deck() == myDeck && mStage != STAGE_MENU)
}
/*if (mView->deck() == myDeck && mStage != STAGE_MENU)
renderDeckBackground();*/
#endif
mView->Render();
Expand Down
26 changes: 24 additions & 2 deletions projects/mtg/src/GameStateDuel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ enum ENUM_OPERATION_LEVELS

int GameStateDuel::selectedPlayerDeckId = 0;
int GameStateDuel::selectedAIDeckId = 0;
static std::string kBgFile = "";

GameStateDuel::GameStateDuel(GameApp* parent) :
GameState(parent, "duel")
Expand Down Expand Up @@ -181,6 +182,7 @@ GameStateDuel::~GameStateDuel()
{
End();
SAFE_DELETE(tournament);
kBgFile = ""; //Reset the chosen backgorund.
}

void GameStateDuel::Start()
Expand Down Expand Up @@ -370,6 +372,7 @@ void GameStateDuel::End()
#endif

MTGAbility::deletedpointers.clear(); // Clear the list of deallocated pointer.
kBgFile = ""; //Reset the chosen backgorund.
}

//TODO Move This to utils or ResourceManager. Don't we have more generic functions that can do that?
Expand Down Expand Up @@ -1084,10 +1087,29 @@ void GameStateDuel::Render()
JRenderer::GetInstance()->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}
#else
JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture("bgdeckeditor.jpg");
//Now it's possibile to randomly use up to 3 background images for deck selection (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())
JRenderer::GetInstance()->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 deck selection.
wpTex = NULL;
}
} else
kBgFile = "bgdeckeditor.jpg"; //Fallback to default background image for deck selection.
}
if(!wpTex)
wpTex = WResourceManager::Instance()->RetrieveTexture(kBgFile);
if (wpTex)
{
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad("bgdeckeditor.jpg");
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad(kBgFile);
JRenderer::GetInstance()->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}
#endif
Expand Down
28 changes: 26 additions & 2 deletions projects/mtg/src/GameStateOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ namespace GameStateOptionsConst
const int kReloadID = 5;
}

static std::string kBgFile = "";

GameStateOptions::GameStateOptions(GameApp* parent) :
GameState(parent, "options"), mReload(false), grabber(NULL), optionsMenu(NULL), optionsTabs(NULL)
{
}

GameStateOptions::~GameStateOptions()
{
kBgFile = ""; //Reset the chosen backgorund.
}

void GameStateOptions::Start()
Expand Down Expand Up @@ -153,6 +157,7 @@ void GameStateOptions::End()
JRenderer::GetInstance()->EnableVSync(false);
SAFE_DELETE(optionsTabs);
SAFE_DELETE(optionsMenu);
kBgFile = ""; //Reset the chosen backgorund.
}

void GameStateOptions::Update(float dt)
Expand Down Expand Up @@ -237,10 +242,29 @@ void GameStateOptions::Render()
//Erase
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
#if !defined (PSP)
JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture("bgdeckeditor.jpg");
//Now it's possibile to randomly use up to 3 background images for game settings (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())
JRenderer::GetInstance()->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 game settings.
wpTex = NULL;
}
} else
kBgFile = "bgdeckeditor.jpg"; //Fallback to default background image for game settings.
}
if(!wpTex)
wpTex = WResourceManager::Instance()->RetrieveTexture(kBgFile);
if (wpTex)
{
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad("bgdeckeditor.jpg");
JQuadPtr wpQuad = WResourceManager::Instance()->RetrieveTempQuad(kBgFile);
JRenderer::GetInstance()->RenderQuad(wpQuad.get(), 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}
#else
Expand Down

0 comments on commit c55c9c2

Please sign in to comment.