Jeck - Please review: this makes minor changes to a lot of files, and major changes to the WCache flatten() function.
* Removed all calls to Release(JQuad*). * Updated flatten(). Prior flatten was buggy beyond belief. * Done some extensive testing, but if this causes more trouble than it fixes, we'll have to revert. It's too close to release time.
This commit is contained in:
@@ -20,6 +20,7 @@ class GameStateMenu: public GameState, public JGuiListener
|
|||||||
JTexture * bgTexture;
|
JTexture * bgTexture;
|
||||||
JQuad * mBg;
|
JQuad * mBg;
|
||||||
JQuad * mSplash;
|
JQuad * mSplash;
|
||||||
|
JTexture * splashTex;
|
||||||
float mCreditsYPos;
|
float mCreditsYPos;
|
||||||
int currentState;
|
int currentState;
|
||||||
//JMusic * bgMusic;
|
//JMusic * bgMusic;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class GameStateShop: public GameState, public JGuiListener
|
|||||||
JLBFont * itemFont;
|
JLBFont * itemFont;
|
||||||
JTexture * altThumb[8];
|
JTexture * altThumb[8];
|
||||||
JQuad * mBack;
|
JQuad * mBack;
|
||||||
|
JQuad * mBg;
|
||||||
|
JTexture * mBgTex;
|
||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
int mStage;
|
int mStage;
|
||||||
char starterBuffer[128], boosterBuffer[128];
|
char starterBuffer[128], boosterBuffer[128];
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class GuiPhaseBar : public GuiLayer
|
|||||||
static const unsigned Phases = 12;
|
static const unsigned Phases = 12;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
JQuad* quad;
|
|
||||||
Phase* phase;
|
Phase* phase;
|
||||||
float angle;
|
float angle;
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class ShopItems:public JGuiController,public JGuiListener{
|
|||||||
PriceList * pricelist;
|
PriceList * pricelist;
|
||||||
int mX, mY, mHeight;
|
int mX, mY, mHeight;
|
||||||
JLBFont* mFont;
|
JLBFont* mFont;
|
||||||
|
JTexture * mBgAATex;
|
||||||
JQuad * mBgAA;
|
JQuad * mBgAA;
|
||||||
MTGAllCards * collection;
|
MTGAllCards * collection;
|
||||||
SimpleMenu * dialog;
|
SimpleMenu * dialog;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
class WResource{
|
class WResource{
|
||||||
public:
|
public:
|
||||||
friend class WResourceManager;
|
friend class WResourceManager;
|
||||||
|
friend struct WCacheSort;
|
||||||
template<class cacheItem,class cacheActual> friend class WCache;
|
template<class cacheItem,class cacheActual> friend class WCache;
|
||||||
|
|
||||||
WResource();
|
WResource();
|
||||||
@@ -64,8 +65,7 @@ public:
|
|||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
unsigned long size();
|
unsigned long size();
|
||||||
bool isGood();
|
bool isGood();
|
||||||
bool isLocked();
|
|
||||||
bool Attempt(string filename, int submode, int & error);
|
bool Attempt(string filename, int submode, int & error);
|
||||||
bool compare(JTexture * t) {return (t == texture);};
|
bool compare(JTexture * t) {return (t == texture);};
|
||||||
JTexture * Actual(); //Return this texture as is. Does not make a new one.
|
JTexture * Actual(); //Return this texture as is. Does not make a new one.
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this
|
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this
|
||||||
#define OPERATIONAL_SIZE 5000000 // Size required by Wagic for operational stuff. 3MB is not enough. The cache will usually try to take (Total Ram - Operational size)
|
#define OPERATIONAL_SIZE 5000000 // Size required by Wagic for operational stuff. 3MB is not enough. The cache will usually try to take (Total Ram - Operational size)
|
||||||
#define MIN_LINEAR_RAM 1000000
|
#define MIN_LINEAR_RAM 1000000
|
||||||
|
#ifdef DEBUG_CACHE
|
||||||
|
#define MAX_CACHE_TIME 2000 //The threshold above which we try to prevent nowTime() from looping.
|
||||||
|
#else
|
||||||
|
#define MAX_CACHE_TIME 2000000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define THUMBNAILS_OFFSET 100000000
|
#define THUMBNAILS_OFFSET 100000000
|
||||||
#define OTHERS_OFFSET 2000000000
|
#define OTHERS_OFFSET 2000000000
|
||||||
@@ -67,6 +73,10 @@ enum ENUM_CACHE_ERROR{
|
|||||||
CACHE_ERROR_NOT_MANAGED,
|
CACHE_ERROR_NOT_MANAGED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WCacheSort{
|
||||||
|
bool operator()(const WResource * l, const WResource * r); //Predicate for use in sorting. See flatten().
|
||||||
|
};
|
||||||
|
|
||||||
template <class cacheItem, class cacheActual>
|
template <class cacheItem, class cacheActual>
|
||||||
class WCache{
|
class WCache{
|
||||||
public:
|
public:
|
||||||
@@ -84,7 +94,6 @@ public:
|
|||||||
void Refresh(); //Refreshes all cache items.
|
void Refresh(); //Refreshes all cache items.
|
||||||
unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime.
|
unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime.
|
||||||
void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit".
|
void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit".
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool RemoveItem(cacheItem * item, bool force = true); //Removes an item, deleting it. if(force), ignores locks / permanent
|
bool RemoveItem(cacheItem * item, bool force = true); //Removes an item, deleting it. if(force), ignores locks / permanent
|
||||||
bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care.
|
bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care.
|
||||||
@@ -121,6 +130,7 @@ public:
|
|||||||
WResourceManager();
|
WResourceManager();
|
||||||
~WResourceManager();
|
~WResourceManager();
|
||||||
|
|
||||||
|
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);
|
||||||
JSample * RetrieveSample(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
JSample * RetrieveSample(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
||||||
JTexture * RetrieveTexture(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
JTexture * RetrieveTexture(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
|
||||||
@@ -130,7 +140,6 @@ public:
|
|||||||
int RetrieveError();
|
int RetrieveError();
|
||||||
|
|
||||||
void Release(JTexture * tex);
|
void Release(JTexture * tex);
|
||||||
void Release(JQuad * quad);
|
|
||||||
void Release(JSample * sample);
|
void Release(JSample * sample);
|
||||||
bool RemoveOldest();
|
bool RemoveOldest();
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ void GameApp::Create()
|
|||||||
jq->SetHotSpot(12, 12);
|
jq->SetHotSpot(12, 12);
|
||||||
jq = resources.RetrieveQuad("shadow.png", 0, 0, 16, 16,"shadow",RETRIEVE_MANAGE);
|
jq = resources.RetrieveQuad("shadow.png", 0, 0, 16, 16,"shadow",RETRIEVE_MANAGE);
|
||||||
jq->SetHotSpot(8, 8);
|
jq->SetHotSpot(8, 8);
|
||||||
|
jq = resources.RetrieveQuad("phasebar.png",0,0,0,0,"phasebar",RETRIEVE_MANAGE);
|
||||||
|
|
||||||
collection = NEW MTGAllCards();
|
collection = NEW MTGAllCards();
|
||||||
|
|
||||||
@@ -223,7 +224,6 @@ void GameApp::Destroy()
|
|||||||
|
|
||||||
void GameApp::Update()
|
void GameApp::Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (systemError.size()) return;
|
if (systemError.size()) return;
|
||||||
JGE* mEngine = JGE::GetInstance();
|
JGE* mEngine = JGE::GetInstance();
|
||||||
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonClick(PSP_CTRL_TRIANGLE))
|
if (mEngine->GetButtonState(PSP_CTRL_START) && mEngine->GetButtonClick(PSP_CTRL_TRIANGLE))
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ void GameStateDeckViewer::Start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Grab a texture in VRAM.
|
//Grab a texture in VRAM.
|
||||||
pspIconsTexture = resources.RetrieveTexture("iconspsp.png");
|
pspIconsTexture = resources.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++){
|
||||||
@@ -183,9 +183,6 @@ void GameStateDeckViewer::End()
|
|||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
|
|
||||||
resources.Release(pspIconsTexture);
|
resources.Release(pspIconsTexture);
|
||||||
for (int i=0; i < 8; i++){
|
|
||||||
resources.Release(pspIcons[i]);
|
|
||||||
}
|
|
||||||
SAFE_DELETE(myCollection);
|
SAFE_DELETE(myCollection);
|
||||||
SAFE_DELETE(myDeck);
|
SAFE_DELETE(myDeck);
|
||||||
SAFE_DELETE(pricelist);
|
SAFE_DELETE(pricelist);
|
||||||
|
|||||||
@@ -270,7 +270,6 @@ void GameStateMenu::End()
|
|||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
|
|
||||||
resources.Release(bgTexture);
|
resources.Release(bgTexture);
|
||||||
resources.Release(mBg);
|
|
||||||
SAFE_DELETE(mGuiController);
|
SAFE_DELETE(mGuiController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,12 +291,16 @@ void GameStateMenu::Update(float dt)
|
|||||||
//Force default, if necessary.
|
//Force default, if necessary.
|
||||||
if(options[Options::ACTIVE_PROFILE].str == "")
|
if(options[Options::ACTIVE_PROFILE].str == "")
|
||||||
options[Options::ACTIVE_PROFILE].str = "Default";
|
options[Options::ACTIVE_PROFILE].str = "Default";
|
||||||
|
|
||||||
|
//Release splash texture
|
||||||
|
resources.Release(splashTex);
|
||||||
|
splashTex = NULL;
|
||||||
|
mSplash = NULL;
|
||||||
|
|
||||||
//check for deleted collection / first-timer
|
//check for deleted collection / first-timer
|
||||||
std::ifstream file(options.profileFile(PLAYER_COLLECTION).c_str());
|
std::ifstream file(options.profileFile(PLAYER_COLLECTION).c_str());
|
||||||
if(file){
|
if(file){
|
||||||
file.close();
|
file.close();
|
||||||
resources.Release(mSplash);
|
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
}else{
|
}else{
|
||||||
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
||||||
@@ -409,8 +412,10 @@ void GameStateMenu::Render()
|
|||||||
renderer->ClearScreen(ARGB(0,0,0,0));
|
renderer->ClearScreen(ARGB(0,0,0,0));
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||||
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
|
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
|
||||||
if(!mSplash)
|
if(!splashTex){
|
||||||
mSplash = resources.RetrieveQuad("splash.jpg");
|
splashTex = resources.RetrieveTexture("splash.jpg",RETRIEVE_LOCK);
|
||||||
|
mSplash = resources.RetrieveTempQuad("splash.jpg");
|
||||||
|
}
|
||||||
if (mSplash){
|
if (mSplash){
|
||||||
renderer->RenderQuad(mSplash,0,0);
|
renderer->RenderQuad(mSplash,0,0);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -39,9 +39,14 @@ void GameStateShop::Start()
|
|||||||
altThumb[5] = resources.RetrieveTexture("white_thumb.jpg", RETRIEVE_LOCK);
|
altThumb[5] = resources.RetrieveTexture("white_thumb.jpg", RETRIEVE_LOCK);
|
||||||
altThumb[6] = resources.RetrieveTexture("land_thumb.jpg", RETRIEVE_LOCK);
|
altThumb[6] = resources.RetrieveTexture("land_thumb.jpg", RETRIEVE_LOCK);
|
||||||
altThumb[7] = resources.RetrieveTexture("gold_thumb.jpg", RETRIEVE_LOCK);
|
altThumb[7] = resources.RetrieveTexture("gold_thumb.jpg", RETRIEVE_LOCK);
|
||||||
|
|
||||||
|
|
||||||
mBack = resources.GetQuad("back");
|
mBack = resources.GetQuad("back");
|
||||||
|
//resources.Unmiss("shop.jpg"); //Last resort.
|
||||||
|
mBgTex = resources.RetrieveTexture("shop.jpg",RETRIEVE_LOCK);
|
||||||
|
if(mBgTex)
|
||||||
|
mBg = resources.RetrieveQuad("shop.jpg");
|
||||||
|
else
|
||||||
|
mBg = NULL;
|
||||||
|
|
||||||
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
|
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||||
itemFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
itemFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
@@ -123,6 +128,9 @@ void GameStateShop::load(){
|
|||||||
void GameStateShop::End()
|
void GameStateShop::End()
|
||||||
{
|
{
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
|
resources.Release(mBgTex);
|
||||||
|
mBgTex = NULL;
|
||||||
|
mBg = NULL;
|
||||||
|
|
||||||
//Release alternate thumbnails.
|
//Release alternate thumbnails.
|
||||||
for(int i=0;i<8;i++){
|
for(int i=0;i<8;i++){
|
||||||
@@ -166,7 +174,7 @@ void GameStateShop::Render()
|
|||||||
//Erase
|
//Erase
|
||||||
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.RetrieveQuad("shop.jpg");
|
|
||||||
if (mBg) r->RenderQuad(mBg,0,0);
|
if (mBg) r->RenderQuad(mBg,0,0);
|
||||||
|
|
||||||
if (shop)
|
if (shop)
|
||||||
|
|||||||
@@ -4,23 +4,14 @@
|
|||||||
|
|
||||||
GuiBackground::GuiBackground()
|
GuiBackground::GuiBackground()
|
||||||
{
|
{
|
||||||
JTexture* texture = resources.GetTexture("backdrop.jpg");
|
|
||||||
if (texture)
|
|
||||||
quad = NEW JQuad(texture, 0, 0, 480, 255);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
quad = NULL;
|
|
||||||
GameApp::systemError = "Error loading background texture : " __FILE__;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiBackground::~GuiBackground()
|
GuiBackground::~GuiBackground()
|
||||||
{
|
{
|
||||||
delete(quad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiBackground::Render()
|
void GuiBackground::Render()
|
||||||
{
|
{
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
renderer->RenderQuad(quad, 0, 18);
|
renderer->RenderQuad(resources.RetrieveTempQuad("backdrop.jpg"), 0, 18);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,44 +6,31 @@ GuiFrame::GuiFrame()
|
|||||||
{
|
{
|
||||||
if (resources.GetTexture("wood.png"))
|
if (resources.GetTexture("wood.png"))
|
||||||
wood = resources.RetrieveQuad("wood.png", 0, 0, SCREEN_WIDTH, 28);
|
wood = resources.RetrieveQuad("wood.png", 0, 0, SCREEN_WIDTH, 28);
|
||||||
else
|
else{
|
||||||
{
|
|
||||||
wood = NULL;
|
wood = NULL;
|
||||||
GameApp::systemError += "Can't load wood texture : " __FILE__ "\n";
|
GameApp::systemError += "Can't load wood texture : " __FILE__ "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resources.GetTexture("gold.png"))
|
|
||||||
{
|
goldGlow = gold1 = gold2 = NULL;
|
||||||
gold1 = resources.RetrieveQuad("gold.png", 0, 0, SCREEN_WIDTH, 6, "gold1");
|
if (resources.GetTexture("gold.png")){
|
||||||
gold2 = resources.RetrieveQuad("gold.png", 0, 6, SCREEN_WIDTH, 6, "gold2");
|
gold1 = resources.RetrieveQuad("gold.png", 0, 0, SCREEN_WIDTH, 6, "gold1");
|
||||||
}
|
gold2 = resources.RetrieveQuad("gold.png", 0, 6, SCREEN_WIDTH, 6, "gold2");
|
||||||
else
|
if (resources.GetTexture("goldglow.png"))
|
||||||
{
|
goldGlow = resources.RetrieveQuad("goldglow.png", 1, 1, SCREEN_WIDTH - 2, 18);
|
||||||
gold1 = gold2 = NULL;
|
if (gold2){
|
||||||
GameApp::systemError += "Can't load gold texture : " __FILE__ "\n";
|
gold2->SetColor(ARGB(127, 255, 255, 255));
|
||||||
}
|
gold2->SetHFlip(true);
|
||||||
if (resources.GetTexture("goldglow.png"))
|
|
||||||
goldGlow = resources.RetrieveQuad("goldglow.png", 1, 1, SCREEN_WIDTH - 2, 18);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
goldGlow = NULL;
|
|
||||||
GameApp::systemError += "Can't load gold glow texture : " __FILE__ "\n";
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
step = 0.0;
|
step = 0.0;
|
||||||
|
|
||||||
if (gold2){
|
|
||||||
gold2->SetColor(ARGB(127, 255, 255, 255));
|
|
||||||
gold2->SetHFlip(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiFrame::~GuiFrame()
|
GuiFrame::~GuiFrame()
|
||||||
{
|
{
|
||||||
resources.Release(gold2);
|
|
||||||
resources.Release(gold1);
|
|
||||||
resources.Release(wood);
|
|
||||||
resources.Release(goldGlow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiFrame::Render()
|
void GuiFrame::Render()
|
||||||
@@ -51,15 +38,21 @@ void GuiFrame::Render()
|
|||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
float sized = step / 4; if (sized > SCREEN_WIDTH) sized -= SCREEN_WIDTH;
|
float sized = step / 4; if (sized > SCREEN_WIDTH) sized -= SCREEN_WIDTH;
|
||||||
renderer->RenderQuad(wood, 0, 0);
|
renderer->RenderQuad(wood, 0, 0);
|
||||||
renderer->RenderQuad(gold1, -sized, 16);
|
if(gold1){
|
||||||
renderer->RenderQuad(gold1, -sized + 479, 16);
|
renderer->RenderQuad(gold1, -sized, 16);
|
||||||
|
renderer->RenderQuad(gold1, -sized + 479, 16);
|
||||||
|
|
||||||
|
if(goldGlow){
|
||||||
|
goldGlow->SetColor(ARGB((100+(rand()%50)), 255, 255, 255));
|
||||||
|
renderer->RenderQuad(goldGlow, -sized, 9);
|
||||||
|
renderer->RenderQuad(goldGlow, -sized + 480, 9);
|
||||||
|
}
|
||||||
|
|
||||||
goldGlow->SetColor(ARGB((100+(rand()%50)), 255, 255, 255));
|
if(gold2){
|
||||||
renderer->RenderQuad(goldGlow, -sized, 9);
|
renderer->RenderQuad(gold2, step / 2, 16);
|
||||||
renderer->RenderQuad(goldGlow, -sized + 480, 9);
|
renderer->RenderQuad(gold2, step / 2 - 479, 16);
|
||||||
|
}
|
||||||
renderer->RenderQuad(gold2, step / 2, 16);
|
}
|
||||||
renderer->RenderQuad(gold2, step / 2 - 479, 16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiFrame::Update(float dt)
|
void GuiFrame::Update(float dt)
|
||||||
|
|||||||
@@ -23,19 +23,19 @@ static int colors[] =
|
|||||||
|
|
||||||
GuiPhaseBar::GuiPhaseBar() : phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
|
GuiPhaseBar::GuiPhaseBar() : phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
|
||||||
{
|
{
|
||||||
JTexture* texture = resources.GetTexture("phasebar.png");
|
JQuad * quad;
|
||||||
if (texture)
|
if ((quad = resources.GetQuad("phasebar")) != NULL){
|
||||||
quad = NEW JQuad(texture, 0, 0, Width, Height);
|
quad->mHeight = Height;
|
||||||
|
quad->mWidth = Width;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
quad = NULL;
|
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
|
||||||
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiPhaseBar::~GuiPhaseBar()
|
GuiPhaseBar::~GuiPhaseBar()
|
||||||
{
|
{
|
||||||
delete(quad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiPhaseBar::Update(float dt)
|
void GuiPhaseBar::Update(float dt)
|
||||||
@@ -49,6 +49,7 @@ void GuiPhaseBar::Render()
|
|||||||
static const float CENTER = SCREEN_HEIGHT_F / 2 + 10;
|
static const float CENTER = SCREEN_HEIGHT_F / 2 + 10;
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
JQuad * quad = resources.GetQuad("phasebar");
|
||||||
unsigned p = (phase->id + Phases - 4) * (Width+1);
|
unsigned p = (phase->id + Phases - 4) * (Width+1);
|
||||||
float scale;
|
float scale;
|
||||||
float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
|
float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
|
||||||
|
|||||||
@@ -107,9 +107,8 @@ int ShopItem::updateCount(DeckDataWrapper * ddw){
|
|||||||
|
|
||||||
ShopItem::~ShopItem(){
|
ShopItem::~ShopItem(){
|
||||||
OutputDebugString("delete shopitem\n");
|
OutputDebugString("delete shopitem\n");
|
||||||
if(mRelease){
|
if(thumb)
|
||||||
resources.Release(thumb);
|
resources.Release(thumb->mTex);
|
||||||
}
|
|
||||||
SAFE_DELETE(mesh);
|
SAFE_DELETE(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,9 +218,12 @@ ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y
|
|||||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), _collection));
|
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), _collection));
|
||||||
showCardList = true;
|
showCardList = true;
|
||||||
|
|
||||||
mBgAA = resources.RetrieveQuad("shop_aliasing.png");
|
mBgAA = NULL;
|
||||||
if(mBgAA)
|
mBgAATex = resources.RetrieveTexture("shop_aliasing.png",RETRIEVE_LOCK);
|
||||||
|
if(mBgAATex){
|
||||||
|
mBgAA = resources.RetrieveQuad("shop_aliasing.png");
|
||||||
mBgAA->SetTextureRect(0,0,250,120);
|
mBgAA->SetTextureRect(0,0,250,120);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -453,7 +455,7 @@ ShopItems::~ShopItems(){
|
|||||||
SAFE_DELETE(dialog);
|
SAFE_DELETE(dialog);
|
||||||
safeDeleteDisplay();
|
safeDeleteDisplay();
|
||||||
SAFE_DELETE(myCollection);
|
SAFE_DELETE(myCollection);
|
||||||
resources.Release(mBgAA);
|
resources.Release(mBgAATex);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& ShopItem::toString(ostream& out) const
|
ostream& ShopItem::toString(ostream& out) const
|
||||||
|
|||||||
@@ -184,12 +184,6 @@ void SimpleMenu::Close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::destroy(){
|
void SimpleMenu::destroy(){
|
||||||
resources.Release(SimpleMenu::spadeR);
|
|
||||||
resources.Release(SimpleMenu::spadeL);
|
|
||||||
resources.Release(SimpleMenu::side);
|
|
||||||
resources.Release(SimpleMenu::spadeRTex);
|
|
||||||
resources.Release(SimpleMenu::spadeLTex);
|
|
||||||
resources.Release(SimpleMenu::sideTex);
|
|
||||||
SAFE_DELETE(SimpleMenu::jewel);
|
SAFE_DELETE(SimpleMenu::jewel);
|
||||||
SAFE_DELETE(SimpleMenu::stars);
|
SAFE_DELETE(SimpleMenu::stars);
|
||||||
SAFE_DELETE(SimpleMenu::jewelTex);
|
SAFE_DELETE(SimpleMenu::jewelTex);
|
||||||
|
|||||||
@@ -84,18 +84,6 @@ WCachedTexture::~WCachedTexture(){
|
|||||||
JTexture * WCachedTexture::Actual(){
|
JTexture * WCachedTexture::Actual(){
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
bool WCachedTexture::isLocked(){
|
|
||||||
if(locks != WRES_UNLOCKED)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for(vector<WTrackedQuad*>::iterator it=trackedQuads.begin();it!=trackedQuads.end();it++){
|
|
||||||
if((*it)->isLocked())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WCachedTexture::ReleaseQuad(JQuad* quad){
|
bool WCachedTexture::ReleaseQuad(JQuad* quad){
|
||||||
if(quad == NULL)
|
if(quad == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -273,8 +261,8 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){
|
|||||||
if(submode & TEXTURE_SUB_5551)
|
if(submode & TEXTURE_SUB_5551)
|
||||||
format = GU_PSM_5551;
|
format = GU_PSM_5551;
|
||||||
|
|
||||||
if(!realname.size()){
|
if(!realname.size()){ //realname should not be empty, even if file 404s.
|
||||||
error = CACHE_ERROR_404;
|
error = CACHE_ERROR_BAD;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +332,6 @@ bool WCachedSample::Attempt(string filename, int submode, int & error){
|
|||||||
error = CACHE_ERROR_404;
|
error = CACHE_ERROR_404;
|
||||||
else
|
else
|
||||||
error = CACHE_ERROR_BAD;
|
error = CACHE_ERROR_BAD;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <JGE.h>
|
#include <JGE.h>
|
||||||
#include <JFileSystem.h>
|
#include <JFileSystem.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "../include/WResourceManager.h"
|
#include "../include/WResourceManager.h"
|
||||||
|
|
||||||
|
|
||||||
int idCounter = OTHERS_OFFSET;
|
int idCounter = OTHERS_OFFSET;
|
||||||
|
|
||||||
WResourceManager resources;
|
WResourceManager resources;
|
||||||
@@ -60,7 +60,7 @@ void WResourceManager::DebugRender(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
sprintf(buf,"Total Size: %lu (%lu cached, %lu managed)",Size(),SizeCached(),SizeManaged());
|
sprintf(buf,"Time: %u. Total Size: %lu (%lu cached, %lu managed). ",lastTime,Size(),SizeCached(),SizeManaged());
|
||||||
font->DrawString(buf, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
|
font->DrawString(buf, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
|
||||||
|
|
||||||
#ifdef DEBUG_CACHE
|
#ifdef DEBUG_CACHE
|
||||||
@@ -125,7 +125,7 @@ unsigned int WResourceManager::CountManaged(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int WResourceManager::nowTime(){
|
unsigned int WResourceManager::nowTime(){
|
||||||
if(lastTime == 65535)
|
if(lastTime > MAX_CACHE_TIME)
|
||||||
FlattenTimes();
|
FlattenTimes();
|
||||||
|
|
||||||
return ++lastTime;
|
return ++lastTime;
|
||||||
@@ -336,25 +336,17 @@ void WResourceManager::Release(JTexture * tex){
|
|||||||
textureWCache.Release(tex);
|
textureWCache.Release(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WResourceManager::Release(JQuad * quad){
|
void WResourceManager::Unmiss(string filename){
|
||||||
if(!quad)
|
|
||||||
return;
|
|
||||||
|
|
||||||
map<int,WCachedTexture*>::iterator it;
|
map<int,WCachedTexture*>::iterator it;
|
||||||
for(it = textureWCache.cache.begin();it!=textureWCache.cache.end();it++){
|
int id = textureWCache.makeID(0,filename,CACHE_NORMAL);
|
||||||
if(it->second && it->second->ReleaseQuad(quad))
|
textureWCache.RemoveMiss(id);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(it != textureWCache.cache.end() && it->second)
|
|
||||||
textureWCache.RemoveItem(it->second,false); //won't remove locked.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WResourceManager::ClearUnlocked(){
|
void WResourceManager::ClearUnlocked(){
|
||||||
textureWCache.ClearUnlocked();
|
textureWCache.ClearUnlocked();
|
||||||
sampleWCache.ClearUnlocked();
|
sampleWCache.ClearUnlocked();
|
||||||
psiWCache.ClearUnlocked();
|
psiWCache.ClearUnlocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WResourceManager::Cleanup(){
|
bool WResourceManager::Cleanup(){
|
||||||
int check = 0;
|
int check = 0;
|
||||||
|
|
||||||
@@ -1037,10 +1029,9 @@ cacheItem * WCache<cacheItem, cacheActual>::Get(int id, string filename, int sty
|
|||||||
if(style != RETRIEVE_MANAGE){
|
if(style != RETRIEVE_MANAGE){
|
||||||
it = cache.find(lookup);
|
it = cache.find(lookup);
|
||||||
//Well, we've found something...
|
//Well, we've found something...
|
||||||
if(it != cache.end()) {
|
if(it != cache.end()){
|
||||||
if (!it->second)
|
mError = CACHE_ERROR_NONE; //We found an entry in cache, so not an error.
|
||||||
mError = CACHE_ERROR_404;
|
return it->second; //A hit, or maybe a miss.
|
||||||
return it->second; //A hit.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1143,23 +1134,35 @@ bool WCache<cacheItem, cacheActual>::Cleanup(){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WCacheSort::operator()(const WResource * l, const WResource * r){
|
||||||
|
if(!l || !r)
|
||||||
|
return false;
|
||||||
|
return (l->lastTime < r->lastTime);
|
||||||
|
}
|
||||||
|
|
||||||
template <class cacheItem, class cacheActual>
|
template <class cacheItem, class cacheActual>
|
||||||
unsigned int WCache<cacheItem, cacheActual>::Flatten(){
|
unsigned int WCache<cacheItem, cacheActual>::Flatten(){
|
||||||
unsigned int youngest = (unsigned int) 65535;
|
vector<cacheItem*> items;
|
||||||
unsigned int oldest = 0;
|
unsigned int oldest = 0;
|
||||||
|
unsigned int lastSet = 0;
|
||||||
|
|
||||||
|
if(!cache.size())
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (typename map<int,cacheItem*>::iterator it = cache.begin(); it != cache.end(); ++it){
|
for (typename map<int,cacheItem*>::iterator it = cache.begin(); it != cache.end(); ++it){
|
||||||
if(!it->second) continue;
|
if(!it->second) continue;
|
||||||
if(it->second->lastTime < youngest) youngest = it->second->lastTime;
|
items.push_back(it->second);
|
||||||
if(it->second->lastTime > oldest) oldest = it->second->lastTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (typename map<int,cacheItem*>::iterator it = cache.begin(); it != cache.end(); ++it){
|
sort(items.begin(), items.end(), WCacheSort());
|
||||||
if(!it->second) continue;
|
|
||||||
it->second->lastTime -= youngest;
|
for (typename vector<cacheItem*>::iterator it = items.begin(); it != items.end(); ++it){
|
||||||
|
assert((*it) && (*it)->lastTime > lastSet);
|
||||||
|
lastSet = (*it)->lastTime;
|
||||||
|
(*it)->lastTime = ++oldest;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (oldest - youngest);
|
return oldest + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class cacheItem, class cacheActual>
|
template <class cacheItem, class cacheActual>
|
||||||
|
|||||||
Reference in New Issue
Block a user