Frontend: Add settings window

This commit is contained in:
Connor McLaughlin
2019-11-07 23:52:19 +10:00
parent 57c4101ff4
commit 36b7690056
5 changed files with 240 additions and 31 deletions

View File

@ -22,8 +22,8 @@ void Settings::SetDefaults()
bios_path = "scph1001.bin";
memory_card_a_filename = "memory_card_a.mcd";
memory_card_b_filename.clear();
memory_card_a_path = "memory_card_a.mcd";
memory_card_b_path.clear();
}
void Settings::Load(const char* filename)
@ -46,8 +46,8 @@ void Settings::Load(const char* filename)
bios_path = ini.GetValue("BIOS", "Path", "scph1001.bin");
memory_card_a_filename = ini.GetValue("MemoryCard", "CardAPath", "memory_card_a.mcd");
memory_card_b_filename = ini.GetValue("MemoryCard", "CardBPath", "");
memory_card_a_path = ini.GetValue("MemoryCard", "CardAPath", "memory_card_a.mcd");
memory_card_b_path = ini.GetValue("MemoryCard", "CardBPath", "");
}
bool Settings::Save(const char* filename) const
@ -67,13 +67,13 @@ bool Settings::Save(const char* filename) const
ini.SetValue("BIOS", "Path", bios_path.c_str());
if (!memory_card_a_filename.empty())
ini.SetValue("MemoryCard", "CardAPath", memory_card_a_filename.c_str());
if (!memory_card_a_path.empty())
ini.SetValue("MemoryCard", "CardAPath", memory_card_a_path.c_str());
else
ini.DeleteValue("MemoryCard", "CardAPath", nullptr);
if (!memory_card_b_filename.empty())
ini.SetValue("MemoryCard", "CardBPath", memory_card_b_filename.c_str());
if (!memory_card_b_path.empty())
ini.SetValue("MemoryCard", "CardBPath", memory_card_b_path.c_str());
else
ini.DeleteValue("MemoryCard", "CardBPath", nullptr);
@ -82,6 +82,8 @@ bool Settings::Save(const char* filename) const
}
static std::array<const char*, 3> s_gpu_renderer_names = {{"D3D11", "OpenGL", "Software"}};
static std::array<const char*, 3> s_gpu_renderer_display_names = {
{"Hardware (D3D11)", "Hardware (OpenGL)", "Software"}};
std::optional<Settings::GPURenderer> Settings::ParseRendererName(const char* str)
{
@ -101,3 +103,8 @@ const char* Settings::GetRendererName(GPURenderer renderer)
{
return s_gpu_renderer_names[static_cast<int>(renderer)];
}
const char* Settings::GetRendererDisplayName(GPURenderer renderer)
{
return s_gpu_renderer_display_names[static_cast<int>(renderer)];
}

View File

@ -8,12 +8,14 @@ struct Settings
{
HardwareD3D11,
HardwareOpenGL,
Software
Software,
Count
};
Settings();
bool start_paused = false;
bool speed_limiter_enabled = true;
GPURenderer gpu_renderer = GPURenderer::Software;
u32 gpu_resolution_scale = 1;
@ -21,6 +23,7 @@ struct Settings
bool gpu_vsync = true;
bool gpu_true_color = false;
bool display_linear_filtering = true;
bool display_fullscreen = false;
struct DebugSettings
{
@ -38,8 +41,8 @@ struct Settings
// TODO: Controllers, memory cards, etc.
std::string bios_path;
std::string memory_card_a_filename;
std::string memory_card_b_filename;
std::string memory_card_a_path;
std::string memory_card_b_path;
void SetDefaults();
void Load(const char* filename);
@ -47,4 +50,5 @@ struct Settings
static std::optional<GPURenderer> ParseRendererName(const char* str);
static const char* GetRendererName(GPURenderer renderer);
static const char* GetRendererDisplayName(GPURenderer renderer);
};

View File

@ -376,16 +376,16 @@ void System::UpdateMemoryCards()
m_pad->SetMemoryCard(0, nullptr);
m_pad->SetMemoryCard(1, nullptr);
if (!m_settings.memory_card_a_filename.empty())
if (!m_settings.memory_card_a_path.empty())
{
std::shared_ptr<MemoryCard> card = MemoryCard::Open(this, m_settings.memory_card_a_filename);
std::shared_ptr<MemoryCard> card = MemoryCard::Open(this, m_settings.memory_card_a_path);
if (card)
m_pad->SetMemoryCard(0, std::move(card));
}
if (!m_settings.memory_card_b_filename.empty())
if (!m_settings.memory_card_b_path.empty())
{
std::shared_ptr<MemoryCard> card = MemoryCard::Open(this, m_settings.memory_card_b_filename);
std::shared_ptr<MemoryCard> card = MemoryCard::Open(this, m_settings.memory_card_b_path);
if (card)
m_pad->SetMemoryCard(1, std::move(card));
}