Another change that looks bigger than it is: changed out the global extern WResourceManager to a real singleton. This means that it's no longer being init'ed at static initialization time, and we can debug construction/destruction properly; it's also safer in a multithreaded context.

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