From 387ecab0f374b93f8195cd19cc7cb3ddfc4c7b17 Mon Sep 17 00:00:00 2001 From: IOleg-sus Date: Wed, 15 Jan 2025 15:34:14 +0200 Subject: [PATCH] added new CheatFlag(sv_cheats 1/0) --- gameui/GameUI.vpc | 4 ++++ gameui/OptionsSubModification.cpp | 25 ++++++++++++++++--------- gameui/OptionsSubModification.h | 3 ++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gameui/GameUI.vpc b/gameui/GameUI.vpc index 330e1ec7..847d2ec8 100644 --- a/gameui/GameUI.vpc +++ b/gameui/GameUI.vpc @@ -233,6 +233,10 @@ $Project "GameUI" $File "OptionsSubVideo.h" $File "OptionsSubVoice.cpp" $File "OptionsSubVoice.h" + $File "OptionsSubModificcation.cpp" + $File "OptionsSubModificcation.h" + + } $Folder "Link Libraries" diff --git a/gameui/OptionsSubModification.cpp b/gameui/OptionsSubModification.cpp index 8475bc83..f84389eb 100644 --- a/gameui/OptionsSubModification.cpp +++ b/gameui/OptionsSubModification.cpp @@ -10,11 +10,13 @@ #include "OptionsSubModification.h" #include "CvarSlider.h" +#include "CvarToggleCheckButton.h" #include "EngineInterface.h" #include #include #include "tier1/convar.h" +#include "vgui_controls/Controls.h" #include // memdbgon must be the last include file in a .cpp file!!! @@ -25,7 +27,7 @@ using namespace vgui; COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : PropertyPage(parent, nullptr) { // Create the slider for aspect ratio adjustments - m_pEnableModificationsCheckBox = new CCvarSlider( + m_pAspectRatioSlider = new CCvarSlider( this, "AspectRatioSlider", "Aspect Ratio", @@ -33,13 +35,17 @@ COptionsSubModification::COptionsSubModification(vgui::Panel *parent) : Property "r_aspectratio", true // Allow fractional values ); + m_aspectRatioLabel = new TextEntry(this, "AspectRatioLabel"); m_aspectRatioLabel->AddActionSignalTarget(this); + m_pChangeCheatFlag = new CCvarToggleCheckButton( + this , "ChangeCheatFlag" , "Change Cheat Flag" , "sv_cheats" + ); // Load settings from the associated resource file LoadControlSettings("Resource\\OptionsSubModification.res"); - UpdateLabel(m_pEnableModificationsCheckBox, m_aspectRatioLabel); + UpdateLabel(m_pAspectRatioSlider, m_aspectRatioLabel); } COptionsSubModification::~COptionsSubModification() = default; @@ -54,7 +60,7 @@ void COptionsSubModification::OnTextChanged(Panel *panel) int numParsed = sscanf(buf, "%f", &fValue); if ((numParsed == 1) && (fValue >= 0.0f)) { - m_pEnableModificationsCheckBox->SetSliderValue(fValue); + m_pAspectRatioSlider->SetSliderValue(fValue); PostActionSignal(new KeyValues("ApplyButtonEnable")); } } @@ -64,8 +70,8 @@ void COptionsSubModification::OnTextChanged(Panel *panel) //----------------------------------------------------------------------------- void COptionsSubModification::OnResetData() { - m_pEnableModificationsCheckBox->Reset(); - // m_aspectRatioLabel->Reset(); + m_pAspectRatioSlider->Reset(); + m_pChangeCheatFlag->Reset(); } //----------------------------------------------------------------------------- @@ -73,8 +79,9 @@ void COptionsSubModification::OnResetData() //----------------------------------------------------------------------------- void COptionsSubModification::OnApplyChanges() { - m_pEnableModificationsCheckBox->ApplyChanges(); - // m_aspectRatioLabel->ApplyChanges(); + m_pAspectRatioSlider->ApplyChanges(); + m_pChangeCheatFlag->ApplyChanges(); + } //----------------------------------------------------------------------------- @@ -85,9 +92,9 @@ void COptionsSubModification::OnControlModified(Panel *panel) PostActionSignal(new KeyValues("ApplyButtonEnable")); // Update the label based on slider changes - if (panel == m_pEnableModificationsCheckBox && m_pEnableModificationsCheckBox->HasBeenModified()) + if (panel == m_pAspectRatioSlider && m_pAspectRatioSlider->HasBeenModified()) { - UpdateLabel(m_pEnableModificationsCheckBox, m_aspectRatioLabel); + UpdateLabel(m_pAspectRatioSlider, m_aspectRatioLabel); } } diff --git a/gameui/OptionsSubModification.h b/gameui/OptionsSubModification.h index 7ea73039..66321fb7 100644 --- a/gameui/OptionsSubModification.h +++ b/gameui/OptionsSubModification.h @@ -76,7 +76,8 @@ private: vgui::TextEntry *m_pTouchYawSensitivityLabel; vgui::TextEntry *m_pTouchPitchSensitivityLabel; */ vgui::TextEntry *m_aspectRatioLabel; - CCvarSlider *m_pEnableModificationsCheckBox; + CCvarToggleCheckButton *m_pChangeCheatFlag; + CCvarSlider *m_pAspectRatioSlider; }; #endif // OPTIONS_SUB_MODIFICATION_H