mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
System: Add option to use a single memory card for playlists
This commit is contained in:
parent
dedeee1698
commit
d9893bb127
|
@ -410,6 +410,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
|||
si.SetStringValue("MemoryCards", "Card1Path", "memcards/shared_card_1.mcd");
|
||||
si.SetStringValue("MemoryCards", "Card2Type", Settings::GetMemoryCardTypeName(Settings::DEFAULT_MEMORY_CARD_2_TYPE));
|
||||
si.SetStringValue("MemoryCards", "Card2Path", "memcards/shared_card_2.mcd");
|
||||
si.SetBoolValue("MemoryCards", "UsePlaylistTitle", true);
|
||||
|
||||
si.SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(Settings::DEFAULT_LOG_LEVEL));
|
||||
si.SetStringValue("Logging", "LogFilter", "");
|
||||
|
@ -519,7 +520,9 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
|
|||
g_cdrom.SetUseReadThread(g_settings.cdrom_read_thread);
|
||||
|
||||
if (g_settings.memory_card_types != old_settings.memory_card_types ||
|
||||
g_settings.memory_card_paths != old_settings.memory_card_paths)
|
||||
g_settings.memory_card_paths != old_settings.memory_card_paths ||
|
||||
(g_settings.memory_card_use_playlist_title != old_settings.memory_card_use_playlist_title &&
|
||||
System::HasMediaPlaylist()))
|
||||
{
|
||||
System::UpdateMemoryCards();
|
||||
}
|
||||
|
|
|
@ -164,6 +164,7 @@ void Settings::Load(SettingsInterface& si)
|
|||
si.GetStringValue("MemoryCards", "Card2Type", GetMemoryCardTypeName(DEFAULT_MEMORY_CARD_2_TYPE)).c_str())
|
||||
.value_or(DEFAULT_MEMORY_CARD_2_TYPE);
|
||||
memory_card_paths[1] = si.GetStringValue("MemoryCards", "Card2Path", "memcards/shared_card_2.mcd");
|
||||
memory_card_use_playlist_title = si.GetBoolValue("MemoryCards", "UsePlaylistTitle", true);
|
||||
|
||||
log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str())
|
||||
.value_or(DEFAULT_LOG_LEVEL);
|
||||
|
@ -258,6 +259,7 @@ void Settings::Save(SettingsInterface& si) const
|
|||
si.SetStringValue("MemoryCards", "Card1Path", memory_card_paths[0].c_str());
|
||||
si.SetStringValue("MemoryCards", "Card2Type", GetMemoryCardTypeName(memory_card_types[1]));
|
||||
si.SetStringValue("MemoryCards", "Card2Path", memory_card_paths[1].c_str());
|
||||
si.SetBoolValue("MemoryCards", "UsePlaylistTitle", memory_card_use_playlist_title);
|
||||
|
||||
si.SetStringValue("Logging", "LogLevel", GetLogLevelName(log_level));
|
||||
si.SetStringValue("Logging", "LogFilter", log_filter.c_str());
|
||||
|
|
|
@ -143,6 +143,7 @@ struct Settings
|
|||
std::array<ControllerType, NUM_CONTROLLER_AND_CARD_PORTS> controller_types{};
|
||||
std::array<MemoryCardType, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_types{};
|
||||
std::array<std::string, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_paths{};
|
||||
bool memory_card_use_playlist_title = true;
|
||||
|
||||
LOGLEVEL log_level = LOGLEVEL_INFO;
|
||||
std::string log_filter;
|
||||
|
|
|
@ -1187,7 +1187,12 @@ void UpdateMemoryCards()
|
|||
|
||||
case MemoryCardType::PerGameTitle:
|
||||
{
|
||||
if (s_running_game_title.empty())
|
||||
if (!s_media_playlist_filename.empty() && g_settings.memory_card_use_playlist_title)
|
||||
{
|
||||
const std::string playlist_title(GameList::GetTitleForPath(s_media_playlist_filename.c_str()));
|
||||
card = MemoryCard::Open(g_host_interface->GetGameMemoryCardPath(playlist_title.c_str(), i));
|
||||
}
|
||||
else if (s_running_game_title.empty())
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(5.0f,
|
||||
"Per-game memory card cannot be used for slot %u as the running "
|
||||
|
@ -1268,6 +1273,11 @@ void UpdateRunningGame(const char* path, CDImage* image)
|
|||
g_host_interface->OnRunningGameChanged();
|
||||
}
|
||||
|
||||
bool HasMediaPlaylist()
|
||||
{
|
||||
return !s_media_playlist_filename.empty();
|
||||
}
|
||||
|
||||
u32 GetMediaPlaylistCount()
|
||||
{
|
||||
return static_cast<u32>(s_media_playlist.size());
|
||||
|
|
|
@ -108,6 +108,9 @@ bool HasMedia();
|
|||
bool InsertMedia(const char* path);
|
||||
void RemoveMedia();
|
||||
|
||||
/// Returns true if a playlist is being used.
|
||||
bool HasMediaPlaylist();
|
||||
|
||||
/// Returns the number of entries in the media/disc playlist.
|
||||
u32 GetMediaPlaylistCount();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "inputbindingwidgets.h"
|
||||
#include "qthostinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "settingwidgetbinder.h"
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
|
@ -12,39 +13,53 @@
|
|||
|
||||
static constexpr char MEMORY_CARD_IMAGE_FILTER[] = "All Memory Card Types (*.mcd *.mcr *.mc)";
|
||||
|
||||
MemoryCardSettingsWidget::MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
|
||||
MemoryCardSettingsWidget::MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
|
||||
SettingsDialog* dialog)
|
||||
: QWidget(parent), m_host_interface(host_interface)
|
||||
{
|
||||
createUi();
|
||||
createUi(dialog);
|
||||
}
|
||||
|
||||
MemoryCardSettingsWidget::~MemoryCardSettingsWidget() = default;
|
||||
|
||||
void MemoryCardSettingsWidget::createUi()
|
||||
void MemoryCardSettingsWidget::createUi(SettingsDialog* dialog)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(m_port_ui.size()); i++)
|
||||
{
|
||||
createPortSettingsUi(i, &m_port_ui[i]);
|
||||
createPortSettingsUi(dialog, i, &m_port_ui[i]);
|
||||
layout->addWidget(m_port_ui[i].container);
|
||||
}
|
||||
|
||||
{
|
||||
QGroupBox* note_box = new QGroupBox(this);
|
||||
QHBoxLayout* note_layout = new QHBoxLayout(note_box);
|
||||
QGroupBox* box = new QGroupBox(tr("Shared Settings"), this);
|
||||
QVBoxLayout* box_layout = new QVBoxLayout(box);
|
||||
|
||||
QCheckBox* playlist_title_as_game_title = new QCheckBox(tr("Use Single Card For Playlist"), box);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, playlist_title_as_game_title, "MemoryCards",
|
||||
"UsePlaylistTitle", true);
|
||||
box_layout->addWidget(playlist_title_as_game_title);
|
||||
dialog->registerWidgetHelp(
|
||||
playlist_title_as_game_title, tr("Use Single Card For Playlist"), tr("Checked"),
|
||||
tr("When using a playlist (m3u) and per-game (title) memory cards, a single memory card "
|
||||
"will be used for all discs. If unchecked, a separate card will be used for each disc."));
|
||||
|
||||
QHBoxLayout* note_layout = new QHBoxLayout();
|
||||
QLabel* note_label =
|
||||
new QLabel(tr("If one of the \"separate card per game\" memory card modes is chosen, these memory "
|
||||
"cards will be saved to the memcards directory."),
|
||||
note_box);
|
||||
box);
|
||||
note_label->setWordWrap(true);
|
||||
note_layout->addWidget(note_label, 1);
|
||||
|
||||
QPushButton* open_memcards = new QPushButton(tr("Open..."), note_box);
|
||||
QPushButton* open_memcards = new QPushButton(tr("Open..."), box);
|
||||
connect(open_memcards, &QPushButton::clicked, this, &MemoryCardSettingsWidget::onOpenMemCardsDirectoryClicked);
|
||||
note_layout->addWidget(open_memcards);
|
||||
layout->addWidget(note_box);
|
||||
box_layout->addLayout(note_layout);
|
||||
|
||||
layout->addWidget(box);
|
||||
}
|
||||
|
||||
layout->addStretch(1);
|
||||
|
@ -52,7 +67,7 @@ void MemoryCardSettingsWidget::createUi()
|
|||
setLayout(layout);
|
||||
}
|
||||
|
||||
void MemoryCardSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui)
|
||||
void MemoryCardSettingsWidget::createPortSettingsUi(SettingsDialog* dialog, int index, PortSettingsUI* ui)
|
||||
{
|
||||
ui->container = new QGroupBox(tr("Memory Card %1").arg(index + 1), this);
|
||||
ui->layout = new QVBoxLayout(ui->container);
|
||||
|
|
|
@ -9,13 +9,14 @@
|
|||
#include <vector>
|
||||
|
||||
class QtHostInterface;
|
||||
class SettingsDialog;
|
||||
|
||||
class MemoryCardSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
|
||||
MemoryCardSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog);
|
||||
~MemoryCardSettingsWidget();
|
||||
|
||||
private:
|
||||
|
@ -29,8 +30,8 @@ private:
|
|||
QLineEdit* memory_card_path;
|
||||
};
|
||||
|
||||
void createUi();
|
||||
void createPortSettingsUi(int index, PortSettingsUI* ui);
|
||||
void createUi(SettingsDialog* dialog);
|
||||
void createPortSettingsUi(SettingsDialog* dialog, int index, PortSettingsUI* ui);
|
||||
void onBrowseMemoryCardPathClicked(int index);
|
||||
void onOpenMemCardsDirectoryClicked();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
|
|||
m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
|
||||
m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);
|
||||
m_controller_settings = new ControllerSettingsWidget(host_interface, m_ui.settingsContainer);
|
||||
m_memory_card_settings = new MemoryCardSettingsWidget(host_interface, m_ui.settingsContainer);
|
||||
m_memory_card_settings = new MemoryCardSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
||||
m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
||||
m_audio_settings = new AudioSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
||||
m_advanced_settings = new AdvancedSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
||||
|
|
Loading…
Reference in a new issue