Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firmware cache options and more confirmation dialogs #8078

Merged
merged 4 commits into from Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion rpcs3/Emu/System.cpp
Expand Up @@ -656,6 +656,11 @@ std::string Emulator::GetHdd1Dir()
return fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", GetEmuDir());
}

std::string Emulator::GetCacheDir()
{
return fs::get_cache_dir() + "cache/";
}

#ifdef _WIN32
std::string Emulator::GetExeDir()
{
Expand Down Expand Up @@ -1430,7 +1435,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool

ppu_load_exec(ppu_exec);

_main->cache = fs::get_cache_dir() + "cache/";
_main->cache = GetCacheDir();

if (!m_title_id.empty() && m_cat != "1P")
{
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/System.h
Expand Up @@ -182,6 +182,7 @@ class Emulator final
static std::string GetEmuDir();
static std::string GetHddDir();
static std::string GetHdd1Dir();
static std::string GetCacheDir();
static std::string GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id = "");

static std::string GetCustomConfigDir();
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3.vcxproj
Expand Up @@ -2265,6 +2265,7 @@
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
</CustomBuild>
<ClInclude Include="rpcs3qt\gui_save.h" />
<ClInclude Include="rpcs3qt\stylesheets.h" />
<CustomBuild Include="rpcs3qt\skylander_dialog.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/rpcs3.vcxproj.filters
Expand Up @@ -1137,6 +1137,9 @@
<ClInclude Include="rpcs3qt\config_adapter.h">
<Filter>Gui\settings</Filter>
</ClInclude>
<ClInclude Include="rpcs3qt\gui_save.h">
<Filter>Gui\settings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="debug\moc_predefs.h.cbt">
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/rpcs3qt/config_adapter.cpp
Expand Up @@ -63,4 +63,10 @@ namespace cfg_adapter
const cfg_location loc = settings_location[type];
return get_is_dynamic(loc);
}

std::string get_setting_name(emu_settings_type type)
{
const cfg_location loc = settings_location[type];
return loc[loc.size() - 1];
}
}
3 changes: 3 additions & 0 deletions rpcs3/rpcs3qt/config_adapter.h
Expand Up @@ -18,4 +18,7 @@ namespace cfg_adapter

/** Returns dynamic property for some particular setting.*/
bool get_is_dynamic(emu_settings_type type);

/** Returns the string for a given setting.*/
std::string get_setting_name(emu_settings_type type);
}
44 changes: 19 additions & 25 deletions rpcs3/rpcs3qt/emu_settings.cpp
Expand Up @@ -145,15 +145,15 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
{
if (!combobox)
{
cfg_log.fatal("EnhanceComboBox '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceComboBox '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

if (is_ranged)
{
if (sorted)
{
cfg_log.warning("EnhanceCombobox '%s': ignoring sorting request on ranged combo box", GetSettingName(type));
cfg_log.warning("EnhanceCombobox '%s': ignoring sorting request on ranged combo box", cfg_adapter::get_setting_name(type));
}

const QStringList range = GetSettingOptions(type);
Expand Down Expand Up @@ -207,7 +207,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
if (index == -1)
{
const std::string def = GetSettingDefault(type);
cfg_log.fatal("EnhanceComboBox '%s' tried to set an invalid value: %s. Setting to default: %s", GetSettingName(type), selected, def);
cfg_log.fatal("EnhanceComboBox '%s' tried to set an invalid value: %s. Setting to default: %s", cfg_adapter::get_setting_name(type), selected, def);
combobox->setCurrentIndex(combobox->findData(qstr(def)));
m_broken_types.insert(type);
}
Expand Down Expand Up @@ -235,7 +235,7 @@ void emu_settings::EnhanceCheckBox(QCheckBox* checkbox, emu_settings_type type)
{
if (!checkbox)
{
cfg_log.fatal("EnhanceCheckBox '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceCheckBox '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -244,7 +244,7 @@ void emu_settings::EnhanceCheckBox(QCheckBox* checkbox, emu_settings_type type)

if (def != "true" && def != "false")
{
cfg_log.fatal("EnhanceCheckBox '%s' was used with an invalid emu_settings_type", GetSettingName(type));
cfg_log.fatal("EnhanceCheckBox '%s' was used with an invalid emu_settings_type", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -257,7 +257,7 @@ void emu_settings::EnhanceCheckBox(QCheckBox* checkbox, emu_settings_type type)
}
else if (selected != "false")
{
cfg_log.fatal("EnhanceCheckBox '%s' tried to set an invalid value: %s. Setting to default: %s", GetSettingName(type), selected, def);
cfg_log.fatal("EnhanceCheckBox '%s' tried to set an invalid value: %s. Setting to default: %s", cfg_adapter::get_setting_name(type), selected, def);
checkbox->setChecked(def == "true");
m_broken_types.insert(type);
}
Expand All @@ -273,7 +273,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)
{
if (!slider)
{
cfg_log.fatal("EnhanceSlider '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceSlider '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -286,7 +286,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)

if (!ok_def || !ok_min || !ok_max)
{
cfg_log.fatal("EnhanceSlider '%s' was used with an invalid emu_settings_type", GetSettingName(type));
cfg_log.fatal("EnhanceSlider '%s' was used with an invalid emu_settings_type", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -295,7 +295,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)

if (!ok_sel || val < min || val > max)
{
cfg_log.fatal("EnhanceSlider '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", GetSettingName(type), val, def, min, max);
cfg_log.fatal("EnhanceSlider '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", cfg_adapter::get_setting_name(type), val, def, min, max);
val = def;
m_broken_types.insert(type);
}
Expand All @@ -313,7 +313,7 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con
{
if (!spinbox)
{
cfg_log.fatal("EnhanceSpinBox '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceSpinBox '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -326,7 +326,7 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con

if (!ok_def || !ok_min || !ok_max)
{
cfg_log.fatal("EnhanceSpinBox '%s' was used with an invalid type", GetSettingName(type));
cfg_log.fatal("EnhanceSpinBox '%s' was used with an invalid type", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -335,7 +335,7 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con

if (!ok_sel || val < min || val > max)
{
cfg_log.fatal("EnhanceSpinBox '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", GetSettingName(type), selected, def, min, max);
cfg_log.fatal("EnhanceSpinBox '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", cfg_adapter::get_setting_name(type), selected, def, min, max);
val = def;
m_broken_types.insert(type);
}
Expand All @@ -355,7 +355,7 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty
{
if (!spinbox)
{
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -368,7 +368,7 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty

if (!ok_def || !ok_min || !ok_max)
{
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid type", GetSettingName(type));
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid type", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -377,7 +377,7 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty

if (!ok_sel || val < min || val > max)
{
cfg_log.fatal("EnhanceDoubleSpinBox '%s' tried to set an invalid value: %f. Setting to default: %f. Allowed range: [%f, %f]", GetSettingName(type), val, def, min, max);
cfg_log.fatal("EnhanceDoubleSpinBox '%s' tried to set an invalid value: %f. Setting to default: %f. Allowed range: [%f, %f]", cfg_adapter::get_setting_name(type), val, def, min, max);
val = def;
m_broken_types.insert(type);
}
Expand All @@ -397,7 +397,7 @@ void emu_settings::EnhanceLineEdit(QLineEdit* edit, emu_settings_type type)
{
if (!edit)
{
cfg_log.fatal("EnhanceEdit '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceEdit '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -414,7 +414,7 @@ void emu_settings::EnhanceRadioButton(QButtonGroup* button_group, emu_settings_t
{
if (!button_group)
{
cfg_log.fatal("EnhanceRadioButton '%s' was used with an invalid object", GetSettingName(type));
cfg_log.fatal("EnhanceRadioButton '%s' was used with an invalid object", cfg_adapter::get_setting_name(type));
return;
}

Expand All @@ -423,7 +423,7 @@ void emu_settings::EnhanceRadioButton(QButtonGroup* button_group, emu_settings_t

if (button_group->buttons().count() < options.size())
{
cfg_log.fatal("EnhanceRadioButton '%s': wrong button count", GetSettingName(type));
cfg_log.fatal("EnhanceRadioButton '%s': wrong button count", cfg_adapter::get_setting_name(type));
return;
}

Expand Down Expand Up @@ -460,12 +460,6 @@ QStringList emu_settings::GetSettingOptions(emu_settings_type type) const
return cfg_adapter::get_options(const_cast<cfg_location&&>(settings_location[type]));
}

std::string emu_settings::GetSettingName(emu_settings_type type) const
{
const cfg_location loc = settings_location[type];
return loc[loc.size() - 1];
}

std::string emu_settings::GetSettingDefault(emu_settings_type type) const
{
return cfg_adapter::get_node(m_defaultSettings, settings_location[type]).Scalar();
Expand Down Expand Up @@ -499,7 +493,7 @@ void emu_settings::OpenCorrectionDialog(QWidget* parent)
const std::string def = GetSettingDefault(type);
const std::string old = GetSetting(type);
SetSetting(type, def);
cfg_log.success("The config entry '%s' was corrected from '%s' to '%s'", GetSettingName(type), old, def);
cfg_log.success("The config entry '%s' was corrected from '%s' to '%s'", cfg_adapter::get_setting_name(type), old, def);
}

m_broken_types.clear();
Expand Down
3 changes: 0 additions & 3 deletions rpcs3/rpcs3qt/emu_settings.h
Expand Up @@ -58,9 +58,6 @@ class emu_settings : public QObject
/** Returns the valid options for a given setting.*/
QStringList GetSettingOptions(emu_settings_type type) const;

/** Returns the string for a given setting.*/
std::string GetSettingName(emu_settings_type type) const;

/** Returns the default value of the setting type.*/
std::string GetSettingDefault(emu_settings_type type) const;

Expand Down
46 changes: 42 additions & 4 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -388,7 +388,7 @@ QString game_list_frame::GetLastPlayedBySerial(const QString& serial)

std::string game_list_frame::GetCacheDirBySerial(const std::string& serial)
{
return fs::get_cache_dir() + "cache/" + serial;
return Emu.GetCacheDir() + serial;
}

std::string game_list_frame::GetDataDirBySerial(const std::string& serial)
Expand Down Expand Up @@ -817,6 +817,36 @@ void game_list_frame::itemSelectionChangedSlot()
Q_EMIT NotifyGameSelection(game);
}

bool game_list_frame::GetBootConfirmation(const gui_save& gui_save_entry)
{
if (m_gui_settings && !Emu.IsStopped())
{
QString title = tr("Close Running Game?");
QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n");

if (gui_save_entry == gui::ib_confirm_boot)
{
message = tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n");
}
else if (gui_save_entry == gui::ib_confirm_exit)
{
title = tr("Exit RPCS3?");
message = tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n");
}

int result = QMessageBox::Yes;

m_gui_settings->ShowConfirmationBox(title, message, gui_save_entry, &result, this);

if (result != QMessageBox::Yes)
{
return false;
}
}

return true;
}

void game_list_frame::ShowContextMenu(const QPoint &pos)
{
QPoint global_pos;
Expand Down Expand Up @@ -1029,7 +1059,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
Emu.GetCallbacks().enable_pads(true);
}
});
connect(hide_serial, &QAction::triggered, [=, this](bool checked)
connect(hide_serial, &QAction::triggered, [serial, this](bool checked)
{
if (checked)
m_hidden_list.insert(serial);
Expand All @@ -1039,9 +1069,12 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
m_gui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.values()));
Refresh();
});
connect(create_ppu_cache, &QAction::triggered, [=, this]
connect(create_ppu_cache, &QAction::triggered, [gameinfo, this]
{
CreatePPUCache(gameinfo);
if (GetBootConfirmation())
{
CreatePPUCache(gameinfo);
}
});
connect(remove_game, &QAction::triggered, [=, this]
{
Expand Down Expand Up @@ -1398,6 +1431,11 @@ void game_list_frame::BatchCreatePPUCaches()
return;
}

if (!GetBootConfirmation())
{
return;
}

progress_dialog* pdlg = new progress_dialog(tr("PPU Cache Batch Creation"), tr("Creating all PPU caches"), tr("Cancel"), 0, total, true, this);
pdlg->setAutoClose(false);
pdlg->setAutoReset(false);
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/rpcs3qt/game_list_frame.h
Expand Up @@ -4,6 +4,7 @@

#include "custom_dock_widget.h"
#include "game_compatibility.h"
#include "gui_save.h"

#include <QMainWindow>
#include <QToolBar>
Expand Down Expand Up @@ -68,6 +69,8 @@ class game_list_frame : public custom_dock_widget

void SetShowHidden(bool show);

bool GetBootConfirmation(const gui_save& gui_save_entry = gui_save());

public Q_SLOTS:
void BatchCreatePPUCaches();
void BatchRemovePPUCaches();
Expand Down
30 changes: 30 additions & 0 deletions rpcs3/rpcs3qt/gui_save.h
@@ -0,0 +1,30 @@
#pragma once

#include <QString>
#include <QVariant>

struct gui_save
{
QString key;
QString name;
QVariant def;

gui_save()
{
key = "";
name = "";
def = QVariant();
}

gui_save(const QString& k, const QString& n, const QVariant& d)
{
key = k;
name = n;
def = d;
}

bool operator==(const gui_save& rhs) const noexcept
{
return key == rhs.key && name == rhs.name && def == rhs.def;
}
};