From 439baff4ccec3074d09da35897b87205b3990cac Mon Sep 17 00:00:00 2001 From: gnick79 Date: Thu, 3 Feb 2011 17:51:12 +0000 Subject: [PATCH] - Moving "Custom Projection Hack" stuff toward a new modal dialog window git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7049 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/CMakeLists.txt | 1 + Source/Core/DolphinWX/DolphinWX.vcproj | 8 + Source/Core/DolphinWX/Src/ISOProperties.cpp | 170 +++++--------------- Source/Core/DolphinWX/Src/ISOProperties.h | 34 ++-- Source/Core/DolphinWX/Src/PHackSettings.cpp | 159 ++++++++++++++++++ Source/Core/DolphinWX/Src/PHackSettings.h | 70 ++++++++ 6 files changed, 292 insertions(+), 150 deletions(-) create mode 100644 Source/Core/DolphinWX/Src/PHackSettings.cpp create mode 100644 Source/Core/DolphinWX/Src/PHackSettings.h diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 31054afaac..8db806b765 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -41,6 +41,7 @@ if(wxWidgets_FOUND) Src/NetPlayServer.cpp Src/NetWindow.cpp Src/PatchAddEdit.cpp + Src/PHackSettings.cpp Src/UDPConfigDiag.cpp Src/WiimoteConfigDiag.cpp Src/MemoryCards/WiiSaveCrypted.cpp diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index e2bd176af9..4c43cc10a2 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -924,6 +924,14 @@ RelativePath=".\Src\PatchAddEdit.h" > + + + + diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 39fcd01ecc..ac19e3ef3b 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -26,6 +26,7 @@ #include "VolumeCreator.h" #include "Filesystem.h" #include "ISOProperties.h" +#include "PHackSettings.h" #include "PatchAddEdit.h" #include "ARCodeAddEdit.h" #include "GeckoCodeDiag.h" @@ -49,6 +50,7 @@ DiscIO::IFileSystem *pFileSystem = NULL; std::vector onFrame; std::vector arCodes; +PHackData PHack_Data; BEGIN_EVENT_TABLE(CISOProperties, wxDialog) @@ -57,7 +59,7 @@ BEGIN_EVENT_TABLE(CISOProperties, wxDialog) EVT_BUTTON(ID_EDITCONFIG, CISOProperties::OnEditConfig) EVT_CHOICE(ID_EMUSTATE, CISOProperties::SetRefresh) EVT_CHOICE(ID_EMU_ISSUES, CISOProperties::SetRefresh) - EVT_CHOICE(ID_PHACK_CHOICE, CISOProperties::SetRefresh) + EVT_BUTTON(ID_PHSETTINGS, CISOProperties::PHackButtonClicked) EVT_LISTBOX(ID_PATCHES_LIST, CISOProperties::ListSelectionChanged) EVT_BUTTON(ID_EDITPATCH, CISOProperties::PatchButtonClicked) EVT_BUTTON(ID_ADDPATCH, CISOProperties::PatchButtonClicked) @@ -116,14 +118,8 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW CreateGUIControls(DiscIO::IsVolumeWadFile(OpenISO)); - std::string _iniFilename; - - _iniFilename = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + "PH_PRESETS.ini"; - PHPresetsIni.Load(_iniFilename.c_str()); - //PHPresetsIni.SortSections(); - //PHPresetsIni.Save(_iniFilename.c_str()); + std::string _iniFilename = OpenISO->GetUniqueID(); - _iniFilename = OpenISO->GetUniqueID(); if (!_iniFilename.length()) { char tmp[17]; @@ -342,27 +338,14 @@ void CISOProperties::CreateGUIControls(bool IsWad) UseZTPSpeedupHack = new wxCheckBox(m_GameConfig, ID_ZTP_SPEEDUP, _("ZTP hack"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator); UseZTPSpeedupHack->SetToolTip(_("Enable this to speed up The Legend of Zelda: Twilight Princess. Disable for ANY other game.")); DListCache = new wxCheckBox(m_GameConfig, ID_DLISTCACHE, _("DList Cache"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator); + // Hack - PHackEnable = new wxCheckBox(m_GameConfig, ID_PHACKENABLE, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); - PHackEnable->SetToolTip(_("Customize some Orthographic Projection parameters.")); - PHackChoiceText = new wxStaticText(m_GameConfig, ID_PHACK_CHOICE_TEXT, _("Presets: "), wxDefaultPosition, wxDefaultSize); - PHackChoice = new wxChoice(m_GameConfig, ID_PHACK_CHOICE, wxDefaultPosition, wxDefaultSize, wxArrayString(0, wxString("", *wxConvCurrent)), 0, wxDefaultValidator); - PHackChoice->SetToolTip(_("Load preset values from hack patterns available.")); - szrPHackSettings = new wxFlexGridSizer(3,5,5); - PHackZNearText = new wxStaticText(m_GameConfig, ID_PHACK_ZNEAR_TEXT, _("zNear Correction: "), wxDefaultPosition, wxDefaultSize); - PHackZNear = new wxTextCtrl(m_GameConfig, ID_PHACK_ZNEAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - PHackZNear->SetToolTip(_("Adds the specified value to zNear Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); - PHackSZNear = new wxCheckBox(m_GameConfig, ID_PHACK_SZNEAR, _("(-)+zNear"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); - PHackSZNear->SetToolTip(_("Changes sign to zNear Parameter (after correction)")); - PHackZFarText = new wxStaticText(m_GameConfig, ID_PHACK_ZFAR_TEXT, _("zFar Correction: "), wxDefaultPosition, wxDefaultSize); - PHackZFar = new wxTextCtrl(m_GameConfig, ID_PHACK_ZFAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - PHackZFar->SetToolTip(_("Adds the specified value to zFar Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); - PHackSZFar = new wxCheckBox(m_GameConfig, ID_PHACK_SZFAR, _("(-)+zFar"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); - PHackSZFar->SetToolTip(_("Changes sign to zFar Parameter (after correction)")); - PHackExP = new wxCheckBox(m_GameConfig, ID_PHACK_EXP, _("Extra Parameter"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); - PHackExP->SetToolTip(_("Extra Parameter useful in '\'Metroid: Other M'\' only.")); + szrPHackSettings = new wxFlexGridSizer(0); + PHackEnable = new wxCheckBox(m_GameConfig, ID_PHACKENABLE, _("Custom Projection Hack"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); + PHackEnable->SetToolTip(_("Enables Custom Projection Hack")); + PHSettings = new wxButton(m_GameConfig, ID_PHSETTINGS, _("Settings..."), wxDefaultPosition, wxDefaultSize, 0); + PHSettings->SetToolTip(_("Customize some Orthographic Projection parameters.")); - // Emulation State sEmuState = new wxBoxSizer(wxHORIZONTAL); EmuStateText = new wxStaticText(m_GameConfig, ID_EMUSTATE_TEXT, _("Emulation State: "), wxDefaultPosition, wxDefaultSize); arrayStringFor_EmuState.Add(_("Not Set")); @@ -414,23 +397,9 @@ void CISOProperties::CreateGUIControls(bool IsWad) sbVideoOverrides->Add(UseXFB, 0, wxEXPAND|wxLEFT, 5); sbVideoOverrides->Add(UseZTPSpeedupHack, 0, wxEXPAND|wxLEFT, 5); sbVideoOverrides->Add(DListCache, 0, wxEXPAND|wxLEFT, 5); - sbVideoOverrides->AddSpacer(5); - - sbPHackSettings = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Custom Projection Hack")); - sbPHackSettings->Add(PHackEnable, 0, wxEXPAND|wxLEFT, 5); - sbPHackSettings->AddSpacer(15); - sbPHackSettings->Add(PHackChoiceText, 0, wxEXPAND|wxLEFT, 5); - sbPHackSettings->Add(PHackChoice, 0, wxEXPAND|wxLEFT, 5); - sbPHackSettings->Add(szrPHackSettings, 0, wxEXPAND|wxLEFT|wxTOP, 5); - sbVideoOverrides->Add(sbPHackSettings, 0, wxEXPAND); - - szrPHackSettings->Add(PHackZNearText, 0, wxALIGN_CENTER_VERTICAL); - szrPHackSettings->Add(PHackZNear, 1, wxEXPAND); - szrPHackSettings->Add(PHackSZNear, 0, wxEXPAND|wxLEFT, 5); - szrPHackSettings->Add(PHackZFarText, 0, wxALIGN_CENTER_VERTICAL); - szrPHackSettings->Add(PHackZFar, 1, wxEXPAND); - szrPHackSettings->Add(PHackSZFar, 0, wxEXPAND|wxLEFT, 5); - szrPHackSettings->Add(PHackExP, 0, wxEXPAND|wxTOP, 5); + szrPHackSettings->Add(PHackEnable, 0, wxEXPAND|wxLEFT, 5); + szrPHackSettings->Add(PHSettings, 0, wxLEFT, 5); + sbVideoOverrides->Add(szrPHackSettings, 0, wxEXPAND); sbGameConfig = new wxStaticBoxSizer(wxVERTICAL, m_GameConfig, _("Game-Specific Settings")); sbGameConfig->Add(OverrideText, 0, wxEXPAND|wxALL, 5); @@ -598,15 +567,7 @@ void CISOProperties::OnCheckBoxClicked(wxCommandEvent& event) if (event.GetId() == ID_PHACKENABLE) { - PHackSZNear->Enable(choice); - PHackSZFar->Enable(choice); - PHackZNearText->Enable(choice); - PHackZNear->Enable(choice); - PHackZFarText->Enable(choice); - PHackZFar->Enable(choice); - PHackExP->Enable(choice); - PHackChoiceText->Enable(choice); - PHackChoice->Enable(choice); + PHSettings->Enable(choice); } } @@ -870,33 +831,6 @@ void CISOProperties::SetRefresh(wxCommandEvent& event) if (event.GetId() == ID_EMUSTATE) EmuIssues->Enable(event.GetSelection() != 0); - else if (event.GetId() == ID_PHACK_CHOICE) - { - bool bTemp; - std::string sTemp; - char sIndex[15]; - int index = event.GetSelection(); - bRefreshList = false; - - if (index > 1) - { - index -= 2; - sprintf(sIndex,"%d", index); - - PHPresetsIni.Get(sIndex, "PH_SZNear", &bTemp); - PHackSZNear->Set3StateValue((wxCheckBoxState)bTemp); - PHPresetsIni.Get(sIndex, "PH_SZFar", &bTemp); - PHackSZFar->Set3StateValue((wxCheckBoxState)bTemp); - PHPresetsIni.Get(sIndex, "PH_ExtraParam", &bTemp); - PHackExP->Set3StateValue((wxCheckBoxState)bTemp); - PHPresetsIni.Get(sIndex, "PH_ZNear", &sTemp); - PHackZNear->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); - PHPresetsIni.Get(sIndex, "PH_ZFar", &sTemp); - PHackZFar->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); - - bRefreshList = true; - } - } } void CISOProperties::LoadGameConfig() @@ -904,7 +838,6 @@ void CISOProperties::LoadGameConfig() bool bTemp; int iTemp; std::string sTemp; - char sIndex[15]; if (GameIni.Get("Core", "CPUThread", &bTemp)) CPUThread->Set3StateValue((wxCheckBoxState)bTemp); @@ -1008,53 +941,14 @@ void CISOProperties::LoadGameConfig() GameIni.Get("Video", "ProjectionHack", &bTemp); PHackEnable->Set3StateValue((wxCheckBoxState)bTemp); - PHackSZNear->Enable(bTemp); - PHackSZFar->Enable(bTemp); - PHackZNearText->Enable(bTemp); - PHackZNear->Enable(bTemp); - PHackZFarText->Enable(bTemp); - PHackZFar->Enable(bTemp); - PHackExP->Enable(bTemp); - PHackChoiceText->Enable(bTemp); - PHackChoice->Enable(bTemp); - - PHackChoice->Clear(); - PHackChoice->Append(_("Custom")); - for (int i=0 ; ; i++) - { - sprintf(sIndex,"%d",i); - if (!PHPresetsIni.Exists(sIndex, "Title")) - break; - PHPresetsIni.Get(sIndex, "Title", &sTemp); - if (sTemp.empty()) - sTemp = wxString(_("(UNKNOWN)")).char_str(); - if (i == 0) - PHackChoice->Append(wxString("-----------", *wxConvCurrent)); - PHackChoice->Append(wxString(sTemp.c_str(), *wxConvCurrent)); - } - PHackChoice->Select(0); - - GameIni.Get("Video", "PH_SZNear", &bTemp); - PHackSZNear->Set3StateValue((wxCheckBoxState)bTemp); - GameIni.Get("Video", "PH_SZFar", &bTemp); - PHackSZFar->Set3StateValue((wxCheckBoxState)bTemp); - GameIni.Get("Video", "PH_ExtraParam", &bTemp); - PHackExP->Set3StateValue((wxCheckBoxState)bTemp); - - GameIni.Get("Video", "PH_ZNear", &sTemp); - if (!sTemp.empty()) - { - PHackZNear->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); - bRefreshList = true; - } - - GameIni.Get("Video", "PH_ZFar", &sTemp); - if (!sTemp.empty()) - { - PHackZFar->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); - bRefreshList = true; - } + PHSettings->Enable(bTemp); + + GameIni.Get("Video", "PH_SZNear", &PHack_Data.PHackSZNear); + GameIni.Get("Video", "PH_SZFar", &PHack_Data.PHackSZFar); + GameIni.Get("Video", "PH_ExtraParam", &PHack_Data.PHackExP); + GameIni.Get("Video", "PH_ZNear", &PHack_Data.PHZNear); + GameIni.Get("Video", "PH_ZFar", &PHack_Data.PHZFar); GameIni.Get("EmuState", "EmulationStateId", &iTemp, 0/*Not Set*/); EmuState->SetSelection(iTemp); @@ -1175,12 +1069,13 @@ bool CISOProperties::SaveGameConfig() GameIni.Set("Video", "DlistCachingEnable", DListCache->Get3StateValue()); GameIni.Set("Video", "ProjectionHack", PHackEnable->Get3StateValue()); - GameIni.Set("Video", "PH_SZNear", PHackSZNear->Get3StateValue()); - GameIni.Set("Video", "PH_SZFar", PHackSZFar->Get3StateValue()); - GameIni.Set("Video", "PH_ExtraParam", PHackExP->Get3StateValue()); - GameIni.Set("Video", "PH_ZNear", (const char*)PHackZNear->GetValue().mb_str(*wxConvCurrent)); - GameIni.Set("Video", "PH_ZFar", (const char*)PHackZFar->GetValue().mb_str(*wxConvCurrent)); + GameIni.Set("Video", "PH_SZNear", PHack_Data.PHackSZNear ? 1 : 0); + GameIni.Set("Video", "PH_SZFar", PHack_Data.PHackSZFar ? 1 : 0); + GameIni.Set("Video", "PH_ExtraParam", PHack_Data.PHackExP ? 1 : 0); + + GameIni.Set("Video", "PH_ZNear", PHack_Data.PHZNear); + GameIni.Set("Video", "PH_ZFar", PHack_Data.PHZFar); GameIni.Set("EmuState", "EmulationStateId", EmuState->GetSelection()); GameIni.Set("EmuState", "EmulationIssues", (const char*)EmuIssues->GetValue().mb_str(*wxConvCurrent)); @@ -1289,6 +1184,17 @@ void CISOProperties::PatchList_Save() lines.clear(); } +void CISOProperties::PHackButtonClicked(wxCommandEvent& event) +{ + if (event.GetId() == ID_PHSETTINGS) + { + ::PHack_Data = PHack_Data; + CPHackSettings dlg(this, 1); + if (dlg.ShowModal() == wxID_OK) + PHack_Data = ::PHack_Data; + } +} + void CISOProperties::PatchButtonClicked(wxCommandEvent& event) { int selection = Patches->GetSelection(); diff --git a/Source/Core/DolphinWX/Src/ISOProperties.h b/Source/Core/DolphinWX/Src/ISOProperties.h index 862e2375b0..ba22e7424e 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.h +++ b/Source/Core/DolphinWX/Src/ISOProperties.h @@ -37,6 +37,15 @@ #include "ActionReplay.h" #include "GeckoCodeDiag.h" +struct PHackData +{ + bool PHackSZNear; + bool PHackSZFar; + bool PHackExP; + std::string PHZNear; + std::string PHZFar; +}; + class CISOProperties : public wxDialog { public: @@ -55,6 +64,8 @@ class CISOProperties : public wxDialog void ActionReplayList_Load(); bool SaveGameConfig(); + PHackData PHack_Data; + private: DECLARE_EVENT_TABLE(); @@ -63,7 +74,6 @@ class CISOProperties : public wxDialog wxStaticBoxSizer *sbCoreOverrides; wxStaticBoxSizer *sbWiiOverrides; wxStaticBoxSizer *sbVideoOverrides; - wxStaticBoxSizer *sbPHackSettings; wxBoxSizer *sEmuState; wxBoxSizer *sPatches; wxBoxSizer *sPatchButtons; @@ -93,8 +103,8 @@ class CISOProperties : public wxDialog wxCheckBox *ForceFiltering, *EFBCopyEnable, *EFBAccessEnable, *EFBToTextureEnable, *SafeTextureCache, *DstAlphaPass, *UseXFB, *UseZTPSpeedupHack, - *DListCache, *PHackEnable, *PHackSZNear, *PHackSZFar, *PHackExP; - wxChoice *PHackChoice; + *DListCache, *PHackEnable; + wxButton *PHSettings; wxButton *EditConfig; wxStaticText *EmuStateText; @@ -128,17 +138,12 @@ class CISOProperties : public wxDialog wxStaticText *m_MakerText; wxStaticText *m_CommentText; wxStaticText *m_BannerText; - wxStaticText *PHackChoiceText; - wxStaticText *PHackZNearText; - wxStaticText *PHackZFarText; wxTextCtrl *m_Name; wxTextCtrl *m_GameID; wxTextCtrl *m_Country; wxTextCtrl *m_MakerID; wxTextCtrl *m_Date; wxTextCtrl *m_FST; - wxTextCtrl *PHackZNear; - wxTextCtrl *PHackZFar; wxArrayString arrayStringFor_Lang; wxChoice *m_Lang; wxTextCtrl *m_ShortName; @@ -187,15 +192,7 @@ class CISOProperties : public wxDialog ID_ZTP_SPEEDUP, ID_DLISTCACHE, ID_PHACKENABLE, - ID_PHACK_CHOICE_TEXT, - ID_PHACK_CHOICE, - ID_PHACK_SZNEAR, - ID_PHACK_SZFAR, - ID_PHACK_ZNEAR_TEXT, - ID_PHACK_ZNEAR, - ID_PHACK_ZFAR_TEXT, - ID_PHACK_ZFAR, - ID_PHACK_EXP, + ID_PHSETTINGS, ID_ENABLEPROGRESSIVESCAN, ID_ENABLEWIDESCREEN, ID_EDITCONFIG, @@ -263,6 +260,7 @@ class CISOProperties : public wxDialog void SetRefresh(wxCommandEvent& event); void OnChangeBannerLang(wxCommandEvent& event); void OnCheckBoxClicked(wxCommandEvent& event); + void PHackButtonClicked(wxCommandEvent& event); GameListItem *OpenGameListItem; @@ -276,7 +274,7 @@ class CISOProperties : public wxDialog void ExportDir(const char* _rFullPath, const char* _rExportFilename, const int partitionNum = 0); - IniFile GameIni, PHPresetsIni; + IniFile GameIni; std::string GameIniFile; void LoadGameConfig(); diff --git a/Source/Core/DolphinWX/Src/PHackSettings.cpp b/Source/Core/DolphinWX/Src/PHackSettings.cpp new file mode 100644 index 0000000000..aae58fc16c --- /dev/null +++ b/Source/Core/DolphinWX/Src/PHackSettings.cpp @@ -0,0 +1,159 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "PHackSettings.h" +#include "ConfigManager.h" + +extern PHackData PHack_Data; + +BEGIN_EVENT_TABLE(CPHackSettings, wxDialog) + EVT_CHOICE(ID_PHACK_CHOICE, CPHackSettings::SetRefresh) + EVT_CLOSE(CPHackSettings::OnClose) + EVT_BUTTON(wxID_OK, CPHackSettings::SavePHackData) +END_EVENT_TABLE() + +CPHackSettings::CPHackSettings(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) + : wxDialog(parent, id, title, position, size, style) +{ + CreateGUIControls(); + std::string _iniFilename; + _iniFilename = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + "PH_PRESETS.ini"; + PHPresetsIni.Load(_iniFilename.c_str()); + //PHPresetsIni.SortSections(); + //PHPresetsIni.Save(_iniFilename.c_str()); + + LoadPHackData(); +} + +CPHackSettings::~CPHackSettings() +{ +} + +void CPHackSettings::CreateGUIControls() +{ + PHackChoiceText = new wxStaticText(this, ID_PHACK_CHOICE_TEXT, _("Presets: "), wxDefaultPosition, wxDefaultSize); + PHackChoice = new wxChoice(this, ID_PHACK_CHOICE, wxDefaultPosition, wxDefaultSize, wxArrayString(0, wxString("", *wxConvCurrent)), 0, wxDefaultValidator); + PHackChoice->SetToolTip(_("Load preset values from hack patterns available.")); + PHackZNearText = new wxStaticText(this, ID_PHACK_ZNEAR_TEXT, _("zNear Correction: "), wxDefaultPosition, wxDefaultSize); + PHackZNear = new wxTextCtrl(this, ID_PHACK_ZNEAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + PHackZNear->SetToolTip(_("Adds the specified value to zNear Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); + PHackSZNear = new wxCheckBox(this, ID_PHACK_SZNEAR, _("(-)+zNear"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); + PHackSZNear->SetToolTip(_("Changes sign to zNear Parameter (after correction)")); + PHackZFarText = new wxStaticText(this, ID_PHACK_ZFAR_TEXT, _("zFar Correction: "), wxDefaultPosition, wxDefaultSize); + PHackZFar = new wxTextCtrl(this, ID_PHACK_ZFAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + PHackZFar->SetToolTip(_("Adds the specified value to zFar Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); + PHackSZFar = new wxCheckBox(this, ID_PHACK_SZFAR, _("(-)+zFar"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); + PHackSZFar->SetToolTip(_("Changes sign to zFar Parameter (after correction)")); + PHackExP = new wxCheckBox(this, ID_PHACK_EXP, _("Extra Parameter"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); + PHackExP->SetToolTip(_("Extra Parameter useful in '\'Metroid: Other M'\' only.")); + + wxStaticBoxSizer *sbPHackSettings = new wxStaticBoxSizer(wxVERTICAL, this, _("Parameters")); + wxFlexGridSizer *szrPHackSettings = new wxFlexGridSizer(3, 5, 5); + sbPHackSettings->Add(szrPHackSettings, 0, wxEXPAND|wxLEFT|wxTOP, 5); + szrPHackSettings->Add(PHackZNearText, 0, wxALIGN_CENTER_VERTICAL); + szrPHackSettings->Add(PHackZNear, 1, wxEXPAND); + szrPHackSettings->Add(PHackSZNear, 0, wxEXPAND|wxLEFT, 5); + szrPHackSettings->Add(PHackZFarText, 0, wxALIGN_CENTER_VERTICAL); + szrPHackSettings->Add(PHackZFar, 1, wxEXPAND); + szrPHackSettings->Add(PHackSZFar, 0, wxEXPAND|wxLEFT, 5); + szrPHackSettings->Add(PHackExP, 0, wxEXPAND|wxTOP|wxBOTTOM, 5); + + wxBoxSizer* sPHackButtons = new wxBoxSizer(wxHORIZONTAL); + wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + sPHackButtons->Add(0, 0, 1, wxEXPAND, 5); + sPHackButtons->Add(bOK, 0, wxALL, 5); + sPHackButtons->Add(bCancel, 0, wxALL, 5); + + wxBoxSizer* sPHack = new wxBoxSizer(wxVERTICAL); + sPHack->Add(PHackChoiceText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5); + sPHack->Add(PHackChoice, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5); + sPHack->Add(sbPHackSettings, 0, wxEXPAND|wxALL, 5); + sPHack->Add(sPHackButtons, 0, wxEXPAND, 5); + + SetSizerAndFit(sPHack); +} + +void CPHackSettings::LoadPHackData() +{ + std::string sTemp; + char sIndex[15]; + + PHackChoice->Clear(); + PHackChoice->Append(_("[Custom]")); + for (int i=0 ; ; i++) + { + sprintf(sIndex,"%d",i); + if (!PHPresetsIni.Exists(sIndex, "Title")) + break; + PHPresetsIni.Get(sIndex, "Title", &sTemp); + if (sTemp.empty()) + sTemp = wxString(_("(UNKNOWN)")).char_str(); + if (i == 0) + PHackChoice->Append(wxString("-----------", *wxConvCurrent)); + PHackChoice->Append(wxString(sTemp.c_str(), *wxConvCurrent)); + } + PHackChoice->Select(0); + + PHackSZNear->Set3StateValue((wxCheckBoxState)PHack_Data.PHackSZNear); + PHackSZFar->Set3StateValue((wxCheckBoxState)PHack_Data.PHackSZFar); + PHackExP->Set3StateValue((wxCheckBoxState)PHack_Data.PHackExP); + + PHackZNear->SetValue(wxString(PHack_Data.PHZNear.c_str(), *wxConvCurrent)); + PHackZFar->SetValue(wxString(PHack_Data.PHZFar.c_str(), *wxConvCurrent)); +} + +void CPHackSettings::SetRefresh(wxCommandEvent& event) +{ + bool bTemp; + std::string sTemp; + char sIndex[15]; + int index = event.GetSelection(); + if (index > 1) + { + index -= 2; + sprintf(sIndex,"%d", index); + + PHPresetsIni.Get(sIndex, "PH_SZNear", &bTemp); + PHackSZNear->Set3StateValue((wxCheckBoxState)bTemp); + PHPresetsIni.Get(sIndex, "PH_SZFar", &bTemp); + PHackSZFar->Set3StateValue((wxCheckBoxState)bTemp); + PHPresetsIni.Get(sIndex, "PH_ExtraParam", &bTemp); + PHackExP->Set3StateValue((wxCheckBoxState)bTemp); + PHPresetsIni.Get(sIndex, "PH_ZNear", &sTemp); + PHackZNear->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); + PHPresetsIni.Get(sIndex, "PH_ZFar", &sTemp); + PHackZFar->SetValue(wxString(sTemp.c_str(), *wxConvCurrent)); + } +} + +void CPHackSettings::OnClose(wxCloseEvent& WXUNUSED (event)) +{ + Destroy(); +} + +void CPHackSettings::SavePHackData(wxCommandEvent& WXUNUSED (event)) +{ + PHack_Data.PHackSZNear = (bool)PHackSZNear->Get3StateValue(); + PHack_Data.PHackSZFar = (bool)PHackSZFar->Get3StateValue(); + PHack_Data.PHackExP = (bool)PHackExP->Get3StateValue(); + + PHack_Data.PHZNear = PHackZNear->GetValue().char_str(); + PHack_Data.PHZFar = PHackZFar->GetValue().char_str(); + + AcceptAndClose(); +} \ No newline at end of file diff --git a/Source/Core/DolphinWX/Src/PHackSettings.h b/Source/Core/DolphinWX/Src/PHackSettings.h new file mode 100644 index 0000000000..56f7dcdac4 --- /dev/null +++ b/Source/Core/DolphinWX/Src/PHackSettings.h @@ -0,0 +1,70 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef __PHACK_SETTINGS_h__ +#define __PHACK_SETTINGS_h__ + +#include +#include +#include "ISOProperties.h" + +class CPHackSettings : public wxDialog +{ + public: + CPHackSettings(wxWindow* parent, + wxWindowID id = 1, + const wxString& title = _("Custom Projection Hack Settings"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + virtual ~CPHackSettings(); + + private: + DECLARE_EVENT_TABLE(); + + wxChoice *PHackChoice; + wxCheckBox *PHackSZNear; + wxCheckBox *PHackSZFar; + wxCheckBox *PHackExP; + wxStaticText *PHackChoiceText; + wxStaticText *PHackZNearText; + wxStaticText *PHackZFarText; + wxTextCtrl *PHackZNear; + wxTextCtrl *PHackZFar; + + enum { + ID_PHACK_CHOICE_TEXT = 1000, + ID_PHACK_CHOICE, + ID_PHACK_SZNEAR, + ID_PHACK_SZFAR, + ID_PHACK_ZNEAR_TEXT, + ID_PHACK_ZNEAR, + ID_PHACK_ZFAR_TEXT, + ID_PHACK_ZFAR, + ID_PHACK_EXP + }; + + IniFile PHPresetsIni; + + void SetRefresh(wxCommandEvent& event); + void CreateGUIControls(); + + void OnClose(wxCloseEvent& event); + void SavePHackData(wxCommandEvent& event); + void LoadPHackData(); +}; +#endif // __PHACK_SETTINGS_h__