mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 17:02:40 +00:00
code cleanup
This commit is contained in:
parent
5a67a10883
commit
54c3494635
@ -274,6 +274,12 @@ void Emulator::Run(const std::filesystem::path& file) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO disable with config option
|
||||
if (!game_info.game_serial.empty()) {
|
||||
std::thread savethread(StartAutosave, game_info.game_serial);
|
||||
savethread.detach();
|
||||
}
|
||||
|
||||
linker->Execute();
|
||||
|
||||
window->InitTimers();
|
||||
@ -333,11 +339,6 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file, std::string
|
||||
linker->LoadModule(entry.path());
|
||||
}
|
||||
}
|
||||
|
||||
if (!game_serial.empty()) {
|
||||
std::thread savethread(StartAutosave, game_serial);
|
||||
savethread.detach();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_QT_GUI
|
||||
@ -410,19 +411,24 @@ void Emulator::UpdatePlayTime(const std::string& serial) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void StartAutosave(std::string game_serial) {
|
||||
void Emulator::StartAutosave(std::string game_serial) {
|
||||
|
||||
const int SaveInterval = 0; // TODO enable setting backup intervals
|
||||
|
||||
const auto backup_dir =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) / "1" / "BACKUPS";
|
||||
const auto save_dir =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) / "1" / game_serial;
|
||||
if (!std ::filesystem::exists(backup_dir)) {
|
||||
std::filesystem::create_directory(backup_dir);
|
||||
}
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::minutes(5));
|
||||
const auto backup_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) /
|
||||
"savedata" / "1" / game_serial / "BACKUPSAVES";
|
||||
const auto save_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "savedata" /
|
||||
"1" / game_serial / "SPRJ0005";
|
||||
std::this_thread::sleep_for(std::chrono::minutes(1));
|
||||
try {
|
||||
std::filesystem::copy(save_dir, backup_dir,
|
||||
std::filesystem::copy(save_dir, backup_dir / game_serial,
|
||||
std::filesystem::copy_options::overwrite_existing |
|
||||
std::filesystem::copy_options::recursive);
|
||||
LOG_INFO(Config, "Backup saves created");
|
||||
LOG_INFO(Frontend, "Backup saves created");
|
||||
} catch (std::exception& ex) {
|
||||
fmt::print("Error creating backup saves. Exception: {}\n", ex.what());
|
||||
}
|
||||
|
@ -12,9 +12,6 @@
|
||||
#include "sdl_window.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
void StartAutosave(std::string game_serial);
|
||||
|
||||
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
|
||||
|
||||
struct SysModules {
|
||||
@ -23,10 +20,12 @@ struct SysModules {
|
||||
};
|
||||
|
||||
class Emulator {
|
||||
|
||||
public:
|
||||
Emulator();
|
||||
~Emulator();
|
||||
|
||||
int user_id{};
|
||||
void Run(const std::filesystem::path& file);
|
||||
void UpdatePlayTime(const std::string& serial);
|
||||
|
||||
@ -37,6 +36,7 @@ private:
|
||||
Core::Linker* linker;
|
||||
std::unique_ptr<Frontend::WindowSDL> window;
|
||||
std::chrono::steady_clock::time_point start_time;
|
||||
static void StartAutosave(std::string game_serial);
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@ -67,8 +67,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>822</width>
|
||||
<height>487</height>
|
||||
<width>1028</width>
|
||||
<height>649</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
|
||||
@ -189,6 +189,38 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="BackupSaveGroupBox">
|
||||
<property name="title">
|
||||
<string>Backup Saving</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="BackupCheckBox">
|
||||
<property name="text">
|
||||
<string>Create backup saves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="BackupFreqLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Backup Frequency (in minutes)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="BackupFreqComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -228,13 +260,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ps4proCheckBox">
|
||||
<property name="text">
|
||||
<string>Is PS4 Pro</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="discordRPCCheckbox">
|
||||
<property name="text">
|
||||
@ -301,7 +326,7 @@
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="updaterTabLayoutLeft">
|
||||
<property name="spacing">
|
||||
<number>-1</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
@ -685,8 +710,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>396</width>
|
||||
<height>222</height>
|
||||
<width>922</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
|
||||
@ -976,8 +1001,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>536</width>
|
||||
<height>192</height>
|
||||
<width>922</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
|
||||
@ -1227,8 +1252,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>146</width>
|
||||
<height>215</height>
|
||||
<width>922</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="pathsTabLayout" stretch="0">
|
||||
@ -1293,8 +1318,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>288</width>
|
||||
<height>163</height>
|
||||
<width>922</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,1">
|
||||
|
Loading…
Reference in New Issue
Block a user