mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-06 17:32: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
|
#endif
|
||||||
|
|
||||||
|
// TODO disable with config option
|
||||||
|
if (!game_info.game_serial.empty()) {
|
||||||
|
std::thread savethread(StartAutosave, game_info.game_serial);
|
||||||
|
savethread.detach();
|
||||||
|
}
|
||||||
|
|
||||||
linker->Execute();
|
linker->Execute();
|
||||||
|
|
||||||
window->InitTimers();
|
window->InitTimers();
|
||||||
@ -333,11 +339,6 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file, std::string
|
|||||||
linker->LoadModule(entry.path());
|
linker->LoadModule(entry.path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!game_serial.empty()) {
|
|
||||||
std::thread savethread(StartAutosave, game_serial);
|
|
||||||
savethread.detach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_QT_GUI
|
#ifdef ENABLE_QT_GUI
|
||||||
@ -410,19 +411,24 @@ void Emulator::UpdatePlayTime(const std::string& serial) {
|
|||||||
}
|
}
|
||||||
#endif
|
#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) {
|
while (true) {
|
||||||
std::this_thread::sleep_for(std::chrono::minutes(5));
|
std::this_thread::sleep_for(std::chrono::minutes(1));
|
||||||
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";
|
|
||||||
try {
|
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::overwrite_existing |
|
||||||
std::filesystem::copy_options::recursive);
|
std::filesystem::copy_options::recursive);
|
||||||
LOG_INFO(Config, "Backup saves created");
|
LOG_INFO(Frontend, "Backup saves created");
|
||||||
} catch (std::exception& ex) {
|
} catch (std::exception& ex) {
|
||||||
fmt::print("Error creating backup saves. Exception: {}\n", ex.what());
|
fmt::print("Error creating backup saves. Exception: {}\n", ex.what());
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@
|
|||||||
#include "sdl_window.h"
|
#include "sdl_window.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
void StartAutosave(std::string game_serial);
|
|
||||||
|
|
||||||
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
|
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
|
||||||
|
|
||||||
struct SysModules {
|
struct SysModules {
|
||||||
@ -23,10 +20,12 @@ struct SysModules {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Emulator {
|
class Emulator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator();
|
Emulator();
|
||||||
~Emulator();
|
~Emulator();
|
||||||
|
|
||||||
|
int user_id{};
|
||||||
void Run(const std::filesystem::path& file);
|
void Run(const std::filesystem::path& file);
|
||||||
void UpdatePlayTime(const std::string& serial);
|
void UpdatePlayTime(const std::string& serial);
|
||||||
|
|
||||||
@ -37,6 +36,7 @@ private:
|
|||||||
Core::Linker* linker;
|
Core::Linker* linker;
|
||||||
std::unique_ptr<Frontend::WindowSDL> window;
|
std::unique_ptr<Frontend::WindowSDL> window;
|
||||||
std::chrono::steady_clock::time_point start_time;
|
std::chrono::steady_clock::time_point start_time;
|
||||||
|
static void StartAutosave(std::string game_serial);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@ -67,8 +67,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>822</width>
|
<width>1028</width>
|
||||||
<height>487</height>
|
<height>649</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
|
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
|
||||||
@ -189,6 +189,38 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -228,13 +260,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="ps4proCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Is PS4 Pro</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="discordRPCCheckbox">
|
<widget class="QCheckBox" name="discordRPCCheckbox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -301,7 +326,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QVBoxLayout" name="updaterTabLayoutLeft">
|
<layout class="QVBoxLayout" name="updaterTabLayoutLeft">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>-1</number>
|
<number>7</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||||
@ -685,8 +710,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>396</width>
|
<width>922</width>
|
||||||
<height>222</height>
|
<height>598</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
|
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
|
||||||
@ -976,8 +1001,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>536</width>
|
<width>922</width>
|
||||||
<height>192</height>
|
<height>598</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
|
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
|
||||||
@ -1227,8 +1252,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>146</width>
|
<width>922</width>
|
||||||
<height>215</height>
|
<height>598</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="pathsTabLayout" stretch="0">
|
<layout class="QVBoxLayout" name="pathsTabLayout" stretch="0">
|
||||||
@ -1293,8 +1318,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>288</width>
|
<width>922</width>
|
||||||
<height>163</height>
|
<height>598</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,1">
|
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,1">
|
||||||
|
Loading…
Reference in New Issue
Block a user