Fixes issue 1255.
(wxString / char * conversion) Move CopySJISToString to WxUtils. Add ability to view sjis name and comment for japanese memcards Add ability to format sjis memcards CopySJISToString needs work on linux git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3945 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
5013ab957c
commit
e941dd79cd
|
@ -327,16 +327,16 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
//SetItem(_Index, COLUMN_TITLE, wxString(wxString(rISOFile.GetName()).wc_str(convFrom) , convTo), -1);
|
//SetItem(_Index, COLUMN_TITLE, wxString(wxString(rISOFile.GetName()).wc_str(convFrom) , convTo), -1);
|
||||||
//SetItem(_Index, COLUMN_NOTES, wxString(wxString(rISOFile.GetDescription()).wc_str(convFrom) , convTo), -1);
|
//SetItem(_Index, COLUMN_NOTES, wxString(wxString(rISOFile.GetDescription()).wc_str(convFrom) , convTo), -1);
|
||||||
|
|
||||||
if (CopySJISToString(name, rISOFile.GetName(0).c_str()))
|
if (WxUtils::CopySJISToString(name, rISOFile.GetName(0).c_str()))
|
||||||
SetItem(_Index, COLUMN_TITLE, name, -1);
|
SetItem(_Index, COLUMN_TITLE, name, -1);
|
||||||
if (CopySJISToString(description, rISOFile.GetDescription(0).c_str()))
|
if (WxUtils::CopySJISToString(description, rISOFile.GetDescription(0).c_str()))
|
||||||
SetItem(_Index, COLUMN_NOTES, description, -1);
|
SetItem(_Index, COLUMN_NOTES, description, -1);
|
||||||
m_gameList.append(StringFromFormat("%s (J)\n", (const char*)name.mb_str(wxConvUTF8)));
|
m_gameList.append(StringFromFormat("%s (J)\n", (const char*)name.mb_str(wxConvUTF8)));
|
||||||
break;
|
break;
|
||||||
case DiscIO::IVolume::COUNTRY_USA:
|
case DiscIO::IVolume::COUNTRY_USA:
|
||||||
if (CopySJISToString(name, rISOFile.GetName(0).c_str()))
|
if (WxUtils::CopySJISToString(name, rISOFile.GetName(0).c_str()))
|
||||||
SetItem(_Index, COLUMN_TITLE, name, -1);
|
SetItem(_Index, COLUMN_TITLE, name, -1);
|
||||||
if (CopySJISToString(description, rISOFile.GetDescription(0).c_str()))
|
if (WxUtils::CopySJISToString(description, rISOFile.GetDescription(0).c_str()))
|
||||||
SetItem(_Index, COLUMN_NOTES, description, -1);
|
SetItem(_Index, COLUMN_NOTES, description, -1);
|
||||||
m_gameList.append(StringFromFormat("%s (U)\n", (const char*)name.mb_str(wxConvUTF8)));
|
m_gameList.append(StringFromFormat("%s (U)\n", (const char*)name.mb_str(wxConvUTF8)));
|
||||||
break;
|
break;
|
||||||
|
@ -1063,57 +1063,4 @@ void CGameListCtrl::UnselectAll()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameListCtrl::CopySJISToString( wxString& _rDestination, const char* _src )
|
|
||||||
{
|
|
||||||
bool returnCode = false;
|
|
||||||
#ifdef WIN32
|
|
||||||
// HyperIris: because dolphin using "Use Multi-Byte Character Set",
|
|
||||||
// we must convert the SJIS chars to unicode then to our windows local by hand
|
|
||||||
u32 unicodeNameSize = MultiByteToWideChar(932, MB_PRECOMPOSED,
|
|
||||||
_src, (int)strlen(_src), NULL, NULL);
|
|
||||||
if (unicodeNameSize > 0)
|
|
||||||
{
|
|
||||||
u16* pUnicodeStrBuffer = new u16[unicodeNameSize + 1];
|
|
||||||
if (pUnicodeStrBuffer)
|
|
||||||
{
|
|
||||||
memset(pUnicodeStrBuffer, 0, (unicodeNameSize + 1) * sizeof(u16));
|
|
||||||
if (MultiByteToWideChar(932, MB_PRECOMPOSED,
|
|
||||||
_src, (int)strlen(_src),
|
|
||||||
(LPWSTR)pUnicodeStrBuffer, unicodeNameSize))
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _UNICODE
|
|
||||||
_rDestination = (LPWSTR)pUnicodeStrBuffer;
|
|
||||||
returnCode = true;
|
|
||||||
#else
|
|
||||||
u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0,
|
|
||||||
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
if (ansiNameSize > 0)
|
|
||||||
{
|
|
||||||
char* pAnsiStrBuffer = new char[ansiNameSize + 1];
|
|
||||||
if (pAnsiStrBuffer)
|
|
||||||
{
|
|
||||||
memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char));
|
|
||||||
if (WideCharToMultiByte(CP_ACP, 0,
|
|
||||||
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
|
||||||
pAnsiStrBuffer, ansiNameSize, NULL, NULL))
|
|
||||||
{
|
|
||||||
_rDestination = pAnsiStrBuffer;
|
|
||||||
returnCode = true;
|
|
||||||
}
|
|
||||||
delete pAnsiStrBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
delete pUnicodeStrBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
_rDestination = wxString(wxString(_src,wxConvLibc),wxConvUTF8);
|
|
||||||
returnCode = true;
|
|
||||||
#endif
|
|
||||||
return returnCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,6 @@ private:
|
||||||
static size_t m_numberItem;
|
static size_t m_numberItem;
|
||||||
static void CompressCB(const char* text, float percent, void* arg);
|
static void CompressCB(const char* text, float percent, void* arg);
|
||||||
static void MultiCompressCB(const char* text, float percent, void* arg);
|
static void MultiCompressCB(const char* text, float percent, void* arg);
|
||||||
|
|
||||||
// hyperiris: put it here will be nice, if we moce to wx unicode, it simple to fix
|
|
||||||
bool CopySJISToString(wxString& _rDestination, const char* _src);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
|
||||||
|
|
||||||
// hyperiris: temp fix, need real work
|
// hyperiris: temp fix, need real work
|
||||||
wxString name;
|
wxString name;
|
||||||
CopySJISToString(name, OpenGameListItem->GetName(0).c_str());
|
WxUtils::CopySJISToString(name, OpenGameListItem->GetName(0).c_str());
|
||||||
|
|
||||||
SetTitle(wxString::Format(wxT("%s%s"),
|
SetTitle(wxString::Format(wxT("%s%s"),
|
||||||
wxString::FromAscii(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str()),
|
wxString::FromAscii(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str()),
|
||||||
|
@ -1014,65 +1014,13 @@ void CISOProperties::OnChangeBannerLang(wxCommandEvent& event)
|
||||||
|
|
||||||
void CISOProperties::ChangeBannerDetails(int lang)
|
void CISOProperties::ChangeBannerDetails(int lang)
|
||||||
{
|
{
|
||||||
wxString name;
|
wxString name,
|
||||||
CopySJISToString(name, OpenGameListItem->GetName(lang).c_str());
|
description;
|
||||||
wxString description;
|
|
||||||
CopySJISToString(description, OpenGameListItem->GetDescription(lang).c_str());
|
WxUtils::CopySJISToString(name, OpenGameListItem->GetName(lang).c_str());
|
||||||
|
WxUtils::CopySJISToString(description, OpenGameListItem->GetDescription(lang).c_str());
|
||||||
|
|
||||||
m_ShortName->SetValue(name);
|
m_ShortName->SetValue(name);
|
||||||
m_Maker->SetValue(wxString::FromAscii(OpenGameListItem->GetCompany().c_str()));//dev too
|
m_Maker->SetValue(wxString::FromAscii(OpenGameListItem->GetCompany().c_str()));//dev too
|
||||||
m_Comment->SetValue(description);
|
m_Comment->SetValue(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CISOProperties::CopySJISToString( wxString& _rDestination, const char* _src )
|
|
||||||
{
|
|
||||||
bool returnCode = false;
|
|
||||||
#ifdef WIN32
|
|
||||||
// HyperIris: because dolphin using "Use Multi-Byte Character Set",
|
|
||||||
// we must convert the SJIS chars to unicode then to our windows local by hand
|
|
||||||
u32 unicodeNameSize = MultiByteToWideChar(932, MB_PRECOMPOSED,
|
|
||||||
_src, (int)strlen(_src), NULL, NULL);
|
|
||||||
if (unicodeNameSize > 0)
|
|
||||||
{
|
|
||||||
u16* pUnicodeStrBuffer = new u16[unicodeNameSize + 1];
|
|
||||||
if (pUnicodeStrBuffer)
|
|
||||||
{
|
|
||||||
memset(pUnicodeStrBuffer, 0, (unicodeNameSize + 1) * sizeof(u16));
|
|
||||||
if (MultiByteToWideChar(932, MB_PRECOMPOSED,
|
|
||||||
_src, (int)strlen(_src),
|
|
||||||
(LPWSTR)pUnicodeStrBuffer, unicodeNameSize))
|
|
||||||
{
|
|
||||||
#ifdef _UNICODE
|
|
||||||
_rDestination = (LPWSTR)pUnicodeStrBuffer;
|
|
||||||
returnCode = true;
|
|
||||||
#else
|
|
||||||
u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0,
|
|
||||||
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
if (ansiNameSize > 0)
|
|
||||||
{
|
|
||||||
char* pAnsiStrBuffer = new char[ansiNameSize + 1];
|
|
||||||
if (pAnsiStrBuffer)
|
|
||||||
{
|
|
||||||
memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char));
|
|
||||||
if (WideCharToMultiByte(CP_ACP, 0,
|
|
||||||
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
|
||||||
pAnsiStrBuffer, ansiNameSize, NULL, NULL))
|
|
||||||
{
|
|
||||||
_rDestination = pAnsiStrBuffer;
|
|
||||||
returnCode = true;
|
|
||||||
}
|
|
||||||
delete pAnsiStrBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
delete[] pUnicodeStrBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
_rDestination = wxString(wxString(_src,wxConvLibc),wxConvUTF8);
|
|
||||||
returnCode = true;
|
|
||||||
#endif
|
|
||||||
return returnCode;
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <wx/gbsizer.h>
|
#include <wx/gbsizer.h>
|
||||||
#include <wx/notebook.h>
|
#include <wx/notebook.h>
|
||||||
#include <wx/mimetype.h>
|
#include <wx/mimetype.h>
|
||||||
|
#include "WxUtils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "ISOFile.h"
|
#include "ISOFile.h"
|
||||||
|
@ -251,8 +252,5 @@ class CISOProperties : public wxDialog
|
||||||
void ActionReplayList_Load();
|
void ActionReplayList_Load();
|
||||||
void ActionReplayList_Save();
|
void ActionReplayList_Save();
|
||||||
void ChangeBannerDetails(int lang);
|
void ChangeBannerDetails(int lang);
|
||||||
|
|
||||||
// HyperIris: duplicate from GameListCtrl, who can merge them and put them in a suitable place?
|
|
||||||
bool CopySJISToString(wxString& _rDestination, const char* _src);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "MemcardManager.h"
|
#include "MemcardManager.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
|
#include "WxUtils.h"
|
||||||
|
|
||||||
#define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator
|
#define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator
|
||||||
#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
|
#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
|
||||||
|
@ -116,7 +117,7 @@ CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString
|
||||||
}
|
}
|
||||||
else itemsPerPage = 16;
|
else itemsPerPage = 16;
|
||||||
maxPages = (128 / itemsPerPage) - 1;
|
maxPages = (128 / itemsPerPage) - 1;
|
||||||
#ifdef DEBUG_MCM
|
#ifdef MCM_DEBUG_FRAME
|
||||||
MemcardManagerDebug = NULL;
|
MemcardManagerDebug = NULL;
|
||||||
#endif
|
#endif
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
|
@ -134,7 +135,7 @@ CMemcardManager::~CMemcardManager()
|
||||||
delete memoryCard[SLOT_B];
|
delete memoryCard[SLOT_B];
|
||||||
memoryCard[SLOT_B] = NULL;
|
memoryCard[SLOT_B] = NULL;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_MCM
|
#ifdef MCM_DEBUG_FRAME
|
||||||
if (MemcardManagerDebug)
|
if (MemcardManagerDebug)
|
||||||
{
|
{
|
||||||
MemcardManagerDebug->Destroy();
|
MemcardManagerDebug->Destroy();
|
||||||
|
@ -553,7 +554,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||||
slot = SLOT_A;
|
slot = SLOT_A;
|
||||||
case ID_SAVEIMPORT_B:
|
case ID_SAVEIMPORT_B:
|
||||||
{
|
{
|
||||||
wxString temp = wxFileSelector(wxT("Select a save file to import"),
|
wxString fileName = wxFileSelector(wxT("Select a save file to import"),
|
||||||
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxString::FromAscii(""): wxString::FromAscii(DefaultIOPath.c_str()), wxEmptyString, wxEmptyString, wxString::Format
|
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0) ? wxString::FromAscii(""): wxString::FromAscii(DefaultIOPath.c_str()), wxEmptyString, wxEmptyString, wxString::Format
|
||||||
(
|
(
|
||||||
wxT("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|")
|
wxT("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|")
|
||||||
|
@ -564,8 +565,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||||
wxFileSelectorDefaultWildcardStr
|
wxFileSelectorDefaultWildcardStr
|
||||||
),
|
),
|
||||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
const char * fileName = temp.mb_str();
|
if (!fileName.empty() && !fileName2.empty())
|
||||||
if (!temp.empty() && !fileName2.empty())
|
|
||||||
{
|
{
|
||||||
wxString temp2 = wxFileSelector(wxT("Save GCI as.."),
|
wxString temp2 = wxFileSelector(wxT("Save GCI as.."),
|
||||||
wxEmptyString, wxEmptyString, wxT(".gci"), wxString::Format
|
wxEmptyString, wxEmptyString, wxT(".gci"), wxString::Format
|
||||||
|
@ -578,9 +578,9 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||||
if (temp2.empty()) break;
|
if (temp2.empty()) break;
|
||||||
fileName2 = temp2.mb_str();
|
fileName2 = temp2.mb_str();
|
||||||
}
|
}
|
||||||
if (temp.length() > 0)
|
if (fileName.length() > 0)
|
||||||
{
|
{
|
||||||
CopyDeleteSwitch(memoryCard[slot]->ImportGci(fileName, fileName2), slot);
|
CopyDeleteSwitch(memoryCard[slot]->ImportGci(fileName.mb_str(), fileName2), slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -648,13 +648,6 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||||
|
|
||||||
bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||||
{
|
{
|
||||||
wxString wxBlock;
|
|
||||||
wxString wxFirstBlock;
|
|
||||||
wxString wxLabel;
|
|
||||||
wxString tString;
|
|
||||||
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (memoryCard[card]) delete memoryCard[card];
|
if (memoryCard[card]) delete memoryCard[card];
|
||||||
|
|
||||||
// TODO: add error checking and animate icons
|
// TODO: add error checking and animate icons
|
||||||
|
@ -662,6 +655,17 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||||
|
|
||||||
if (memoryCard[card]->fail) return false;
|
if (memoryCard[card]->fail) return false;
|
||||||
|
|
||||||
|
int j;
|
||||||
|
bool ascii = memoryCard[card]->IsAsciiEncoding();
|
||||||
|
|
||||||
|
wxString wxTitle,
|
||||||
|
wxComment,
|
||||||
|
wxBlock,
|
||||||
|
wxFirstBlock,
|
||||||
|
wxLabel,
|
||||||
|
tString;
|
||||||
|
|
||||||
|
|
||||||
m_MemcardList[card]->Hide();
|
m_MemcardList[card]->Hide();
|
||||||
m_MemcardList[card]->ClearAll();
|
m_MemcardList[card]->ClearAll();
|
||||||
|
|
||||||
|
@ -751,10 +755,23 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||||
int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);
|
int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);
|
||||||
|
|
||||||
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
|
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
|
||||||
|
|
||||||
if (!memoryCard[card]->DEntry_Comment1(j, title)) title[0]=0;
|
if (!memoryCard[card]->DEntry_Comment1(j, title)) title[0]=0;
|
||||||
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title));
|
|
||||||
if (!memoryCard[card]->DEntry_Comment2(j, comment)) comment[0]=0;
|
if (!memoryCard[card]->DEntry_Comment2(j, comment)) comment[0]=0;
|
||||||
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxString::FromAscii(comment));
|
|
||||||
|
if (ascii)
|
||||||
|
{
|
||||||
|
wxTitle = wxString::FromAscii(title);
|
||||||
|
wxComment = wxString::FromAscii(comment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WxUtils::CopySJISToString(wxTitle, title);
|
||||||
|
WxUtils::CopySJISToString(wxComment, comment);
|
||||||
|
}
|
||||||
|
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxTitle);
|
||||||
|
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxComment);
|
||||||
|
|
||||||
blocks = memoryCard[card]->DEntry_BlockCount(j);
|
blocks = memoryCard[card]->DEntry_BlockCount(j);
|
||||||
if (blocks == 0xFFFF) blocks = 0;
|
if (blocks == 0xFFFF) blocks = 0;
|
||||||
wxBlock.Printf(wxT("%10d"), blocks);
|
wxBlock.Printf(wxT("%10d"), blocks);
|
||||||
|
@ -847,7 +864,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||||
t_Status[card]->SetLabel(wxLabel);
|
t_Status[card]->SetLabel(wxLabel);
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_MCM
|
#ifdef MCM_DEBUG_FRAME
|
||||||
if(MemcardManagerDebug == NULL)
|
if(MemcardManagerDebug == NULL)
|
||||||
{
|
{
|
||||||
MemcardManagerDebug = new CMemcardManagerDebug((wxFrame *)NULL, wxDefaultPosition, wxSize(950, 400));
|
MemcardManagerDebug = new CMemcardManagerDebug((wxFrame *)NULL, wxDefaultPosition, wxSize(950, 400));
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#undef CONFIG_FILE
|
#undef CONFIG_FILE
|
||||||
#define CONFIG_FILE "./MemcardManager.ini"
|
#define CONFIG_FILE "./MemcardManager.ini"
|
||||||
#define DEBUG_MCM
|
#define DEBUG_MCM
|
||||||
|
#define MCM_DEBUG_FRAME
|
||||||
#include "MCMdebug.h"
|
#include "MCMdebug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ class CMemcardManager
|
||||||
std::string DefaultMemcard[2],
|
std::string DefaultMemcard[2],
|
||||||
DefaultIOPath;
|
DefaultIOPath;
|
||||||
IniFile MemcardManagerIni;
|
IniFile MemcardManagerIni;
|
||||||
#ifdef DEBUG_MCM
|
#ifdef MCM_DEBUG_FRAME
|
||||||
CMemcardManagerDebug * MemcardManagerDebug;
|
CMemcardManagerDebug * MemcardManagerDebug;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ GCMemcard::GCMemcard(const char *filename)
|
||||||
fail = false;
|
fail = false;
|
||||||
if (!mcd)
|
if (!mcd)
|
||||||
{
|
{
|
||||||
if (!PanicYesNo("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename))
|
if (!AskYesNo("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename))
|
||||||
{
|
{
|
||||||
fail = true;
|
fail = true;
|
||||||
return;
|
return;
|
||||||
|
@ -83,7 +83,7 @@ GCMemcard::GCMemcard(const char *filename)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mcdFile = mcd;
|
mcdFile = mcd;
|
||||||
Format();
|
Format(!AskYesNo("Format as ascii (NTSC\\PAL)?\nChoose no for sjis (NTSC-J)", filename));
|
||||||
fclose(mcd);
|
fclose(mcd);
|
||||||
mcd = fopen(filename, "r+b");
|
mcd = fopen(filename, "r+b");
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,11 @@ bool GCMemcard::IsOpen()
|
||||||
return (mcdFile!=NULL);
|
return (mcdFile!=NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GCMemcard::IsAsciiEncoding()
|
||||||
|
{
|
||||||
|
return hdr.Encoding[1] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool GCMemcard::Save()
|
bool GCMemcard::Save()
|
||||||
{
|
{
|
||||||
bool completeWrite = true;
|
bool completeWrite = true;
|
||||||
|
@ -769,17 +774,17 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u8 index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GCMemcard::ImportGci(const char *fileName, std::string fileName2)
|
u32 GCMemcard::ImportGci(const char *inputFile, std::string outputFile)
|
||||||
{
|
{
|
||||||
if (fileName2.empty() && !mcdFile) return OPENFAIL;
|
if (outputFile.empty() && !mcdFile) return OPENFAIL;
|
||||||
|
|
||||||
FILE *gci = fopen(fileName, "rb");
|
FILE *gci = fopen(inputFile, "rb");
|
||||||
if (!gci) return OPENFAIL;
|
if (!gci) return OPENFAIL;
|
||||||
|
|
||||||
int offset;
|
int offset;
|
||||||
char * tmp = new char[0xD];
|
char * tmp = new char[0xD];
|
||||||
std::string fileType;
|
std::string fileType;
|
||||||
SplitPath(fileName, NULL, NULL, &fileType);
|
SplitPath(inputFile, NULL, NULL, &fileType);
|
||||||
|
|
||||||
if( !strcasecmp(fileType.c_str(), ".gci"))
|
if( !strcasecmp(fileType.c_str(), ".gci"))
|
||||||
offset = GCI;
|
offset = GCI;
|
||||||
|
@ -837,9 +842,9 @@ u32 GCMemcard::ImportGci(const char *fileName, std::string fileName2)
|
||||||
fread(tempSaveData, 1, size, gci);
|
fread(tempSaveData, 1, size, gci);
|
||||||
fclose(gci);
|
fclose(gci);
|
||||||
u32 ret;
|
u32 ret;
|
||||||
if(!fileName2.empty())
|
if(!outputFile.empty())
|
||||||
{
|
{
|
||||||
FILE * gci2 = fopen(fileName2.c_str(), "wb");
|
FILE * gci2 = fopen(outputFile.c_str(), "wb");
|
||||||
bool completeWrite = true;
|
bool completeWrite = true;
|
||||||
if (!gci2) return OPENFAIL;
|
if (!gci2) return OPENFAIL;
|
||||||
fseek(gci2, 0, SEEK_SET);
|
fseek(gci2, 0, SEEK_SET);
|
||||||
|
@ -1132,7 +1137,7 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays)
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCMemcard::Format(bool New, int slot, u16 SizeMb, bool sjis, bool hdrOnly)
|
bool GCMemcard::Format(bool sjis, bool New, int slot, u16 SizeMb, bool hdrOnly)
|
||||||
{
|
{
|
||||||
//Currently only formats cards for slot A
|
//Currently only formats cards for slot A
|
||||||
u32 data_size = BLOCK_SIZE * (SizeMb * MBIT_TO_BLOCKS - MC_FST_BLOCKS);
|
u32 data_size = BLOCK_SIZE * (SizeMb * MBIT_TO_BLOCKS - MC_FST_BLOCKS);
|
||||||
|
|
|
@ -174,8 +174,9 @@ public:
|
||||||
~GCMemcard();
|
~GCMemcard();
|
||||||
|
|
||||||
bool IsOpen();
|
bool IsOpen();
|
||||||
|
bool IsAsciiEncoding();
|
||||||
bool Save();
|
bool Save();
|
||||||
bool Format(bool New = true, int slot = 0, u16 SizeMb = MemCard2043Mb, bool sjis = false, bool hdrOnly = false);
|
bool Format(bool sjis = false, bool New = true, int slot = 0, u16 SizeMb = MemCard2043Mb, bool hdrOnly = false);
|
||||||
|
|
||||||
void calc_checksumsBE(u16 *buf, u32 num, u16 *c1, u16 *c2);
|
void calc_checksumsBE(u16 *buf, u32 num, u16 *c1, u16 *c2);
|
||||||
u32 TestChecksums();
|
u32 TestChecksums();
|
||||||
|
@ -238,7 +239,7 @@ public:
|
||||||
u32 CopyFrom(GCMemcard& source, u8 index);
|
u32 CopyFrom(GCMemcard& source, u8 index);
|
||||||
|
|
||||||
// reads a .gci/.gcs/.sav file and calls ImportFile or saves out a gci file
|
// reads a .gci/.gcs/.sav file and calls ImportFile or saves out a gci file
|
||||||
u32 ImportGci(const char* fileName, std::string fileName2);
|
u32 ImportGci(const char* inputFile, std::string outputFile);
|
||||||
|
|
||||||
// writes a .gci file to disk containing index
|
// writes a .gci file to disk containing index
|
||||||
u32 ExportGci(u8 index, const char* fileName, std::string* fileName2);
|
u32 ExportGci(u8 index, const char* fileName, std::string* fileName2);
|
||||||
|
|
|
@ -45,4 +45,58 @@ void Explore(const char *path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CopySJISToString(wxString& _rDestination, const char* _src)
|
||||||
|
{
|
||||||
|
bool returnCode = false;
|
||||||
|
#ifdef WIN32
|
||||||
|
// HyperIris: because dolphin using "Use Multi-Byte Character Set",
|
||||||
|
// we must convert the SJIS chars to unicode then to our windows local by hand
|
||||||
|
u32 unicodeNameSize = MultiByteToWideChar(932, MB_PRECOMPOSED,
|
||||||
|
_src, (int)strlen(_src), NULL, NULL);
|
||||||
|
if (unicodeNameSize > 0)
|
||||||
|
{
|
||||||
|
u16* pUnicodeStrBuffer = new u16[unicodeNameSize + 1];
|
||||||
|
if (pUnicodeStrBuffer)
|
||||||
|
{
|
||||||
|
memset(pUnicodeStrBuffer, 0, (unicodeNameSize + 1) * sizeof(u16));
|
||||||
|
if (MultiByteToWideChar(932, MB_PRECOMPOSED,
|
||||||
|
_src, (int)strlen(_src),
|
||||||
|
(LPWSTR)pUnicodeStrBuffer, unicodeNameSize))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
_rDestination = (LPWSTR)pUnicodeStrBuffer;
|
||||||
|
returnCode = true;
|
||||||
|
#else
|
||||||
|
u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0,
|
||||||
|
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
||||||
|
NULL, NULL, NULL, NULL);
|
||||||
|
if (ansiNameSize > 0)
|
||||||
|
{
|
||||||
|
char* pAnsiStrBuffer = new char[ansiNameSize + 1];
|
||||||
|
if (pAnsiStrBuffer)
|
||||||
|
{
|
||||||
|
memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char));
|
||||||
|
if (WideCharToMultiByte(CP_ACP, 0,
|
||||||
|
(LPCWSTR)pUnicodeStrBuffer, unicodeNameSize,
|
||||||
|
pAnsiStrBuffer, ansiNameSize, NULL, NULL))
|
||||||
|
{
|
||||||
|
_rDestination = pAnsiStrBuffer;
|
||||||
|
returnCode = true;
|
||||||
|
}
|
||||||
|
delete pAnsiStrBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
delete pUnicodeStrBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
_rDestination = wxString(wxString(_src,wxConvLibc),wxConvUTF8);
|
||||||
|
returnCode = true;
|
||||||
|
#endif
|
||||||
|
return returnCode;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -26,6 +26,7 @@ void Launch(const char *filename);
|
||||||
// Launch an file explorer window on a certain path
|
// Launch an file explorer window on a certain path
|
||||||
void Explore(const char *path);
|
void Explore(const char *path);
|
||||||
|
|
||||||
|
bool CopySJISToString(wxString& _rDestination, const char* _src);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // WXUTILS
|
#endif // WXUTILS
|
||||||
|
|
Loading…
Reference in New Issue