diff --git a/projects/mtg/include/WResourceManager.h b/projects/mtg/include/WResourceManager.h index b9656aa80..de6fe7d92 100644 --- a/projects/mtg/include/WResourceManager.h +++ b/projects/mtg/include/WResourceManager.h @@ -130,8 +130,23 @@ struct WManagedQuad class WResourceManager: public JResourceManager { public: - WResourceManager(); - ~WResourceManager(); + static WResourceManager* Instance() + { + if (sInstance == NULL) + { + sInstance = NEW WResourceManager; + } + + return sInstance; + } + + static void Terminate() + { + if (sInstance) + SAFE_DELETE(sInstance); + } + + virtual ~WResourceManager(); void Unmiss(string filename); JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL); @@ -200,7 +215,12 @@ public: string debugMessage; #endif -private: +private: + /* + ** Singleton object only accessibly via Instance(), constructor is private + */ + WResourceManager(); + bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards? void FlattenTimes(); //To prevent bad cache timing on int overflow @@ -222,7 +242,8 @@ private: typedef std::map FontMap; FontMap mWFontMap; std::string mFontFileExtension; + + static WResourceManager* sInstance; }; -extern WResourceManager resources; #endif diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 3f9918c37..f6995e642 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -1091,16 +1091,16 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty AIPlayerBaka::AIPlayerBaka(MTGDeck * deck, string file, string fileSmall, string avatarFile) : AIPlayer(deck, file, fileSmall) { - mAvatarTex = resources.RetrieveTexture(avatarFile, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); + mAvatarTex = WResourceManager::Instance()->RetrieveTexture(avatarFile, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); if (!mAvatarTex) { avatarFile = "baka.jpg"; - mAvatarTex = resources.RetrieveTexture(avatarFile, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); + mAvatarTex = WResourceManager::Instance()->RetrieveTexture(avatarFile, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); } if (mAvatarTex) - mAvatar = resources.RetrieveQuad(avatarFile, 0, 0, 35, 50, "bakaAvatar", RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR); + mAvatar = WResourceManager::Instance()->RetrieveQuad(avatarFile, 0, 0, 35, 50, "bakaAvatar", RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR); else mAvatar = NULL; diff --git a/projects/mtg/src/AIStats.cpp b/projects/mtg/src/AIStats.cpp index d18900613..132ab47c7 100644 --- a/projects/mtg/src/AIStats.cpp +++ b/projects/mtg/src/AIStats.cpp @@ -192,7 +192,7 @@ void AIStats::Render() x0 = 280; JRenderer::GetInstance()->FillRoundRect(x0, 10, 200, 180, 5, ARGB(50,0,0,0)); - WFont * f = resources.GetWFont(Fonts::MAIN_FONT); + WFont * f = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); int i = 0; char buffer[512]; list::iterator it; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index ece53eecb..9db2530d2 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -41,7 +41,7 @@ void NextGamePhase::Render() GameObserver * g = GameObserver::GetInstance(); int nextPhase = (g->getCurrentGamePhase() + 1) % Constants::MTG_PHASE_CLEANUP; - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; @@ -75,12 +75,12 @@ const string Interruptible::getDisplayName() const void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad) { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetColor(ARGB(255,255,255,255)); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->DrawString(_(action).c_str(), x + 30, y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); - JQuad * quad = resources.RetrieveCard(source, CACHE_THUMB); + JQuad * quad = WResourceManager::Instance()->RetrieveCard(source, CACHE_THUMB); if (!quad) quad = CardGui::AlternateThumbQuad(source); if (quad) @@ -372,7 +372,7 @@ const string Interruptible::getDisplayName() const void PutInGraveyard::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); if (!removeFromGame) @@ -384,7 +384,7 @@ const string Interruptible::getDisplayName() const mFont->DrawString(_("is exiled").c_str(), x + 30, y, JGETEXT_LEFT); } JRenderer * renderer = JRenderer::GetInstance(); - JQuad * quad = resources.RetrieveCard(card, CACHE_THUMB); + JQuad * quad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB); if (quad) { quad->SetColor(ARGB(255,255,255,255)); @@ -420,7 +420,7 @@ const string Interruptible::getDisplayName() const void DrawAction::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; @@ -996,13 +996,13 @@ void ActionStack::Render() height += current->mHeight; } - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetColor(ARGB(255,255,255,255)); JRenderer * renderer = JRenderer::GetInstance(); - //JQuad * back = resources.GetQuad("interrupt"); + //JQuad * back = WResourceManager::Instance()->GetQuad("interrupt"); //float xScale = width / back->mWidth; //float yScale = height / back->mHeight; renderer->FillRoundRect(x0 + 16, y0 + 16, width + 2, height + 2, 10, ARGB(128,0,0,0)); @@ -1061,7 +1061,7 @@ void ActionStack::Render() height += current->mHeight; } - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetColor(ARGB(255,255,255,255)); diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 7e933b557..995eff10d 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -99,7 +99,7 @@ void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode) void CardGui::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * renderer = JRenderer::GetInstance(); GameObserver * game = GameObserver::GetInstance(); @@ -109,10 +109,10 @@ void CardGui::Render() tc = game->getCurrentTargetChooser(); bool alternate = true; - JQuad * quad = resources.RetrieveCard(card, CACHE_THUMB); + JQuad * quad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB); #if defined (WIN32) || defined (LINUX) //On pcs we render the big image if the thumbnail is not available - if (!quad) quad = resources.RetrieveCard(card); + if (!quad) quad = WResourceManager::Instance()->RetrieveCard(card); #endif if (quad) alternate = false; @@ -125,7 +125,7 @@ void CardGui::Render() JQuad* shadow = NULL; if (actZ > 1) { - shadow = resources.GetQuad("shadow"); + shadow = WResourceManager::Instance()->GetQuad("shadow"); shadow->SetColor(ARGB(static_cast(actA)/2,255,255,255)); renderer->RenderQuad(shadow, actX + (actZ - 1) * 15, actY + (actZ - 1) * 15, actT, 28 * actZ / 16, 40 * actZ / 16); } @@ -145,15 +145,15 @@ void CardGui::Render() JQuad * icon = NULL; if (card->hasSubtype("plains")) - icon = resources.GetQuad("c_white"); + icon = WResourceManager::Instance()->GetQuad("c_white"); else if (card->hasSubtype("swamp")) - icon = resources.GetQuad("c_black"); + icon = WResourceManager::Instance()->GetQuad("c_black"); else if (card->hasSubtype("forest")) - icon = resources.GetQuad("c_green"); + icon = WResourceManager::Instance()->GetQuad("c_green"); else if (card->hasSubtype("mountain")) - icon = resources.GetQuad("c_red"); + icon = WResourceManager::Instance()->GetQuad("c_red"); else if (card->hasSubtype("island")) - icon = resources.GetQuad("c_blue"); + icon = WResourceManager::Instance()->GetQuad("c_blue"); if (icon) { @@ -201,7 +201,7 @@ void CardGui::Render() if (tc && !tc->canTarget(card)) { if (!shadow) - shadow = resources.GetQuad("shadow"); + shadow = WResourceManager::Instance()->GetQuad("shadow"); shadow->SetColor(ARGB(200,255,255,255)); renderer->RenderQuad(shadow, actX, actY, actT, (28 * actZ + 1) / 16, 40 * actZ / 16); } @@ -215,35 +215,35 @@ JQuad * CardGui::AlternateThumbQuad(MTGCard * card) if (card->data->countColors() > 1) { - q = resources.RetrieveTempQuad("gold_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold_thumb.jpg"); } else { switch (card->data->getColor()) { case Constants::MTG_COLOR_ARTIFACT: - q = resources.RetrieveTempQuad("artifact_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("artifact_thumb.jpg"); break; case Constants::MTG_COLOR_GREEN: - q = resources.RetrieveTempQuad("green_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("green_thumb.jpg"); break; case Constants::MTG_COLOR_BLUE: - q = resources.RetrieveTempQuad("blue_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("blue_thumb.jpg"); break; case Constants::MTG_COLOR_RED: - q = resources.RetrieveTempQuad("red_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("red_thumb.jpg"); break; case Constants::MTG_COLOR_BLACK: - q = resources.RetrieveTempQuad("black_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("black_thumb.jpg"); break; case Constants::MTG_COLOR_WHITE: - q = resources.RetrieveTempQuad("white_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("white_thumb.jpg"); break; case Constants::MTG_COLOR_LAND: - q = resources.RetrieveTempQuad("land_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("land_thumb.jpg"); break; default: - q = resources.RetrieveTempQuad("gold_thumb.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold_thumb.jpg"); break; } } @@ -262,35 +262,35 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos) if (card->data->countColors() > 1) { - q = resources.RetrieveTempQuad("gold.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg"); } else { switch (card->data->getColor()) { case Constants::MTG_COLOR_ARTIFACT: - q = resources.RetrieveTempQuad("artifact.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("artifact.jpg"); break; case Constants::MTG_COLOR_GREEN: - q = resources.RetrieveTempQuad("green.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("green.jpg"); break; case Constants::MTG_COLOR_BLUE: - q = resources.RetrieveTempQuad("blue.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("blue.jpg"); break; case Constants::MTG_COLOR_RED: - q = resources.RetrieveTempQuad("red.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("red.jpg"); break; case Constants::MTG_COLOR_BLACK: - q = resources.RetrieveTempQuad("black.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("black.jpg"); break; case Constants::MTG_COLOR_WHITE: - q = resources.RetrieveTempQuad("white.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("white.jpg"); break; case Constants::MTG_COLOR_LAND: - q = resources.RetrieveTempQuad("land.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("land.jpg"); break; default: - q = resources.RetrieveTempQuad("gold.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg"); break; } } @@ -303,7 +303,7 @@ void CardGui::AlternateRender(MTGCard * card, const Pos& pos) renderer->RenderQuad(q, x, pos.actY, pos.actT, scale, scale); } // Write the title - WFont * font = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); float backup_scale = font->GetScale(); font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetScale(kWidthScaleFactor * pos.actZ); @@ -489,35 +489,35 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) if (card->data->countColors() > 1) { - q = resources.RetrieveTempQuad("gold.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg"); } else { switch (card->data->getColor()) { case Constants::MTG_COLOR_ARTIFACT: - q = resources.RetrieveTempQuad("artifact.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("artifact.jpg"); break; case Constants::MTG_COLOR_GREEN: - q = resources.RetrieveTempQuad("green.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("green.jpg"); break; case Constants::MTG_COLOR_BLUE: - q = resources.RetrieveTempQuad("blue.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("blue.jpg"); break; case Constants::MTG_COLOR_RED: - q = resources.RetrieveTempQuad("red.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("red.jpg"); break; case Constants::MTG_COLOR_BLACK: - q = resources.RetrieveTempQuad("black.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("black.jpg"); break; case Constants::MTG_COLOR_WHITE: - q = resources.RetrieveTempQuad("white.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("white.jpg"); break; case Constants::MTG_COLOR_LAND: - q = resources.RetrieveTempQuad("land.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("land.jpg"); break; default: - q = resources.RetrieveTempQuad("gold.jpg"); + q = WResourceManager::Instance()->RetrieveTempQuad("gold.jpg"); break; } } @@ -545,7 +545,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) renderer->RenderQuad(quad, x, imgY, pos.actT, imgScale, imgScale); // Write the title - WFont * font = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); float backup_scale = font->GetScale(); font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetScale(kWidthScaleFactor * pos.actZ); @@ -716,7 +716,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos) float x = pos.actX; - JQuad * quad = resources.RetrieveCard(card); + JQuad * quad = WResourceManager::Instance()->RetrieveCard(card); if (quad) { if (quad->mHeight < quad->mWidth) @@ -731,7 +731,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos) //No card found, attempt to render the thumbnail instead (better than nothing, even if it gets super stretched) JQuad * q; - if ((q = resources.RetrieveCard(card, CACHE_THUMB))) + if ((q = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB))) { float scale = pos.actZ * 250 / q->mHeight; q->SetColor(ARGB(255,255,255,255)); @@ -748,7 +748,7 @@ void CardGui::RenderCountersBig(const Pos& pos) // Write Named Counters if (card->counters) { - WFont * font = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetScale(kWidthScaleFactor * pos.actZ); std::vector txt = card->formattedText(); diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index 2d1545dfd..2fbcb05ae 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -64,7 +64,7 @@ const vector& CardPrimitive::formattedText() s[found] = '/'; found = s.find_first_of("{}", found + 1); } - WFont * mFont = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); mFont->FormatText(s, ftdText); } return ftdText; diff --git a/projects/mtg/src/Credits.cpp b/projects/mtg/src/Credits.cpp index 6b37f15bf..49c72340b 100644 --- a/projects/mtg/src/Credits.cpp +++ b/projects/mtg/src/Credits.cpp @@ -163,7 +163,7 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app) if (unlocked && options[Options::SFXVOLUME].number > 0) { - JSample * sample = resources.RetrieveSample("bonus.wav"); + JSample * sample = WResourceManager::Instance()->RetrieveSample("bonus.wav"); if (sample) { JSoundSystem::GetInstance()->PlaySample(sample); @@ -205,10 +205,10 @@ JQuad * Credits::GetUnlockedQuad(string textureName) { if (!textureName.size()) return NULL; - JTexture * unlockedTex = resources.RetrieveTexture(textureName); + JTexture * unlockedTex = WResourceManager::Instance()->RetrieveTexture(textureName); if (!unlockedTex) return NULL; - return resources.RetrieveQuad(unlockedTextureName, 2, 2, unlockedTex->mWidth - 4, unlockedTex->mHeight - 4); + return WResourceManager::Instance()->RetrieveQuad(unlockedTextureName, 2, 2, unlockedTex->mWidth - 4, unlockedTex->mHeight - 4); } @@ -218,9 +218,9 @@ void Credits::Render() return; GameObserver * g = GameObserver::GetInstance(); JRenderer * r = JRenderer::GetInstance(); - WFont * f = resources.GetWFont(Fonts::MAIN_FONT); - WFont * f2 = resources.GetWFont(Fonts::MENU_FONT); - WFont * f3 = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * f = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); + WFont * f2 = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); + WFont * f3 = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); f->SetScale(1); f->SetColor(ARGB(255,255,255,255)); f2->SetScale(1); diff --git a/projects/mtg/src/Damage.cpp b/projects/mtg/src/Damage.cpp index 893d22e59..8d5ce3b30 100644 --- a/projects/mtg/src/Damage.cpp +++ b/projects/mtg/src/Damage.cpp @@ -175,14 +175,14 @@ int Damage::resolve() } void Damage::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; sprintf(buffer, _("Deals %i damage to").c_str(), damage); mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); - JQuad * quad = resources.RetrieveCard(source, CACHE_THUMB); + JQuad * quad = WResourceManager::Instance()->RetrieveCard(source, CACHE_THUMB); if (quad) { float scale = 30 / quad->mHeight; diff --git a/projects/mtg/src/DamagerDamaged.cpp b/projects/mtg/src/DamagerDamaged.cpp index 0e57113cd..6e5e91f2a 100644 --- a/projects/mtg/src/DamagerDamaged.cpp +++ b/projects/mtg/src/DamagerDamaged.cpp @@ -67,7 +67,7 @@ void DamagerDamaged::clearDamage() void DamagerDamaged::Render(CombatStep mode) { TransientCardView::Render(); - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); switch (mode) diff --git a/projects/mtg/src/DeckEditorMenu.cpp b/projects/mtg/src/DeckEditorMenu.cpp index 11fb6e56f..865bb8834 100644 --- a/projects/mtg/src/DeckEditorMenu.cpp +++ b/projects/mtg/src/DeckEditorMenu.cpp @@ -48,7 +48,7 @@ void DeckEditorMenu::Render() DeckMenu::Render(); if (deckTitle.size() > 0) { - WFont *mainFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); DWORD currentColor = mainFont->GetColor(); mainFont->SetColor(ARGB(255,255,255,255)); mainFont->DrawString(deckTitle.c_str(), statsX + (statsWidth / 2), statsHeight / 2, JGETEXT_CENTER); @@ -90,7 +90,7 @@ void DeckEditorMenu::drawDeckStatistics() << "Mana: " << setprecision(2) << stw->avgManaCost << " " << "Spell: " << setprecision(2) << stw->avgSpellCost << endl; - WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mainFont->DrawString(deckStatsString.str().c_str(), descX, descY + 25); } diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index fc96d44b9..dd2f2afe1 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -78,7 +78,7 @@ JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOve // we want to cap the deck titles to 15 characters to avoid overflowing deck names title = _(_title); displayTitle = title; - mFont = resources.GetWFont(fontId); + mFont = WResourceManager::Instance()->GetWFont(fontId); startId = 0; selectionT = 0; @@ -93,7 +93,7 @@ JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOve mSelectionTargetY = selectionY = kVerticalMargin; if (NULL == stars) - stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars"))); + stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars"))); stars->FireAt(mX, mY); updateScroller(); @@ -107,7 +107,7 @@ void DeckMenu::RenderBackground() static bool loadBackground = true; if (loadBackground) { - JQuad *background = resources.RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551); + JQuad *background = WResourceManager::Instance()->RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551); if (background) JRenderer::GetInstance()->RenderQuad(background, 0, 0); else @@ -152,13 +152,13 @@ void DeckMenu::initMenuItems() mSelectionTargetY = selectionY = sY; //Grab a texture in VRAM. - pspIconsTexture = resources.RetrieveTexture("iconspsp.png", RETRIEVE_LOCK); + pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_LOCK); char buf[512]; for (int i = 0; i < 8; i++) { sprintf(buf, "iconspsp%d", i); - pspIcons[i] = resources.RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf); + pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf); pspIcons[i]->SetHotSpot(16, 16); } @@ -189,7 +189,7 @@ void DeckMenu::Render() mSelectedDeckId = i; mSelectedDeck = currentMenuItem->meta; - WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); // display the "more info" button if special condition is met if (showDetailsScreen()) { @@ -207,7 +207,7 @@ void DeckMenu::Render() // display the avatar image if (currentMenuItem->imageFilename.size() > 0) { - JQuad * quad = resources.RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR); + JQuad * quad = WResourceManager::Instance()->RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR); if (quad) renderer->RenderQuad(quad, avatarX, avatarY); } // fill in the description part of the screen @@ -332,6 +332,6 @@ void DeckMenu::destroy() DeckMenu::~DeckMenu() { - resources.Release(pspIconsTexture); + WResourceManager::Instance()->Release(pspIconsTexture); SAFE_DELETE(mScroller); } diff --git a/projects/mtg/src/DeckMenuItem.cpp b/projects/mtg/src/DeckMenuItem.cpp index 0c32ed6cb..811a4043c 100644 --- a/projects/mtg/src/DeckMenuItem.cpp +++ b/projects/mtg/src/DeckMenuItem.cpp @@ -12,7 +12,7 @@ const int kHorizontalScrollSpeed = 30; // higher numbers mean faster scrolling DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData) : JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y) { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); meta = deckMetaData; mText = trim(text); if (autoTranslate) @@ -23,10 +23,10 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f float newImageWidth = 0.0f; if (meta && !meta->getGamesPlayed()) { - JTexture * tex = resources.RetrieveTexture("new.png"); + JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png"); if (tex) { - JQuad * quad = resources.RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle around the texture because of bilinear filtering + JQuad * quad = WResourceManager::Instance()->RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle around the texture because of bilinear filtering newImageWidth = quad->mWidth; } } @@ -58,7 +58,7 @@ void DeckMenuItem::Update(float dt) void DeckMenuItem::RenderWithOffset(float yOffset) { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); if (!( mHasFocus && mScrollEnabled )) mScrollerOffset = 0; @@ -71,10 +71,10 @@ void DeckMenuItem::RenderWithOffset(float yOffset) //Render a "new" icon for decks that have never been played yet if (meta && !meta->getGamesPlayed()) { - JTexture * tex = resources.RetrieveTexture("new.png"); + JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png"); if (tex) { - JQuad * quad = resources.RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle aroudn the texture because of bilinear filtering + JQuad * quad = WResourceManager::Instance()->RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle aroudn the texture because of bilinear filtering quad->SetHotSpot(quad->mWidth/2.0f, quad->mHeight/2.0f); float x = mX + min(ITEM_PX_WIDTH - quad->mWidth, GetWidth() )/2 + quad->mWidth/2; if (quad) JRenderer::GetInstance()->RenderQuad(quad, x , mY + yOffset + quad->mHeight/2, 0.5); @@ -112,7 +112,7 @@ void DeckMenuItem::Relocate(float x, float y) float DeckMenuItem::GetWidth() { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); return mFont->GetStringWidth(mText.c_str()); } diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 523aa8e84..82d6b5ebe 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -39,7 +39,7 @@ void ExtraCost::Render() { if (!mCostRenderString.empty()) { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetColor(ARGB(255,255,255,255)); mFont->DrawString(mCostRenderString, 20, 20, JGETEXT_LEFT); diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index a496333dd..53d40055a 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -73,6 +73,7 @@ GameApp::GameApp() : GameApp::~GameApp() { + WResourceManager::Terminate(); } void GameApp::Create() @@ -114,14 +115,14 @@ void GameApp::Create() LOG("Checking for music files"); //Test for Music files presence - string filepath = JGE_GET_RES(resources.musicFile("Track0.mp3")); + string filepath = JGE_GET_RES(WResourceManager::Instance()->musicFile("Track0.mp3")); std::ifstream file(filepath.c_str()); if (file) file.close(); else HasMusic = 0; - filepath = JGE_GET_RES(resources.musicFile("Track1.mp3")); + filepath = JGE_GET_RES(WResourceManager::Instance()->musicFile("Track1.mp3")); std::ifstream file2(filepath.c_str()); if (file2) file2.close(); @@ -130,21 +131,21 @@ void GameApp::Create() LOG("Loading Textures"); LOG("--Loading menuicons.png"); - resources.RetrieveTexture("menuicons.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("menuicons.png", RETRIEVE_MANAGE); LOG("---Gettings menuicons.png quads"); //Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id - manaIcons[Constants::MTG_COLOR_GREEN] = resources.RetrieveQuad("menuicons.png", 2 + 0 * 36, 38, 32, 32, "c_green", + manaIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 0 * 36, 38, 32, 32, "c_green", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_BLUE] = resources.RetrieveQuad("menuicons.png", 2 + 1 * 36, 38, 32, 32, "c_blue", + manaIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 1 * 36, 38, 32, 32, "c_blue", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_RED] = resources.RetrieveQuad("menuicons.png", 2 + 3 * 36, 38, 32, 32, "c_red", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_BLACK] = resources.RetrieveQuad("menuicons.png", 2 + 2 * 36, 38, 32, 32, "c_black", + manaIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 3 * 36, 38, 32, 32, "c_red", RETRIEVE_MANAGE); + manaIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 2 * 36, 38, 32, 32, "c_black", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_WHITE] = resources.RetrieveQuad("menuicons.png", 2 + 4 * 36, 38, 32, 32, "c_white", + manaIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 4 * 36, 38, 32, 32, "c_white", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_LAND] = resources.RetrieveQuad("menuicons.png", 2 + 5 * 36, 38, 32, 32, "c_land", + manaIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 5 * 36, 38, 32, 32, "c_land", RETRIEVE_MANAGE); - manaIcons[Constants::MTG_COLOR_ARTIFACT] = resources.RetrieveQuad("menuicons.png", 2 + 6 * 36, 38, 32, 32, "c_artifact", + manaIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 6 * 36, 38, 32, 32, "c_artifact", RETRIEVE_MANAGE); for (int i = sizeof(manaIcons) / sizeof(manaIcons[0]) - 1; i >= 0; --i) @@ -152,49 +153,49 @@ void GameApp::Create() manaIcons[i]->SetHotSpot(16, 16); LOG("--Loading back.jpg"); - resources.RetrieveTexture("back.jpg", RETRIEVE_MANAGE); - JQuad * jq = resources.RetrieveQuad("back.jpg", 0, 0, 0, 0, "back", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("back.jpg", RETRIEVE_MANAGE); + JQuad * jq = WResourceManager::Instance()->RetrieveQuad("back.jpg", 0, 0, 0, 0, "back", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(jq->mWidth / 2, jq->mHeight / 2); - resources.RetrieveTexture("back_thumb.jpg", RETRIEVE_MANAGE); - resources.RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, "back_thumb", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("back_thumb.jpg", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, "back_thumb", RETRIEVE_MANAGE); LOG("--Loading particles.png"); - resources.RetrieveTexture("particles.png", RETRIEVE_MANAGE); - jq = resources.RetrieveQuad("particles.png", 0, 0, 32, 32, "particles", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("particles.png", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("particles.png", 0, 0, 32, 32, "particles", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(16, 16); - jq = resources.RetrieveQuad("particles.png", 64, 0, 32, 32, "stars", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("particles.png", 64, 0, 32, 32, "stars", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(16, 16); LOG("--Loading fonts"); string lang = options[Options::LANG].str; std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower); - resources.InitFonts(lang); + WResourceManager::Instance()->InitFonts(lang); LOG("--Loading various textures"); - resources.RetrieveTexture("phasebar.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("wood.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("gold.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("goldglow.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("backdrop.jpg", RETRIEVE_MANAGE); - resources.RetrieveTexture("handback.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("BattleIcon.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("DefenderIcon.png", RETRIEVE_MANAGE); - resources.RetrieveTexture("shadow.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("phasebar.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("wood.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("gold.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("goldglow.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("backdrop.jpg", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("handback.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("BattleIcon.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("DefenderIcon.png", RETRIEVE_MANAGE); + WResourceManager::Instance()->RetrieveTexture("shadow.png", RETRIEVE_MANAGE); - jq = resources.RetrieveQuad("BattleIcon.png", 0, 0, 25, 25, "BattleIcon", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("BattleIcon.png", 0, 0, 25, 25, "BattleIcon", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(12, 12); - jq = resources.RetrieveQuad("DefenderIcon.png", 0, 0, 24, 23, "DefenderIcon", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("DefenderIcon.png", 0, 0, 24, 23, "DefenderIcon", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(12, 12); - jq = resources.RetrieveQuad("shadow.png", 0, 0, 16, 16, "shadow", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("shadow.png", 0, 0, 16, 16, "shadow", RETRIEVE_MANAGE); if (jq) jq->SetHotSpot(8, 8); - jq = resources.RetrieveQuad("phasebar.png", 0, 0, 0, 0, "phasebar", RETRIEVE_MANAGE); + jq = WResourceManager::Instance()->RetrieveQuad("phasebar.png", 0, 0, 0, 0, "phasebar", RETRIEVE_MANAGE); LOG("Init Collection"); collection = NEW MTGAllCards(); @@ -352,7 +353,7 @@ void GameApp::Render() if (systemError.size()) { fprintf(stderr, "%s", systemError.c_str()); - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); if (mFont) mFont->DrawString(systemError.c_str(), 1, 1); return; @@ -365,7 +366,7 @@ void GameApp::Render() mCurrentState->Render(); #ifdef DEBUG_CACHE - resources.DebugRender(); + WResourceManager::Instance()->DebugRender(); #endif #ifdef DEBUG @@ -373,7 +374,7 @@ void GameApp::Render() float fps = mEngine->GetFPS(); totalFPS += fps; nbUpdates+=1; - WFont * mFont= resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont= WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); char buf[512]; sprintf(buf, "avg:%.02f - %.02f fps",totalFPS/nbUpdates, fps); if (mFont) @@ -464,7 +465,7 @@ void GameApp::playMusic(string filename, bool loop) if (HasMusic && options[Options::MUSICVOLUME].number > 0) { - music = resources.ssLoadMusic(filename.c_str()); + music = WResourceManager::Instance()->ssLoadMusic(filename.c_str()); if (music) JSoundSystem::GetInstance()->PlayMusic(music, loop); currentMusicFile = filename; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index bb4c2f06a..965227da5 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -265,8 +265,8 @@ void GameObserver::startGame(Rules * rules) { for (int i = 0; i < players[0]->game->hand->nb_cards; i++) { - resources.RetrieveCard(players[0]->game->hand->cards[i], CACHE_THUMB); - resources.RetrieveCard(players[0]->game->hand->cards[i]); + WResourceManager::Instance()->RetrieveCard(players[0]->game->hand->cards[i], CACHE_THUMB); + WResourceManager::Instance()->RetrieveCard(players[0]->game->hand->cards[i]); } } diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index 1a52206ae..54a36785e 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -640,7 +640,7 @@ void GameSettings::reloadProfile(bool images) SAFE_DELETE(profileOptions); checkProfile(); if (images) - resources.Refresh(); //Update images + WResourceManager::Instance()->Refresh(); //Update images } void GameSettings::checkProfile() diff --git a/projects/mtg/src/GameStateAwards.cpp b/projects/mtg/src/GameStateAwards.cpp index 1cb5f6896..a977026a5 100644 --- a/projects/mtg/src/GameStateAwards.cpp +++ b/projects/mtg/src/GameStateAwards.cpp @@ -137,7 +137,7 @@ void GameStateAwards::Render() JRenderer * r = JRenderer::GetInstance(); r->ClearScreen(ARGB(0,0,0,0)); - JQuad * mBg = resources.RetrieveTempQuad("awardback.jpg", TEXTURE_SUB_5551); + JQuad * mBg = WResourceManager::Instance()->RetrieveTempQuad("awardback.jpg", TEXTURE_SUB_5551); if (mBg) r->RenderQuad(mBg, 0, 0); diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index dcfd2e2f3..5f00b5f05 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -224,30 +224,30 @@ void GameStateDeckViewer::Start() displayed_deck = myCollection; //Icons - mIcons[Constants::MTG_COLOR_ARTIFACT] = resources.GetQuad("c_artifact"); - mIcons[Constants::MTG_COLOR_LAND] = resources.GetQuad("c_land"); - mIcons[Constants::MTG_COLOR_WHITE] = resources.GetQuad("c_white"); - mIcons[Constants::MTG_COLOR_RED] = resources.GetQuad("c_red"); - mIcons[Constants::MTG_COLOR_BLACK] = resources.GetQuad("c_black"); - mIcons[Constants::MTG_COLOR_BLUE] = resources.GetQuad("c_blue"); - mIcons[Constants::MTG_COLOR_GREEN] = resources.GetQuad("c_green"); + mIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->GetQuad("c_artifact"); + mIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->GetQuad("c_land"); + mIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->GetQuad("c_white"); + mIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->GetQuad("c_red"); + mIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->GetQuad("c_black"); + mIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->GetQuad("c_blue"); + mIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->GetQuad("c_green"); for (int i = 0; i < 7; i++) { mIcons[i]->SetHotSpot(16, 16); } //Grab a texture in VRAM. - pspIconsTexture = resources.RetrieveTexture("iconspsp.png", RETRIEVE_LOCK); + pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_LOCK); char buf[512]; for (int i = 0; i < 8; i++) { sprintf(buf, "iconspsp%d", i); - pspIcons[i] = resources.RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf); + pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf); pspIcons[i]->SetHotSpot(16, 16); } - backQuad = resources.GetQuad("back"); + backQuad = WResourceManager::Instance()->GetQuad("back"); //init welcome menu updateDecks(); @@ -267,7 +267,7 @@ void GameStateDeckViewer::End() SAFE_DELETE(menu); SAFE_DELETE(subMenu); - resources.Release(pspIconsTexture); + WResourceManager::Instance()->Release(pspIconsTexture); if (myCollection) { SAFE_DELETE(myCollection); @@ -617,7 +617,7 @@ void GameStateDeckViewer::Update(float dt) void GameStateDeckViewer::renderOnScreenBasicInfo() { JRenderer *renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); char buffer[256]; int myD = (displayed_deck == myDeck); @@ -656,7 +656,7 @@ int GameStateDeckViewer::getCurrentPos() void GameStateDeckViewer::renderSlideBar() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); int total = displayed_deck->Size(); if (total == 0) return; @@ -726,7 +726,7 @@ void GameStateDeckViewer::renderDeckBackground() void GameStateDeckViewer::renderOnScreenMenu() { - WFont * font = resources.GetWFont(Fonts::MAIN_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); font->SetColor(ARGB(255,255,255,255)); JRenderer * r = JRenderer::GetInstance(); float pspIconsSize = 0.5; @@ -1292,7 +1292,7 @@ void GameStateDeckViewer::renderOnScreenMenu() void GameStateDeckViewer::renderCard(int id, float rotation) { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); MTGCard * card = cardIndex[id]; float max_scale = 0.96f; @@ -1317,12 +1317,12 @@ void GameStateDeckViewer::renderCard(int id, float rotation) if (!options[Options::DISABLECARDS].number) { - quad = resources.RetrieveCard(card, RETRIEVE_EXISTING); - cacheError = resources.RetrieveError(); + quad = WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_EXISTING); + cacheError = WResourceManager::Instance()->RetrieveError(); if (!quad && cacheError != CACHE_ERROR_404) { if (last_user_activity > (abs(2 - id) + 1) * NO_USER_ACTIVITY_SHOWCARD_DELAY) - quad = resources.RetrieveCard(card); + quad = WResourceManager::Instance()->RetrieveCard(card); else { quad = backQuad; @@ -1350,7 +1350,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation) { Pos pos = Pos(x, y, scale * 285 / 250, 0.0, 255); CardGui::DrawCard(card, pos, DrawMode::kText); - if (!options[Options::DISABLECARDS].number) quad = resources.RetrieveCard(card, CACHE_THUMB); + if (!options[Options::DISABLECARDS].number) quad = WResourceManager::Instance()->RetrieveCard(card, CACHE_THUMB); if (quad) { float _scale = 285 * scale / quad->mHeight; @@ -1389,7 +1389,7 @@ void GameStateDeckViewer::renderCard(int id) void GameStateDeckViewer::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * r = JRenderer::GetInstance(); r->ClearScreen(ARGB(0,0,0,0)); diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 3361918c3..b8260953f 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -262,7 +262,7 @@ void GameStateDuel::End() //TODO Move This to utils or ResourceManager. Don't we have more generic functions that can do that? bool GameStateDuel::MusicExist(string FileName) { - string filepath = JGE_GET_RES(resources.musicFile(FileName)); + string filepath = JGE_GET_RES(WResourceManager::Instance()->musicFile(FileName)); std::ifstream file(filepath.c_str()); if (file) { @@ -512,7 +512,7 @@ void GameStateDuel::Update(float dt) void GameStateDuel::Render() { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * r = JRenderer::GetInstance(); r->ClearScreen(ARGB(0,0,0,0)); diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 79d2712c3..803c4f967 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -105,7 +105,7 @@ void GameStateMenu::Create() for (int j = 0; j < 2; j++) { sprintf(buf, "menuicons%d%d", i, j); - mIcons[n] = resources.RetrieveQuad("menuicons.png", 2 + i * 36.0f, 2.0f + j * 36.0f, 32.0f, 32.0f, buf); + mIcons[n] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + i * 36.0f, 2.0f + j * 36.0f, 32.0f, 32.0f, buf); if (mIcons[n]) mIcons[n]->SetHotSpot(16, 16); n++; @@ -138,7 +138,7 @@ void GameStateMenu::Destroy() SAFE_DELETE(mGuiController); SAFE_DELETE(subMenuController); SAFE_DELETE(gameTypeMenu); - resources.Release(bgTexture); + WResourceManager::Instance()->Release(bgTexture); SAFE_DELETE(scroller); } @@ -158,8 +158,8 @@ void GameStateMenu::Start() if (options[Options::MOMIR_MODE_UNLOCKED].number) hasChosenGameType = 0; if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) hasChosenGameType = 0; */ - bgTexture = resources.RetrieveTexture("menutitle.png", RETRIEVE_LOCK); - mBg = resources.RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering. + bgTexture = WResourceManager::Instance()->RetrieveTexture("menutitle.png", RETRIEVE_LOCK); + mBg = WResourceManager::Instance()->RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering. if (mBg) mBg->SetHotSpot(128, 50); @@ -303,7 +303,7 @@ void GameStateMenu::End() { JRenderer::GetInstance()->EnableVSync(false); - resources.Release(bgTexture); + WResourceManager::Instance()->Release(bgTexture); SAFE_DELETE(mGuiController); } @@ -422,18 +422,18 @@ void GameStateMenu::ensureMGuiController() mGuiController = NEW JGuiController(100, this); if (mGuiController) { - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); mFont->SetColor(ARGB(255,255,255,255)); mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT / 2, mIcons[8], mIcons[9], - "particle1.psi", resources.GetQuad("particles"), true)); + "particle1.psi", WResourceManager::Instance()->GetQuad("particles"), true)); mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT / 2, mIcons[2], - mIcons[3], "particle2.psi", resources.GetQuad("particles"))); + mIcons[3], "particle2.psi", WResourceManager::Instance()->GetQuad("particles"))); mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT / 2, mIcons[0], mIcons[1], - "particle3.psi", resources.GetQuad("particles"))); + "particle3.psi", WResourceManager::Instance()->GetQuad("particles"))); mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT / 2, mIcons[6], mIcons[7], - "particle4.psi", resources.GetQuad("particles"))); + "particle4.psi", WResourceManager::Instance()->GetQuad("particles"))); mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT / 2, mIcons[4], mIcons[5], - "particle5.psi", resources.GetQuad("particles"))); + "particle5.psi", WResourceManager::Instance()->GetQuad("particles"))); } } } @@ -492,7 +492,7 @@ void GameStateMenu::Update(float dt) options[Options::ACTIVE_PROFILE].str = "Default"; //Release splash texture - resources.Release(splashTex); + WResourceManager::Instance()->Release(splashTex); splashTex = NULL; mSplash = NULL; @@ -513,7 +513,7 @@ void GameStateMenu::Update(float dt) genNbCardsStr(); resetDirectory(); //All major things have been loaded, resize the cache to use it as efficiently as possible - resources.ResetCacheLimits(); + WResourceManager::Instance()->ResetCacheLimits(); } break; case MENU_STATE_MAJOR_FIRST_TIME: @@ -633,7 +633,7 @@ void GameStateMenu::Render() return; JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG) { } @@ -641,8 +641,8 @@ void GameStateMenu::Render() { if (!splashTex) { - splashTex = resources.RetrieveTexture("splash.jpg", RETRIEVE_LOCK); - mSplash = resources.RetrieveTempQuad("splash.jpg"); + splashTex = WResourceManager::Instance()->RetrieveTexture("splash.jpg", RETRIEVE_LOCK); + mSplash = WResourceManager::Instance()->RetrieveTempQuad("splash.jpg"); } if (mSplash) renderer->RenderQuad(mSplash, 0, 0); @@ -651,10 +651,10 @@ void GameStateMenu::Render() string wp = loadRandomWallpaper(); if (wp.size()) { - JTexture * wpTex = resources.RetrieveTexture(wp); + JTexture * wpTex = WResourceManager::Instance()->RetrieveTexture(wp); if (wpTex) { - JQuad * wpQuad = resources.RetrieveTempQuad(wp); + JQuad * wpQuad = WResourceManager::Instance()->RetrieveTempQuad(wp); renderer->RenderQuad(wpQuad, 0, 0, 0, SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight); } } @@ -678,7 +678,7 @@ void GameStateMenu::Render() } else { - mFont = resources.GetWFont(Fonts::MAIN_FONT); + mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); PIXEL_TYPE colors[] = { ARGB(255,3,3,0), ARGB(255,8,8,0), ARGB(255,21,21,10), ARGB(255,50,50,30), }; @@ -700,14 +700,14 @@ void GameStateMenu::Render() if (mBg) renderer->RenderQuad(mBg, SCREEN_WIDTH / 2, 50); - JQuad * jq = resources.RetrieveTempQuad("button_shoulder.png"); + JQuad * jq = WResourceManager::Instance()->RetrieveTempQuad("button_shoulder.png"); if (jq) { int alp = 255; if (options.newAward()) alp = (int) (sin(timeIndex) * 255); float olds = mFont->GetScale(); - mFont = resources.GetWFont(Fonts::OPTION_FONT); + mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); jq->SetColor(ARGB(abs(alp),255,255,255)); mFont->SetColor(ARGB(abs(alp),0,0,0)); string s = _("Trophy Room"); @@ -716,7 +716,7 @@ void GameStateMenu::Render() mFont->SetScale(50.0f / mFont->GetStringWidth(s.c_str())); renderer->RenderQuad(jq, SCREEN_WIDTH - 64, 2); mFont->DrawString(s, SCREEN_WIDTH - 10, 9, JGETEXT_RIGHT); - mFont = resources.GetWFont(Fonts::MENU_FONT); + mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); mFont->SetScale(olds); } } @@ -728,14 +728,14 @@ void GameStateMenu::Render() void GameStateMenu::ButtonPressed(int controllerId, int controlId) { - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); DebugTrace("GameStateMenu: controllerId " << controllerId << " selected"); switch (controllerId) { case MENU_LANGUAGE_SELECTION: setLang(controlId); - resources.ReloadWFonts(); // Fix for choosing Chinese language at first time. + WResourceManager::Instance()->ReloadWFonts(); // Fix for choosing Chinese language at first time. subMenuController->Close(); currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_SUBMENU_CLOSING; break; diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 16d68723d..1a9ca83b8 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -243,7 +243,7 @@ void GameStateOptions::Render() "Please support this project with donations at http://wololo.net/wagic", }; - WFont * mFont = resources.GetWFont(Fonts::MAGIC_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); mFont->SetColor(ARGB(255,200,200,200)); mFont->SetScale(1.0); float startpos = 272 - timer; diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 349f7402d..5a3c88afc 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -123,16 +123,16 @@ void GameStateShop::Start() } //alternateRender doesn't lock, so lock our thumbnails for hgeDistort. - altThumb[0] = resources.RetrieveTexture("artifact_thumb.jpg", RETRIEVE_LOCK); - altThumb[1] = resources.RetrieveTexture("green_thumb.jpg", RETRIEVE_LOCK); - altThumb[2] = resources.RetrieveTexture("blue_thumb.jpg", RETRIEVE_LOCK); - altThumb[3] = resources.RetrieveTexture("red_thumb.jpg", RETRIEVE_LOCK); - altThumb[4] = resources.RetrieveTexture("black_thumb.jpg", RETRIEVE_LOCK); - altThumb[5] = resources.RetrieveTexture("white_thumb.jpg", RETRIEVE_LOCK); - altThumb[6] = resources.RetrieveTexture("land_thumb.jpg", RETRIEVE_LOCK); - altThumb[7] = resources.RetrieveTexture("gold_thumb.jpg", RETRIEVE_LOCK); + altThumb[0] = WResourceManager::Instance()->RetrieveTexture("artifact_thumb.jpg", RETRIEVE_LOCK); + altThumb[1] = WResourceManager::Instance()->RetrieveTexture("green_thumb.jpg", RETRIEVE_LOCK); + altThumb[2] = WResourceManager::Instance()->RetrieveTexture("blue_thumb.jpg", RETRIEVE_LOCK); + altThumb[3] = WResourceManager::Instance()->RetrieveTexture("red_thumb.jpg", RETRIEVE_LOCK); + altThumb[4] = WResourceManager::Instance()->RetrieveTexture("black_thumb.jpg", RETRIEVE_LOCK); + altThumb[5] = WResourceManager::Instance()->RetrieveTexture("white_thumb.jpg", RETRIEVE_LOCK); + altThumb[6] = WResourceManager::Instance()->RetrieveTexture("land_thumb.jpg", RETRIEVE_LOCK); + altThumb[7] = WResourceManager::Instance()->RetrieveTexture("gold_thumb.jpg", RETRIEVE_LOCK); - mBack = resources.GetQuad("back"); + mBack = WResourceManager::Instance()->GetQuad("back"); JRenderer::GetInstance()->EnableVSync(true); @@ -194,7 +194,7 @@ string GameStateShop::descPurchase(int controlId, bool tiny) } void GameStateShop::beginPurchase(int controlId) { - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); mFont->SetScale(DEFAULT_MENU_FONT_SCALE); SAFE_DELETE(menu); if (mInventory[controlId] <= 0) @@ -428,7 +428,7 @@ void GameStateShop::End() //Release alternate thumbnails. for (int i = 0; i < 8; i++) { - resources.Release(altThumb[i]); + WResourceManager::Instance()->Release(altThumb[i]); altThumb[i] = NULL; } @@ -652,17 +652,17 @@ void GameStateShop::deleteDisplay() void GameStateShop::Render() { //Erase - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * r = JRenderer::GetInstance(); r->ClearScreen(ARGB(0,0,0,0)); if (mStage == STAGE_FADE_IN) return; - JQuad * mBg = resources.RetrieveTempQuad("shop.jpg", TEXTURE_SUB_5551); + JQuad * mBg = WResourceManager::Instance()->RetrieveTempQuad("shop.jpg", TEXTURE_SUB_5551); if (mBg) r->RenderQuad(mBg, 0, 0); - JQuad * quad = resources.RetrieveTempQuad("shop_light.jpg", TEXTURE_SUB_5551); + JQuad * quad = WResourceManager::Instance()->RetrieveTempQuad("shop_light.jpg", TEXTURE_SUB_5551); if (quad) { r->EnableTextureFilter(false); diff --git a/projects/mtg/src/GuiBackground.cpp b/projects/mtg/src/GuiBackground.cpp index 2dfe82080..fdf361674 100644 --- a/projects/mtg/src/GuiBackground.cpp +++ b/projects/mtg/src/GuiBackground.cpp @@ -20,11 +20,11 @@ void GuiBackground::Render() GameObserver * go = GameObserver::GetInstance(); if (go && go->mRules && go->mRules->bg.size()) { - quad = resources.RetrieveTempQuad(go->mRules->bg); + quad = WResourceManager::Instance()->RetrieveTempQuad(go->mRules->bg); } if (!quad) { - quad = resources.RetrieveTempQuad("backdrop.jpg"); + quad = WResourceManager::Instance()->RetrieveTempQuad("backdrop.jpg"); } if (!quad) return; diff --git a/projects/mtg/src/GuiCombat.cpp b/projects/mtg/src/GuiCombat.cpp index 2e2b9c7bc..e7eafc90c 100644 --- a/projects/mtg/src/GuiCombat.cpp +++ b/projects/mtg/src/GuiCombat.cpp @@ -39,7 +39,7 @@ GuiCombat::GuiCombat(GameObserver* go) : { if (NULL == ok_tex) { - ok_tex = resources.RetrieveTexture("Ok.png", RETRIEVE_LOCK); + ok_tex = WResourceManager::Instance()->RetrieveTexture("Ok.png", RETRIEVE_LOCK); } } @@ -47,7 +47,7 @@ GuiCombat::~GuiCombat() { if (ok_tex) { - resources.Release(ok_tex); + WResourceManager::Instance()->Release(ok_tex); ok_tex = NULL; } @@ -391,7 +391,7 @@ void GuiCombat::Render() { go->opponent()->mAvatar->SetHotSpot(18, 25); enemy_avatar.Render(go->opponent()->mAvatar); - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetColor(ARGB(255, 255, 64, 0)); { char buf[10]; @@ -402,14 +402,14 @@ void GuiCombat::Render() } if (ok_tex) { - JQuad *ok_quad = resources.RetrieveTempQuad("Ok.png"); + JQuad *ok_quad = WResourceManager::Instance()->RetrieveTempQuad("Ok.png"); ok_quad->SetHotSpot(28, 22); ok.Render(ok_quad); } renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0)); if (FIRST_STRIKE == step) { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetColor(ARGB(255, 64, 255, 64)); mFont->DrawString("First strike damage", 370, 2); } diff --git a/projects/mtg/src/GuiFrame.cpp b/projects/mtg/src/GuiFrame.cpp index f59d14e67..8e0dca6f3 100644 --- a/projects/mtg/src/GuiFrame.cpp +++ b/projects/mtg/src/GuiFrame.cpp @@ -5,8 +5,8 @@ GuiFrame::GuiFrame() { - if (resources.GetTexture("wood.png")) - wood = resources.RetrieveQuad("wood.png", 0, 0, SCREEN_WIDTH, 28); + if (WResourceManager::Instance()->GetTexture("wood.png")) + wood = WResourceManager::Instance()->RetrieveQuad("wood.png", 0, 0, SCREEN_WIDTH, 28); else { wood = NULL; @@ -14,12 +14,12 @@ GuiFrame::GuiFrame() } goldGlow = gold1 = gold2 = NULL; - if (resources.GetTexture("gold.png")) + if (WResourceManager::Instance()->GetTexture("gold.png")) { - gold1 = resources.RetrieveQuad("gold.png", 0, 0, SCREEN_WIDTH, 6, "gold1"); - gold2 = resources.RetrieveQuad("gold.png", 0, 6, SCREEN_WIDTH, 6, "gold2"); - if (resources.GetTexture("goldglow.png")) - goldGlow = resources.RetrieveQuad("goldglow.png", 1, 1, SCREEN_WIDTH - 2, 18); + gold1 = WResourceManager::Instance()->RetrieveQuad("gold.png", 0, 0, SCREEN_WIDTH, 6, "gold1"); + gold2 = WResourceManager::Instance()->RetrieveQuad("gold.png", 0, 6, SCREEN_WIDTH, 6, "gold2"); + if (WResourceManager::Instance()->GetTexture("goldglow.png")) + goldGlow = WResourceManager::Instance()->RetrieveQuad("goldglow.png", 1, 1, SCREEN_WIDTH - 2, 18); if (gold2) { gold2->SetColor(ARGB(127, 255, 255, 255)); diff --git a/projects/mtg/src/GuiHand.cpp b/projects/mtg/src/GuiHand.cpp index 8894cc139..1b76d69b5 100644 --- a/projects/mtg/src/GuiHand.cpp +++ b/projects/mtg/src/GuiHand.cpp @@ -35,7 +35,7 @@ HandLimitor::HandLimitor(GuiHand* hand) : GuiHand::GuiHand(MTGHand* hand) : GuiLayer(), hand(hand) { - back = resources.RetrieveTempQuad("handback.png"); + back = WResourceManager::Instance()->RetrieveTempQuad("handback.png"); if (back) back->SetTextureRect(1, 0, 100, 250); else @@ -68,7 +68,7 @@ GuiHandOpponent::GuiHandOpponent(MTGHand* hand) : void GuiHandOpponent::Render() { - JQuad * quad = resources.GetQuad("back_thumb"); + JQuad * quad = WResourceManager::Instance()->GetQuad("back_thumb"); float x = 45; for (vector::iterator it = cards.begin(); it != cards.end(); ++it) @@ -202,7 +202,7 @@ void GuiHandSelf::Render() //Empty hand if (state == Open && cards.size() == 0) { - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetColor(ARGB(255,255,0,0)); if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number) { diff --git a/projects/mtg/src/GuiMana.cpp b/projects/mtg/src/GuiMana.cpp index c31a84edd..cd6a9faaa 100644 --- a/projects/mtg/src/GuiMana.cpp +++ b/projects/mtg/src/GuiMana.cpp @@ -11,7 +11,7 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : Pos(x, y, 0.5, 0.0, 255), f(-1), destx(destx), desty(desty), mode(ALIVE), color(color) { hgeParticleSystemInfo * psi = NULL; - JQuad * mq = resources.GetQuad("stars"); + JQuad * mq = WResourceManager::Instance()->GetQuad("stars"); if (!mq) { @@ -22,22 +22,22 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : switch (color) { case Constants::MTG_COLOR_RED: - psi = resources.RetrievePSI("manared.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("manared.psi", mq); break; case Constants::MTG_COLOR_BLUE: - psi = resources.RetrievePSI("manablue.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("manablue.psi", mq); break; case Constants::MTG_COLOR_GREEN: - psi = resources.RetrievePSI("managreen.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("managreen.psi", mq); break; case Constants::MTG_COLOR_BLACK: - psi = resources.RetrievePSI("manablack.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("manablack.psi", mq); break; case Constants::MTG_COLOR_WHITE: - psi = resources.RetrievePSI("manawhite.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("manawhite.psi", mq); break; default: - psi = resources.RetrievePSI("mana.psi", mq); + psi = WResourceManager::Instance()->RetrievePSI("mana.psi", mq); } if (!psi) @@ -45,7 +45,7 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : psi = NEW hgeParticleSystemInfo(); if (!psi) return; - hgeParticleSystemInfo * defaults = resources.RetrievePSI("mana.psi", mq); + hgeParticleSystemInfo * defaults = WResourceManager::Instance()->RetrievePSI("mana.psi", mq); if (defaults) { memcpy(psi, defaults, sizeof(hgeParticleSystemInfo)); @@ -242,7 +242,7 @@ void GuiMana::RenderStatic() { int values[Constants::MTG_NB_COLORS]; int totalColors = 0; - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); JRenderer * r = JRenderer::GetInstance(); for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) values[i] = 0; diff --git a/projects/mtg/src/GuiPhaseBar.cpp b/projects/mtg/src/GuiPhaseBar.cpp index 761857fe0..4aeee7a50 100644 --- a/projects/mtg/src/GuiPhaseBar.cpp +++ b/projects/mtg/src/GuiPhaseBar.cpp @@ -44,7 +44,7 @@ GuiPhaseBar::GuiPhaseBar() : phase(NULL), angle(0.0f) { JQuad * quad = NULL; - if ((quad = resources.GetQuad("phasebar")) != NULL) + if ((quad = WResourceManager::Instance()->GetQuad("phasebar")) != NULL) { quad->mHeight = kHeight; quad->mWidth = kWidth; @@ -68,7 +68,7 @@ void GuiPhaseBar::Update(float dt) void GuiPhaseBar::Render() { GameObserver * g = GameObserver::GetInstance(); - JQuad * quad = resources.GetQuad("phasebar"); + JQuad * quad = WResourceManager::Instance()->GetQuad("phasebar"); JRenderer::GetInstance()->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255)); @@ -101,7 +101,7 @@ void GuiPhaseBar::Render() } //print phase name - WFont * font = resources.GetWFont(Fonts::MAIN_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); string currentP = _("your turn"); string interrupt = ""; if (g->currentPlayer == g->players[1]) diff --git a/projects/mtg/src/GuiPlay.cpp b/projects/mtg/src/GuiPlay.cpp index 8f7811578..051730c9f 100644 --- a/projects/mtg/src/GuiPlay.cpp +++ b/projects/mtg/src/GuiPlay.cpp @@ -119,7 +119,7 @@ void GuiPlay::BattleField::EnstackAttacker(CardView* card) card->x = currentAttacker * (HORZWIDTH - 20) / (attackers + 1); card->y = baseY + (game->players[0] == card->card->controller() ? 20 + y : -20 - y); ++currentAttacker; - // JRenderer::GetInstance()->RenderQuad(resources.GetQuad("BattleIcon"), card->actX, card->actY, 0, 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()), 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime())); + // JRenderer::GetInstance()->RenderQuad(WResourceManager::Instance()->GetQuad("BattleIcon"), card->actX, card->actY, 0, 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()), 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime())); } void GuiPlay::BattleField::EnstackBlocker(CardView* card) { diff --git a/projects/mtg/src/GuiStatic.cpp b/projects/mtg/src/GuiStatic.cpp index 65883cdf7..43845a07b 100644 --- a/projects/mtg/src/GuiStatic.cpp +++ b/projects/mtg/src/GuiStatic.cpp @@ -32,7 +32,7 @@ void GuiAvatar::Render() JRenderer * r = JRenderer::GetInstance(); int life = player->life; int poisonCount = player->poisonCount; - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); //Avatar int lifeDiff = life - currentLife; @@ -152,7 +152,7 @@ void GuiGameZone::toggleDisplay() void GuiGameZone::Render() { //Texture - JQuad * quad = resources.GetQuad("back_thumb"); + JQuad * quad = WResourceManager::Instance()->GetQuad("back_thumb"); float scale = defaultHeight / quad->mHeight; quad->SetColor(ARGB((int)(actA),255,255,255)); @@ -169,7 +169,7 @@ void GuiGameZone::Render() ARGB(abs(128 - wave),255,255,255)); //Number of cards - WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[11]; int mAlpha = (int) (actA); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index d9d8980c4..b8ab0e03c 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3690,7 +3690,7 @@ int AManaProducer::reactToClick(MTGCardInstance * _card) if (options[Options::SFXVOLUME].number > 0) { - JSample * sample = resources.RetrieveSample("mana.wav"); + JSample * sample = WResourceManager::Instance()->RetrieveSample("mana.wav"); if (sample) JSoundSystem::GetInstance()->PlaySample(sample); } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 61697590e..22c74a42a 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -570,7 +570,7 @@ int MTGCardInstance::canBlock(MTGCardInstance * opponent) JQuad * MTGCardInstance::getIcon() { - return resources.RetrieveCard(this, CACHE_THUMB); + return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB); } MTGCardInstance * MTGCardInstance::getNextPartner() @@ -891,13 +891,13 @@ JSample * MTGCardInstance::getSample() JSample * js; if (sample.size()) - return resources.RetrieveSample(sample); + return WResourceManager::Instance()->RetrieveSample(sample); for (int i = types.size() - 1; i > 0; i--) { string type = Subtypes::subtypesList->find(types[i]); type = type + ".wav"; - js = resources.RetrieveSample(type); + js = WResourceManager::Instance()->RetrieveSample(type); if (js) { sample = string(type); @@ -912,7 +912,7 @@ JSample * MTGCardInstance::getSample() continue; string type = Constants::MTGBasicAbilities[i]; type = type + ".wav"; - js = resources.RetrieveSample(type); + js = WResourceManager::Instance()->RetrieveSample(type); if (js) { sample = string(type); @@ -922,7 +922,7 @@ JSample * MTGCardInstance::getSample() string type = Subtypes::subtypesList->find(types[0]); type = type + ".wav"; - js = resources.RetrieveSample(type); + js = WResourceManager::Instance()->RetrieveSample(type); if (js) { sample = string(type); diff --git a/projects/mtg/src/MTGGamePhase.cpp b/projects/mtg/src/MTGGamePhase.cpp index c9d994a1c..5002afece 100644 --- a/projects/mtg/src/MTGGamePhase.cpp +++ b/projects/mtg/src/MTGGamePhase.cpp @@ -7,7 +7,7 @@ MTGGamePhase::MTGGamePhase(int id) : { animation = 0; currentState = -1; - mFont = resources.GetWFont(Fonts::MAIN_FONT); + mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); mFont->SetBase(0); // using 2nd font } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 7045e2c3c..4660b5a90 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -355,7 +355,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone { if (card->isCreature()) { - JSample * sample = resources.RetrieveSample("graveyard.wav"); + JSample * sample = WResourceManager::Instance()->RetrieveSample("graveyard.wav"); if (sample) JSoundSystem::GetInstance()->PlaySample(sample); } diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 3fd307b73..d2697e4fb 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1403,7 +1403,7 @@ void MTGMomirRule::Render() { if (!textAlpha) return; - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); mFont->SetScale(2 - (float) textAlpha / 130); mFont->SetColor(ARGB(textAlpha,255,255,255)); mFont->DrawString(text.c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, JGETEXT_CENTER); @@ -1521,7 +1521,7 @@ HUDDisplay::HUDDisplay(int _id) : { timestamp = 0; popdelay = 2; - f = resources.GetWFont(Fonts::MAIN_FONT); + f = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); maxWidth = 0; } diff --git a/projects/mtg/src/MenuItem.cpp b/projects/mtg/src/MenuItem.cpp index 9455de5de..4b2691487 100644 --- a/projects/mtg/src/MenuItem.cpp +++ b/projects/mtg/src/MenuItem.cpp @@ -10,7 +10,7 @@ MenuItem::MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _ { mText = _(text); updatedSinceLastRender = 1; - mParticleSys = NEW hgeParticleSystem(resources.RetrievePSI(particle, particleTex)); + mParticleSys = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI(particle, particleTex)); mParticleSys->MoveTo(mX, mY); mHasFocus = hasFocus; diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index c6a782988..51254abbd 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -19,7 +19,7 @@ OptionItem::OptionItem(int _id, string _displayValue) : //OptionInteger void OptionInteger::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT)); JRenderer * renderer = JRenderer::GetInstance(); @@ -78,7 +78,7 @@ void OptionSelect::Entering(JButton key) void OptionSelect::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT)); JRenderer * renderer = JRenderer::GetInstance(); @@ -193,7 +193,7 @@ void OptionProfile::populate() void OptionProfile::Render() { JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetScale(1); int spacing = 2 + (int) mFont->GetHeight(); @@ -206,7 +206,7 @@ void OptionProfile::Render() else sprintf(buf, "profiles/%s/avatar.jpg", selections[value].c_str()); string filename = buf; - JQuad * mAvatar = resources.RetrieveTempQuad(filename, TEXTURE_SUB_EXACT); + JQuad * mAvatar = WResourceManager::Instance()->RetrieveTempQuad(filename, TEXTURE_SUB_EXACT); if (mAvatar) { @@ -472,7 +472,7 @@ JQuad * OptionTheme::getImage() else sprintf(buf, "themes/%s/preview.png", val.c_str()); string filename = buf; - return resources.RetrieveTempQuad(filename, TEXTURE_SUB_EXACT); + return WResourceManager::Instance()->RetrieveTempQuad(filename, TEXTURE_SUB_EXACT); } float OptionTheme::getHeight() @@ -520,7 +520,7 @@ void OptionTheme::Render() renderer->RenderQuad(q, x, y, 0, scale, scale); } - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT_HEADER)); mFont->DrawString(buf, x + 2, y + 2); if (bChecked && author.size()) @@ -554,7 +554,7 @@ void OptionTheme::confirmChange(bool confirmed) if (ts) ts->Reload(); - resources.Refresh(); //Update images + WResourceManager::Instance()->Refresh(); //Update images prior_value = value; } } @@ -571,7 +571,7 @@ void OptionKey::Update(float dt) } void OptionKey::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT)); JRenderer * renderer = JRenderer::GetInstance(); @@ -652,7 +652,7 @@ bool OptionKey::isModal() void OptionKey::Overlay() { JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(ARGB(255, 0, 0, 0)); if (grabbed) { diff --git a/projects/mtg/src/Player.cpp b/projects/mtg/src/Player.cpp index 1d59464f5..85320330d 100644 --- a/projects/mtg/src/Player.cpp +++ b/projects/mtg/src/Player.cpp @@ -46,7 +46,7 @@ Player::~Player() { SAFE_DELETE(manaPool); SAFE_DELETE(game); - resources.Release(mAvatarTex); + WResourceManager::Instance()->Release(mAvatarTex); mAvatar = NULL; mAvatarTex = NULL; } @@ -55,13 +55,13 @@ void Player::loadAvatar(string file) { if (mAvatarTex) { - resources.Release(mAvatarTex); + WResourceManager::Instance()->Release(mAvatarTex); mAvatar = NULL; mAvatarTex = NULL; } - mAvatarTex = resources.RetrieveTexture(file, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); + mAvatarTex = WResourceManager::Instance()->RetrieveTexture(file, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR); if (mAvatarTex) - mAvatar = resources.RetrieveQuad(file, 0, 0, 35, 50, "playerAvatar", RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR); + mAvatar = WResourceManager::Instance()->RetrieveQuad(file, 0, 0, 35, 50, "playerAvatar", RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR); else mAvatar = NULL; } diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 5e88176b1..9cd996c42 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -43,16 +43,16 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, float x, floa JRenderer* renderer = JRenderer::GetInstance(); - if (!spadeLTex) spadeLTex = resources.RetrieveTexture("spade_ul.png", RETRIEVE_MANAGE); - if (!spadeRTex) spadeRTex = resources.RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE); + if (!spadeLTex) spadeLTex = WResourceManager::Instance()->RetrieveTexture("spade_ul.png", RETRIEVE_MANAGE); + if (!spadeRTex) spadeRTex = WResourceManager::Instance()->RetrieveTexture("spade_ur.png", RETRIEVE_MANAGE); if (!jewelTex) jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM); - if (!sideTex) sideTex = resources.RetrieveTexture("menuside.png", RETRIEVE_MANAGE); - if (NULL == spadeL) spadeL = resources.RetrieveQuad("spade_ul.png", 0, 0, 11, 11, "spade_ul", RETRIEVE_MANAGE); - if (NULL == spadeR) spadeR = resources.RetrieveQuad("spade_ur.png", 0, 0, 11, 11, "spade_ur", RETRIEVE_MANAGE); + if (!sideTex) sideTex = WResourceManager::Instance()->RetrieveTexture("menuside.png", RETRIEVE_MANAGE); + if (NULL == spadeL) spadeL = WResourceManager::Instance()->RetrieveQuad("spade_ul.png", 0, 0, 11, 11, "spade_ul", RETRIEVE_MANAGE); + if (NULL == spadeR) spadeR = WResourceManager::Instance()->RetrieveQuad("spade_ur.png", 0, 0, 11, 11, "spade_ur", RETRIEVE_MANAGE); if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3); - if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7, "menuside", RETRIEVE_MANAGE); + if (NULL == side) side = WResourceManager::Instance()->RetrieveQuad("menuside.png", 1, 1, 1, 7, "menuside", RETRIEVE_MANAGE); - if (NULL == stars) stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars"))); + if (NULL == stars) stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars"))); stars->FireAt(mX, mY); } @@ -89,8 +89,8 @@ void SimpleMenu::drawVertPole(float x, float y, float height) void SimpleMenu::Render() { - WFont * titleFont = resources.GetWFont(Fonts::SMALLFACE_FONT); - WFont * mFont = resources.GetWFont(fontId); + WFont * titleFont = WResourceManager::Instance()->GetWFont(Fonts::SMALLFACE_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); if (0 == mWidth) { float sY = mY + kVerticalMargin; @@ -140,7 +140,7 @@ void SimpleMenu::Render() { if (static_cast (mObjects[i])->hasFocus()) { - resources.GetWFont(Fonts::MAIN_FONT)->DrawString(static_cast (mObjects[i])->desc.c_str(), mX + WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT)->DrawString(static_cast (mObjects[i])->desc.c_str(), mX + mWidth + 10, mY + 15); mFont->SetColor(ARGB(255,255,255,0)); } diff --git a/projects/mtg/src/SimpleMenuItem.cpp b/projects/mtg/src/SimpleMenuItem.cpp index 54b3e5b01..0ec23036b 100644 --- a/projects/mtg/src/SimpleMenuItem.cpp +++ b/projects/mtg/src/SimpleMenuItem.cpp @@ -21,7 +21,7 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string t void SimpleMenuItem::RenderWithOffset(float yOffset) { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); } @@ -69,7 +69,7 @@ void SimpleMenuItem::Relocate(float x, float y) float SimpleMenuItem::GetWidth() { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); mFont->SetScale(1.0); return mFont->GetStringWidth(mText.c_str()); } diff --git a/projects/mtg/src/SimplePad.cpp b/projects/mtg/src/SimplePad.cpp index 125f64602..e57179926 100644 --- a/projects/mtg/src/SimplePad.cpp +++ b/projects/mtg/src/SimplePad.cpp @@ -304,7 +304,7 @@ string SimplePad::Finish() void SimplePad::Render() { //This could use some cleaning up to make margins more explicit - WFont * mFont = resources.GetWFont(Fonts::MENU_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); float offX = 0, offY = 0; float kH = mFont->GetHeight(); diff --git a/projects/mtg/src/SimplePopup.cpp b/projects/mtg/src/SimplePopup.cpp index bf647241c..8691ca447 100644 --- a/projects/mtg/src/SimplePopup.cpp +++ b/projects/mtg/src/SimplePopup.cpp @@ -22,7 +22,7 @@ SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const mTitle = _title; mMaxLines = 12; - mTextFont = resources.GetWFont(fontId); + mTextFont = WResourceManager::Instance()->GetWFont(fontId); this->mCount = 1; // a hack to ensure the menus do book keeping correctly. Since we aren't adding items to the menu, this is required mStatsWrapper = NULL; Update(deckMetaData); @@ -128,7 +128,7 @@ void SimplePopup::drawCorner(string imageName, bool flipX, bool flipY, float x, { LOG(" Drawing a Corner! "); JRenderer* r = JRenderer::GetInstance(); - JQuad *horizontalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551); + JQuad *horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); horizontalBarImage->SetHFlip(flipX); horizontalBarImage->SetVFlip(flipY); @@ -140,7 +140,7 @@ void SimplePopup::drawHorzPole(string imageName, bool flipX = false, bool flipY { LOG(" Drawing a horizontal border! "); JRenderer* r = JRenderer::GetInstance(); - JQuad *horizontalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551); + JQuad *horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); if ( horizontalBarImage != NULL ) { horizontalBarImage->SetHFlip(flipX); @@ -159,7 +159,7 @@ void SimplePopup::drawVertPole(string imageName, bool flipX = false, bool flipY { LOG(" Drawing a Vertical border! "); JRenderer* r = JRenderer::GetInstance(); - JQuad *verticalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551); + JQuad *verticalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551); if ( verticalBarImage != NULL ) { verticalBarImage->SetHFlip(flipX); diff --git a/projects/mtg/src/StoryFlow.cpp b/projects/mtg/src/StoryFlow.cpp index ed4c180a3..6738fdcfb 100644 --- a/projects/mtg/src/StoryFlow.cpp +++ b/projects/mtg/src/StoryFlow.cpp @@ -46,7 +46,7 @@ StoryText::StoryText(string text, float _mX, float _mY, string _align, int _font } void StoryText::Render() { - WFont * mFont = resources.GetWFont(font); + WFont * mFont = WResourceManager::Instance()->GetWFont(font); mFont->SetColor(ARGB(200,255,255,255)); mFont->SetScale(1.0); mFont->DrawString(text.c_str(), mX, mY, align); @@ -54,7 +54,7 @@ void StoryText::Render() float StoryText::getHeight() { - WFont * mFont = resources.GetWFont(font); + WFont * mFont = WResourceManager::Instance()->GetWFont(font); return mFont->GetHeight(); } @@ -171,7 +171,7 @@ void StoryReward::Update(float dt) if (!rewardSoundPlayed && options[Options::SFXVOLUME].number > 0) { - JSample * sample = resources.RetrieveSample("bonus.wav"); + JSample * sample = WResourceManager::Instance()->RetrieveSample("bonus.wav"); if (sample) { JSoundSystem::GetInstance()->PlaySample(sample); @@ -193,7 +193,7 @@ StoryImage::StoryImage(string img, float mX, float mY) : } void StoryImage::Render() { - JQuad * quad = resources.RetrieveTempQuad(img); + JQuad * quad = WResourceManager::Instance()->RetrieveTempQuad(img); if (quad) { float x = mX; @@ -208,7 +208,7 @@ void StoryImage::Render() float StoryImage::getHeight() { - JQuad * quad = resources.RetrieveQuad(img); + JQuad * quad = WResourceManager::Instance()->RetrieveQuad(img); if (quad) { return quad->mHeight; @@ -233,7 +233,7 @@ StoryPage::StoryPage(StoryFlow * mParent) : void StoryChoice::Render() { - WFont * mFont = resources.GetWFont(font); + WFont * mFont = WResourceManager::Instance()->GetWFont(font); mFont->SetColor(ARGB(200,255,255,255)); if (mHasFocus) mFont->SetColor(ARGB(255,255,255,0)); mFont->SetScale(mScale); @@ -242,7 +242,7 @@ void StoryChoice::Render() float StoryChoice::getHeight() { - WFont * mFont = resources.GetWFont(font); + WFont * mFont = WResourceManager::Instance()->GetWFont(font); return mFont->GetHeight() * mScale; } diff --git a/projects/mtg/src/StyleManager.cpp b/projects/mtg/src/StyleManager.cpp index b7c9d5cb6..3ec11235a 100644 --- a/projects/mtg/src/StyleManager.cpp +++ b/projects/mtg/src/StyleManager.cpp @@ -45,7 +45,7 @@ void StyleManager::loadRules() { killRules(); //TODO Placeholder until XML format available. - string filename = JGE_GET_RES(resources.graphicsFile("style.txt")); + string filename = JGE_GET_RES(WResourceManager::Instance()->graphicsFile("style.txt")); TiXmlDocument xmlfile(filename.c_str()); if (!xmlfile.LoadFile()) return; TiXmlHandle hDoc(&xmlfile); @@ -121,7 +121,7 @@ void StyleManager::determineActive(MTGDeck * p1, MTGDeck * p2) { string prior = activeStyle; activeStyle = check; - if (prior != activeStyle) resources.Refresh(); + if (prior != activeStyle) WResourceManager::Instance()->Refresh(); return; } topRule = -1; @@ -158,6 +158,6 @@ void StyleManager::determineActive(MTGDeck * p1, MTGDeck * p2) map::iterator mi = styles.find(rules[topRule]->style); if (mi != styles.end()) activeStyle = mi->first; } - if (prior != activeStyle) resources.Refresh(); + if (prior != activeStyle) WResourceManager::Instance()->Refresh(); } diff --git a/projects/mtg/src/Tasks.cpp b/projects/mtg/src/Tasks.cpp index 366b9d00b..ab01caae7 100644 --- a/projects/mtg/src/Tasks.cpp +++ b/projects/mtg/src/Tasks.cpp @@ -427,7 +427,7 @@ void TaskList::Start() mState = TASKS_IN; if (!mBgTex) { - mBgTex = resources.RetrieveTexture("taskboard.png", RETRIEVE_LOCK); + mBgTex = WResourceManager::Instance()->RetrieveTexture("taskboard.png", RETRIEVE_LOCK); float unitH = static_cast (mBgTex->mHeight / 4); float unitW = static_cast (mBgTex->mWidth / 4); if (unitH == 0 || unitW == 0) return; @@ -517,9 +517,9 @@ void TaskList::Render() { JRenderer * r = JRenderer::GetInstance(); //Setup fonts. - WFont * f = resources.GetWFont(Fonts::MAIN_FONT); - WFont * f2 = resources.GetWFont(Fonts::MAGIC_FONT); - WFont * f3 = resources.GetWFont(Fonts::MENU_FONT); //OPTION_FONT + WFont * f = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); + WFont * f2 = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); + WFont * f3 = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); //OPTION_FONT f2->SetColor(ARGB(255, 205, 237, 240)); f3->SetColor(ARGB(255, 219, 206, 151)); @@ -611,7 +611,7 @@ TaskList::~TaskList() { SAFE_DELETE(tasks[i]); } - if (mBgTex) resources.Release(mBgTex); + if (mBgTex) WResourceManager::Instance()->Release(mBgTex); for (int i = 0; i < 9; i++) SAFE_DELETE(mBg[i]); } diff --git a/projects/mtg/src/TextScroller.cpp b/projects/mtg/src/TextScroller.cpp index dd7880c91..075bb785e 100644 --- a/projects/mtg/src/TextScroller.cpp +++ b/projects/mtg/src/TextScroller.cpp @@ -47,7 +47,7 @@ void TextScroller::Update(float dt) if (!strings.size()) return; start += mScrollSpeed * dt; - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); if (start > mFont->GetStringWidth(mText.c_str())) { start = -mWidth; @@ -66,7 +66,7 @@ void TextScroller::Update(float dt) void TextScroller::Render() { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); mFont->DrawString(mText.c_str(), mX, mY, JGETEXT_LEFT, start, mWidth); } @@ -97,7 +97,7 @@ TextScroller( fontId, x, y, width, scrollSpeed) mNbItemsShown = numItemsShown; mMarginX = 0; timer=0; - WFont *mFont = resources.GetWFont(fontId); + WFont *mFont = WResourceManager::Instance()->GetWFont(fontId); mOriginalY = mY; mMarginY = mY - mFont->GetHeight(); Add("\n"); // initialize the scroller with a blank line @@ -144,6 +144,6 @@ void VerticalTextScroller::Update(float dt) void VerticalTextScroller::Render() { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); mFont->DrawString(mText.c_str(), mX, mY); } \ No newline at end of file diff --git a/projects/mtg/src/TranslateKeys.cpp b/projects/mtg/src/TranslateKeys.cpp index 86481a869..bbcd2f643 100644 --- a/projects/mtg/src/TranslateKeys.cpp +++ b/projects/mtg/src/TranslateKeys.cpp @@ -112,19 +112,19 @@ const KeyRep& translateKey(LocalKeySym key) KeyRep& k = res->second; switch (key) { - case PSP_CTRL_SELECT : k.second = resources.RetrieveQuad("iconspsp.png", (float)2*32, 32, 64, 32, "PSP_CTRL_SELECT", RETRIEVE_NORMAL); break; - case PSP_CTRL_START : k.second = resources.RetrieveQuad("iconspsp.png", (float)0*32, 32, 64, 32, "PSP_CTRL_START", RETRIEVE_NORMAL); break; - case PSP_CTRL_UP : k.second = resources.RetrieveQuad("iconspsp.png", (float)0*32, 0, 32, 32, "PSP_CTRL_UP", RETRIEVE_NORMAL); break; - case PSP_CTRL_RIGHT : k.second = resources.RetrieveQuad("iconspsp.png", (float)3*32, 0, 32, 32, "PSP_CTRL_RIGHT", RETRIEVE_NORMAL); break; - case PSP_CTRL_DOWN : k.second = resources.RetrieveQuad("iconspsp.png", (float)1*32, 0, 32, 32, "PSP_CTRL_DOWN", RETRIEVE_NORMAL); break; - case PSP_CTRL_LEFT : k.second = resources.RetrieveQuad("iconspsp.png", (float)2*32, 0, 32, 32, "PSP_CTRL_LEFT", RETRIEVE_NORMAL); break; - case PSP_CTRL_LTRIGGER : k.second = resources.RetrieveQuad("iconspsp.png", (float)6*32, 32, 64, 32, "PSP_CTRL_LTRIGGER", RETRIEVE_NORMAL); break; - case PSP_CTRL_RTRIGGER : k.second = resources.RetrieveQuad("iconspsp.png", (float)8*32, 32, 64, 32, "PSP_CTRL_RTRIGGER", RETRIEVE_NORMAL); break; - case PSP_CTRL_TRIANGLE : k.second = resources.RetrieveQuad("iconspsp.png", (float)5*32, 0, 32, 32, "PSP_CTRL_TRIANGLE", RETRIEVE_NORMAL); break; - case PSP_CTRL_CIRCLE : k.second = resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL); break; - case PSP_CTRL_CROSS : k.second = resources.RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL); break; - case PSP_CTRL_SQUARE : k.second = resources.RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL); break; - case PSP_CTRL_HOLD : k.second = resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_HOLD", RETRIEVE_NORMAL); break; + case PSP_CTRL_SELECT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)2*32, 32, 64, 32, "PSP_CTRL_SELECT", RETRIEVE_NORMAL); break; + case PSP_CTRL_START : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)0*32, 32, 64, 32, "PSP_CTRL_START", RETRIEVE_NORMAL); break; + case PSP_CTRL_UP : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)0*32, 0, 32, 32, "PSP_CTRL_UP", RETRIEVE_NORMAL); break; + case PSP_CTRL_RIGHT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)3*32, 0, 32, 32, "PSP_CTRL_RIGHT", RETRIEVE_NORMAL); break; + case PSP_CTRL_DOWN : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)1*32, 0, 32, 32, "PSP_CTRL_DOWN", RETRIEVE_NORMAL); break; + case PSP_CTRL_LEFT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)2*32, 0, 32, 32, "PSP_CTRL_LEFT", RETRIEVE_NORMAL); break; + case PSP_CTRL_LTRIGGER : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)6*32, 32, 64, 32, "PSP_CTRL_LTRIGGER", RETRIEVE_NORMAL); break; + case PSP_CTRL_RTRIGGER : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)8*32, 32, 64, 32, "PSP_CTRL_RTRIGGER", RETRIEVE_NORMAL); break; + case PSP_CTRL_TRIANGLE : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)5*32, 0, 32, 32, "PSP_CTRL_TRIANGLE", RETRIEVE_NORMAL); break; + case PSP_CTRL_CIRCLE : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL); break; + case PSP_CTRL_CROSS : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL); break; + case PSP_CTRL_SQUARE : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL); break; + case PSP_CTRL_HOLD : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_HOLD", RETRIEVE_NORMAL); break; default: /* Unknown key : no icon */ ; } return k; @@ -191,18 +191,18 @@ const KeyRep& translateKey(JButton key) { KeyRep& k = res->second; switch (key) { - case JGE_BTN_CTRL : k.second = resources.RetrieveQuad("iconspsp.png", (float)2*32, 32, 64, 32, "PSP_CTRL_SELECT", RETRIEVE_NORMAL); break; - case JGE_BTN_MENU : k.second = resources.RetrieveQuad("iconspsp.png", (float)0*32, 32, 64, 32, "PSP_CTRL_START", RETRIEVE_NORMAL); break; - case JGE_BTN_UP : k.second = resources.RetrieveQuad("iconspsp.png", (float)0*32, 0, 32, 32, "PSP_CTRL_UP", RETRIEVE_NORMAL); break; - case JGE_BTN_RIGHT : k.second = resources.RetrieveQuad("iconspsp.png", (float)3*32, 0, 32, 32, "PSP_CTRL_RIGHT", RETRIEVE_NORMAL); break; - case JGE_BTN_DOWN : k.second = resources.RetrieveQuad("iconspsp.png", (float)1*32, 0, 32, 32, "PSP_CTRL_DOWN", RETRIEVE_NORMAL); break; - case JGE_BTN_LEFT : k.second = resources.RetrieveQuad("iconspsp.png", (float)2*32, 0, 32, 32, "PSP_CTRL_LEFT", RETRIEVE_NORMAL); break; - case JGE_BTN_PREV : k.second = resources.RetrieveQuad("iconspsp.png", (float)6*32, 32, 64, 32, "PSP_CTRL_LTRIGGER", RETRIEVE_NORMAL); break; - case JGE_BTN_NEXT : k.second = resources.RetrieveQuad("iconspsp.png", (float)8*32, 32, 64, 32, "PSP_CTRL_RTRIGGER", RETRIEVE_NORMAL); break; - case JGE_BTN_CANCEL : k.second = resources.RetrieveQuad("iconspsp.png", (float)5*32, 0, 32, 32, "PSP_CTRL_TRIANGLE", RETRIEVE_NORMAL); break; - case JGE_BTN_OK : k.second = resources.RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL); break; - case JGE_BTN_SEC : k.second = resources.RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL); break; - case JGE_BTN_PRI : k.second = resources.RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL); break; + case JGE_BTN_CTRL : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)2*32, 32, 64, 32, "PSP_CTRL_SELECT", RETRIEVE_NORMAL); break; + case JGE_BTN_MENU : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)0*32, 32, 64, 32, "PSP_CTRL_START", RETRIEVE_NORMAL); break; + case JGE_BTN_UP : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)0*32, 0, 32, 32, "PSP_CTRL_UP", RETRIEVE_NORMAL); break; + case JGE_BTN_RIGHT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)3*32, 0, 32, 32, "PSP_CTRL_RIGHT", RETRIEVE_NORMAL); break; + case JGE_BTN_DOWN : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)1*32, 0, 32, 32, "PSP_CTRL_DOWN", RETRIEVE_NORMAL); break; + case JGE_BTN_LEFT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)2*32, 0, 32, 32, "PSP_CTRL_LEFT", RETRIEVE_NORMAL); break; + case JGE_BTN_PREV : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)6*32, 32, 64, 32, "PSP_CTRL_LTRIGGER", RETRIEVE_NORMAL); break; + case JGE_BTN_NEXT : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)8*32, 32, 64, 32, "PSP_CTRL_RTRIGGER", RETRIEVE_NORMAL); break; + case JGE_BTN_CANCEL : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)5*32, 0, 32, 32, "PSP_CTRL_TRIANGLE", RETRIEVE_NORMAL); break; + case JGE_BTN_OK : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)4*32, 0, 32, 32, "PSP_CTRL_CIRCLE", RETRIEVE_NORMAL); break; + case JGE_BTN_SEC : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)7*32, 0, 32, 32, "PSP_CTRL_CROSS", RETRIEVE_NORMAL); break; + case JGE_BTN_PRI : k.second = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float)6*32, 0, 32, 32, "PSP_CTRL_SQUARE", RETRIEVE_NORMAL); break; default: /* Unknown key : no icon */ ; } return k; diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index cc7265884..88e7e3d71 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -17,7 +17,7 @@ WResource::~WResource() WResource::WResource() { locks = WRES_UNLOCKED; - lastTime = resources.nowTime(); + lastTime = WResourceManager::Instance()->nowTime(); loadedMode = 0; } @@ -60,7 +60,7 @@ void WResource::unlock(bool force) void WResource::hit() { - lastTime = resources.nowTime(); + lastTime = WResourceManager::Instance()->nowTime(); } WCachedResource::~WCachedResource() @@ -174,7 +174,7 @@ WTrackedQuad * WCachedTexture::GetTrackedQuad(float offX, float offY, float widt There's a risk this erases the texture calling the quad creation.... Erwan 2010/03/13 if(!quad) { //Probably out of memory. Try again. - resources.Cleanup(); + WResourceManager::Instance()->Cleanup(); quad = NEW JQuad(texture,offX,offY,width,height); } */ @@ -289,16 +289,16 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error) } } - realname = resources.cardFile(filename); + realname = WResourceManager::Instance()->cardFile(filename); } else { if (submode & TEXTURE_SUB_THUMB) filename.insert(0, "thumbnails/"); if (submode & TEXTURE_SUB_AVATAR) - realname = resources.avatarFile(filename); + realname = WResourceManager::Instance()->avatarFile(filename); else - realname = resources.graphicsFile(filename); + realname = WResourceManager::Instance()->graphicsFile(filename); } //Apply pixel mode @@ -362,7 +362,7 @@ bool WCachedSample::Attempt(string filename, int submode, int & error) { loadedMode = submode; - sample = JSoundSystem::GetInstance()->LoadSample(resources.sfxFile(filename).c_str()); + sample = JSoundSystem::GetInstance()->LoadSample(WResourceManager::Instance()->sfxFile(filename).c_str()); if (!isGood()) { @@ -417,7 +417,7 @@ bool WCachedParticles::Attempt(string filename, int submode, int & error) JFileSystem* fileSys = JFileSystem::GetInstance(); - if (!fileSys->OpenFile(resources.graphicsFile(filename))) + if (!fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename))) { error = CACHE_ERROR_404; return false; diff --git a/projects/mtg/src/WDataSrc.cpp b/projects/mtg/src/WDataSrc.cpp index e004cea88..f9bf57918 100644 --- a/projects/mtg/src/WDataSrc.cpp +++ b/projects/mtg/src/WDataSrc.cpp @@ -37,7 +37,7 @@ bool WSyncable::prev() //WSrcImage JQuad * WSrcImage::getImage(int offset) { - return resources.RetrieveTempQuad(filename); + return WResourceManager::Instance()->RetrieveTempQuad(filename); } WSrcImage::WSrcImage(string s) @@ -60,15 +60,15 @@ JQuad * WSrcCards::getImage(int offset) #else if (mDelay && mLastInput < mDelay) { - return resources.RetrieveCard(getCard(offset), RETRIEVE_EXISTING); + return WResourceManager::Instance()->RetrieveCard(getCard(offset), RETRIEVE_EXISTING); } #endif - return resources.RetrieveCard(getCard(offset)); + return WResourceManager::Instance()->RetrieveCard(getCard(offset)); } JQuad * WSrcCards::getThumb(int offset) { - return resources.RetrieveCard(getCard(offset), RETRIEVE_THUMB); + return WResourceManager::Instance()->RetrieveCard(getCard(offset), RETRIEVE_THUMB); } WSrcCards::~WSrcCards() diff --git a/projects/mtg/src/WFont.cpp b/projects/mtg/src/WFont.cpp index da345b0fe..553f38ae7 100644 --- a/projects/mtg/src/WFont.cpp +++ b/projects/mtg/src/WFont.cpp @@ -371,7 +371,7 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO { // tricky: the single byte font is always mFontID + kSingleByteFontOffset! // See WResourceManager::InitFonts() - WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset); + WFont * mFont = WResourceManager::Instance()->GetWFont(mFontID + Fonts::kSingleByteFontOffset); mFont->SetScale(GetScale()); mFont->SetColor(GetColor()); mFont->DrawString(s, x, y, align, leftOffset, width); @@ -572,7 +572,7 @@ float WFBFont::GetStringWidth(const char *s) const } else { - WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset); + WFont * mFont = WResourceManager::Instance()->GetWFont(mFontID + Fonts::kSingleByteFontOffset); mFont->SetScale(GetScale()); return mFont->GetStringWidth(s); } @@ -773,7 +773,7 @@ void WGBKFont::DrawString(const char *s, float x, float y, int align, float left { // tricky: the single byte font is always mFontID + kSingleByteFontOffset! // See WResourceManager::InitFonts() - WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset); + WFont * mFont = WResourceManager::Instance()->GetWFont(mFontID + Fonts::kSingleByteFontOffset); mFont->SetScale(GetScale()); mFont->SetColor(GetColor()); mFont->DrawString(s, x, y, align, leftOffset, width); @@ -993,7 +993,7 @@ float WGBKFont::GetStringWidth(const char *s) const } else { - WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset); + WFont * mFont = WResourceManager::Instance()->GetWFont(mFontID + Fonts::kSingleByteFontOffset); mFont->SetScale(GetScale()); return mFont->GetStringWidth(s); } diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index 71636da0c..26d710c81 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -77,12 +77,12 @@ void WGuiItem::Entering(JButton key) } float WGuiItem::minWidth() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); return mFont->GetStringWidth(_(displayValue).c_str()) + 4; } float WGuiItem::minHeight() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); return mFont->GetHeight(); } @@ -95,7 +95,7 @@ bool WGuiItem::Leaving(JButton key) void WGuiItem::Render() { JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); DWORD oldcolor = mFont->GetColor(); mFont->SetColor(getColor(WGuiColor::TEXT)); float fH = (height - mFont->GetHeight()) / 2; @@ -188,7 +188,7 @@ PIXEL_TYPE WDecoStyled::getColor(int type) //WGuiHeader void WGuiHeader::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT)); JRenderer * renderer = JRenderer::GetInstance(); @@ -299,7 +299,7 @@ void WGuiList::Render() //List is empty. if (!items.size() && failMsg != "") { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT_FAIL)); mFont->DrawString(_(failMsg).c_str(), x + width / 2, y, JGETEXT_RIGHT); return; @@ -439,7 +439,7 @@ string WDecoEnum::lookupVal(int value) void WDecoEnum::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT)); JRenderer * renderer = JRenderer::GetInstance(); mFont->DrawString(_(getDisplay()).c_str(), getX() + 2, getY() + 3); @@ -1095,7 +1095,7 @@ void WGuiTabMenu::Add(WGuiBase * it) void WGuiTabMenu::Render() { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); JRenderer * renderer = JRenderer::GetInstance(); if (!items.size()) return; @@ -1127,7 +1127,7 @@ void WGuiTabMenu::save() void WGuiAward::Overlay() { JRenderer * r = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetScale(0.8f); mFont->SetColor(getColor(WGuiColor::TEXT)); @@ -1138,7 +1138,7 @@ void WGuiAward::Overlay() float fH = mFont->GetHeight(); if (fH < 16) fH = 18; - JQuad * button = resources.RetrieveQuad("iconspsp.png", (float) 4 * 32, 0, 32, 32, "", RETRIEVE_NORMAL); + JQuad * button = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) 4 * 32, 0, 32, 32, "", RETRIEVE_NORMAL); r->FillRoundRect(5, 10, fW + 32, fH + 2, 2, getColor(WGuiColor::BACK)); if (button) r->RenderQuad(button, 10, 12, 0, .5, .5); @@ -1157,16 +1157,16 @@ void WGuiAward::Underlay() if (n.size()) { sprintf(buf, "trophy_%s.png", n.c_str()); //Trophy specific to the award - trophy = resources.RetrieveTempQuad(buf); //Themed version... + trophy = WResourceManager::Instance()->RetrieveTempQuad(buf); //Themed version... } if (!trophy && id >= Options::SET_UNLOCKS) { - trophy = resources.RetrieveTempQuad("trophy_set.png"); //TODO FIXME: Should look in set dir too. + trophy = WResourceManager::Instance()->RetrieveTempQuad("trophy_set.png"); //TODO FIXME: Should look in set dir too. } if (!trophy) //Fallback to basic trophy image. - trophy = resources.RetrieveTempQuad("trophy.png"); + trophy = WResourceManager::Instance()->RetrieveTempQuad("trophy.png"); if (trophy) { @@ -1181,7 +1181,7 @@ void WGuiAward::Render() if (!goa) return; JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetScale(1); mFont->SetColor(getColor(WGuiColor::TEXT)); @@ -1296,14 +1296,14 @@ void WGuiCardImage::Render() JQuad * q; if (bThumb) { - q = resources.GetQuad("back_thumb"); + q = WResourceManager::Instance()->GetQuad("back_thumb"); #if defined WIN32 || defined LINUX if(!q) - q = resources.GetQuad("back"); + q = WResourceManager::Instance()->GetQuad("back"); #endif } else - q = resources.GetQuad("back"); + q = WResourceManager::Instance()->GetQuad("back"); float scale = p.actZ * 257.f / q->mHeight; q->SetColor(ARGB(255,255,255,255)); renderer->RenderQuad(q, p.x, p.y, 0, scale, scale); @@ -1362,14 +1362,14 @@ void WGuiCardDistort::Render() //Default to back. if (bThumb) { - q = resources.GetQuad("back_thumb"); + q = WResourceManager::Instance()->GetQuad("back_thumb"); #if defined WIN32 || defined LINUX if(!q) - q = resources.GetQuad("back"); + q = WResourceManager::Instance()->GetQuad("back"); #endif } else - q = resources.GetQuad("back"); + q = WResourceManager::Instance()->GetQuad("back"); } else { @@ -1457,7 +1457,7 @@ void WGuiListRow::Render() //List is empty. if (!items.size() && failMsg != "") { - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT_FAIL)); mFont->DrawString(_(failMsg).c_str(), x + width / 2, y, JGETEXT_RIGHT); return; @@ -2228,7 +2228,7 @@ void WGuiKeyBinder::Render() if (confirmMenu) { JRenderer * renderer = JRenderer::GetInstance(); - WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT); + WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); mFont->SetColor(ARGB(255, 255, 0, 0)); renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240)); diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 92b57919a..496c22c90 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -19,7 +19,6 @@ const unsigned int kConstrainedCacheLimit = 8 * 1024 * 1024; extern bool neofont; int idCounter = OTHERS_OFFSET; -WResourceManager resources; namespace { @@ -28,6 +27,8 @@ namespace const std::string kExtension_font(".font"); } +WResourceManager* WResourceManager::sInstance = NULL; + int WResourceManager::RetrieveError() { return lastError; @@ -46,7 +47,7 @@ bool WResourceManager::RemoveOldest() void WResourceManager::DebugRender() { JRenderer* renderer = JRenderer::GetInstance(); - WFont * font = resources.GetWFont(Fonts::MAIN_FONT); + WFont * font = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); font->SetColor(ARGB(255,255,255,255)); if (!font || !renderer) return; @@ -1198,7 +1199,7 @@ cacheItem* WCache::Retrieve(int id, const string& filena //Unlink the managed resource from the cache. UnlinkCache(tc); - //Post it in managed resources. + //Post it in managed WResourceManager::Instance()-> managed[makeID(id, filename, submode)] = tc; tc->deadbolt(); } diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index 9f3f466d3..ee3f9c4d7 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -243,7 +243,7 @@ std::vector split(const std::string &s, char delim) // Not sure how this translates into non-english fonts. std::string wordWrap(std::string sentence, float width, int fontId) { - WFont * mFont = resources.GetWFont(fontId); + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); float lineWidth = mFont->GetStringWidth( sentence.c_str() ); string retVal = sentence; if ( lineWidth < width ) return sentence;