-fixed too short help and synopsis (issue 146)

-cleaned up and speeded up some stuff
This commit is contained in:
fix94.1 2012-11-01 16:39:42 +00:00
parent 7e0fa2417c
commit f82408249c
23 changed files with 210 additions and 240 deletions

13
source/const_str.hpp Normal file
View File

@ -0,0 +1,13 @@
#ifndef _CONST_STR_HPP_
#define _CONST_STR_HPP_
#include "wstringEx/wstringEx.hpp"
#include "gui/text.hpp"
#include "defines.h"
#include "svnrev.h"
static const string &VERSION_STRING = sfmt("%s (%s-r%s)", APP_NAME, APP_VERSION, SVN_REV);
static const wstringEx SVN_REV_W(SVN_REV);
#endif

View File

@ -100,7 +100,7 @@ u32 fsop_GetFolderKb(const char *source)
return ret;
}
u32 fsop_GetFreeSpaceKb(char *path) // Return free kb on the device passed
u32 fsop_GetFreeSpaceKb(const char *path) // Return free kb on the device passed
{
struct statvfs s;

View File

@ -11,7 +11,7 @@ typedef void (*progress_callback_t)(int status,int total,void *user_data);
bool fsop_GetFileSizeBytes(char *path, size_t *filesize);
u64 fsop_GetFolderBytes(const char *source);
u32 fsop_GetFolderKb(const char *source);
u32 fsop_GetFreeSpaceKb(char *path);
u32 fsop_GetFreeSpaceKb(const char *path);
bool fsop_FileExist(const char *fn);
bool fsop_DirExist(const char *path);
void fsop_MakeFolder(char *path);

View File

@ -36,37 +36,33 @@
#include "memory/memory.h"
// DIOS-MIOS
DML_CFG *DMLCfg = NULL;
DML_CFG DMLCfg;
void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCheatPath, const char *partition, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting, bool widescreen, bool new_dm_cfg)
{
gprintf("Wiiflow GC: Launch game '%s' through memory (new method)\n", GamePath);
memset(&DMLCfg, 0, sizeof(DML_CFG));
DMLCfg = (DML_CFG*)malloc(sizeof(DML_CFG));
if(DMLCfg == NULL)
return;
memset(DMLCfg, 0, sizeof(DML_CFG));
DMLCfg->Magicbytes = 0xD1050CF6;
DMLCfg.Magicbytes = 0xD1050CF6;
if(new_dm_cfg)
DMLCfg->CfgVersion = 0x00000002;
DMLCfg.CfgVersion = 0x00000002;
else
DMLCfg->CfgVersion = 0x00000001;
DMLCfg.CfgVersion = 0x00000001;
if(videoSetting == 0)
DMLCfg->VideoMode |= DML_VID_NONE;
DMLCfg.VideoMode |= DML_VID_NONE;
else if(videoSetting == 1)
DMLCfg->VideoMode |= DML_VID_DML_AUTO;
DMLCfg.VideoMode |= DML_VID_DML_AUTO;
else
DMLCfg->VideoMode |= DML_VID_FORCE;
DMLCfg.VideoMode |= DML_VID_FORCE;
DMLCfg->Config |= DML_CFG_ACTIVITY_LED; //Sorry but I like it lol, option will may follow
DMLCfg->Config |= DML_CFG_PADHOOK; //Makes life easier, l+z+b+digital down...
DMLCfg.Config |= DML_CFG_ACTIVITY_LED; //Sorry but I like it lol, option will may follow
DMLCfg.Config |= DML_CFG_PADHOOK; //Makes life easier, l+z+b+digital down...
if(GamePath != NULL)
{
strncpy(DMLCfg->GamePath, GamePath, sizeof(DMLCfg->GamePath));
DMLCfg->Config |= DML_CFG_GAME_PATH;
strncpy(DMLCfg.GamePath, GamePath, sizeof(DMLCfg.GamePath));
DMLCfg.Config |= DML_CFG_GAME_PATH;
}
if(CheatPath != NULL && NewCheatPath != NULL && cheats)
@ -79,31 +75,31 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, const char *NewCh
}
else
ptr = strstr(CheatPath, ":/") + 1;
strncpy(DMLCfg->CheatPath, ptr, sizeof(DMLCfg->CheatPath));
strncpy(DMLCfg.CheatPath, ptr, sizeof(DMLCfg.CheatPath));
gprintf("Cheat Path: %s\n", ptr);
DMLCfg->Config |= DML_CFG_CHEAT_PATH;
DMLCfg.Config |= DML_CFG_CHEAT_PATH;
}
if(cheats)
DMLCfg->Config |= DML_CFG_CHEATS;
DMLCfg.Config |= DML_CFG_CHEATS;
if(debugger)
DMLCfg->Config |= DML_CFG_DEBUGGER;
if(NMM > 0)
DMLCfg->Config |= DML_CFG_NMM;
DMLCfg.Config |= DML_CFG_DEBUGGER;
if(NMM)
DMLCfg.Config |= DML_CFG_NMM;
if(NMM > 1)
DMLCfg->Config |= DML_CFG_NMM_DEBUG;
if(nodisc > 0)
DMLCfg.Config |= DML_CFG_NMM_DEBUG;
if(nodisc)
{
if(new_dm_cfg)
DMLCfg->Config |= DML_CFG_NODISC_CFG2;
DMLCfg.Config |= DML_CFG_NODISC_CFG2;
else
DMLCfg->Config |= DML_CFG_NODISC_CFG1;
DMLCfg.Config |= DML_CFG_NODISC_CFG1;
}
if(widescreen && new_dm_cfg)
DMLCfg->Config |= DML_CFG_FORCE_WIDE;
DMLCfg.Config |= DML_CFG_FORCE_WIDE;
if(DMLvideoMode > 3)
DMLCfg->VideoMode |= DML_VID_PROG_PATCH;
DMLCfg.VideoMode |= DML_VID_PROG_PATCH;
}
void DML_Old_SetOptions(const char *GamePath)
@ -125,36 +121,27 @@ void DML_Old_SetOptions(const char *GamePath)
void DML_New_SetBootDiscOption(bool new_dm_cfg)
{
gprintf("Booting GC game\n");
memset(&DMLCfg, 0, sizeof(DML_CFG));
DMLCfg = (DML_CFG*)malloc(sizeof(DML_CFG));
if(DMLCfg == NULL)
return;
memset(DMLCfg, 0, sizeof(DML_CFG));
DMLCfg->Magicbytes = 0xD1050CF6;
DMLCfg.Magicbytes = 0xD1050CF6;
if(new_dm_cfg)
DMLCfg->CfgVersion = 0x00000002;
DMLCfg.CfgVersion = 0x00000002;
else
DMLCfg->CfgVersion = 0x00000001;
DMLCfg->VideoMode |= DML_VID_DML_AUTO;
DMLCfg.CfgVersion = 0x00000001;
DMLCfg.VideoMode |= DML_VID_DML_AUTO;
DMLCfg->Config |= DML_CFG_BOOT_DISC;
DMLCfg.Config |= DML_CFG_BOOT_DISC;
}
void DML_New_WriteOptions()
{
if(DMLCfg == NULL)
return;
//Write options into memory
memcpy((void *)0x80001700, DMLCfg, sizeof(DML_CFG));
memcpy((void *)0x80001700, &DMLCfg, sizeof(DML_CFG));
DCFlushRange((void *)(0x80001700), sizeof(DML_CFG));
//DML v1.2+
memcpy((void *)0x81200000, DMLCfg, sizeof(DML_CFG));
memcpy((void *)0x81200000, &DMLCfg, sizeof(DML_CFG));
DCFlushRange((void *)(0x81200000), sizeof(DML_CFG));
free(DMLCfg);
}
@ -328,7 +315,7 @@ u32 __SYS_UnlockSram(u32 write);
u32 __SYS_SyncSram(void);
}
void GC_SetVideoMode(u8 videomode, u8 videoSetting)
void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS)
{
syssram *sram;
sram = __SYS_LockSram();
@ -354,33 +341,33 @@ void GC_SetVideoMode(u8 videomode, u8 videoSetting)
if(videomode == 1)
{
if(DMLCfg != NULL && videoSetting == 2)
DMLCfg->VideoMode |= DML_VID_FORCE_PAL50;
if(DIOSMIOS && videoSetting == 2)
DMLCfg.VideoMode |= DML_VID_FORCE_PAL50;
vmode = &TVPal528IntDf;
}
else if(videomode == 2)
{
if(DMLCfg != NULL && videoSetting == 2)
DMLCfg->VideoMode |= DML_VID_FORCE_NTSC;
if(DIOSMIOS && videoSetting == 2)
DMLCfg.VideoMode |= DML_VID_FORCE_NTSC;
vmode = &TVNtsc480IntDf;
}
else if(videomode == 3)
{
if(DMLCfg != NULL && videoSetting == 2)
DMLCfg->VideoMode |= DML_VID_FORCE_PAL60;
if(DIOSMIOS && videoSetting == 2)
DMLCfg.VideoMode |= DML_VID_FORCE_PAL60;
vmode = &TVEurgb60Hz480IntDf;
vmode_reg = 5;
}
else if(videomode == 4 ||videomode == 6)
{
if(DMLCfg != NULL && videoSetting == 2)
DMLCfg->VideoMode |= DML_VID_FORCE_PROG;
if(DIOSMIOS && videoSetting == 2)
DMLCfg.VideoMode |= DML_VID_FORCE_PROG;
vmode = &TVNtsc480Prog;
}
else if(videomode == 5 || videomode == 7)
{
if(DMLCfg != NULL && videoSetting == 2)
DMLCfg->VideoMode |= DML_VID_FORCE_PROG;
if(DIOSMIOS && videoSetting == 2)
DMLCfg.VideoMode |= DML_VID_FORCE_PROG;
vmode = &TVNtsc480Prog;
vmode_reg = 5;
}

View File

@ -85,7 +85,7 @@ void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *game
void DEVO_Boot();
// General
void GC_SetVideoMode(u8 videomode, u8 videoSetting);
void GC_SetVideoMode(u8 videomode, u8 videoSetting, bool DIOSMIOS);
void GC_SetLanguage(u8 lang);
int GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir);

View File

@ -3,7 +3,7 @@
int currentStr = 0;
static char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
static char general_buffer[MAX_MSG_SIZE];
static char general_buffer[MAX_MSG_SIZE * 2];
// Simplified use of sprintf
char *fmt(const char *format, ...)

View File

@ -24,16 +24,16 @@ WIP_Code *get_wip_list()
int load_wip_patches(u8 *dir, u8 *gameid)
{
char filepath[150];
char GameID[8];
memset(GameID, 0, sizeof(GameID));
char GameID[7];
GameID[6] = '\0';
memcpy(GameID, gameid, 6);
snprintf(filepath, sizeof(filepath), "%s/%s.wip", dir, GameID);
FILE *fp = fopen(filepath, "rb");
if(!fp)
{
memset(GameID, 0, sizeof(GameID));
memcpy(GameID, gameid, 3);
GameID[3] = '\0';
snprintf(filepath, sizeof(filepath), "%s/%s.wip", dir, GameID);
fp = fopen(filepath, "rb");
}

View File

@ -2,14 +2,11 @@
#include <ogc/system.h>
#include <unistd.h>
#include "defines.h"
#include "svnrev.h"
#include "const_str.hpp"
#include "booter/external_booter.hpp"
#include "channel/nand.hpp"
#include "devicemounter/DeviceHandler.hpp"
#include "gecko/gecko.h"
#include "gecko/wifi_gecko.h"
#include "gui/video.hpp"
#include "gui/text.hpp"
#include "homebrew/homebrew.h"
@ -25,12 +22,13 @@
CMenu mainMenu;
bool useMainIOS = false;
int main(int argc, char **argv)
{
mainIOS = DOL_MAIN_IOS;
__exception_setreload(5);
InitGecko(); //USB Gecko and SD buffer
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
gprintf(" \nWelcome to %s!\nThis is the debug output.\n", VERSION_STRING.c_str());
m_vid.init(); // Init video
MEM_init(); //Inits both mem1lo and mem2

View File

@ -77,7 +77,7 @@ void MEM1_free(void *p)
unsigned int MEM1_freesize()
{
return SYS_GetArena1Size();
return (g_mem1lo.FreeSize() + SYS_GetArena1Size());
}
void MEM2_cleanup(void)

View File

@ -1,6 +1,7 @@
#include "mem2alloc.hpp"
#include <ogc/system.h>
#include <ogc/cache.h>
#include <algorithm>
#include <string.h>
@ -11,7 +12,7 @@
void CMEM2Alloc::init(unsigned int size)
{
m_baseAddress = (SBlock *)std::max(((u32)SYS_GetArena2Lo() + 31) & ~31, IOS_RELOAD_AREA);
m_endAddress = (SBlock *)((char *)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
m_endAddress = (SBlock *)((u8*)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
if (m_endAddress > (SBlock *)0x93100000) //rest is reserved for usb/usb2/network and other stuff... (0xE0000 bytes)
m_endAddress = (SBlock *)0x93100000;
SYS_SetArena2Lo(m_endAddress);
@ -40,7 +41,9 @@ void CMEM2Alloc::cleanup(void)
void CMEM2Alloc::clear(void)
{
m_first = 0;
memset(m_baseAddress, 0, (u8 *)m_endAddress - (u8 *)m_baseAddress);
u32 Size = (u32)m_endAddress - (u32)m_baseAddress;
memset(m_baseAddress, 0, Size);
DCFlushRange(m_baseAddress, Size);
}
unsigned int CMEM2Alloc::usableSize(void *p)
@ -211,7 +214,7 @@ unsigned int CMEM2Alloc::FreeSize()
LockMutex lock(m_mutex);
if (m_first == 0)
return (const char *) m_endAddress - (const char *) m_baseAddress;
return (u32)m_endAddress - (u32)m_baseAddress;
SBlock *i;
unsigned int size = 0;

View File

@ -2591,28 +2591,17 @@ int CMenu::MIOSisDML()
return 0;
}
void CMenu::RemoveCover( char * id )
void CMenu::RemoveCover(const char *id)
{
FILE *fp = fopen(fmt("%s/%s.png", m_boxPicDir.c_str(), id), "rb");
if (fp != NULL)
{
fclose(fp);
remove(fmt("%s/%s.png", m_boxPicDir.c_str(), id));
}
fp = fopen(fmt("%s/%s.png", m_picDir.c_str(), id), "rb");
if (fp != NULL)
{
fclose(fp);
remove(fmt("%s/%s.png", m_picDir.c_str(), id));
}
fp = fopen(fmt("%s/%s.wfc", m_cacheDir.c_str(), id), "rb");
if (fp != NULL)
{
fclose(fp);
remove(fmt("%s/%s.wfc", m_cacheDir.c_str(), id));
}
const char *CoverPath = NULL;
if(id == NULL)
return;
CoverPath = fmt("%s/%s.png", m_boxPicDir.c_str(), id);
fsop_deleteFile(CoverPath);
CoverPath = fmt("%s/%s.png", m_picDir.c_str(), id);
fsop_deleteFile(CoverPath);
CoverPath = fmt("%s/%s.wfc", m_cacheDir.c_str(), id);
fsop_deleteFile(CoverPath);
}
void CMenu::_TempLoadIOS(int IOS)

View File

@ -967,13 +967,7 @@ private:
void _CategorySettings(bool fromGameSet = false);
bool _Home();
bool _ExitTo();
//
void _mainLoopCommon(bool withCF = false, bool adjusting = false);
//
vector<dir_discHdr> _searchGamesByID(const char *gameId);
/* vector<dir_discHdr> _searchGamesByTitle(wchar_t letter);
vector<dir_discHdr> _searchGamesByType(const char type);
vector<dir_discHdr> _searchGamesByRegion(const char region); */
public:
void directlaunch(const char *GameID);
private:
@ -1001,7 +995,7 @@ private:
const char *_cfDomain(bool selected = false);
void UpdateCache(u32 view = COVERFLOW_MAX);
int MIOSisDML();
void RemoveCover( char * id );
void RemoveCover(const char *id);
SFont _font(CMenu::FontSet &fontSet, const char *domain, const char *key, u32 fontSize, u32 lineSpacing, u32 weight, u32 index, const char *genKey);
STexture _texture(TexSet &texSet, const char *domain, const char *key, STexture def);
vector<STexture> _textures(TexSet &texSet, const char *domain, const char *key);

View File

@ -1,15 +1,15 @@
#include "menu.hpp"
#include "defines.h"
#include "svnrev.h"
#include "channel/nand.hpp"
#include "loader/alt_ios.h"
#include "loader/cios.h"
#include "loader/sys.h"
#include "const_str.hpp"
const int pixels_to_skip = 10;
extern const u8 english_txt[];
static const wstringEx ENGLISH_TXT_W((const char*)english_txt);
//About menu
s16 m_aboutLblTitle;
@ -125,15 +125,14 @@ void CMenu::_textAbout(void)
help_text.fromUTF8(help);
MEM2_free(help);
fclose(f);
m_btnMgr.setText(m_aboutLblInfo, help_text);
}
else
help_text.fromUTF8((char*)english_txt);
m_btnMgr.setText(m_aboutLblInfo, wfmt(L"%s", help_text.toUTF8().c_str()), false);
m_btnMgr.setText(m_aboutLblInfo, ENGLISH_TXT_W);
}
else
{
m_btnMgr.setText(m_aboutLblTitle, wfmt( L"%s (%s-r%s)", APP_NAME, APP_VERSION, SVN_REV), false);
m_btnMgr.setText(m_aboutLblTitle, VERSION_STRING);
wstringEx developers(wfmt(_fmt("about6", L"\nCurrent Developers:\n%s"), DEVELOPERS));
wstringEx pDevelopers(wfmt(_fmt("about7", L"Past Developers:\n%s"), PAST_DEVELOPERS));
@ -157,11 +156,9 @@ void CMenu::_textAbout(void)
origGUI.toUTF8().c_str(),
codethx.toUTF8().c_str(),
sites.toUTF8().c_str(),
thanks.toUTF8().c_str()),
false
thanks.toUTF8().c_str())
);
}
switch(IOS_GetType(CurrentIOS.Version))
{
case IOS_TYPE_D2X:

View File

@ -90,7 +90,7 @@ void CMenu::_CheatSettings()
_textCheatSettings();
if (txtavailable)
m_btnMgr.setText(m_cheatLblTitle,wfmt(L"%s",m_cheatfile.getGameName().c_str()));
m_btnMgr.setText(m_cheatLblTitle, m_cheatfile.getGameName());
else
m_btnMgr.setText(m_cheatLblTitle, L"");
@ -244,7 +244,7 @@ void CMenu::_CheatSettings()
_showCheatSettings();
if(txtavailable)
m_btnMgr.setText(m_cheatLblTitle,wfmt(L"%s",m_cheatfile.getGameName().c_str()));
m_btnMgr.setText(m_cheatLblTitle, m_cheatfile.getGameName());
else
m_btnMgr.setText(m_cheatLblTitle, L"");
@ -308,7 +308,7 @@ void CMenu::_showCheatSettings(void)
// cheat in range?
if (((m_cheatSettingsPage-1)*CHEATSPERPAGE + i + 1) <= m_cheatfile.getCnt())
{
m_btnMgr.setText(m_cheatLblItem[i], wfmt(L"%s", m_cheatfile.getCheatName((m_cheatSettingsPage-1)*CHEATSPERPAGE + i).c_str()));
m_btnMgr.setText(m_cheatLblItem[i], m_cheatfile.getCheatName((m_cheatSettingsPage-1)*CHEATSPERPAGE + i));
m_btnMgr.setText(m_cheatBtnItem[i], _optBoolToString(m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i]));
m_btnMgr.show(m_cheatLblItem[i], true);

View File

@ -8,6 +8,7 @@
#include "menu.hpp"
#include "types.h"
#include "const_str.hpp"
#include "banner/BannerWindow.hpp"
#include "booter/external_booter.hpp"
#include "channel/channel_launcher.h"
@ -845,10 +846,10 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
if(disc)
{
loader = 0;
loader = 1;
DML_New_SetBootDiscOption(m_new_dm_cfg);
}
else if(loader == 1 || (loader == 0 && (strcasestr(path.c_str(), "boot.bin") != NULL || !m_devo_installed)))
else if(loader == 1 || strcasestr(path.c_str(), "boot.bin") != NULL || !m_devo_installed)
{
loader = 1;
m_cfg.setString("DML", "current_item", id);
@ -875,18 +876,19 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id.c_str()));
string newPath = &path[path.find_first_of(":/")+1];
if(m_new_dml)
DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath.c_str(), DeviceName[currentPartition], cheats, DML_debug, NMM, nodisc, videoMode, videoSetting, DM_Widescreen, m_new_dm_cfg);
DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath.c_str(), DeviceName[currentPartition],
cheats, DML_debug, NMM, nodisc, videoMode, videoSetting, DM_Widescreen, m_new_dm_cfg);
else
DML_Old_SetOptions(newPath.c_str());
if(!nodisc || !m_new_dml)
WDVD_StopMotor();
}
else if(loader == 2 || (loader == 0 && m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL))
else
{
loader = 2;
DEVO_GetLoader(m_dataDir.c_str());
}
bool DIOSMIOS = (loader == 1);
m_gcfg1.save(true);
m_gcfg2.save(true);
@ -894,10 +896,17 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
m_cfg.save(true);
cleanup();
GC_SetVideoMode(videoMode, videoSetting);
GC_SetVideoMode(videoMode, videoSetting, DIOSMIOS);
GC_SetLanguage(GClanguage);
if(loader == 2 && !disc)
if(DIOSMIOS)
{
DML_New_WriteOptions();
ShutdownBeforeExit();
WII_Initialize();
WII_LaunchTitle(0x100000100LL);
}
else
{
if(AHBRPOT_Patched())
loadIOS(58, false);
@ -907,13 +916,6 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
DEVO_SetOptions(path.c_str(), currentPartition, id.c_str(), memcard_emu);
DEVO_Boot();
}
else
{
DML_New_WriteOptions();
ShutdownBeforeExit();
WII_Initialize();
WII_LaunchTitle(0x100000100LL);
}
Sys_Exit();
}

View File

@ -78,6 +78,8 @@ extern const u8 pegi_16_png[];
extern const u8 pegi_18_png[];
GameXMLInfo gameinfo;
wstringEx gameinfo_Synopsis_w;
wstringEx gameinfo_Title_w;
static bool titlecheck = false;
u8 cnt_controlsreq = 0, cnt_controls = 0;
@ -133,9 +135,6 @@ void CMenu::_gameinfo(void)
page = 1;
amount_of_skips = 0;
m_btnMgr.reset(m_gameinfoLblSynopsis);
m_btnMgr.setText(m_gameinfoLblSynopsis, wfmt(L"%s", gameinfo.Synopsis.c_str()));
m_btnMgr.hide(m_gameinfoLblID, true);
m_btnMgr.hide(m_gameinfoLblDev, true);
m_btnMgr.hide(m_gameinfoLblRegion, true);
@ -160,6 +159,7 @@ void CMenu::_gameinfo(void)
else
m_btnMgr.show(m_gameinfoLblUser[i]);
m_btnMgr.reset(m_gameinfoLblSynopsis);
m_btnMgr.show(m_gameinfoLblSynopsis, false);
}
else if (BTN_LEFT_PRESSED && !(m_thrdWorking && m_thrdStop))
@ -317,10 +317,12 @@ void CMenu::_textGameInfo(void)
titlecheck = gametdb.IsLoaded() && gametdb.GetGameXMLInfo(m_cf.getId().c_str(), &gameinfo);
if(titlecheck)
{
gprintf("ID: %s\nTitle: %s\n", gameinfo.GameID.c_str(), gameinfo.Title.c_str());
gameinfo_Title_w.fromUTF8(gameinfo.Title);
m_btnMgr.setText(m_gameinfoLblTitle, gameinfo_Title_w, true);
gameinfo_Synopsis_w.fromUTF8(gameinfo.Synopsis);
m_btnMgr.setText(m_gameinfoLblSynopsis, gameinfo_Synopsis_w);
m_btnMgr.setText(m_gameinfoLblID, wfmt(L"GameID: %s", gameinfo.GameID.c_str()), true);
m_btnMgr.setText(m_gameinfoLblTitle, wfmt(L"%s", gameinfo.Title.c_str()), true);
m_btnMgr.setText(m_gameinfoLblSynopsis, wfmt(L"%s", gameinfo.Synopsis.c_str()), false);
m_btnMgr.setText(m_gameinfoLblDev, wfmt(_fmt("gameinfo1",L"Developer: %s"), gameinfo.Developer.c_str()), true);
m_btnMgr.setText(m_gameinfoLblPublisher, wfmt(_fmt("gameinfo2",L"Publisher: %s"), gameinfo.Publisher.c_str()), true);
m_btnMgr.setText(m_gameinfoLblRegion, wfmt(_fmt("gameinfo3",L"Region: %s"), gameinfo.Region.c_str()), true);
@ -329,7 +331,6 @@ void CMenu::_textGameInfo(void)
int year = gameinfo.PublishDate >> 16;
int day = gameinfo.PublishDate & 0xFF;
int month = (gameinfo.PublishDate >> 8) & 0xFF;
switch(CONF_GetRegion())
{
case 0:

View File

@ -1,9 +1,9 @@
#include "menu.hpp"
#include "svnrev.h"
#include "loader/cios.h"
#include "loader/nk.h"
#include "loader/sys.h"
#include "const_str.hpp"
s16 m_homeLblTitle;
s16 m_exittoLblTitle;
@ -265,8 +265,7 @@ void CMenu::_initHomeAndExitToMenu(CMenu::SThemeData &theme)
void CMenu::_textHome(void)
{
m_btnMgr.setText(m_homeLblTitle, wfmt( L"%s (%s-r%s)", APP_NAME, APP_VERSION, SVN_REV), false);
m_btnMgr.setText(m_homeLblTitle, VERSION_STRING);
m_btnMgr.setText(m_homeBtnSettings, _t("home1", L"Settings"));
m_btnMgr.setText(m_homeBtnReloadCache, _t("home2", L"Reload Cache"));
m_btnMgr.setText(m_homeBtnUpdate, _t("home3", L"Update"));
@ -278,7 +277,6 @@ void CMenu::_textHome(void)
void CMenu::_textExitTo(void)
{
m_btnMgr.setText(m_exittoLblTitle, _t("exit_to", L"Exit To"));
m_btnMgr.setText(m_homeBtnExitToHBC, _t("hbc", L"Homebrew Channel"));
m_btnMgr.setText(m_homeBtnExitToMenu, _t("menu", L"System Menu"));
m_btnMgr.setText(m_homeBtnExitToPriiloader, _t("prii", L"Priiloader"));

View File

@ -1,19 +1,19 @@
#include "menu.hpp"
#include "svnrev.h"
#include "defines.h"
#include "const_str.hpp"
#include "lockMutex.hpp"
#include "loader/sys.h"
#include "loader/wbfs.h"
int version_num = 0, num_versions = 0, i;
int CMenu::_version[9] = {0, atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV), atoi(SVN_REV)};
const u32 SVN_REV_NUM = atoi(SVN_REV);
int CMenu::_version[9] = {0, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM, SVN_REV_NUM};
const int pixels_to_skip = 10;
void CMenu::_system()
{
int msg = 0, newVer = atoi(SVN_REV);
int msg = 0, newVer = SVN_REV_NUM;
lwp_t thread = LWP_THREAD_NULL;
wstringEx prevMsg;
@ -62,11 +62,11 @@ void CMenu::_system()
m_btnMgr.hide(m_downloadPBar);
m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -2.f, 0.f);
m_btnMgr.hide(m_downloadLblMessage[1], 0, 0, -2.f, 0.f);
CMenu::_version[1] = m_version.getInt("GENERAL", "version", atoi(SVN_REV));
CMenu::_version[1] = m_version.getInt("GENERAL", "version", SVN_REV_NUM);
num_versions = m_version.getInt("GENERAL", "num_versions", 1);
for (i = 2; i < num_versions; i++)
{
CMenu::_version[i] = m_version.getInt(fmt("VERSION%i", i-1u), "version", atoi(SVN_REV));
CMenu::_version[i] = m_version.getInt(fmt("VERSION%i", i-1u), "version", SVN_REV_NUM);
//add the changelog info here
}
if (num_versions > 1 && version_num == 0) version_num = 1;
@ -277,14 +277,12 @@ void CMenu::_textSystem(void)
{
m_btnMgr.setText(m_systemLblTitle, _t("sys1", L"Update WiiFlow"));
m_btnMgr.setText(m_systemLblVersionTxt, _t("sys2", L"WiiFlow Version:"));
m_btnMgr.setText(m_systemLblVersion, wfmt(L"r%s", SVN_REV).c_str());
m_btnMgr.setText(m_systemLblVersion, SVN_REV_W);
m_btnMgr.setText(m_systemBtnBack, _t("sys3", L"Cancel"));
m_btnMgr.setText(m_systemBtnDownload, _t("sys4", L"Upgrade"));
i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
if (i == 0)
{
m_btnMgr.setText(m_systemLblVerSelectVal, wfmt(L"%i", atoi(SVN_REV)).c_str());
}
m_btnMgr.setText(m_systemLblVerSelectVal, SVN_REV_W);
else
{
m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i])));

View File

@ -71,14 +71,14 @@ void CMenu::_addDiscProgress(int status, int total, void *user_data)
}
}
vector<dir_discHdr> CMenu::_searchGamesByID(const char *gameId)
static inline bool _searchGamesByID(const char *gameId)
{
vector<dir_discHdr> retval;
for (vector<dir_discHdr>::iterator itr = m_gameList.begin(); itr != m_gameList.end(); itr++)
if (strncmp((const char *) (*itr).id, gameId, strlen(gameId)) == 0)
retval.push_back(*itr);
return retval;
for(vector<dir_discHdr>::const_iterator itr = m_gameList.begin(); itr != m_gameList.end(); ++itr)
{
if(strncmp(itr->id, gameId, 6) == 0)
return true;
}
return false;
}
void CMenu::_Messenger(int message, int info, char *cinfo, void *user_data)
@ -179,7 +179,7 @@ int CMenu::_GCgameInstaller(void *obj)
}
char partition[6];
snprintf(partition, sizeof(partition), "%s:/", DeviceName[currentPartition]);
strncpy(partition, fmt("%s:/", DeviceName[currentPartition]), sizeof(partition));
u32 needed = 0;
@ -226,18 +226,24 @@ int CMenu::_GCgameInstaller(void *obj)
int CMenu::_GCcopyGame(void *obj)
{
CMenu &m = *(CMenu *)obj;
char folder[50];
char source[300];
char target[300];
string GC_Path(m.m_cf.getHdr()->path);
if(strcasestr(GC_Path.c_str(), "boot.bin") != NULL)
GC_Path.erase(GC_Path.end() - 13, GC_Path.end());
else
GC_Path.erase(GC_Path.end() - 9, GC_Path.end());
char source[300];
strncpy(source, GC_Path.c_str(), sizeof(source));
snprintf(folder, sizeof(folder), DML_DIR, DeviceName[SD]);
snprintf(target, sizeof(target), "%s/%s", folder, &GC_Path[GC_Path.find_last_of("/")]+1);
source[299] = '\0';
char folder[50];
strncpy(folder, fmt(DML_DIR, DeviceName[SD]), sizeof(folder));
folder[49] = '\0';
char target[300];
strncpy(target, fmt("%s/%s", folder, strrchr(source, '/') + 1), sizeof(target));
target[299] = '\0';
LWP_MutexLock(m.m_mutex);
m._setThrdMsg(L"", 0);
@ -259,6 +265,8 @@ int CMenu::_GCcopyGame(void *obj)
bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
{
lwp_t thread = 0;
char GameID[7];
GameID[6] = '\0';
static discHdr header ATTRIBUTE_ALIGN(32);
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
bool done = false;
@ -266,11 +274,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
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();
SetupInput();
_showWBFS(op);
switch (op)
{
@ -329,14 +335,15 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
if (Disc_IsWii() == 0)
{
Disc_ReadHeader(&header);
if(_searchGamesByID((const char *) header.id).size() != 0)
memcpy(GameID, header.id, 6);
if(_searchGamesByID(GameID))
{
error(_t("wbfsoperr4", L"Game already installed"));
out = true;
break;
}
cfPos = string((char *)header.id);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), string((const char *)header.id, sizeof header.id).c_str(), string((const char *)header.title, sizeof header.title).c_str()));
cfPos = string(GameID);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, header.title));
done = true;
upd_usb = true;
m_thrdWorking = true;
@ -347,19 +354,15 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
else if(Disc_IsGC() == 0)
{
Disc_ReadGCHeader(&gcheader);
char gcfolder[300];
char dmlgamedir[50];
strncpy(dmlgamedir, (currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR, sizeof(dmlgamedir));
snprintf(gcfolder, sizeof(gcfolder), "%s [%s]", gcheader.title, (char *)gcheader.id);
if(_searchGamesByID((const char *) gcheader.id).size() != 0)
memcpy(GameID, gcheader.id, 6);
if(_searchGamesByID(GameID))
{
error(_t("wbfsoperr4", L"Game already installed"));
out = true;
break;
}
cfPos = string((char *) gcheader.id);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), string((const char *)gcheader.id, sizeof gcheader.id).c_str(), string((const char *)gcheader.title, sizeof gcheader.title).c_str()));
cfPos = string(GameID);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gcheader.title));
done = true;
upd_dml = true;
m_thrdWorking = true;
@ -375,13 +378,15 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
break;
case CMenu::WO_REMOVE_GAME:
if(m_cf.getHdr()->type == TYPE_GC_GAME)
{
if(strcasestr(m_cf.getHdr()->path, "boot.bin") != NULL)
{
string GC_Path(m_cf.getHdr()->path);
if(strcasestr(GC_Path.c_str(), "boot.bin") != NULL)
GC_Path.erase(GC_Path.end() - 13, GC_Path.end());
else
GC_Path.erase(GC_Path.end() - 9, GC_Path.end());
fsop_deleteFolder(GC_Path.c_str());
}
else
fsop_deleteFile(m_cf.getHdr()->path);
upd_dml = true;
}
else if(m_cf.getHdr()->type == TYPE_PLUGIN)
@ -391,11 +396,11 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
}
else if(m_cf.getHdr()->type == TYPE_WII_GAME)
{
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), (char *) m_cf.getHdr()->path);
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), m_cf.getHdr()->path);
upd_usb = true;
}
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", true))
RemoveCover((char *)m_cf.getId().c_str());
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", false))
RemoveCover(m_cf.getId().c_str());
m_btnMgr.show(m_wbfsPBar);
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
m_btnMgr.setProgress(m_wbfsPBar, 1.f);
@ -413,32 +418,25 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
GC_Path.erase(GC_Path.end() - 13, GC_Path.end());
else
GC_Path.erase(GC_Path.end() - 9, GC_Path.end());
if(fsop_GetFreeSpaceKb((char*)"sd:/")<fsop_GetFolderKb(GC_Path.c_str()))
if(fsop_GetFreeSpaceKb("sd:/") < fsop_GetFolderKb(GC_Path.c_str()))
{
m_btnMgr.hide(m_wbfsBtnGo);
_setThrdMsg(wfmt(_fmt("wbfsop24", L"Not enough space: %d blocks needed, %d available"), fsop_GetFolderKb(GC_Path.c_str()), fsop_GetFreeSpaceKb((char*)"sd:/")), 0.f);
_setThrdMsg(wfmt(_fmt("wbfsop24", L"Not enough space: %d blocks needed, %d available"), fsop_GetFolderKb(GC_Path.c_str()), fsop_GetFreeSpaceKb("sd:/")), 0.f);
break;
}
m_btnMgr.show(m_wbfsPBar);
m_btnMgr.setProgress(m_wbfsPBar, 0.f);
m_btnMgr.hide(m_wbfsBtnGo);
m_btnMgr.hide(m_wbfsBtnBack);
m_btnMgr.show(m_wbfsLblMessage);
m_btnMgr.setText(m_wbfsLblMessage, L"");
cfPos = string((char*)m_cf.getHdr()->id);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop10", L"Copying [%s] %s..."), (u8*)m_cf.getHdr()->id, (u8*)m_cf.getTitle().toUTF8().c_str()));
cfPos = string(m_cf.getHdr()->id);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop10", L"Copying [%s] %s..."), m_cf.getHdr()->id, m_cf.getTitle().toUTF8().c_str()));
done = true;
upd_dml = true;
m_thrdWorking = true;
m_thrdProgress = 0.f;
m_thrdMessageAdded = false;
m_cf.stopCoverLoader();
_stopSounds();
MusicPlayer.Cleanup();
SoundHandle.Cleanup();
soundDeinit();
NandHandle.Disable_Emu();
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_GCcopyGame, (void *)this, 0, 8 * 1024, 64);
break;
}

View File

@ -30,6 +30,7 @@
void Plugin::init(const string& m_pluginsDir)
{
PluginMagicWord[8] = '\0';
pluginsDir = m_pluginsDir;
//Ready to add plugins
adding = true;
@ -150,8 +151,6 @@ void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
{
if(pos < Plugins.size())
{
char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8);
if(ForceMode == 1)
cfg.setBool(PLUGIN_DOMAIN, PluginMagicWord, false);
@ -165,11 +164,9 @@ void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg)
{
enabledPlugins.clear();
char PluginMagicWord[9];
u8 enabledPluginsNumber = 0;
for(u8 i = 0; i < Plugins.size(); i++)
{
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8);
if(cfg.getBool(PLUGIN_DOMAIN, PluginMagicWord, true))
{
@ -264,8 +261,8 @@ string Plugin::GenerateCoverLink(dir_discHdr gameHeader, const string& constURL,
strncpy(gamePath, gameHeader.path, sizeof(gamePath));
const string& cachedCRC = Checksums.getString("CHECKSUMS", gamePath);
char crc_string[9];
memset(crc_string, 0, sizeof(crc_string));
if(cachedCRC.size() > 1)
crc_string[8] = '\0';
if(cachedCRC.size() == 8)
{
gprintf("CRC32 of %s is cached\n", gamePath);
strncpy(crc_string, cachedCRC.c_str(), 8);

View File

@ -74,6 +74,7 @@ private:
s8 GetPluginPosition(u32 magic);
vector<PluginOptions> Plugins;
vector<bool> enabledPlugins;
char PluginMagicWord[9];
s8 Plugin_Pos;
string pluginsDir;
bool adding;

View File

@ -1,10 +1,8 @@
#include "wstringEx.hpp"
using namespace std;
wstringEx::wstringEx(const wchar_t *s) :
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(s)
basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >(s)
{
}
@ -15,26 +13,22 @@ wstringEx::wstringEx(const basic_string<wchar_t, char_traits<wchar_t>, allocator
wstringEx::wstringEx(const string &s)
{
std::string::size_type size;
size = s.size();
size_type size = s.size();
resize(size);
for (std::string::size_type i = 0; i < size; ++i)
for (size_type i = 0; i < size; ++i)
(*this)[i] = (unsigned char)s[i];
}
wstringEx &wstringEx::operator=(const string &s)
{
std::string::size_type size;
size = s.size();
this->resize(size);
for (std::string::size_type i = 0; i < size; ++i)
size_type size = s.size();
resize(size);
for (size_type i = 0; i < size; ++i)
(*this)[i] = (unsigned char)s[i];
return *this;
}
static size_t utf8Len(const char *s)
static inline size_t utf8Len(const string &s)
{
size_t len = 0;
@ -72,7 +66,7 @@ static size_t utf8Len(const char *s)
return len;
}
void wstringEx::fromUTF8(const char *s)
void wstringEx::fromUTF8(const string &s)
{
size_t len = utf8Len(s);

View File

@ -3,19 +3,19 @@
#define __WSTRINGEX_HPP
#include <string>
using namespace std;
class wstringEx : public std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
class wstringEx : public basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >
{
public:
wstringEx(void) { }
wstringEx(const wchar_t *s);
wstringEx(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > &ws);
wstringEx(const std::string &s);
wstringEx &operator=(const std::string &s);
void fromUTF8(const char *s);
std::string toUTF8(void) const;
wstringEx(const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > &ws);
wstringEx(const string &s);
wstringEx &operator=(const string &s);
void fromUTF8(const string &s);
string toUTF8(void) const;
};
#endif // !defined(__WSTRINGEX_HPP)