mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-01 12:46:01 +00:00
Remove save migration code (#1621)
This commit is contained in:
parent
7b68004a40
commit
2d7766b70b
|
@ -3,13 +3,14 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <common/version.h>
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <fmt/xchar.h> // for wstring support
|
#include <fmt/xchar.h> // for wstring support
|
||||||
#include <toml.hpp>
|
#include <toml.hpp>
|
||||||
#include "common/logging/formatter.h"
|
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "logging/formatter.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
namespace toml {
|
namespace toml {
|
||||||
template <typename TC, typename K>
|
template <typename TC, typename K>
|
||||||
|
@ -81,7 +82,8 @@ std::vector<std::string> m_pkg_viewer;
|
||||||
std::vector<std::string> m_elf_viewer;
|
std::vector<std::string> m_elf_viewer;
|
||||||
std::vector<std::string> m_recent_files;
|
std::vector<std::string> m_recent_files;
|
||||||
std::string emulator_language = "en";
|
std::string emulator_language = "en";
|
||||||
// Settings
|
|
||||||
|
// Language
|
||||||
u32 m_language = 1; // english
|
u32 m_language = 1; // english
|
||||||
|
|
||||||
bool isNeoMode() {
|
bool isNeoMode() {
|
||||||
|
@ -334,6 +336,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
||||||
main_window_geometry_w = w;
|
main_window_geometry_w = w;
|
||||||
main_window_geometry_h = h;
|
main_window_geometry_h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir) {
|
bool addGameInstallDir(const std::filesystem::path& dir) {
|
||||||
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
|
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
|
||||||
settings_install_dirs.end()) {
|
settings_install_dirs.end()) {
|
||||||
|
@ -342,47 +345,60 @@ bool addGameInstallDir(const std::filesystem::path& dir) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeGameInstallDir(const std::filesystem::path& dir) {
|
void removeGameInstallDir(const std::filesystem::path& dir) {
|
||||||
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);
|
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);
|
||||||
if (iterator != settings_install_dirs.end()) {
|
if (iterator != settings_install_dirs.end()) {
|
||||||
settings_install_dirs.erase(iterator);
|
settings_install_dirs.erase(iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAddonInstallDir(const std::filesystem::path& dir) {
|
void setAddonInstallDir(const std::filesystem::path& dir) {
|
||||||
settings_addon_install_dir = dir;
|
settings_addon_install_dir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowTheme(u32 theme) {
|
void setMainWindowTheme(u32 theme) {
|
||||||
mw_themes = theme;
|
mw_themes = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIconSize(u32 size) {
|
void setIconSize(u32 size) {
|
||||||
m_icon_size = size;
|
m_icon_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIconSizeGrid(u32 size) {
|
void setIconSizeGrid(u32 size) {
|
||||||
m_icon_size_grid = size;
|
m_icon_size_grid = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSliderPosition(u32 pos) {
|
void setSliderPosition(u32 pos) {
|
||||||
m_slider_pos = pos;
|
m_slider_pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSliderPositionGrid(u32 pos) {
|
void setSliderPositionGrid(u32 pos) {
|
||||||
m_slider_pos_grid = pos;
|
m_slider_pos_grid = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTableMode(u32 mode) {
|
void setTableMode(u32 mode) {
|
||||||
m_table_mode = mode;
|
m_table_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowWidth(u32 width) {
|
void setMainWindowWidth(u32 width) {
|
||||||
m_window_size_W = width;
|
m_window_size_W = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindowHeight(u32 height) {
|
void setMainWindowHeight(u32 height) {
|
||||||
m_window_size_H = height;
|
m_window_size_H = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPkgViewer(const std::vector<std::string>& pkgList) {
|
void setPkgViewer(const std::vector<std::string>& pkgList) {
|
||||||
m_pkg_viewer.resize(pkgList.size());
|
m_pkg_viewer.resize(pkgList.size());
|
||||||
m_pkg_viewer = pkgList;
|
m_pkg_viewer = pkgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList) {
|
void setElfViewer(const std::vector<std::string>& elfList) {
|
||||||
m_elf_viewer.resize(elfList.size());
|
m_elf_viewer.resize(elfList.size());
|
||||||
m_elf_viewer = elfList;
|
m_elf_viewer = elfList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
||||||
m_recent_files.resize(recentFiles.size());
|
m_recent_files.resize(recentFiles.size());
|
||||||
m_recent_files = recentFiles;
|
m_recent_files = recentFiles;
|
||||||
|
@ -395,18 +411,23 @@ void setEmulatorLanguage(std::string language) {
|
||||||
u32 getMainWindowGeometryX() {
|
u32 getMainWindowGeometryX() {
|
||||||
return main_window_geometry_x;
|
return main_window_geometry_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryY() {
|
u32 getMainWindowGeometryY() {
|
||||||
return main_window_geometry_y;
|
return main_window_geometry_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryW() {
|
u32 getMainWindowGeometryW() {
|
||||||
return main_window_geometry_w;
|
return main_window_geometry_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowGeometryH() {
|
u32 getMainWindowGeometryH() {
|
||||||
return main_window_geometry_h;
|
return main_window_geometry_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::filesystem::path>& getGameInstallDirs() {
|
const std::vector<std::filesystem::path>& getGameInstallDirs() {
|
||||||
return settings_install_dirs;
|
return settings_install_dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path getAddonInstallDir() {
|
std::filesystem::path getAddonInstallDir() {
|
||||||
if (settings_addon_install_dir.empty()) {
|
if (settings_addon_install_dir.empty()) {
|
||||||
// Default for users without a config file or a config file from before this option existed
|
// Default for users without a config file or a config file from before this option existed
|
||||||
|
@ -414,36 +435,47 @@ std::filesystem::path getAddonInstallDir() {
|
||||||
}
|
}
|
||||||
return settings_addon_install_dir;
|
return settings_addon_install_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowTheme() {
|
u32 getMainWindowTheme() {
|
||||||
return mw_themes;
|
return mw_themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getIconSize() {
|
u32 getIconSize() {
|
||||||
return m_icon_size;
|
return m_icon_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getIconSizeGrid() {
|
u32 getIconSizeGrid() {
|
||||||
return m_icon_size_grid;
|
return m_icon_size_grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getSliderPosition() {
|
u32 getSliderPosition() {
|
||||||
return m_slider_pos;
|
return m_slider_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getSliderPositionGrid() {
|
u32 getSliderPositionGrid() {
|
||||||
return m_slider_pos_grid;
|
return m_slider_pos_grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getTableMode() {
|
u32 getTableMode() {
|
||||||
return m_table_mode;
|
return m_table_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowWidth() {
|
u32 getMainWindowWidth() {
|
||||||
return m_window_size_W;
|
return m_window_size_W;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getMainWindowHeight() {
|
u32 getMainWindowHeight() {
|
||||||
return m_window_size_H;
|
return m_window_size_H;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getPkgViewer() {
|
std::vector<std::string> getPkgViewer() {
|
||||||
return m_pkg_viewer;
|
return m_pkg_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getElfViewer() {
|
std::vector<std::string> getElfViewer() {
|
||||||
return m_elf_viewer;
|
return m_elf_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getRecentFiles() {
|
std::vector<std::string> getRecentFiles() {
|
||||||
return m_recent_files;
|
return m_recent_files;
|
||||||
}
|
}
|
||||||
|
@ -455,6 +487,7 @@ std::string getEmulatorLanguage() {
|
||||||
u32 GetLanguage() {
|
u32 GetLanguage() {
|
||||||
return m_language;
|
return m_language;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(const std::filesystem::path& path) {
|
void load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
|
@ -545,18 +578,6 @@ void load(const std::filesystem::path& path) {
|
||||||
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
|
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
|
||||||
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
|
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
|
||||||
|
|
||||||
// TODO Migration code, after a major release this should be removed.
|
|
||||||
auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {});
|
|
||||||
if (!old_game_install_dir.empty()) {
|
|
||||||
addGameInstallDir(std::filesystem::path{old_game_install_dir});
|
|
||||||
} else {
|
|
||||||
const auto install_dir_array =
|
|
||||||
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
|
|
||||||
for (const auto& dir : install_dir_array) {
|
|
||||||
addGameInstallDir(std::filesystem::path{dir});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
|
||||||
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
|
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
|
||||||
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
|
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
|
||||||
|
@ -575,6 +596,7 @@ void load(const std::filesystem::path& path) {
|
||||||
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(const std::filesystem::path& path) {
|
void save(const std::filesystem::path& path) {
|
||||||
toml::value data;
|
toml::value data;
|
||||||
|
|
||||||
|
@ -655,9 +677,6 @@ void save(const std::filesystem::path& path) {
|
||||||
|
|
||||||
data["Settings"]["consoleLanguage"] = m_language;
|
data["Settings"]["consoleLanguage"] = m_language;
|
||||||
|
|
||||||
// TODO Migration code, after a major release this should be removed.
|
|
||||||
data.at("GUI").as_table().erase("installDir");
|
|
||||||
|
|
||||||
std::ofstream file(path, std::ios::binary);
|
std::ofstream file(path, std::ios::binary);
|
||||||
file << data;
|
file << data;
|
||||||
file.close();
|
file.close();
|
||||||
|
|
Loading…
Reference in a new issue