mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-18 17:29:17 +01:00
c6fd33eeb1
made the channel browser read database.txt. The text should be in the config path (because i couldn't think of a better place for it). And the format for the txt is the first 3 chars of the 4 char ID, then any 1 character, then the name (read up to 51 chars. eg. ULN USB Loader GX Full Channel HAX Homebrew Channel HAT Nintendo Channel The database for ATD mod follows this format, so its a great place to start. If people are going to be passing around a database, it would be wise to keep custom channels off this, as my WADD that says WadManager is not the same as somebody else's WADQ which could be a self destruct or something. Commented out the code that loads titles.txt. It was reported that this file is keeping WiiSportsResort from loading on some Wiis. And it isn't needed anymore since there is the xml file with all the names in it. I left the code in though in case somebody thinks that it is actually useful. Added 1 more game to the list of known alt dols.
174 lines
5.1 KiB
C++
174 lines
5.1 KiB
C++
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <fat.h>
|
|
|
|
#include "libwiigui/gui.h"
|
|
#include "libwiigui/gui_customoptionbrowser.h"
|
|
#include "prompts/PromptWindows.h"
|
|
#include "language/gettext.h"
|
|
#include "fatmounter.h"
|
|
#include "menu.h"
|
|
#include "filelist.h"
|
|
#include "sys.h"
|
|
#include "gct.h"
|
|
|
|
/*** Extern functions ***/
|
|
extern void ResumeGui();
|
|
extern void HaltGui();
|
|
|
|
/*** Extern variables ***/
|
|
extern GuiWindow * mainWindow;
|
|
|
|
/****************************************************************************
|
|
* CheatMenu
|
|
***************************************************************************/
|
|
int CheatMenu(const char * gameID)
|
|
{
|
|
int choice = 0;
|
|
bool exit = false;
|
|
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);
|
|
|
|
char imgPath[100];
|
|
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
|
|
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
|
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
|
|
GuiImageData settingsbg(imgPath, settings_background_png);
|
|
|
|
GuiTrigger trigA;
|
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
GuiTrigger trigB;
|
|
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});
|
|
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
|
GuiImage backBtnImg(&btnOutline);
|
|
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, &btnSoundOver, &btnClick,1);
|
|
backBtn.SetLabel(&backBtnTxt);
|
|
backBtn.SetTrigger(&trigB);
|
|
|
|
GuiText createBtnTxt(tr("Create") , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
|
GuiImage createBtnImg(&btnOutline);
|
|
GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, &btnSoundOver, &btnClick,1);
|
|
createBtn.SetLabel(&createBtnTxt);
|
|
|
|
char txtfilename[55];
|
|
snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID);
|
|
|
|
GCTCheats c;
|
|
int check = c.openTxtfile(txtfilename);
|
|
|
|
int download =0;
|
|
//char tmp[10];
|
|
|
|
|
|
switch(check)
|
|
{
|
|
case -1: WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
|
|
break;
|
|
case 0: 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)
|
|
download = CodeDownload(gameID);
|
|
break;
|
|
case 1:
|
|
int cntcheats = c.getCnt();
|
|
customOptionList cheatslst(cntcheats);
|
|
GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90);
|
|
chtBrowser.SetPosition(0, 90);
|
|
chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
chtBrowser.SetClickable(true);
|
|
|
|
GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor){0, 0, 0, 255});
|
|
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
titleTxt.SetMaxWidth(350, GuiText::SCROLL);
|
|
titleTxt.SetPosition(12,40);
|
|
|
|
for(int i = 0; i <= cntcheats; i++)
|
|
{
|
|
cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str());
|
|
cheatslst.SetName(i, "OFF");
|
|
}
|
|
|
|
HaltGui();
|
|
GuiWindow w(screenwidth, screenheight);
|
|
w.Append(&settingsbackground);
|
|
w.Append(&titleTxt);
|
|
w.Append(&backBtn);
|
|
w.Append(&createBtn);
|
|
w.Append(&chtBrowser);
|
|
mainWindow->SetState(STATE_DISABLED);
|
|
mainWindow->ChangeFocus(&w);
|
|
mainWindow->Append(&w);
|
|
ResumeGui();
|
|
|
|
while(!exit)
|
|
{
|
|
VIDEO_WaitVSync ();
|
|
|
|
ret = chtBrowser.GetClickedOption();
|
|
if (ret != -1)
|
|
{
|
|
const char *strCheck = cheatslst.GetName(ret);
|
|
if (strncmp(strCheck,"ON",2) == 0)
|
|
{
|
|
cheatslst.SetName(ret,"%s","OFF");
|
|
}
|
|
else if (strncmp(strCheck,"OFF",3) == 0)
|
|
{
|
|
cheatslst.SetName(ret,"%s","ON");
|
|
}
|
|
}
|
|
|
|
if(createBtn.GetState() == STATE_CLICKED)
|
|
{
|
|
createBtn.ResetState();
|
|
if (cntcheats > 0)
|
|
{
|
|
int selectednrs[30];
|
|
int x = 0;
|
|
for(int i = 0; i <= cntcheats; i++)
|
|
{
|
|
const char *strCheck = cheatslst.GetName(i);
|
|
if (strncmp(strCheck,"ON",2) == 0)
|
|
{
|
|
selectednrs[x] = i;
|
|
x++;
|
|
}
|
|
}
|
|
|
|
string chtpath = Settings.Cheatcodespath;
|
|
string gctfname = chtpath + c.getGameID() + ".gct";
|
|
c.createGCT(selectednrs,x,gctfname.c_str());
|
|
WindowPrompt(tr("GCT File created"),NULL,tr("OK"));
|
|
exit = true;
|
|
break;
|
|
} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
|
|
|
|
}
|
|
|
|
if(backBtn.GetState() == STATE_CLICKED)
|
|
{
|
|
backBtn.ResetState();
|
|
exit = true;
|
|
break;
|
|
}
|
|
}
|
|
HaltGui();
|
|
mainWindow->SetState(STATE_DEFAULT);
|
|
mainWindow->Remove(&w);
|
|
ResumeGui();
|
|
|
|
break;
|
|
}
|
|
|
|
return choice;
|
|
}
|