Erwan
- Cache size is now an option
This commit is contained in:
@@ -66,25 +66,20 @@ bool JMP3::fillBuffers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize) {
|
bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize) {
|
||||||
printf("load\n");
|
|
||||||
m_inBufferSize = inBufferSize;
|
m_inBufferSize = inBufferSize;
|
||||||
printf("1\n");
|
|
||||||
//m_inBuffer = new char[m_inBufferSize];
|
//m_inBuffer = new char[m_inBufferSize];
|
||||||
//if (!m_inBuffer)
|
//if (!m_inBuffer)
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
m_outBufferSize = outBufferSize;
|
m_outBufferSize = outBufferSize;
|
||||||
printf("2\n");
|
|
||||||
//m_outBuffer = new short[outBufferSize];
|
//m_outBuffer = new short[outBufferSize];
|
||||||
//if (!m_outBuffer)
|
//if (!m_outBuffer)
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
printf("3:%s\n",filename.c_str());
|
|
||||||
m_fileHandle = sceIoOpen(filename.c_str(), PSP_O_RDONLY, 0777);
|
m_fileHandle = sceIoOpen(filename.c_str(), PSP_O_RDONLY, 0777);
|
||||||
if (m_fileHandle < 0)
|
if (m_fileHandle < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printf("4\n");
|
|
||||||
int ret = sceMp3InitResource();
|
int ret = sceMp3InitResource();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -108,53 +103,40 @@ bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize
|
|||||||
initArgs.pcmBufSize = m_outBufferSize;
|
initArgs.pcmBufSize = m_outBufferSize;
|
||||||
initArgs.pcmBuf = (SceVoid*) m_outBuffer;
|
initArgs.pcmBuf = (SceVoid*) m_outBuffer;
|
||||||
|
|
||||||
printf("5\n");
|
|
||||||
m_mp3Handle = sceMp3ReserveMp3Handle(&initArgs);
|
m_mp3Handle = sceMp3ReserveMp3Handle(&initArgs);
|
||||||
if (m_mp3Handle < 0)
|
if (m_mp3Handle < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Alright we are all set up, let's fill the first buffer.
|
// Alright we are all set up, let's fill the first buffer.
|
||||||
printf("5.5\n");
|
|
||||||
bool _filled= fillBuffers();
|
bool _filled= fillBuffers();
|
||||||
if (! _filled) return false;
|
if (! _filled) return false;
|
||||||
|
|
||||||
printf("end = %i, bufsize = %i, outSize = %i\n", fileSize, m_inBufferSize, m_outBufferSize);
|
|
||||||
|
|
||||||
// Start this bitch up!
|
// Start this bitch up!
|
||||||
printf("6\n");
|
|
||||||
int start = sceMp3Init(m_mp3Handle);
|
int start = sceMp3Init(m_mp3Handle);
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printf("7\n");
|
|
||||||
m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle);
|
m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle);
|
||||||
printf("8\n");
|
|
||||||
m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle);
|
m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JMP3::unload() {
|
bool JMP3::unload() {
|
||||||
printf("unload 1\n");
|
|
||||||
if (m_channel >= 0)
|
if (m_channel >= 0)
|
||||||
sceAudioSRCChRelease();
|
sceAudioSRCChRelease();
|
||||||
|
|
||||||
printf("unload 2\n");
|
|
||||||
sceMp3ReleaseMp3Handle(m_mp3Handle);
|
sceMp3ReleaseMp3Handle(m_mp3Handle);
|
||||||
|
|
||||||
printf("unload 3\n");
|
|
||||||
sceMp3TermResource();
|
sceMp3TermResource();
|
||||||
|
|
||||||
printf("unload 4\n");
|
|
||||||
sceIoClose(m_fileHandle);
|
sceIoClose(m_fileHandle);
|
||||||
|
|
||||||
printf("unload 5\n");
|
|
||||||
//delete[] m_inBuffer;
|
//delete[] m_inBuffer;
|
||||||
|
|
||||||
printf("unload 6\n");
|
|
||||||
//delete[] m_outBuffer;
|
//delete[] m_outBuffer;
|
||||||
|
|
||||||
printf("unload 7\n");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class GameApp: public JApp
|
|||||||
static JResourceManager * CommonRes;
|
static JResourceManager * CommonRes;
|
||||||
static hgeParticleSystem * Particles[6];
|
static hgeParticleSystem * Particles[6];
|
||||||
static int HasMusic;
|
static int HasMusic;
|
||||||
|
static string systemError;
|
||||||
static JMusic* music;
|
static JMusic* music;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using std::string;
|
|||||||
#define OPTIONS_DIFFICULTY_MODE_UNLOCKED "prx_handler" //huhu
|
#define OPTIONS_DIFFICULTY_MODE_UNLOCKED "prx_handler" //huhu
|
||||||
#define OPTIONS_MOMIR_MODE_UNLOCKED "prx_rimom" //haha
|
#define OPTIONS_MOMIR_MODE_UNLOCKED "prx_rimom" //haha
|
||||||
#define OPTIONS_DIFFICULTY "difficulty"
|
#define OPTIONS_DIFFICULTY "difficulty"
|
||||||
|
#define OPTIONS_CACHESIZE "cacheSize"
|
||||||
|
|
||||||
// WALDORF - added
|
// WALDORF - added
|
||||||
#define OPTIONS_INTERRUPT_SECONDS "interruptSeconds"
|
#define OPTIONS_INTERRUPT_SECONDS "interruptSeconds"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "../include/GameState.h"
|
#include "../include/GameState.h"
|
||||||
#include "../include/SimpleMenu.h"
|
#include "../include/SimpleMenu.h"
|
||||||
|
|
||||||
|
|
||||||
class GameStateMenu: public GameState, public JGuiListener
|
class GameStateMenu: public GameState, public JGuiListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class MTGGuiPlay: public PlayGuiObjectController {
|
|||||||
float mGlitterX, mGlitterY;
|
float mGlitterX, mGlitterY;
|
||||||
JTexture * mPhaseBarTexture;
|
JTexture * mPhaseBarTexture;
|
||||||
JQuad * mIcons[7];
|
JQuad * mIcons[7];
|
||||||
JTexture * mIconsTexture;
|
|
||||||
JTexture * mBgTex;
|
JTexture * mBgTex;
|
||||||
JQuad * mBg;
|
JQuad * mBg;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class ManaCost{
|
|||||||
int cost[Constants::MTG_NB_COLORS+1];
|
int cost[Constants::MTG_NB_COLORS+1];
|
||||||
ManaCostHybrid * hybrids[10];
|
ManaCostHybrid * hybrids[10];
|
||||||
unsigned int nbhybrids;
|
unsigned int nbhybrids;
|
||||||
|
int extraCostsIsCopy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExtraCosts * extraCosts;
|
ExtraCosts * extraCosts;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define _TEXTURES_CACHE_H
|
#define _TEXTURES_CACHE_H
|
||||||
|
|
||||||
#define MAX_CACHE_OBJECTS 100
|
#define MAX_CACHE_OBJECTS 100
|
||||||
#define CACHE_SIZE_PIXELS 6000000
|
#define CACHE_SIZE_PIXELS 2000000
|
||||||
|
|
||||||
#define CACHE_CARD 1
|
#define CACHE_CARD 1
|
||||||
#define CACHE_THUMB 2
|
#define CACHE_THUMB 2
|
||||||
@@ -43,6 +43,7 @@ class TexturesCache{
|
|||||||
int nb_textures;
|
int nb_textures;
|
||||||
int delete_previous;
|
int delete_previous;
|
||||||
int totalsize;
|
int totalsize;
|
||||||
|
int maxSize;
|
||||||
CardTexture * cache[MAX_CACHE_OBJECTS];
|
CardTexture * cache[MAX_CACHE_OBJECTS];
|
||||||
public:
|
public:
|
||||||
int isInCache(MTGCard * card, int type=CACHE_CARD);
|
int isInCache(MTGCard * card, int type=CACHE_CARD);
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ int AIPlayer::chooseAttackers(){
|
|||||||
int AIPlayer::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy){
|
int AIPlayer::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy){
|
||||||
if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE)) return 0;
|
if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE)) return 0;
|
||||||
if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return 0;
|
if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return 0;
|
||||||
if (!card->power >= ennemy->toughness) return 0;
|
if (!(card->power >= ennemy->toughness)) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,8 +461,8 @@ int AIPlayer::chooseBlockers(){
|
|||||||
}else{
|
}else{
|
||||||
MTGCardInstance * attacker = card->defenser;
|
MTGCardInstance * attacker = card->defenser;
|
||||||
if (opponentsToughness[attacker] <= 0 ||
|
if (opponentsToughness[attacker] <= 0 ||
|
||||||
(card->toughness <= card->defenser->power && opponentForce*2 <life && !canFirstStrikeKill(card,card->defenser)) ||
|
(card->toughness <= attacker->power && opponentForce*2 <life && !canFirstStrikeKill(card,attacker)) ||
|
||||||
card->defenser->nbOpponents()>1){
|
attacker->nbOpponents()>1){
|
||||||
g->mLayers->actionLayer()->reactToClick(a,card);
|
g->mLayers->actionLayer()->reactToClick(a,card);
|
||||||
}else{
|
}else{
|
||||||
set = 1;
|
set = 1;
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ int DeckStat::percentVictories(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeckStats * DeckStats::GetInstance(){
|
DeckStats * DeckStats::GetInstance(){
|
||||||
if (!mInstance) mInstance = NEW DeckStats();
|
if (!mInstance){
|
||||||
|
mInstance = NEW DeckStats();
|
||||||
|
|
||||||
|
}
|
||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +22,7 @@ void DeckStats::cleanStats(){
|
|||||||
for (it = stats.begin(); it != stats.end(); it++){
|
for (it = stats.begin(); it != stats.end(); it++){
|
||||||
SAFE_DELETE(it->second);
|
SAFE_DELETE(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.clear();
|
stats.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +57,10 @@ void DeckStats::load(const char * filename){
|
|||||||
int games = atoi(s.c_str());
|
int games = atoi(s.c_str());
|
||||||
std::getline(file,s);
|
std::getline(file,s);
|
||||||
int victories = atoi(s.c_str());
|
int victories = atoi(s.c_str());
|
||||||
stats[deckfile] = NEW DeckStat(games,victories);
|
map<string,DeckStat *>::iterator it = stats.find(deckfile);
|
||||||
|
if (it == stats.end()){
|
||||||
|
stats[deckfile] = NEW DeckStat(games,victories);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ JResourceManager* GameApp::CommonRes = NEW JResourceManager();
|
|||||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||||
int GameApp::HasMusic = 1;
|
int GameApp::HasMusic = 1;
|
||||||
JMusic * GameApp::music = NULL;
|
JMusic * GameApp::music = NULL;
|
||||||
|
string GameApp::systemError = "";
|
||||||
|
|
||||||
GameState::GameState(GameApp* parent): mParent(parent)
|
GameState::GameState(GameApp* parent): mParent(parent)
|
||||||
{
|
{
|
||||||
@@ -105,6 +106,10 @@ void GameApp::Create()
|
|||||||
CommonRes->LoadJLBFont("graphics/magic",16);
|
CommonRes->LoadJLBFont("graphics/magic",16);
|
||||||
|
|
||||||
|
|
||||||
|
CommonRes->CreateTexture("graphics/phasebar.png");
|
||||||
|
CommonRes->CreateTexture("graphics/background.png");
|
||||||
|
CommonRes->CreateTexture("graphics/back.jpg");
|
||||||
|
|
||||||
//CommonRes->CreateTexture("graphics/interrupt.png");
|
//CommonRes->CreateTexture("graphics/interrupt.png");
|
||||||
//CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
|
//CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
|
||||||
|
|
||||||
@@ -171,7 +176,7 @@ void GameApp::Destroy()
|
|||||||
}
|
}
|
||||||
SAFE_DELETE(cache);
|
SAFE_DELETE(cache);
|
||||||
SampleCache::DestroyInstance();
|
SampleCache::DestroyInstance();
|
||||||
|
delete(DeckStats::GetInstance());
|
||||||
|
|
||||||
SAFE_DELETE(CommonRes);
|
SAFE_DELETE(CommonRes);
|
||||||
|
|
||||||
@@ -182,7 +187,7 @@ void GameApp::Destroy()
|
|||||||
|
|
||||||
SAFE_DELETE(music);
|
SAFE_DELETE(music);
|
||||||
|
|
||||||
delete(DeckStats::GetInstance());
|
|
||||||
|
|
||||||
SimpleMenu::destroy();
|
SimpleMenu::destroy();
|
||||||
|
|
||||||
@@ -196,6 +201,7 @@ void GameApp::Destroy()
|
|||||||
void GameApp::Update()
|
void GameApp::Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
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))
|
||||||
{
|
{
|
||||||
@@ -236,7 +242,12 @@ void GameApp::Update()
|
|||||||
|
|
||||||
void GameApp::Render()
|
void GameApp::Render()
|
||||||
{
|
{
|
||||||
|
if (systemError.size()){
|
||||||
|
fprintf(stderr, systemError.c_str());
|
||||||
|
JLBFont * mFont= CommonRes->GetJLBFont("graphics/simon");
|
||||||
|
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mCurrentState != NULL)
|
if (mCurrentState != NULL)
|
||||||
{
|
{
|
||||||
mCurrentState->Render();
|
mCurrentState->Render();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../include/MenuItem.h"
|
#include "../include/MenuItem.h"
|
||||||
#include "../include/GameOptions.h"
|
#include "../include/GameOptions.h"
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/MTGCard.h"
|
||||||
|
|
||||||
static const char* GAME_VERSION = "WTH?! 0.6.0 - by WilLoW";
|
static const char* GAME_VERSION = "WTH?! 0.6.0 - by WilLoW";
|
||||||
#define ALPHA_WARNING 0
|
#define ALPHA_WARNING 0
|
||||||
@@ -72,6 +73,8 @@ GameStateMenu::~GameStateMenu() {}
|
|||||||
|
|
||||||
void GameStateMenu::Create()
|
void GameStateMenu::Create()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
mDip = NULL;
|
mDip = NULL;
|
||||||
mReadConf = 0;
|
mReadConf = 0;
|
||||||
mCurrentSetName[0] = 0;
|
mCurrentSetName[0] = 0;
|
||||||
@@ -241,8 +244,10 @@ void GameStateMenu::Update(float dt)
|
|||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_MAINMENU :
|
case MENU_STATE_MAJOR_MAINMENU :
|
||||||
if (mGuiController!=NULL){
|
if (mGuiController!=NULL){
|
||||||
mGuiController->Update(dt);
|
mGuiController->Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_SUBMENU :
|
case MENU_STATE_MAJOR_SUBMENU :
|
||||||
subMenuController->Update(dt);
|
subMenuController->Update(dt);
|
||||||
@@ -407,6 +412,7 @@ void GameStateMenu::Render()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ void GameStateOptions::Start()
|
|||||||
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) {
|
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) {
|
||||||
optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "Difficulty", 3, 1));
|
optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "Difficulty", 3, 1));
|
||||||
}
|
}
|
||||||
|
optionsList->Add(NEW OptionItem(OPTIONS_CACHESIZE, "Cache Size", 60, 5));
|
||||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||||
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
|
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
|
||||||
optionsMenu->Add(1, "Save & Back to Main Menu");
|
optionsMenu->Add(1, "Save & Back to Main Menu");
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id,
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
|
||||||
mPhaseBarTexture = JRenderer::GetInstance()->LoadTexture("graphics/phasebar.png", TEX_TYPE_USE_VRAM);
|
mPhaseBarTexture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
|
||||||
for (int i=0; i < 12; i++){
|
for (int i=0; i < 12; i++){
|
||||||
phaseIcons[2*i] = NEW JQuad(mPhaseBarTexture, i*28, 0, 28, 28);
|
phaseIcons[2*i] = NEW JQuad(mPhaseBarTexture, i*28, 0, 28, 28);
|
||||||
phaseIcons[2*i + 1] = NEW JQuad(mPhaseBarTexture, i*28, 28, 28, 28);
|
phaseIcons[2*i + 1] = NEW JQuad(mPhaseBarTexture, i*28, 28, 28, 28);
|
||||||
@@ -36,26 +36,34 @@ MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id,
|
|||||||
mGlitterAlpha = -1;
|
mGlitterAlpha = -1;
|
||||||
mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
|
mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
|
||||||
|
|
||||||
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
|
|
||||||
//load all the icon images
|
//load all the icon images
|
||||||
mIcons[Constants::MTG_COLOR_ARTIFACT] = NEW JQuad(mIconsTexture, 2+6*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
|
||||||
mIcons[Constants::MTG_COLOR_LAND] = NEW JQuad(mIconsTexture, 2+5*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
|
||||||
mIcons[Constants::MTG_COLOR_WHITE] = NEW JQuad(mIconsTexture, 2+4*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
|
||||||
mIcons[Constants::MTG_COLOR_RED] = NEW JQuad(mIconsTexture, 2+3*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red");
|
||||||
mIcons[Constants::MTG_COLOR_BLACK] = NEW JQuad(mIconsTexture, 2+2*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black");
|
||||||
mIcons[Constants::MTG_COLOR_BLUE] = NEW JQuad(mIconsTexture, 2+1*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue");
|
||||||
mIcons[Constants::MTG_COLOR_GREEN] = NEW JQuad(mIconsTexture, 2+0*36, 38, 32, 32);
|
mIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBgTex = JRenderer::GetInstance()->LoadTexture("graphics/background.png", TEX_TYPE_USE_VRAM);
|
mBgTex = GameApp::CommonRes->GetTexture("graphics/background.png");
|
||||||
mBg = NEW JQuad(mBgTex, 0, 0, 480, 272);
|
if (mBgTex) mBg = NEW JQuad(mBgTex, 0, 0, 480, 272);
|
||||||
|
else {
|
||||||
|
mBg = NULL;
|
||||||
|
GameApp::systemError = "error Loading Texture mBgTex in MTGGuiPlay intialization";
|
||||||
|
}
|
||||||
|
|
||||||
mBgTex2 = JRenderer::GetInstance()->LoadTexture("graphics/back.jpg", TEX_TYPE_USE_VRAM);
|
mBgTex2 = GameApp::CommonRes->GetTexture("graphics/back.jpg");
|
||||||
mBg2 = NEW JQuad(mBgTex2, 0, 0, 480, 255);
|
if (mBgTex2){
|
||||||
for (int i= 0; i < 4; i++){
|
mBg2 = NEW JQuad(mBgTex2, 0, 0, 480, 255);
|
||||||
alphaBg[i] = 255;
|
for (int i= 0; i < 4; i++){
|
||||||
|
alphaBg[i] = 255;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
mBg2 = NULL;
|
||||||
|
GameApp::systemError = "error Loading Texture mBgTex2 in MTGGuiPlay intialization";
|
||||||
}
|
}
|
||||||
alphaBg[0] = 0;
|
alphaBg[0] = 0;
|
||||||
AddPlayersGuiInfo();
|
AddPlayersGuiInfo();
|
||||||
@@ -401,20 +409,17 @@ void MTGGuiPlay::Render(){
|
|||||||
MTGGuiPlay::~MTGGuiPlay(){
|
MTGGuiPlay::~MTGGuiPlay(){
|
||||||
LOG("==Destroying MTGGuiPlay==");
|
LOG("==Destroying MTGGuiPlay==");
|
||||||
delete mBg;
|
delete mBg;
|
||||||
delete mBgTex;
|
//delete mBgTex;
|
||||||
for (int i=0; i < 7; i++){
|
|
||||||
delete mIcons[i];
|
|
||||||
}
|
|
||||||
delete mIconsTexture;
|
|
||||||
delete mGlitter;
|
delete mGlitter;
|
||||||
for (int i=0; i < 12; i++){
|
for (int i=0; i < 12; i++){
|
||||||
delete phaseIcons[2*i] ;
|
delete phaseIcons[2*i] ;
|
||||||
delete phaseIcons[2*i + 1];
|
delete phaseIcons[2*i + 1];
|
||||||
}
|
}
|
||||||
delete mPhaseBarTexture;
|
//delete mPhaseBarTexture;
|
||||||
|
|
||||||
SAFE_DELETE(mBg2);
|
SAFE_DELETE(mBg2);
|
||||||
SAFE_DELETE(mBgTex2);
|
//SAFE_DELETE(mBgTex2);
|
||||||
|
|
||||||
LOG("==Destroying MTGGuiPlay Successful==");
|
LOG("==Destroying MTGGuiPlay Successful==");
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ ManaCost::~ManaCost(){
|
|||||||
for (unsigned int i = 0; i < nbhybrids ; i++){
|
for (unsigned int i = 0; i < nbhybrids ; i++){
|
||||||
SAFE_DELETE(hybrids[i]);
|
SAFE_DELETE(hybrids[i]);
|
||||||
}
|
}
|
||||||
|
if (!extraCostsIsCopy) {
|
||||||
|
SAFE_DELETE(extraCosts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaCost::x(){
|
void ManaCost::x(){
|
||||||
@@ -141,6 +144,7 @@ void ManaCost::init(){
|
|||||||
}
|
}
|
||||||
nbhybrids = 0;
|
nbhybrids = 0;
|
||||||
extraCosts = NULL;
|
extraCosts = NULL;
|
||||||
|
extraCostsIsCopy = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,6 +160,7 @@ void ManaCost::copy(ManaCost * _manaCost){
|
|||||||
if (_manaCost->extraCosts){
|
if (_manaCost->extraCosts){
|
||||||
//TODO Deep copy ?
|
//TODO Deep copy ?
|
||||||
extraCosts = _manaCost->extraCosts;
|
extraCosts = _manaCost->extraCosts;
|
||||||
|
extraCostsIsCopy = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/TexturesCache.h"
|
#include "../include/TexturesCache.h"
|
||||||
|
#include "../include/GameOptions.h"
|
||||||
|
|
||||||
TexturesCache::TexturesCache(){
|
TexturesCache::TexturesCache(){
|
||||||
nb_textures = 0;
|
nb_textures = 0;
|
||||||
@@ -9,6 +10,8 @@ TexturesCache::TexturesCache(){
|
|||||||
for (int i=0; i<MAX_CACHE_OBJECTS;i++){
|
for (int i=0; i<MAX_CACHE_OBJECTS;i++){
|
||||||
cache[i] = NULL;
|
cache[i] = NULL;
|
||||||
}
|
}
|
||||||
|
maxSize = GameOptions::GetInstance()->values[OPTIONS_CACHESIZE].getIntValue() * 100000;
|
||||||
|
if (!maxSize) maxSize = CACHE_SIZE_PIXELS;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char buf [4096];
|
char buf [4096];
|
||||||
sprintf(buf, " Init TextureCache : %p\n", this);
|
sprintf(buf, " Init TextureCache : %p\n", this);
|
||||||
@@ -61,7 +64,7 @@ void TexturesCache::removeQuad(int id){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TexturesCache::cleanup(){
|
int TexturesCache::cleanup(){
|
||||||
while (nb_textures >= MAX_CACHE_OBJECTS - 1 || totalsize > CACHE_SIZE_PIXELS){
|
while (nb_textures >= MAX_CACHE_OBJECTS - 1 || totalsize > maxSize){
|
||||||
int i = getOldestQuad();
|
int i = getOldestQuad();
|
||||||
if (i == -1) return 0;
|
if (i == -1) return 0;
|
||||||
removeQuad(i);
|
removeQuad(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user