GUI: Only add extension to new memcards on save

This commit is contained in:
refractionpcsx2 2022-06-21 19:20:18 +01:00
parent 298e626b6e
commit 9a323a9a8d
1 changed files with 18 additions and 10 deletions

View File

@ -60,20 +60,16 @@ CreateMemoryCardDialog::~CreateMemoryCardDialog() = default;
void CreateMemoryCardDialog::nameTextChanged()
{
const QString controlName(m_ui.name->text());
QString controlName(m_ui.name->text());
const int cursorPos = m_ui.name->cursorPosition();
QString nameWithoutExtension;
if (controlName.endsWith(QStringLiteral(".ps2")))
nameWithoutExtension = controlName.left(controlName.size() - 4);
else
nameWithoutExtension = controlName;
controlName.replace(".", "");
QSignalBlocker sb(m_ui.name);
if (nameWithoutExtension.isEmpty())
if (controlName.isEmpty())
m_ui.name->setText(QString());
else
m_ui.name->setText(nameWithoutExtension + QStringLiteral(".ps2"));
m_ui.name->setText(controlName);
m_ui.name->setCursorPosition(cursorPos);
updateState();
@ -109,8 +105,20 @@ void CreateMemoryCardDialog::updateState()
void CreateMemoryCardDialog::createCard()
{
const QString name(m_ui.name->text());
const std::string nameStr(name.toStdString());
QString name(m_ui.name->text());
std::string nameStr;
if (m_fileType == MemoryCardFileType::PS1)
{
name += QStringLiteral(".mcr");
}
else
{
name += QStringLiteral(".ps2");
}
nameStr = name.toStdString();
if (FileMcd_GetCardInfo(nameStr).has_value())
{
QMessageBox::critical(this, tr("Create Memory Card"),