This commit is contained in:
thedarkness1981 2009-07-31 12:45:14 +00:00
parent 8e42f68cae
commit 6e3bc5607e
10 changed files with 1825 additions and 1943 deletions

View File

@ -27,7 +27,6 @@ int CheatMenu(const char * gameID) {
bool exit = false; bool exit = false;
int ret = 1; int ret = 1;
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
char imgPath[100]; char imgPath[100];
@ -35,25 +34,24 @@ int CheatMenu(const char * gameID) {
GuiImageData btnOutline(imgPath, button_dialogue_box_png); GuiImageData btnOutline(imgPath, button_dialogue_box_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
GuiImageData settingsbg(imgPath, settings_background_png); GuiImageData settingsbg(imgPath, settings_background_png);
GuiImage settingsbackground(&settingsbg);
GuiTrigger trigA; GuiTrigger trigA;
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);
GuiTrigger trigB; GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiImage settingsbackground(&settingsbg);
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, &btnSoundOver, &btnClick,1); GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, NULL, &btnClick,1);
backBtn.SetLabel(&backBtnTxt); backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB); backBtn.SetTrigger(&trigB);
GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage createBtnImg(&btnOutline); GuiImage createBtnImg(&btnOutline);
GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, &btnSoundOver, &btnClick,1); GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, NULL, &btnClick,1);
createBtn.SetLabel(&createBtnTxt); createBtn.SetLabel(&createBtnTxt);
char txtfilename[55]; char txtfilename[55];
@ -63,8 +61,6 @@ int CheatMenu(const char * gameID) {
int check = c.openTxtfile(txtfilename); int check = c.openTxtfile(txtfilename);
int download =0; int download =0;
//char tmp[10];
switch (check) { switch (check) {
case -1: case -1:
@ -72,9 +68,7 @@ int CheatMenu(const char * gameID) {
break; break;
case 0: case 0:
download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now")); download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now"));
//snprintf(tmp, sizeof(tmp), "%i",download);
//WindowPrompt(0,tmp,tr("OK"),tr("Download Now"));
if (download==0) if (download==0)
download = CodeDownload(gameID); download = CodeDownload(gameID);
break; break;
@ -133,7 +127,6 @@ int CheatMenu(const char * gameID) {
x++; x++;
} }
} }
string chtpath = Settings.Cheatcodespath; string chtpath = Settings.Cheatcodespath;
string gctfname = chtpath + c.getGameID() + ".gct"; string gctfname = chtpath + c.getGameID() + ".gct";
c.createGCT(selectednrs,x,gctfname.c_str()); c.createGCT(selectednrs,x,gctfname.c_str());
@ -141,7 +134,6 @@ int CheatMenu(const char * gameID) {
exit = true; exit = true;
break; break;
} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK")); } else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
} }
if (backBtn.GetState() == STATE_CLICKED) { if (backBtn.GetState() == STATE_CLICKED) {
@ -154,7 +146,6 @@ int CheatMenu(const char * gameID) {
mainWindow->SetState(STATE_DEFAULT); mainWindow->SetState(STATE_DEFAULT);
mainWindow->Remove(&w); mainWindow->Remove(&w);
ResumeGui(); ResumeGui();
break; break;
} }

View File

@ -1,14 +1,26 @@
/*
* gct.h
* Class to handle Ocarina TXT Cheatfiles
* nIxx
*/
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "gct.h" #include "gct.h"
#define OUTOFRANGE "Error:Range" #define ERRORRANGE "Error: CheatNr out of range"
GCTCheats::GCTCheats(void) { GCTCheats::GCTCheats(void) {
iCntCheats = 0; iCntCheats = 0;
} }
GCTCheats::~GCTCheats(void) { GCTCheats::~GCTCheats(void) {
string sGameID ="";
string sGameTitle = "";
/*string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
string sCheatComment[MAXCHEATS];*/
} }
int GCTCheats::getCnt() { int GCTCheats::getCnt() {
@ -27,7 +39,7 @@ string GCTCheats::getCheat(int nr) {
if (nr <= (iCntCheats-1)) { if (nr <= (iCntCheats-1)) {
return sCheats[nr]; return sCheats[nr];
} else { } else {
return OUTOFRANGE;//"Error: CheatNr out of range"; return ERRORRANGE;
} }
} }
@ -35,7 +47,7 @@ string GCTCheats::getCheatName(int nr) {
if (nr <= (iCntCheats-1)) { if (nr <= (iCntCheats-1)) {
return sCheatName[nr]; return sCheatName[nr];
} else { } else {
return "Error: CheatNr out of range"; return ERRORRANGE;
} }
} }
@ -43,7 +55,7 @@ string GCTCheats::getCheatComment(int nr) {
if (nr <= (iCntCheats-1)) { if (nr <= (iCntCheats-1)) {
return sCheatComment[nr]; return sCheatComment[nr];
} else { } else {
return "Error: CheatNr out of range"; return ERRORRANGE;
} }
} }
@ -54,7 +66,7 @@ int GCTCheats::createGCT(int nr,const char * filename) {
if (filestr.fail()) if (filestr.fail())
return 0; return 0;
//Reversed Header and Footer //Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@ -85,7 +97,7 @@ int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
if (filestr.fail()) if (filestr.fail())
return 0; return 0;
//Reversed Header and Footer //Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@ -119,7 +131,7 @@ int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
if (filestr.fail()) if (filestr.fail())
return 0; return 0;
//Reversed Header and Footer //Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@ -204,90 +216,3 @@ int GCTCheats::openTxtfile(const char * filename) {
filestr.close(); filestr.close();
return 1; return 1;
} }
/*int GCTCheats::openTxtfile(const char * filename)
{
ifstream filestr;
int i = 0;
string str;
filestr.open(filename);
if (filestr.fail())
return 0;
filestr.seekg(0,ios_base::end);
int size = filestr.tellg();
if (size <= 0) return -1;
filestr.seekg(0,ios_base::beg);
getline(filestr,sGameID);
getline(filestr,sGameTitle);
filestr.ignore();
while(!filestr.eof())
{
getline(filestr,sCheatName[i]);
string cheatdata;
bool emptyline = false;
do
{
getline(filestr,str,'\n');
cheatdata.append(str);
if (str == "")
{
emptyline = true;
break;
}
size_t found=cheatdata.find(' ');
cheatdata.replace(found,1,"");
if (filestr.eof()) break;
} while(!emptyline);
sCheats[i] = cheatdata;
i++;
}
iCntCheats = i;
filestr.close();
return 1;
}*/
struct GCTCheats::chtentries GCTCheats::getCheatList(void) {
struct GCTCheats::chtentries cheatlist;
int i = 0;
cheatlist.sGameID = sGameID;
cheatlist.sGameTitle = sGameTitle;
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
}
return cheatlist;
}
struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename) {
openTxtfile(filename);
struct GCTCheats::chtentries cheatlist;
int i = 0;
cheatlist.sGameID = sGameID;
cheatlist.sGameTitle = sGameTitle;
cheatlist.iCntCheats = iCntCheats;
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
}
return cheatlist;
}
int GCTCheats::download_txtcheat(int id) {
//ToDo
return 1;
}

View File

@ -1,8 +1,7 @@
/* /*
* gct.h * gct.h
* Class to handle Ocarina TXT Cheatfiles * Class to handle Ocarina TXT Cheatfiles
* WIP: Actually it´s needed to call fatInitDefault() or the file will not be found *
* and no Comments supported for now
*/ */
#ifndef _GCT_H #ifndef _GCT_H
@ -14,19 +13,9 @@
using namespace std; using namespace std;
struct chtentrie {
string sGameID;
string sGameTitle;
string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
string sCheatComment[MAXCHEATS];
int iCntCheats;
};
//!Handles Ocarina TXT Cheatfiles //!Handles Ocarina TXT Cheatfiles
class GCTCheats { class GCTCheats {
private: private:
chtentrie ccc;
string sGameID; string sGameID;
string sGameTitle; string sGameTitle;
string sCheatName[MAXCHEATS]; string sCheatName[MAXCHEATS];
@ -35,15 +24,6 @@ private:
int iCntCheats; int iCntCheats;
public: public:
struct chtentries {
string sGameID;
string sGameTitle;
string sCheatName[MAXCHEATS];
string sCheats[MAXCHEATS];
int iCntCheats;
};
//!Constructor //!Constructor
GCTCheats(void); GCTCheats(void);
//!Destructor //!Destructor
@ -86,18 +66,6 @@ public:
//!Gets Cheat Comment //!Gets Cheat Comment
//!\return Cheat Comment //!\return Cheat Comment
string getCheatComment(int nr); string getCheatComment(int nr);
//!Gets Cheat List
//!\return struct chtentrie
//struct chtentrie getCheatList2(void);
//!Gets Cheat List
//!\return struct chtentries
struct chtentries getCheatList(void);
//!Gets Cheat List from file
//!\param filename name of TXT file
//!\return struct chtentries
struct chtentries getCheatList(const char * filename);
int download_txtcheat(int id);
}; };
#endif /* _GCT_H */ #endif /* _GCT_H */

View File

@ -322,7 +322,6 @@ int MenuHomebrewBrowse() {
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
/*** XML Variables ***/ /*** XML Variables ***/
HomebrewXML XMLInfo[4]; HomebrewXML XMLInfo[4];

View File

@ -10,7 +10,6 @@
#include "fstfile.h" #include "fstfile.h"
/** Alternate dolloader made by WiiPower modified by dimok **/ /** Alternate dolloader made by WiiPower modified by dimok **/
bool Load_Dol(void **buffer, int* dollen, char * filepath) { bool Load_Dol(void **buffer, int* dollen, char * filepath) {
int ret; int ret;
FILE* file; FILE* file;