From f171d629d89d5fd235370d5ff0ba723d175ce6aa Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:04:44 +0100 Subject: [PATCH] Disable '-forceborder' hook and light fix for launcher Disabled as this code is only ran if the VideoConfig file is getting written. To fix this bug, the executable has to be patched. This will be documented and shipped in the next release. --- r5dev/engine/matsys_interface.cpp | 9 +++++-- r5dev/sdklauncher/basepanel.cpp | 40 ++++++++++++++++++++++++------- r5dev/sdklauncher/basepanel.h | 5 ++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/r5dev/engine/matsys_interface.cpp b/r5dev/engine/matsys_interface.cpp index 062c2cc2..2b3e5608 100644 --- a/r5dev/engine/matsys_interface.cpp +++ b/r5dev/engine/matsys_interface.cpp @@ -3,6 +3,10 @@ #include "public/imaterialsystem.h" #include "engine/matsys_interface.h" +// Disabled, as this patch **only** works if we are writing the file. +// See 'resource/ptc/' for more details regarding how this bug has been +// fixed in the engine module. +/* //----------------------------------------------------------------------------- // Updates the material system config //----------------------------------------------------------------------------- @@ -24,14 +28,15 @@ bool UpdateCurrentVideoConfig(MaterialSystem_Config_t* pConfig) return v_UpdateCurrentVideoConfig(pConfig); } +*/ /////////////////////////////////////////////////////////////////////////////// void MatSys_Iface_Attach() { - DetourAttach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); + //DetourAttach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); } void MatSys_Iface_Detach() { - DetourDetach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); + //DetourDetach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); } \ No newline at end of file diff --git a/r5dev/sdklauncher/basepanel.cpp b/r5dev/sdklauncher/basepanel.cpp index 9a76fe03..4a27f2bc 100644 --- a/r5dev/sdklauncher/basepanel.cpp +++ b/r5dev/sdklauncher/basepanel.cpp @@ -374,6 +374,7 @@ void CUIBaseSurface::Init() this->m_NoBorderToggle->SetTabIndex(0); this->m_NoBorderToggle->SetText("No border"); this->m_NoBorderToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_NoBorderToggle->Click += BorderParametersChanged; this->m_EngineVideoGroup->AddControl(this->m_NoBorderToggle); this->m_FpsTextBox = new UIX::UIXTextBox(); @@ -479,6 +480,8 @@ void CUIBaseSurface::Init() this->PerformLayout(); // END DESIGNER CODE + + m_bBorderParamChanged = false; } //----------------------------------------------------------------------------- @@ -719,6 +722,16 @@ void CUIBaseSurface::ForwardCommandToGame(Forms::Control* pSender) } } +//----------------------------------------------------------------------------- +// Purpose: +// Input : *pSender - +//----------------------------------------------------------------------------- +void CUIBaseSurface::BorderParametersChanged(Forms::Control* pSender) +{ + CUIBaseSurface* pSurface = reinterpret_cast<CUIBaseSurface*>(pSender->FindForm()); + pSurface->m_bBorderParamChanged = true; +} + //----------------------------------------------------------------------------- // Purpose: appends the reversed core count value to the command line buffer // Input : &svParameters - @@ -739,6 +752,23 @@ void CUIBaseSurface::AppendReservedCoreCount(string& svParameters) svParameters.append("-numworkerthreads \"" + this->m_WorkerThreadsTextBox->Text() + "\"\n"); } +//----------------------------------------------------------------------------- +// Purpose: +// Input : &svParameters - +//----------------------------------------------------------------------------- +void CUIBaseSurface::AppendBorderParameters(string& svParameters) +{ + if (m_bBorderParamChanged) + { + if (this->m_NoBorderToggle->Checked()) + svParameters.append("-noborder\n"); + else + svParameters.append("-forceborder\n"); + + m_bBorderParamChanged = false; + } +} + //----------------------------------------------------------------------------- // Purpose: clears the form and reloads the playlist // Input : &svParameters - @@ -827,10 +857,7 @@ eLaunchMode CUIBaseSurface::BuildParameter(string& svParameters) else svParameters.append("-fullscreen\n"); - if (this->m_NoBorderToggle->Checked()) - svParameters.append("-noborder\n"); - //else - // svParameters.append("-forceborder\n"); // !TODO: FIX IN ENGINE! + AppendBorderParameters(svParameters); if (StringIsDigit(this->m_FpsTextBox->Text().ToCString())) svParameters.append("+fps_max \"" + this->m_FpsTextBox->Text() + "\"\n"); @@ -1027,10 +1054,7 @@ eLaunchMode CUIBaseSurface::BuildParameter(string& svParameters) else svParameters.append("-fullscreen\n"); - if (this->m_NoBorderToggle->Checked()) - svParameters.append("-noborder\n"); - //else - // svParameters.append("-forceborder\n"); // !TODO: FIX IN ENGINE! + AppendBorderParameters(svParameters); if (StringIsDigit(this->m_FpsTextBox->Text().ToCString())) svParameters.append("+fps_max \"" + this->m_FpsTextBox->Text() + "\"\n"); diff --git a/r5dev/sdklauncher/basepanel.h b/r5dev/sdklauncher/basepanel.h index 2e42edc3..78cdc71a 100644 --- a/r5dev/sdklauncher/basepanel.h +++ b/r5dev/sdklauncher/basepanel.h @@ -33,10 +33,13 @@ private: static void ReloadPlaylists(Forms::Control* pSender); static void VirtualItemToClipboard(const std::unique_ptr<MouseEventArgs>& pEventArgs, Forms::Control* pSender); static void GetVirtualItem(const std::unique_ptr<Forms::RetrieveVirtualItemEventArgs>& pEventArgs, Forms::Control* pSender); + static void ForwardCommandToGame(Forms::Control* pSender); + static void BorderParametersChanged(Forms::Control* pSender); eLaunchMode BuildParameter(string& svParameter); void AppendReservedCoreCount(string& svParameter); + void AppendBorderParameters(string& svParameter); enum class eMode { @@ -105,4 +108,6 @@ private: UIX::UIXButton* m_UpdateSDK; UIX::UIXButton* m_LaunchSDK; UIX::UIXButton* m_ConsoleSendCommand; + + bool m_bBorderParamChanged; };