Replace remained old ini-manager calls

This commit is contained in:
O1L 2015-11-14 23:59:46 +04:00
parent 7dfe9415c4
commit fd13a495de
18 changed files with 194 additions and 119 deletions

View File

@ -6,7 +6,8 @@
void config_context_t::group::init()
{
m_cfg->m_groups[full_name()] = this;
if(!m_cfg->m_groups[full_name()])
m_cfg->m_groups[full_name()] = this;
}
config_context_t::group::group(config_context_t* cfg, const std::string& name)
@ -52,7 +53,10 @@ void config_context_t::assign(const config_context_t& rhs)
for (auto rhs_e : rhs_g.second->entries)
{
g->entries[rhs_e.first]->value_from(rhs_e.second);
if (g->entries[rhs_e.first])
g->entries[rhs_e.first]->value_from(rhs_e.second);
else
g->add_entry(rhs_e.first, rhs_e.second->string_value());
}
}
}
@ -99,11 +103,27 @@ void config_context_t::deserialize(std::istream& stream)
auto name_value = fmt::split(line, { "=" });
switch (name_value.size())
{
case 1: current_group->entries[fmt::trim(name_value[0])]->string_value({}); break;
case 1:
{
if (current_group->entries[fmt::trim(name_value[0])])
current_group->entries[fmt::trim(name_value[0])]->string_value({});
else
current_group->add_entry(fmt::trim(name_value[0]), std::string{});
}
break;
default:
std::cerr << line_index << ": line '" << line << "' has more than one symbol '='. used only first" << std::endl;
case 2: current_group->entries[fmt::trim(name_value[0])]->string_value(fmt::trim(name_value[1])); break;
case 2:
{
if (current_group->entries[fmt::trim(name_value[0])])
current_group->entries[fmt::trim(name_value[0])]->string_value(fmt::trim(name_value[1]));
else
current_group->add_entry(fmt::trim(name_value[0]), fmt::trim(name_value[1]));
}
break;
}
}
@ -142,4 +162,17 @@ std::string config_context_t::to_string() const
serialize(result);
return result.str();
}
}
void config_context_t::add_group(const std::string& name)
{
new group(this, name);
}
config_context_t::group& config_context_t::get_group(const std::string& name)
{
if (!m_groups[name])
add_group(name);
return *m_groups[name];
}

View File

@ -27,6 +27,31 @@ protected:
std::string name() const;
std::string full_name() const;
template<typename T>
void add_entry(const std::string& name, const T& def_value)
{
new entry<T>(this, name, def_value);
}
template<typename T>
T get_entry_value(const std::string& name, const T& def_value)
{
if (!entries[name])
add_entry(name, def_value);
return convert::to<T>(entries[name]->string_value());
}
template<typename T>
void set_entry_value(const std::string& name, const T& value)
{
if (entries[name])
entries[name]->string_value(convert::to<std::string>(value));
else
add_entry(name, value);
}
friend config_context_t;
};
@ -56,7 +81,8 @@ public:
, m_default_value(default_value)
, m_value(default_value)
{
parent->entries[name] = this;
if(!parent->entries[name])
parent->entries[name] = this;
}
T default_value() const
@ -132,4 +158,7 @@ public:
void set_defaults();
std::string to_string() const;
void add_group(const std::string& name);
group& get_group(const std::string& name);
};

View File

@ -1,5 +1,6 @@
#pragma once
#include <string>
#include "types.h"
namespace convert
{
@ -151,6 +152,24 @@ namespace convert
}
};
template<>
struct to_impl_t<std::string, size2i>
{
static std::string func(size2i value)
{
return std::to_string(value.width) + "x" + std::to_string(value.height);
}
};
template<>
struct to_impl_t<std::string, position2i>
{
static std::string func(position2i value)
{
return std::to_string(value.x) + ":" + std::to_string(value.y);
}
};
template<>
struct to_impl_t<int, std::string>
{
@ -231,10 +250,30 @@ namespace convert
return std::stold(value);
}
};
template<>
struct to_impl_t<size2i, std::string>
{
static size2i func(const std::string& value)
{
const auto& data = fmt::split(value, { "x" });
return { std::stoi(data[0]), std::stoi(data[1]) };
}
};
template<>
struct to_impl_t<position2i, std::string>
{
static position2i func(const std::string& value)
{
const auto& data = fmt::split(value, { ":" });
return { std::stoi(data[0]), std::stoi(data[1]) };
}
};
template<typename ReturnType, typename FromType>
ReturnType to(FromType value)
{
return to_impl_t<std::remove_all_extents_t<ReturnType>, std::remove_all_extents_t<FromType>>::func(value);
}
}
}

View File

@ -51,7 +51,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<SDLCheck>false</SDLCheck>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx_d3d12.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>

View File

@ -3,8 +3,6 @@
#include "Emu/System.h"
#include "Emu/state.h"
#include "rpcs3/Ini.h"
#if defined (_WIN32)
#include "XAudio2Thread.h"

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"

View File

@ -9,8 +9,6 @@
#include "Emu/state.h"
#include "Utilities/Log.h"
#include "Ini.h"
std::vector<std::string> simplify_path_blocks(const std::string& path)
{
// fmt::tolower() removed
@ -499,13 +497,10 @@ void VFS::Init(const std::string& path)
void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
{
IniEntry<int> entries_count;
entries_count.Init("count", "VFSManager");
int count = 0;
if (is_load)
{
count = entries_count.LoadValue(count);
count = rpcs3::config.vfs.count.value();
if (!count)
{
@ -524,7 +519,7 @@ void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
else
{
count = (int)res.size();
entries_count.SaveValue(count);
rpcs3::config.vfs.count = count;
}
// Custom EmulationDir
@ -549,30 +544,25 @@ void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
for(int i=0; i<count; ++i)
{
IniEntry<std::string> entry_path;
IniEntry<std::string> entry_device_path;
IniEntry<std::string> entry_mount;
IniEntry<int> entry_device;
rpcs3::config.vfs.add_entry(fmt::format("path[%d]", i), std::string{});
rpcs3::config.vfs.add_entry(fmt::format("device_path[%d]", i), std::string{});
rpcs3::config.vfs.add_entry(fmt::format("mount[%d]", i), std::string{});
rpcs3::config.vfs.add_entry(fmt::format("device[%d]", i), 0);
entry_path.Init(fmt::format("path[%d]", i), "VFSManager");
entry_device_path.Init(fmt::format("device_path[%d]", i), "VFSManager");
entry_mount.Init(fmt::format("mount[%d]", i), "VFSManager");
entry_device.Init(fmt::format("device[%d]", i), "VFSManager");
if (is_load)
{
res[i] = VFSManagerEntry();
res[i].path = entry_path.LoadValue("");
res[i].device_path = entry_device_path.LoadValue("");
res[i].mount = entry_mount.LoadValue("");
res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile);
res[i].path = rpcs3::config.vfs.get_entry_value<std::string>(fmt::format("path[%d]", i), std::string{});
res[i].device_path = rpcs3::config.vfs.get_entry_value<std::string>(fmt::format("device_path[%d]", i), std::string{});
res[i].mount = rpcs3::config.vfs.get_entry_value<std::string>(fmt::format("mount[%d]", i), std::string{});
res[i].device = (vfsDeviceType)rpcs3::config.vfs.get_entry_value<int>(fmt::format("device[%d]", i), 0);
}
else
{
entry_path.SaveValue(res[i].path);
entry_device_path.SaveValue(res[i].device_path);
entry_mount.SaveValue(res[i].mount);
entry_device.SaveValue(res[i].device);
rpcs3::config.vfs.set_entry_value(fmt::format("path[%d]", i), res[i].path);
rpcs3::config.vfs.set_entry_value(fmt::format("device_path[%d]", i), res[i].device_path);
rpcs3::config.vfs.set_entry_value(fmt::format("mount[%d]", i), res[i].mount);
rpcs3::config.vfs.set_entry_value(fmt::format("device[%d]", i), (int)res[i].device);
}
}
}

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/System.h"
#include "Emu/state.h"

View File

@ -6,6 +6,7 @@ class FrameBase : public wxFrame
{
protected:
bool m_is_skip_resize;
std::string m_ini_name;
FrameBase(
wxWindow* parent,
@ -19,6 +20,9 @@ protected:
: wxFrame(parent, id, framename, defposition, defsize, style)
, m_is_skip_resize(is_skip_resize)
{
//TODO
m_ini_name = ininame.empty() ? fmt::ToUTF8(framename) : ininame;
LoadInfo();
Bind(wxEVT_CLOSE_WINDOW, &FrameBase::OnClose, this);
@ -38,23 +42,22 @@ protected:
void LoadInfo()
{
SetSize(wxSize(rpcs3::config.gui.size.width.value(), rpcs3::config.gui.size.height.value()));
SetPosition(wxPoint(rpcs3::config.gui.position.x.value(), rpcs3::config.gui.position.y.value()));
size2i size = rpcs3::config.gui.size.value();
position2i position = rpcs3::config.gui.position.value();
SetSize(wxSize(size.width, size.height));
SetPosition(wxPoint(position.x, position.y));
}
void OnMove(wxMoveEvent& event)
{
rpcs3::config.gui.position.x = GetPosition().x;
rpcs3::config.gui.position.y = GetPosition().y;
rpcs3::config.gui.position = position2i{ GetPosition().x, GetPosition().y };
event.Skip();
}
void OnResize(wxSizeEvent& event)
{
rpcs3::config.gui.size.width = GetSize().GetWidth();
rpcs3::config.gui.size.height = GetSize().GetHeight();
rpcs3::config.gui.position.x = GetPosition().x;
rpcs3::config.gui.position.y = GetPosition().y;
rpcs3::config.gui.size = size2i{ GetSize().GetWidth(), GetSize().GetHeight() };
rpcs3::config.gui.position = position2i{ GetPosition().x, GetPosition().y };
if(m_is_skip_resize) event.Skip();
}

View File

@ -5,7 +5,6 @@
#include "Emu/GameInfo.h"
#include "Emu/state.h"
#include "Utilities/Log.h"
#include "Ini.h"
struct Column
{
@ -196,23 +195,28 @@ public:
}
}
#define ADD_COLUMN(v, dv, t, n, isshown) \
{ \
IniEntry<t> ini; \
ini.Init(m_columns[i].name + "_" + n, path); \
if(isLoad) m_columns[i].v = ini.LoadValue(dv); \
else if(isshown ? m_columns[i].shown : 1) \
{ \
ini.SetValue(m_columns[i].v); \
ini.Save(); \
} \
}
for (u32 i = 0; i < m_columns.size(); ++i)
auto add_column = [isLoad](Column& column, bool is_shown)
{
ADD_COLUMN(pos, m_columns[i].def_pos, int, "position", 1);
ADD_COLUMN(width, m_columns[i].def_width, int, "width", 1);
ADD_COLUMN(shown, true, bool, "shown", 0);
if (isLoad)
{
column.pos = rpcs3::config.game_viewer.get_entry_value<u32>(column.name + "_" + "position", column.def_pos);
column.width = rpcs3::config.game_viewer.get_entry_value<u32>(column.name + "_" + "width", column.def_width);
column.shown = rpcs3::config.game_viewer.get_entry_value<bool>(column.name + "_" + "shown", column.shown);
}
else if (is_shown ? column.shown : 1)
{
rpcs3::config.game_viewer.set_entry_value(column.name + "_" + "position", column.pos);
rpcs3::config.game_viewer.set_entry_value(column.name + "_" + "width", column.width);
rpcs3::config.game_viewer.set_entry_value(column.name + "_" + "shown", column.shown);
rpcs3::config.save();
}
};
for (auto& column : m_columns)
{
add_column(column, true);
}
if (isLoad)

View File

@ -5,9 +5,10 @@
#include "Emu/FS/vfsFile.h"
#include "LLEModulesManager.h"
#include "Emu/System.h"
#include "Emu/state.h"
#include "Emu/FS/VFS.h"
LLEModulesManagerFrame::LLEModulesManagerFrame(wxWindow* parent) : FrameBase(parent, wxID_ANY, "", "LLEModulesManagerFrame", wxSize(800, 600))
LLEModulesManagerFrame::LLEModulesManagerFrame(wxWindow* parent) : wxFrame(parent, wxID_ANY, "LLEModulesManagerFrame")
{
wxBoxSizer *s_panel = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *s_p_panel = new wxBoxSizer(wxVERTICAL);
@ -28,6 +29,7 @@ LLEModulesManagerFrame::LLEModulesManagerFrame(wxWindow* parent) : FrameBase(par
s_panel->Add(p_main, 1, wxEXPAND | wxALL, 5);
SetSizerAndFit(s_panel);
Refresh();
SetSize(350, 500);
b_select->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { OnSelectAll(event, true); event.Skip(); });
b_unselect->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { OnSelectAll(event, false); event.Skip(); });
@ -81,13 +83,10 @@ void LLEModulesManagerFrame::Refresh()
m_funcs.push_back(name);
//IniEntry<bool> load_lib;
//load_lib.Init(name, "LLE");
m_check_list->Check(m_check_list->Append(name +
" v" + std::to_string((int)sprx_loader.m_sprx_module_info.version[0]) +
"." + std::to_string((int)sprx_loader.m_sprx_module_info.version[1])),
false);
rpcs3::config.lle.get_entry_value<bool>(name, false));
}
}
@ -99,9 +98,7 @@ void LLEModulesManagerFrame::UpdateSelection(int index)
if (index < 0)
return;
//IniEntry<bool> load_lib;
//load_lib.Init(m_funcs[index], "LLE");
//load_lib.SaveValue(m_check_list->IsChecked(index));
rpcs3::config.lle.set_entry_value(m_funcs[index], m_check_list->IsChecked(index));
}
void LLEModulesManagerFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event), bool is_checked)

View File

@ -2,7 +2,7 @@
#include "Gui/FrameBase.h"
#include <wx/checklst.h>
class LLEModulesManagerFrame : public FrameBase
class LLEModulesManagerFrame : public wxFrame
{
wxCheckListBox *m_check_list;
std::vector<std::string> m_funcs;

View File

@ -1,5 +1,4 @@
#include "stdafx_gui.h"
#include "Ini.h"
#include "rpcs3.h"
#include "config.h"
#include "MainFrame.h"
@ -222,7 +221,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event))
{
LOG_SUCCESS(HLE, "Game: boot done.");
if (Ini.HLEAlwaysStart.GetValue() && Emu.IsReady())
if (rpcs3::config.misc.always_start.value())
{
Emu.Run();
}
@ -346,7 +345,7 @@ void MainFrame::BootElf(wxCommandEvent& WXUNUSED(event))
LOG_SUCCESS(HLE, "(S)ELF: boot done.");
if (Ini.HLEAlwaysStart.GetValue() && Emu.IsReady())
if (rpcs3::config.misc.always_start.value() && Emu.IsReady())
{
Emu.Run();
}
@ -513,7 +512,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event)
if (event.GetId() == DID_STOPPED_EMU)
{
if (Ini.HLEExitOnStop.GetValue())
if (rpcs3::config.misc.exit_on_stop.value())
{
wxGetApp().Exit();
}

View File

@ -1,4 +1,3 @@
#include "Ini.h"
#include <time.h>
enum ButtonIDs

View File

@ -527,29 +527,20 @@ void VHDDManagerDialog::OnOk(wxCommandEvent& event)
void VHDDManagerDialog::LoadPaths()
{
/*IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager");
size_t count = 0;
count = path_count.LoadValue(count);
size_t count = rpcs3::config.vfs.hdd_count.value();
for(size_t i=0; i<count; ++i)
for (size_t i = 0; i < count; ++i)
{
IniEntry<std::string> path_entry;
path_entry.Init(fmt::format("path[%d]", i), "HDDManager");
m_paths.emplace_back(path_entry.LoadValue(""));
}*/
m_paths.emplace_back(rpcs3::config.vfs.get_entry_value<std::string>(fmt::format("hdd_path[%d]", i), std::string{}));
}
}
void VHDDManagerDialog::SavePaths()
{
/*IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager");
path_count.SaveValue(m_paths.size());
rpcs3::config.vfs.hdd_count = (int)m_paths.size();
for(size_t i=0; i<m_paths.size(); ++i)
for (size_t i = 0; i < m_paths.size(); ++i)
{
IniEntry<std::string> path_entry;
path_entry.Init(fmt::format("path[%d]", i), "HDDManager");
path_entry.SaveValue(m_paths[i]);
}*/
rpcs3::config.vfs.set_entry_value(fmt::format("hdd_path[%d]", i), m_paths[i]);
}
}

View File

@ -351,13 +351,10 @@ namespace loader
{
if (!rpcs3::state.config.core.load_liblv2.value())
{
/*IniEntry<bool> load_lib;
load_lib.Init(sprx_handler.sprx_get_module_name(), "LLE");
if (!load_lib.LoadValue(false))
if (rpcs3::config.lle.get_entry_value<bool>(sprx_handler.sprx_get_module_name(), false) == false)
{
continue;
}*/
}
}
LOG_WARNING(LOADER, "Loading LLE library '%s'", sprx_handler.sprx_get_module_name().c_str());

View File

@ -572,23 +572,9 @@ namespace rpcs3
{
gui_group(config_context_t *cfg) : group{ cfg, "gui" } {}
struct size_group : protected group
{
size_group(group *grp) : group{ grp, "size" } {}
entry<int> width{ this, "width", 900 };
entry<int> height{ this, "height", 600 };
} size{ this };
struct position_group : protected group
{
position_group(group *grp) : group{ grp, "position" } {}
entry<int> x{ this, "horizontal", -1 };
entry<int> y{ this, "vertical", -1 };
} position{ this };
entry<std::string> aui_mgr_perspective{ this, "MainFrameAui", "" };
entry<size2i> size{ this, "size",{ 900, 600 } };
entry<position2i> position{ this, "position",{ -1, -1 } };
entry<std::string> aui_mgr_perspective{ this, "main_frame_aui", "" };
} gui{ this };
@ -741,6 +727,23 @@ namespace rpcs3
entry<bool> emulation_dir_path_enable{ this, "Use path below as EmulationDir", false };
} system{ this };
struct vfs_group : public group
{
vfs_group(config_context_t *cfg) : group{ cfg, "vfs" } {}
entry<int> count{ this, "count", 0 };
entry<int> hdd_count{ this, "hdd_count", 0 };
} vfs{ this };
struct lle_group : public group
{
lle_group(config_context_t *cfg) : group{ cfg, "lle" } {}
} lle{ this };
struct gw_group : public group
{
gw_group(config_context_t *cfg) : group{ cfg, "game_viewer" } {}
} game_viewer{ this };
config_t() = default;
config_t(const std::string &path);
config_t(const config_t& rhs);

View File

@ -7,8 +7,6 @@
#include "Gui/ConLogFrame.h"
#include "Emu/GameInfo.h"
#include "Ini.h"
#include "Emu/Io/Keyboard.h"
#include "Emu/Io/Null/NullKeyboardHandler.h"
#include "Emu/Io/Windows/WindowsKeyboardHandler.h"
@ -153,7 +151,6 @@ bool Rpcs3App::OnInit()
const wxString executablePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath());
wxSetWorkingDirectory(executablePath);
Ini.Load();
Emu.Init();
Emu.SetEmulatorPath(executablePath.ToStdString());
@ -200,8 +197,6 @@ void Rpcs3App::Exit()
}
Emu.Stop();
Ini.Save();
wxApp::Exit();
}