Qt: Disable global save states by default

Add an opt-in to re-enable them.
pull/3755/head
Stenzek 3 weeks ago
parent 97ae01391f
commit 9d0eec7725
No known key found for this signature in database

@ -964,6 +964,7 @@ struct State
llvm::SmallVector<ListEntry, System::PER_GAME_SAVE_STATE_SLOTS + System::GLOBAL_SAVE_STATE_SLOTS> slots;
s32 current_slot = 0;
bool current_slot_global = false;
bool global_slots_enabled = false;
float open_time = 0.0f;
float close_time = 0.0f;
@ -997,8 +998,16 @@ void SaveStateSelectorUI::Open(float open_time /* = DEFAULT_OPEN_TIME */)
s_state.placeholder_texture = FullscreenUI::LoadTexture("no-save.png");
s_state.is_open = true;
s_state.global_slots_enabled = System::AreGlobalSaveStatesEnabled();
RefreshList();
RefreshHotkeyLegend();
if (s_state.slots.empty())
{
FullscreenUI::ShowToast(OSDMessageType::Info, {},
TRANSLATE_STR("SaveStateSelectorUI", "No save state slots available."));
Close();
}
}
void SaveStateSelectorUI::Close()
@ -1038,30 +1047,31 @@ void SaveStateSelectorUI::RefreshList()
s_state.slots.push_back(std::move(li));
}
}
else
if (s_state.global_slots_enabled)
{
// reset slot if it's not global
if (!s_state.current_slot_global)
if (serial.empty() && !s_state.current_slot_global)
{
s_state.current_slot = 0;
s_state.current_slot_global = true;
}
}
for (s32 i = 1; i <= System::GLOBAL_SAVE_STATE_SLOTS; i++)
{
Error error;
bool exists;
std::string path = System::GetGlobalSaveStatePath(i);
std::optional<ExtendedSaveStateInfo> ssi = System::GetExtendedSaveStateInfo(path.c_str(), &error, &exists);
ListEntry li;
if (ssi)
InitializeListEntry(&li, &ssi.value(), std::move(path), i, true);
else
InitializePlaceholderListEntry(&li, std::move(path), i, true, exists, std::move(error));
for (s32 i = 1; i <= System::GLOBAL_SAVE_STATE_SLOTS; i++)
{
Error error;
bool exists;
std::string path = System::GetGlobalSaveStatePath(i);
std::optional<ExtendedSaveStateInfo> ssi = System::GetExtendedSaveStateInfo(path.c_str(), &error, &exists);
ListEntry li;
if (ssi)
InitializeListEntry(&li, &ssi.value(), std::move(path), i, true);
else
InitializePlaceholderListEntry(&li, std::move(path), i, true, exists, std::move(error));
s_state.slots.push_back(std::move(li));
s_state.slots.push_back(std::move(li));
}
}
}
@ -1125,7 +1135,7 @@ void SaveStateSelectorUI::SelectNextSlot(bool open_selector)
s_state.current_slot++;
if (s_state.current_slot >= total_slots)
{
if (!VideoThread::GetGameSerial().empty())
if (s_state.global_slots_enabled && !VideoThread::GetGameSerial().empty())
s_state.current_slot_global ^= true;
s_state.current_slot -= total_slots;
}
@ -1134,8 +1144,8 @@ void SaveStateSelectorUI::SelectNextSlot(bool open_selector)
{
if (!s_state.is_open)
Open();
s_state.open_time = 0.0f;
else
s_state.open_time = 0.0f; // stay open for the full duration
}
else
{
@ -1148,7 +1158,7 @@ void SaveStateSelectorUI::SelectPreviousSlot(bool open_selector)
s_state.current_slot--;
if (s_state.current_slot < 0)
{
if (!VideoThread::GetGameSerial().empty())
if (s_state.global_slots_enabled && !VideoThread::GetGameSerial().empty())
s_state.current_slot_global ^= true;
s_state.current_slot +=
s_state.current_slot_global ? System::GLOBAL_SAVE_STATE_SLOTS : System::PER_GAME_SAVE_STATE_SLOTS;
@ -1158,8 +1168,8 @@ void SaveStateSelectorUI::SelectPreviousSlot(bool open_selector)
{
if (!s_state.is_open)
Open();
s_state.open_time = 0.0f;
else
s_state.open_time = 0.0f; // stay open for the full duration
}
else
{

@ -3310,6 +3310,11 @@ bool System::SaveStateDataToBuffer(std::span<u8> data, size_t* data_size, Error*
return true;
}
bool System::AreGlobalSaveStatesEnabled()
{
return Core::GetBaseBoolSettingValue("Main", "EnableGlobalStates", false);
}
bool System::SaveStateBufferToFile(const SaveStateBuffer& buffer, std::FILE* fp, Error* error,
SaveStateCompressionMode compression)
{

@ -298,6 +298,9 @@ void SaveStateToSlot(bool global, s32 slot);
/// State data access, use with care as the media path is not updated.
bool SaveStateDataToBuffer(std::span<u8> data, size_t* data_size, Error* error);
/// Returns true if global states should be include in the slot list.
bool AreGlobalSaveStatesEnabled();
/// Runs the VM until the CPU execution is canceled.
void Execute();

@ -983,19 +983,23 @@ void MainWindow::populateLoadStateMenu(std::string_view game_serial, QMenu* menu
tr("Undo Load State"));
load_from_state->setEnabled(s_locals.undo_state_timestamp.has_value());
connect(load_from_state, &QAction::triggered, g_core_thread, &CoreThread::undoLoadState);
menu->addSeparator();
if (!game_serial.empty())
{
menu->addSeparator();
for (u32 slot = 1; slot <= System::PER_GAME_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Game Save %1 (%2)"), tr("Game Save %1 (Empty)"), game_serial, static_cast<s32>(slot));
}
if (System::AreGlobalSaveStatesEnabled())
{
menu->addSeparator();
}
std::string_view empty_serial;
for (u32 slot = 1; slot <= System::GLOBAL_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
std::string_view empty_serial;
for (u32 slot = 1; slot <= System::GLOBAL_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
}
}
void MainWindow::populateSaveStateMenu(std::string_view game_serial, QMenu* menu)
@ -1026,19 +1030,23 @@ void MainWindow::populateSaveStateMenu(std::string_view game_serial, QMenu* menu
g_core_thread->saveState(QDir::toNativeSeparators(path));
});
menu->addSeparator();
if (!game_serial.empty())
{
menu->addSeparator();
for (u32 slot = 1; slot <= System::PER_GAME_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Game Save %1 (%2)"), tr("Game Save %1 (Empty)"), game_serial, static_cast<s32>(slot));
}
if (System::AreGlobalSaveStatesEnabled())
{
menu->addSeparator();
}
std::string_view empty_serial;
for (u32 slot = 1; slot <= System::GLOBAL_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
std::string_view empty_serial;
for (u32 slot = 1; slot <= System::GLOBAL_SAVE_STATE_SLOTS; slot++)
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
}
}
void MainWindow::onCheatsMenuAboutToShow()

@ -119,19 +119,30 @@ void MemoryCardSettingsWidget::createUi(SettingsWindow* dialog)
{
QGroupBox* const box = new QGroupBox(tr("Game-Specific Card Settings"), this);
QVBoxLayout* const box_layout = new QVBoxLayout(box);
QGridLayout* const grid_layout = new QGridLayout(box);
layout->addWidget(box);
QCheckBox* playlist_title_as_game_title = new QCheckBox(tr("Use Single Card For Multi-Disc Games"), box);
SettingWidgetBinder::BindWidgetToBoolSetting(m_dialog->getSettingsInterface(), playlist_title_as_game_title,
"MemoryCards", "UsePlaylistTitle", true);
box_layout->addWidget(playlist_title_as_game_title);
grid_layout->addWidget(playlist_title_as_game_title, 0, 0);
dialog->registerWidgetHelp(
playlist_title_as_game_title, tr("Use Single Card For Multi-Disc Games"), tr("Checked"),
tr("When playing a multi-disc game and using 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."));
box_layout->addWidget(QtUtils::CreateHorizontalLine(box));
if (!dialog->isPerGameSettings())
{
QCheckBox* enable_global_states = new QCheckBox(tr("Enable Global Save States"), box);
SettingWidgetBinder::BindWidgetToBoolSetting(m_dialog->getSettingsInterface(), enable_global_states, "Main",
"EnableGlobalStates", false);
grid_layout->addWidget(enable_global_states, 0, 1);
dialog->registerWidgetHelp(enable_global_states, tr("Enable Global Save States"), tr("Unchecked"),
tr("When enabled, the legacy global save state slots will be available. These slots "
"are independent of the current game."));
}
grid_layout->addWidget(QtUtils::CreateHorizontalLine(box), 1, 0, 1, 2);
{
QHBoxLayout* const hbox = new QHBoxLayout();
@ -144,7 +155,7 @@ void MemoryCardSettingsWidget::createUi(SettingsWindow* dialog)
QPushButton* const button = new QPushButton(tr("Memory Card Editor..."), box);
connect(button, &QPushButton::clicked, []() { g_main_window->openMemoryCardEditor(QString(), QString()); });
hbox->addWidget(button);
box_layout->addLayout(hbox);
grid_layout->addLayout(hbox, 2, 0, 1, 2);
}
}

Loading…
Cancel
Save