PCSX2: Memory card minor code improvements

- Adds tooltip for Convert memory card button in the memory card dialog
- Updates several memory card console writes.
- Adds 2018 copyrights to the updated files
This commit is contained in:
FlatOutPS2 2018-01-14 20:53:07 +01:00 committed by Jonathan Li
parent c749f961ef
commit 24b83fd96c
3 changed files with 54 additions and 58 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team * Copyright (C) 2002-2018 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -196,9 +196,9 @@ namespace Dialogs
//wxFilePickerCtrl* m_filepicker; //wxFilePickerCtrl* m_filepicker;
pxRadioPanel *m_radio_CardType; pxRadioPanel *m_radio_CardType;
#ifdef __WXMSW__ #ifdef __WXMSW__
pxCheckBox* m_check_CompressNTFS; pxCheckBox *m_check_CompressNTFS;
#endif #endif
public: public:
virtual ~CreateMemoryCardDialog() = default; virtual ~CreateMemoryCardDialog() = default;

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team * Copyright (C) 2002-2018 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -80,11 +80,11 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, const
s_padding += s_filename | StdExpand(); s_padding += s_filename | StdExpand();
} }
#ifdef __WXMSW__
if( m_check_CompressNTFS )
s_padding += m_check_CompressNTFS | StdExpand();
#endif
s_padding += m_radio_CardType | StdExpand(); s_padding += m_radio_CardType | StdExpand();
#ifdef __WXMSW__
if (m_check_CompressNTFS)
s_padding += m_check_CompressNTFS | StdExpand();
#endif
s_padding += s_buttons | StdCenter(); s_padding += s_buttons | StdCenter();
@ -216,7 +216,7 @@ void Dialogs::CreateMemoryCardDialog::OnOk_Click( wxCommandEvent& evt )
void Dialogs::CreateMemoryCardDialog::CreateControls() void Dialogs::CreateMemoryCardDialog::CreateControls()
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
m_check_CompressNTFS = new pxCheckBox( this, m_check_CompressNTFS = new pxCheckBox( this,
_("Use NTFS compression when creating this card."), _("Use NTFS compression when creating this card."),
GetMsg_McdNtfsCompress() GetMsg_McdNtfsCompress()
@ -229,7 +229,7 @@ void Dialogs::CreateMemoryCardDialog::CreateControls()
// Initial value of the checkbox is saved between calls to the dialog box. If the user checks // Initial value of the checkbox is saved between calls to the dialog box. If the user checks
// the option, it remains checked for future dialog. If the user unchecks it, ditto. // the option, it remains checked for future dialog. If the user unchecks it, ditto.
m_check_CompressNTFS->SetValue( g_Conf->McdCompressNTFS ); m_check_CompressNTFS->SetValue( g_Conf->McdCompressNTFS );
#endif #endif
m_text_filenameInput = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); m_text_filenameInput = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
m_mcd_Extension = new wxStaticText(this, wxID_ANY, L".ps2"); m_mcd_Extension = new wxStaticText(this, wxID_ANY, L".ps2");

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team * Copyright (C) 2002-2018 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -71,9 +71,8 @@ bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const w
wxFileOffset length = mcdFile.Length(); wxFileOffset length = mcdFile.Length();
if( length < (1024*528) && length != 0x20000 ) if (length < (1024 * 528) && length != 0x20000) {
{ Console.Warning("... Memory card appears to be truncated. Ignoring.");
Console.Warning( "... MemoryCard appears to be truncated. Ignoring." );
return false; return false;
} }
@ -487,6 +486,8 @@ void Panels::MemoryCardListPanel_Simple::UpdateUI()
pxSetToolTip( m_button_Duplicate, dupTip ); pxSetToolTip( m_button_Duplicate, dupTip );
m_button_Convert->Enable( card.IsPresent && card.IsFormatted && !card.IsPSX ); m_button_Convert->Enable( card.IsPresent && card.IsFormatted && !card.IsPSX );
pxSetToolTip(m_button_Convert, _("Convert this memory card to or from a folder memory card. Creates a duplicate of the current memory card in the new type.\n\n"
"Note: Only available when a memory card is formatted. Not available for PSX memory cards."));
//m_button_Create->Enable( card.Slot>=0 || card.IsPresent); //m_button_Create->Enable( card.Slot>=0 || card.IsPresent);
m_button_Create->SetLabel( card.IsPresent ? _("Delete") : _("Create ...") ); m_button_Create->SetLabel( card.IsPresent ? _("Delete") : _("Create ...") );
@ -514,9 +515,8 @@ void Panels::MemoryCardListPanel_Simple::Apply()
_parent::Apply(); _parent::Apply();
int used=0; int used=0;
Console.WriteLn( L"Apply Memory cards:" ); Console.WriteLn(L"Apply memory cards:");
for( uint slot=0; slot<8; ++slot ) for(uint slot=0; slot<8; ++slot) {
{
g_Conf->Mcd[slot].Type = m_Cards[slot].Type; g_Conf->Mcd[slot].Type = m_Cards[slot].Type;
g_Conf->Mcd[slot].Enabled = m_Cards[slot].IsEnabled && m_Cards[slot].IsPresent; g_Conf->Mcd[slot].Enabled = m_Cards[slot].IsEnabled && m_Cards[slot].IsPresent;
if (m_Cards[slot].IsPresent) if (m_Cards[slot].IsPresent)
@ -524,14 +524,13 @@ void Panels::MemoryCardListPanel_Simple::Apply()
else else
g_Conf->Mcd[slot].Filename = L""; g_Conf->Mcd[slot].Filename = L"";
if( g_Conf->Mcd[slot].Enabled ) if (g_Conf->Mcd[slot].Enabled) {
{
used++; used++;
Console.WriteLn( L"slot[%d]='%s'", slot, WX_STR(g_Conf->Mcd[slot].Filename.GetFullName()) ); Console.WriteLn(L"slot[%d]='%s'", slot, WX_STR(g_Conf->Mcd[slot].Filename.GetFullName()));
} }
} }
if( !used ) if (!used)
Console.WriteLn( L"No active slots" ); Console.WriteLn(L"No active slots.");
SetForceMcdEjectTimeoutNow(); SetForceMcdEjectTimeoutNow();
@ -539,26 +538,22 @@ void Panels::MemoryCardListPanel_Simple::Apply()
void Panels::MemoryCardListPanel_Simple::AppStatusEvent_OnSettingsApplied() void Panels::MemoryCardListPanel_Simple::AppStatusEvent_OnSettingsApplied()
{ {
for( uint slot=0; slot<8; ++slot ) for (uint slot=0; slot<8; ++slot) {
{
m_Cards[slot].IsEnabled = g_Conf->Mcd[slot].Enabled; m_Cards[slot].IsEnabled = g_Conf->Mcd[slot].Enabled;
m_Cards[slot].Filename = g_Conf->Mcd[slot].Filename; m_Cards[slot].Filename = g_Conf->Mcd[slot].Filename;
//automatically create the enabled but non-existing file such that it can be managed (else will get created anyway on boot) // Automatically create the enabled but non-existing file such that it can be managed (else will get created anyway on boot)
wxString targetFile = (GetMcdPath() + m_Cards[slot].Filename.GetFullName()).GetFullPath(); wxString targetFile = (GetMcdPath() + m_Cards[slot].Filename.GetFullName()).GetFullPath();
if ( m_Cards[slot].IsEnabled && !( wxFileExists( targetFile ) || wxDirExists( targetFile ) ) ) if (m_Cards[slot].IsEnabled && !(wxFileExists(targetFile) || wxDirExists(targetFile))) {
{
wxString errMsg; wxString errMsg;
if (isValidNewFilename(m_Cards[slot].Filename.GetFullName(), GetMcdPath(), errMsg, 5)) if (isValidNewFilename(m_Cards[slot].Filename.GetFullName(), GetMcdPath(), errMsg, 5)) {
{ if (!Dialogs::CreateMemoryCardDialog::CreateIt(targetFile, 8, false)) {
if ( !Dialogs::CreateMemoryCardDialog::CreateIt(targetFile, 8, false) ) Console.Error(L"Automatic creation of memory card '%s' failed. Hope for the best...", WX_STR(targetFile));
Console.Error( L"Automatic createion of MCD '%s' failed. Hope for the best...", WX_STR(targetFile) ); } else {
else Console.WriteLn(L"Memory card created: '%s'.", WX_STR(targetFile));
Console.WriteLn( L"memcard created: '%s'.", WX_STR(targetFile) ); }
} } else {
else Console.Error(L"Memory card was enabled, but it had an invalid file name. Aborting automatic creation. Hope for the best... (%s)", WX_STR(errMsg));
{
Console.Error( L"memcard was enabled but had an invalid file name. Aborting automatic creation. Hope for the best... (%s)", WX_STR(errMsg) );
} }
} }
@ -621,36 +616,38 @@ void Panels::MemoryCardListPanel_Simple::DoRefresh()
// ===================================================================================================== // =====================================================================================================
void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card ) void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card )
{//card can also be the filesystem placeholder. On that case, the changes {
// made to it will be reverted on refresh, and we'll just have a new card at the folder. // card can also be the filesystem placeholder. On that case, the changes
if( card.IsPresent ){ // made to it will be reverted on refresh, and we'll just have a new card at the folder.
Console.WriteLn("Error: Aborted: create mcd invoked but but a file is already associated."); if (card.IsPresent) {
Console.WriteLn("Error: Aborted: create memory card invoked, but a file is already associated.");
return; return;
} }
Dialogs::CreateMemoryCardDialog dialog( this, m_FolderPicker->GetPath(), L"my memory card" ); Dialogs::CreateMemoryCardDialog dialog(this, m_FolderPicker->GetPath(), L"my memory card");
wxWindowID result = dialog.ShowModal(); wxWindowID result = dialog.ShowModal();
if (result != wxID_CANCEL) if (result != wxID_CANCEL) {
{
card.IsEnabled = true; card.IsEnabled = true;
card.Filename = dialog.result_createdMcdFilename; card.Filename = dialog.result_createdMcdFilename;
card.IsPresent = true; card.IsPresent = true;
if ( card.Slot >= 0) if (card.Slot >= 0) {
Console.WriteLn(L"setting new card to slot %u: '%s'", card.Slot, WX_STR(card.Filename.GetFullName())); Console.WriteLn(L"Setting new memory card to slot %u: '%s'", card.Slot, WX_STR(card.Filename.GetFullName()));
else } else {
Console.WriteLn(L"Created a new unassigned card file: '%s'", WX_STR(card.Filename.GetFullName()) ); Console.WriteLn(L"Created a new unassigned memory card file: '%s'", WX_STR(card.Filename.GetFullName()));
}
} else {
card.IsEnabled = false;
} }
else
card.IsEnabled=false;
Apply(); Apply();
RefreshSelections(); RefreshSelections();
} }
void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) { void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card )
if ( !card.IsPresent ) { {
Console.WriteLn( "Error: Aborted: Convert mcd invoked but but a file is not associated." ); if (!card.IsPresent) {
Console.WriteLn("Error: Aborted: Convert memory card invoked, but a file is not associated.");
return; return;
} }
@ -669,12 +666,11 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card ) void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
{ {
if( !card.IsPresent ){ if (!card.IsPresent) {
Console.WriteLn("Error: Aborted: delete mcd invoked but but a file is not associated."); Console.WriteLn("Error: Aborted: delete memory card invoked, but a file is not associated.");
return; return;
} }
bool result = true; bool result = true;
if( card.IsFormatted ) if( card.IsFormatted )
{ {
@ -790,7 +786,7 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card ) void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
{ {
if( !card.IsPresent ){ if( !card.IsPresent ){
Console.WriteLn("Error: Aborted: Rename mcd invoked but no file is associated."); Console.WriteLn("Error: Aborted: Rename memory card invoked, but no file is associated.");
return; return;
} }