-added possibility to delete files in emulator coverflow

-using global variables for magic words now
This commit is contained in:
fix94.1 2012-05-24 18:48:26 +00:00
parent 4d1f861381
commit 6a64e8cb86
10 changed files with 64 additions and 60 deletions

View File

@ -50,3 +50,7 @@ Triiforce"
#define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}"
#define DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"
#define WII_MAGIC 0x5D1C9EA3
#define GC_MAGIC 0xC2339F3D
#define EMU_MAGIC 0x4C4F4C4F

View File

@ -350,3 +350,12 @@ void fsop_deleteFolder(char *source)
gprintf("Deleting directory: %s\n",source);
unlink(source);
}
void fsop_deleteFile(char *source)
{
if(fsop_FileExist(source))
{
gprintf("Deleting file: %s\n",source);
remove(source);
}
}

View File

@ -16,6 +16,7 @@ bool fsop_FileExist(const char *fn);
bool fsop_DirExist(char *path);
bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void *spinner_data);
bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, void *spinner_data);
void fsop_deleteFile(char *source);
void fsop_deleteFolder(char *source);
#endif

View File

@ -15,6 +15,7 @@
#include "lockMutex.hpp"
#include "fonts.h"
#include "gecko.h"
#include "defines.h"
extern const u8 dvdskin_png[];
extern const u8 dvdskin_red_png[];
@ -2550,7 +2551,7 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq)
SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data;
if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK))
{
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb");
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb");
if (file != 0)
{
SWFCHeader header(tex, box, m_compressCache);
@ -2617,7 +2618,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq)
// Try to find the texture in the cache
if (!m_cachePath.empty())
{
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb");
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == EMU_MAGIC ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb");
if (file != 0)
{
bool success = false;

View File

@ -185,7 +185,7 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
if( tmp.hdr.casecolor == 0xffffffff )
tmp.hdr.casecolor = 0;
tmp.hdr.gc_magic = 0xc2339f3d;
tmp.hdr.gc_magic = GC_MAGIC;
(*itr)[(*itr).find_last_of('/')] = 0;
if(strcasecmp(filename, "boot.bin") == 0)
(*itr)[(*itr).find_last_of('/')] = 0;
@ -207,7 +207,7 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
fread( &tmp.hdr, sizeof( discHdr ), 1, fp);
fclose(fp);
if ( tmp.hdr.gc_magic == 0xc2339f3d )
if (tmp.hdr.gc_magic == GC_MAGIC)
{
//mbstowcs( tmp.title, (const char *)tmp.hdr.title, sizeof( tmp.hdr.title ) );
//Asciify(tmp.title);
@ -447,7 +447,7 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
gprintf("Found: %s\n", tmp.path);
sscanf(plugin.getString("PLUGIN","magic","").c_str(), "%08x", &tmp.hdr.magic); //Plugin magic
tmp.hdr.gc_magic = 0x4c4f4c4f; //Abusing gc_magic for general emu detection ;)
tmp.hdr.gc_magic = EMU_MAGIC; //Abusing gc_magic for general emu detection ;)
headerlist.push_back(tmp);
break;
}

View File

@ -22,13 +22,12 @@
#include "wip.h"
#include "memory.h"
#include "gecko.h"
#include "defines.h"
#define ALIGNED(x) __attribute__((aligned(x)))
/* Constants */
#define PTABLE_OFFSET 0x40000
#define WII_MAGIC 0x5D1C9EA3
#define GC_MAGIC 0xC2339F3D
//appentrypoint
u32 appentrypoint;
@ -323,16 +322,13 @@ s32 Disc_Type(bool gc)
struct gc_discHdr *header = (struct gc_discHdr *)buffer;
ret = Disc_ReadGCHeader(header);
if(strcmp((char *)header->id, "GCOPDV") == 0)
{
magic = 0xc2339f3d;
}
magic = GC_MAGIC;
else
{
magic = header->magic;
}
}
if (ret < 0) return ret;
if (ret < 0)
return ret;
/* Check magic word */
if (magic != check) return -1;

View File

@ -50,8 +50,6 @@ void CMenu::_hideGameSettings(bool instant)
m_btnMgr.hide(m_gameSettingsLblNoDVD_Val, instant);
m_btnMgr.hide(m_gameSettingsBtnNoDVD_P, instant);
m_btnMgr.hide(m_gameSettingsBtnNoDVD_M, instant);
m_btnMgr.hide(m_gameSettingsLblIOSreloadBlock, instant);
m_btnMgr.hide(m_gameSettingsBtnIOSreloadBlock, instant);
m_btnMgr.hide(m_gameSettingsLblCustom, instant);
m_btnMgr.hide(m_gameSettingsBtnCustom, instant);
m_btnMgr.hide(m_gameSettingsLblOcarina, instant);
@ -122,7 +120,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.show(m_gameSettingsBtnPageP);
m_btnMgr.show(m_gameSettingsBtnBack);
m_btnMgr.show(m_gameSettingsLblTitle);
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
if(m_current_view == COVERFLOW_USB && _checkSave(string((const char *)m_cf.getHdr()->hdr.id), false))
g_numGCfPages = 5;
@ -142,7 +140,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.show(m_gameSettingsLblCover);
m_btnMgr.show(m_gameSettingsBtnCover);
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.show(m_gameSettingsBtnCategoryMain);
m_btnMgr.show(m_gameSettingsLblCategoryMain);
@ -175,7 +173,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.hide(m_gameSettingsLblCover);
m_btnMgr.hide(m_gameSettingsBtnCover);
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.hide(m_gameSettingsBtnCategoryMain);
m_btnMgr.hide(m_gameSettingsLblCategoryMain);
@ -210,7 +208,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.show(m_gameSettingsBtnDebuggerP);
m_btnMgr.show(m_gameSettingsBtnDebuggerM);
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.show(m_gameSettingsLblHooktype);
m_btnMgr.show(m_gameSettingsLblHooktypeVal);
@ -231,7 +229,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.hide(m_gameSettingsBtnDebuggerP);
m_btnMgr.hide(m_gameSettingsBtnDebuggerM);
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.hide(m_gameSettingsLblHooktype);
m_btnMgr.hide(m_gameSettingsLblHooktypeVal);
@ -247,7 +245,7 @@ void CMenu::_showGameSettings(void)
}
if (m_gameSettingsPage == 3)
{
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.show(m_gameSettingsLblPatchVidModes);
m_btnMgr.show(m_gameSettingsLblPatchVidModesVal);
@ -282,7 +280,7 @@ void CMenu::_showGameSettings(void)
}
else
{
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.hide(m_gameSettingsLblPatchVidModes);
m_btnMgr.hide(m_gameSettingsLblPatchVidModesVal);
@ -333,12 +331,6 @@ void CMenu::_showGameSettings(void)
m_btnMgr.show(m_gameSettingsBtnIOSP);
m_btnMgr.show(m_gameSettingsBtnIOSM);
if (m_current_view != COVERFLOW_HOMEBREW)
{
m_btnMgr.show(m_gameSettingsLblIOSreloadBlock);
m_btnMgr.show(m_gameSettingsBtnIOSreloadBlock);
}
if(m_current_view == COVERFLOW_USB && _checkSave(string((const char *)m_cf.getHdr()->hdr.id), true))
{
m_btnMgr.show(m_gameSettingsLblExtractSave);
@ -360,9 +352,6 @@ void CMenu::_showGameSettings(void)
m_btnMgr.hide(m_gameSettingsBtnIOSP);
m_btnMgr.hide(m_gameSettingsBtnIOSM);
m_btnMgr.hide(m_gameSettingsLblIOSreloadBlock);
m_btnMgr.hide(m_gameSettingsBtnIOSreloadBlock);
m_btnMgr.hide(m_gameSettingsLblExtractSave);
m_btnMgr.hide(m_gameSettingsBtnExtractSave);
}
@ -388,7 +377,7 @@ void CMenu::_showGameSettings(void)
m_btnMgr.setText(m_gameSettingsLblPage, wfmt(L"%i / %i", page, maxpage));
m_btnMgr.setText(m_gameSettingsBtnOcarina, _optBoolToString(m_gcfg2.getOptBool(id, "cheat")));
if(m_cf.getHdr()->hdr.gc_magic != 0xc2339f3d)
if(m_cf.getHdr()->hdr.gc_magic != GC_MAGIC)
{
m_btnMgr.setText(m_gameSettingsBtnVipatch, _optBoolToString(m_gcfg2.getOptBool(id, "vipatch", 0)));
m_btnMgr.setText(m_gameSettingsBtnCountryPatch, _optBoolToString(m_gcfg2.getOptBool(id, "country_patch", 0)));
@ -761,9 +750,6 @@ void CMenu::_initGameSettingsMenu(CMenu::SThemeData &theme)
m_gameSettingsBtnIOSM = _addPicButton(theme, "GAME_SETTINGS/IOS_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 190, 56, 56);
m_gameSettingsBtnIOSP = _addPicButton(theme, "GAME_SETTINGS/IOS_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 190, 56, 56);
m_gameSettingsLblIOSreloadBlock = _addLabel(theme, "GAME_SETTINGS/IOS_RELOAD_BLOCK", theme.lblFont, L"", 40, 250, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_gameSettingsBtnIOSreloadBlock = _addButton(theme, "GAME_SETTINGS/IOS_RELOAD_BLOCK_BTN", theme.btnFont, L"", 330, 250, 270, 56, theme.btnFontColor);
m_gameSettingsLblExtractSave = _addLabel(theme, "GAME_SETTINGS/EXTRACT_SAVE", theme.lblFont, L"", 40, 310, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_gameSettingsBtnExtractSave = _addButton(theme, "GAME_SETTINGS/EXTRACT_SAVE_BTN", theme.btnFont, L"", 330, 310, 270, 56, theme.btnFontColor);
@ -782,8 +768,6 @@ void CMenu::_initGameSettingsMenu(CMenu::SThemeData &theme)
_setHideAnim(m_gameSettingsLblVideo, "GAME_SETTINGS/VIDEO_BTN", 200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsBtnVideoM, "GAME_SETTINGS/VIDEO_MINUS", 200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsBtnVideoP, "GAME_SETTINGS/VIDEO_PLUS", 200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsLblIOSreloadBlock, "GAME_SETTINGS/IOS_RELOAD_BLOCK", -200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsBtnIOSreloadBlock, "GAME_SETTINGS/IOS_RELOAD_BLOCK_BTN", 200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsLblCustom, "GAME_SETTINGS/CUSTOM", -200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsBtnCustom, "GAME_SETTINGS/CUSTOM_BTN", 200, 0, 1.f, 0.f);
_setHideAnim(m_gameSettingsLblDMLGameVideo, "GAME_SETTINGS/DML_VIDEO", -200, 0, 1.f, 0.f);
@ -878,7 +862,6 @@ void CMenu::_textGameSettings(void)
m_btnMgr.setText(m_gameSettingsLblHooktype, _t("cfgg18", L"Hook Type"));
m_btnMgr.setText(m_gameSettingsLblDebugger, _t("cfgg22", L"Debugger"));
m_btnMgr.setText(m_gameSettingsLblEmulation, _t("cfgg24", L"NAND Emulation"));
m_btnMgr.setText(m_gameSettingsLblIOSreloadBlock, _t("cfgg26", L"Disable IOS Reload block"));
m_btnMgr.setText(m_gameSettingsLblAspectRatio, _t("cfgg27", L"Aspect Ratio"));
m_btnMgr.setText(m_gameSettingsLblNMM, _t("cfgg28", L"NMM"));
m_btnMgr.setText(m_gameSettingsLblNoDVD, _t("cfgg29", L"No DVD Patch"));

View File

@ -474,7 +474,7 @@ void CMenu::_game(bool launch)
{
_hideGame();
dir_discHdr *hdr = m_cf.getHdr();
if(currentPartition != SD && hdr->hdr.gc_magic == 0xc2339f3d)
if(currentPartition != SD && hdr->hdr.gc_magic == GC_MAGIC)
{
char gcfolder[300];
snprintf(gcfolder, sizeof(gcfolder), "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id);
@ -499,7 +499,7 @@ void CMenu::_game(bool launch)
if (m_current_view != COVERFLOW_HOMEBREW && m_current_view != COVERFLOW_EMU)
{
// Get banner_title
Banner * banner = m_current_view == COVERFLOW_CHANNEL ? _extractChannelBnr(chantitle) : (m_current_view == COVERFLOW_USB && hdr->hdr.gc_magic != 0xc2339f3d) ? _extractBnr(hdr) : NULL;
Banner * banner = m_current_view == COVERFLOW_CHANNEL ? _extractChannelBnr(chantitle) : (m_current_view == COVERFLOW_USB && hdr->hdr.gc_magic != GC_MAGIC) ? _extractBnr(hdr) : NULL;
if (banner != NULL)
{
if (banner->IsValid())
@ -580,7 +580,7 @@ void CMenu::_game(bool launch)
m_btnMgr.show(m_gameBtnSettings);
}
if ((m_current_view == COVERFLOW_USB || m_cf.getHdr()->hdr.gc_magic == 0xc2339f3d) && !m_locked)
if ((m_current_view == COVERFLOW_USB || m_current_view == COVERFLOW_EMU || m_cf.getHdr()->hdr.gc_magic == GC_MAGIC) && !m_locked)
m_btnMgr.show(m_gameBtnDelete);
}
else
@ -633,7 +633,7 @@ void CMenu::_directlaunch(const string &id)
void CMenu::_launch(dir_discHdr *hdr)
{
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
if(hdr->hdr.gc_magic == 0x4c4f4c4f)
if(hdr->hdr.gc_magic == EMU_MAGIC)
{
string title(&hdr->path[string(hdr->path).find_last_of("/")+1]);
string wiiflow_dol(m_dol);
@ -666,7 +666,7 @@ void CMenu::_launch(dir_discHdr *hdr)
_launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->hdr.magic)), arguments);
return;
}
else if(hdr->hdr.gc_magic == 0xc2339f3d)
else if(hdr->hdr.gc_magic == GC_MAGIC)
{
_launchGC(hdr, true);
return;
@ -1463,13 +1463,13 @@ unsigned int gameSoundThreadStackSize = (unsigned int)32768;
void CMenu::_gameSoundThread(CMenu *m)
{
if(m->m_cf.getHdr()->hdr.gc_magic == 0xc2339f3d)
if(m->m_cf.getHdr()->hdr.gc_magic == GC_MAGIC)
{
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
m->m_gamesound_changed = true;
return;
}
else if(m->m_cf.getHdr()->hdr.gc_magic == 0x4c4f4c4f)
else if(m->m_cf.getHdr()->hdr.gc_magic == EMU_MAGIC)
{
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->hdr.magic), m->m_plugin.GetBannerSoundSize(), false);
m->m_gamesound_changed = true;

View File

@ -250,6 +250,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
bool done = false;
bool upd_usb = false;
bool upd_dml = false;
bool upd_emu = false;
bool out = false;
struct AutoLight { AutoLight(void) { } ~AutoLight(void) { slotLight(false); } } aw;
string cfPos = m_cf.getNextId();
@ -364,18 +365,23 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
}
break;
case CMenu::WO_REMOVE_GAME:
if(m_current_view == COVERFLOW_USB)
{
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), (char *) m_cf.getHdr()->path);
upd_usb = true;
}
else
if(m_cf.getHdr()->hdr.gc_magic == GC_MAGIC)
{
char source[300];
snprintf(source, sizeof(source), "%s/%s", fmt((currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR, DeviceName[currentPartition]), (char *)m_cf.getHdr()->path);
fsop_deleteFolder(source);
upd_dml = true;
}
else if(m_cf.getHdr()->hdr.gc_magic == EMU_MAGIC)
{
fsop_deleteFile((char*)m_cf.getHdr()->path);
upd_emu = true;
}
else if(m_current_view == COVERFLOW_USB)
{
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), (char *) m_cf.getHdr()->path);
upd_usb = true;
}
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", true))
RemoveCover((char *)m_cf.getId().c_str());
m_btnMgr.show(m_wbfsPBar);
@ -459,6 +465,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
if(upd_usb)
UpdateCache(COVERFLOW_USB);
if(upd_emu)
UpdateCache(COVERFLOW_EMU);
_loadList();
_initCF();
m_cf.findId(cfPos.c_str(), true);

View File

@ -14,6 +14,7 @@
#include "gecko/gecko.h"
#include "devicemounter/PartitionHandle.h"
#include "devicemounter/DeviceHandler.hpp"
#include "defines.h"
static const string emptyString;
static const string emptyString2("/");
@ -213,7 +214,7 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, string Device)
strncpy(tmp.path, game.c_str(), sizeof(tmp.path));
gprintf("Found: %ls\n", tmp.title);
tmp.hdr.magic = Plugins.back().magicWord;
tmp.hdr.gc_magic = 0x4c4f4c4f;
tmp.hdr.gc_magic = EMU_MAGIC;
gameHeader.push_back(tmp);
game = ini.nextDomain();
}