diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index b7d23eac90..ed20786896 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -63,6 +63,7 @@ if(wxWidgets_FOUND) MemoryCards/WiiSaveCrypted.cpp NetWindow.cpp PatchAddEdit.cpp + SoftwareVideoConfigDialog.cpp TASInputDlg.cpp VideoConfigDiag.cpp WXInputBase.cpp diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index a2ffefb6e0..e62e2f2e43 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -91,6 +91,7 @@ + Create @@ -139,6 +140,7 @@ + diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters index ec98fb5e26..b9910845a8 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters @@ -154,6 +154,9 @@ GUI + + GUI\Video + @@ -276,6 +279,9 @@ + + GUI\Video + diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index a49cb2fed3..a539ba4470 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -46,6 +46,7 @@ #include "DolphinWX/Frame.h" #include "DolphinWX/Globals.h" #include "DolphinWX/Main.h" +#include "DolphinWX/SoftwareVideoConfigDialog.h" #include "DolphinWX/VideoConfigDiag.h" #include "DolphinWX/WxUtils.h" #include "DolphinWX/Debugger/CodeWindow.h" @@ -704,7 +705,14 @@ void Host_ConnectWiimote(int wm_idx, bool connect) void Host_ShowVideoConfig(void* parent, const std::string& backend_name, const std::string& config_name) { - VideoConfigDiag diag((wxWindow*)parent, WxStrToStr(backend_name), - WxStrToStr(config_name)); - diag.ShowModal(); + if (backend_name == "Direct3D" || backend_name == "OpenGL") + { + VideoConfigDiag diag((wxWindow*)parent, backend_name, config_name); + diag.ShowModal(); + } + else if (backend_name == "Software Renderer") + { + SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name, config_name); + diag.ShowModal(); + } } diff --git a/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp new file mode 100644 index 0000000000..ddd5f710ff --- /dev/null +++ b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp @@ -0,0 +1,144 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Common/FileUtil.h" +#include "Core/Core.h" +#include "DolphinWX/SoftwareVideoConfigDialog.h" +#include "DolphinWX/VideoConfigDiag.h" +#include "DolphinWX/WxUtils.h" + +template +IntegerSetting::IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style) : + wxSpinCtrl(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), + m_setting(setting) +{ + SetRange(minVal, maxVal); + SetValue(m_setting); + Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &IntegerSetting::UpdateValue, this); +} + + +SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& _ininame) : + wxDialog(parent, -1, + wxString(wxString::Format(_("Dolphin %s Graphics Configuration"), title))), + vconfig(g_SWVideoConfig), + ininame(_ininame) +{ + vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + + wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize); + + // -- GENERAL -- + { + wxPanel* const page_general= new wxPanel(notebook, -1, wxDefaultPosition); + notebook->AddPage(page_general, wxT("General")); + wxBoxSizer* const szr_general = new wxBoxSizer(wxVERTICAL); + + // - rendering + { + wxStaticBoxSizer* const group_rendering = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Rendering")); + szr_general->Add(group_rendering, 0, wxEXPAND | wxALL, 5); + wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5); + group_rendering->Add(szr_rendering, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + // backend + wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:")); + wxChoice* const choice_backend = new wxChoice(page_general, wxID_ANY, wxDefaultPosition); + + for (const VideoBackend* backend : g_available_video_backends) + { + choice_backend->AppendString(StrToWxStr(backend->GetDisplayName())); + } + + // TODO: How to get the translated plugin name? + choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName())); + choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &SoftwareVideoConfigDialog::Event_Backend, this); + + szr_rendering->Add(label_backend, 1, wxALIGN_CENTER_VERTICAL, 5); + szr_rendering->Add(choice_backend, 1, 0, 0); + + if (Core::GetState() != Core::CORE_UNINITIALIZED) + { + label_backend->Disable(); + choice_backend->Disable(); + } + + // rasterizer + szr_rendering->Add(new SettingCheckBox(page_general, wxT("Hardware rasterization"), wxT(""), vconfig.bHwRasterizer)); + + // xfb + szr_rendering->Add(new SettingCheckBox(page_general, wxT("Bypass XFB"), wxT(""), vconfig.bBypassXFB)); + } + + // - info + { + wxStaticBoxSizer* const group_info = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Overlay Information")); + szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5); + group_info->Add(szr_info, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_info->Add(new SettingCheckBox(page_general, wxT("Various Statistics"), wxT(""), vconfig.bShowStats)); + } + + // - utility + { + wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Utility")); + szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5); + group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Textures"), wxT(""), vconfig.bDumpTextures)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Objects"), wxT(""), vconfig.bDumpObjects)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Frames"), wxT(""), vconfig.bDumpFrames)); + + // - debug only + wxStaticBoxSizer* const group_debug_only_utility = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Debug Only")); + group_utility->Add(group_debug_only_utility, 0, wxEXPAND | wxBOTTOM, 5); + wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, 5, 5); + group_debug_only_utility->Add(szr_debug_only_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump TEV Stages"), wxT(""), vconfig.bDumpTevStages)); + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump Texture Fetches"), wxT(""), vconfig.bDumpTevTextureFetches)); + } + + // - misc + { + wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Drawn Object Range")); + szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, 5, 5); + group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_misc->Add(new U32Setting(page_general, wxT("Start"), vconfig.drawStart, 0, 100000)); + szr_misc->Add(new U32Setting(page_general, wxT("End"), vconfig.drawEnd, 0, 100000)); + } + + page_general->SetSizerAndFit(szr_general); + } + + wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL); + szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5); + szr_main->Add(new wxButton(this, wxID_OK, wxT("Close"), wxDefaultPosition), + 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5); + + SetSizerAndFit(szr_main); + Center(); + SetFocus(); +} + +SoftwareVideoConfigDialog::~SoftwareVideoConfigDialog() +{ + g_SWVideoConfig.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); +} diff --git a/Source/Core/DolphinWX/SoftwareVideoConfigDialog.h b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.h new file mode 100644 index 0000000000..5c394dfc16 --- /dev/null +++ b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.h @@ -0,0 +1,51 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +// TODO: Merge this with the original VideoConfigDiag or something +// This is an awful way of managing a separate video backend. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Core/ConfigManager.h" +#include "VideoBackends/Software/SWVideoConfig.h" +#include "VideoCommon/VideoBackendBase.h" + +class SoftwareVideoConfigDialog : public wxDialog +{ +public: + SoftwareVideoConfigDialog(wxWindow* parent, const std::string &title, const std::string& ininame); + ~SoftwareVideoConfigDialog(); + + void Event_Backend(wxCommandEvent &ev) + { + VideoBackend* new_backend = g_available_video_backends[ev.GetInt()]; + + if (g_video_backend != new_backend) + { + Close(); + + g_video_backend = new_backend; + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = g_video_backend->GetName(); + + g_video_backend->ShowConfig(GetParent()); + } + ev.Skip(); + } + +protected: + SWVideoConfig& vconfig; + std::string ininame; +}; diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index 1e78abfcb7..42c492b793 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include -#include #include "Common/FileUtil.h" #include "Common/IniFile.h" @@ -14,9 +13,6 @@ #include "Core/Core.h" #include "Core/Host.h" -#include "DolphinWX/VideoConfigDiag.h" -#include "DolphinWX/Debugger/DebuggerPanel.h" - #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DUtil.h" #include "VideoBackends/D3D/Globals.h" @@ -139,13 +135,10 @@ void InitBackendInfo() DX11::D3D::UnloadD3D(); } -void VideoBackend::ShowConfig(void *_hParent) +void VideoBackend::ShowConfig(void *hParent) { -#if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); - VideoConfigDiag diag((wxWindow*)_hParent, _trans("Direct3D"), "gfx_dx11"); - diag.ShowModal(); -#endif + Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx11"); } bool VideoBackend::Initialize(void *&window_handle) diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index aa042c3405..44febec4a9 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -157,7 +157,7 @@ static void InitBackendInfo() void VideoBackend::ShowConfig(void *_hParent) { InitBackendInfo(); - Host_ShowVideoConfig(_hParent, "OpenGL", "gfx_opengl"); + Host_ShowVideoConfig(_hParent, GetDisplayName(), "gfx_opengl"); } bool VideoBackend::Initialize(void *&window_handle) diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 7a0e88011f..415fa0547b 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -33,10 +33,6 @@ #include "VideoBackends/Software/VideoBackend.h" #include "VideoBackends/Software/XFMemLoader.h" -#if defined(HAVE_WX) && HAVE_WX -#include "VideoBackends/Software/VideoConfigDialog.h" -#endif // HAVE_WX - #include "VideoCommon/Fifo.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/PixelEngine.h" @@ -62,12 +58,17 @@ static std::mutex m_csSWVidOccupied; std::string VideoSoftware::GetName() const { - return _trans("Software Renderer"); + return "Software Renderer"; } -void VideoSoftware::ShowConfig(void *_hParent) +std::string VideoSoftware::GetDisplayName() const { - Host_ShowVideoConfig(_hParent, "Software", "gfx_software"); + return "Software Renderer"; +} + +void VideoSoftware::ShowConfig(void *hParent) +{ + Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_software"); } bool VideoSoftware::Initialize(void *&window_handle) diff --git a/Source/Core/VideoBackends/Software/Software.vcxproj b/Source/Core/VideoBackends/Software/Software.vcxproj index 2f1febddfe..39732cd845 100644 --- a/Source/Core/VideoBackends/Software/Software.vcxproj +++ b/Source/Core/VideoBackends/Software/Software.vcxproj @@ -59,7 +59,6 @@ - @@ -87,7 +86,6 @@ - diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index 4694945a5c..dbfe1c7cab 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -14,6 +14,7 @@ class VideoSoftware : public VideoBackend void Shutdown() override; std::string GetName() const override; + std::string GetDisplayName() const override; void EmuStateChange(EMUSTATE_CHANGE newState) override;