*Fixed settings codedumps and other codedumps with carousel and grid (oh boy we had so many memory mess up stuff)

This commit is contained in:
dimok321 2009-06-01 08:45:51 +00:00
parent 99cd6f420e
commit f2822719b1
7 changed files with 44 additions and 36 deletions

View File

@ -240,9 +240,9 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
delete bgOptionsEntry; delete bgOptionsEntry;
delete trigA; delete trigA;
delete trigHeldA;
delete btnSoundClick; delete btnSoundClick;
// delete optionBg;
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
delete optionTxt[i]; delete optionTxt[i];

View File

@ -82,9 +82,7 @@ class GuiCustomOptionBrowser : public GuiElement
GuiImageData * scrollbarBox; GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver; GuiImageData * scrollbarBoxOver;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick; GuiSound * btnSoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;
GuiTrigger * trigB;
GuiTrigger * trigHeldA; GuiTrigger * trigHeldA;
}; };

View File

@ -181,7 +181,6 @@ GuiGameBrowser::~GuiGameBrowser()
delete trigA; delete trigA;
delete trigHeldA; delete trigHeldA;
delete btnSoundClick; delete btnSoundClick;
delete btnSoundOver;
for(int i=0; i<pagesize; i++) for(int i=0; i<pagesize; i++)
{ {

View File

@ -59,7 +59,6 @@ class GuiGameBrowser : public GuiElement
GuiImageData * scrollbarBox; GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver; GuiImageData * scrollbarBoxOver;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick; GuiSound * btnSoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;
GuiTrigger * trigHeldA; GuiTrigger * trigHeldA;

View File

@ -23,19 +23,18 @@
#define IN_SPEED 175 #define IN_SPEED 175
#define SHIFT_SPEED 100 #define SHIFT_SPEED 100
#define SPEED_STEP 4 #define SPEED_STEP 4
#define PAGESIZE 9 #define SAFETY 320
#define SAFETY 9
extern const int vol; extern const int vol;
/** /**
* Constructor for the GuiGameCarousel class. * Constructor for the GuiGameCarousel class.
*/ */
GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset) GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int count, const char *themePath, const u8 *imagebg, int selected, int offset)
{ {
width = w; width = w;
height = h; height = h;
this->gameCnt = (gameCnt < SAFETY) ? gameCnt : SAFETY; gameCnt = (count < SAFETY) ? count : SAFETY;
gameList = l; gameList = l;
pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE; pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE;
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset; listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
@ -49,7 +48,6 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
trigL = new GuiTrigger; trigL = new GuiTrigger;
trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
trigR = new GuiTrigger; trigR = new GuiTrigger;
@ -159,7 +157,6 @@ GuiGameCarousel::~GuiGameCarousel()
delete btnLeft; delete btnLeft;
delete trigA; delete trigA;
delete trigHeldA;
delete trigL; delete trigL;
delete trigR; delete trigR;
delete trigPlus; delete trigPlus;
@ -430,7 +427,7 @@ void GuiGameCarousel::Reload(struct discHdr * l, int count)
LOCK(this); LOCK(this);
gameCnt = count; gameCnt = (count < SAFETY) ? count : SAFETY;
gameList = l; gameList = l;
pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE; pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE;
listOffset = this->FindMenuItem(-1, 1); listOffset = this->FindMenuItem(-1, 1);

View File

@ -55,6 +55,5 @@ class GuiGameCarousel : public GuiElement
GuiTrigger * trigR; GuiTrigger * trigR;
GuiTrigger * trigPlus; GuiTrigger * trigPlus;
GuiTrigger * trigMinus; GuiTrigger * trigMinus;
GuiTrigger * trigHeldA;
}; };
#endif #endif

View File

@ -459,6 +459,17 @@ void GuiGameGrid::Update(GuiTrigger * t)
void GuiGameGrid::Reload(struct discHdr * l, int count) void GuiGameGrid::Reload(struct discHdr * l, int count)
{ {
for(int i=0; i<pagesize; i++)
{
delete game[i];
delete coverImg[i];
delete cover[i];
}
delete [] gameIndex;
delete [] game;
delete [] cover;
delete [] coverImg;
LOCK(this); LOCK(this);
gameList = l; gameList = l;
gameCnt = count; gameCnt = count;
@ -470,16 +481,12 @@ void GuiGameGrid::Reload(struct discHdr * l, int count)
char IDfull[7]; char IDfull[7];
char imgPath[100]; char imgPath[100];
for(int i=0; i<pagesize; i++) { gameIndex = new int[pagesize];
game = new GuiButton * [pagesize];
coverImg = new GuiImage * [pagesize];
cover = new GuiImageData * [pagesize];
if(coverImg[i]) { for(int i=0; i<pagesize; i++) {
delete coverImg[i];
coverImg[i] = NULL;
}
if(cover[i]) {
delete cover[i];
cover[i] = NULL;
}
struct discHdr *header = &gameList[i+changed]; struct discHdr *header = &gameList[i+changed];
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
@ -501,20 +508,29 @@ void GuiGameGrid::Reload(struct discHdr * l, int count)
cover[i] = new GuiImageData(imgPath, nocover_png); //load no image cover[i] = new GuiImageData(imgPath, nocover_png); //load no image
} }
} }
coverImg[i] = new GuiImage(cover[i]); coverImg[i] = new GuiImage(cover[i]);
coverImg[i]->SetWidescreen(CFG.widescreen); coverImg[i]->SetWidescreen(CFG.widescreen);
coverImg[i]->SetScale(0.6); coverImg[i]->SetScale(0.6);
game[i] = new GuiButton(coverImg[i]->GetWidth()*.45,coverImg[i]->GetHeight()*.7);
game[i]->SetParent(this);
game[i]->SetAlignment(ALIGN_TOP,ALIGN_LEFT);
game[i]->SetImage(coverImg[i]);
coverImg[i]->SetParent(game[i]); coverImg[i]->SetParent(game[i]);
coverImg[i]->SetPosition(-10,-35); coverImg[i]->SetPosition(-10,-35);
game[i]->ResetState(); if (i<4)game[i]->SetPosition((117+i*110)+THEME.gamegrid_x,25+THEME.gamegrid_y);
if (i>3)game[i]->SetPosition((117+(i-4)*110)+THEME.gamegrid_x,185+THEME.gamegrid_y);
game[i]->SetRumble(false);
game[i]->SetTrigger(trigA);
game[i]->SetSoundOver(btnSoundOver);
game[i]->SetSoundClick(btnSoundClick);
game[i]->SetEffectGrow();
game[i]->SetVisible(true); game[i]->SetVisible(true);
game[i]->SetImage(coverImg[i]);
game[i]->SetClickable(true); game[i]->SetClickable(true);
coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) { if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
game[i]->SetVisible(false); game[i]->SetVisible(false);
game[i]->SetClickable(false); game[i]->SetClickable(false);
game[i]->RemoveSoundOver();
} }
} }
} }