11#include " GameSettingsManager.hpp"
2- #include < MulNX/Base/UI/UI.hpp>
32
43bool GameSettingsManager::Window () {
54 auto w = MulNX::UI::RAIIWindow (I18n (" ui.game_settings" ).c_str ());
65
7- ImGui::Checkbox (" 作弊模式" , this -> settings . sv_cheats );
8- ImGui::SliderInt (" FPS上限" , this -> settings . fps_max , 0 , 1000 );
9- ImGui::SliderFloat (" 游戏速度" , this -> settings . host_timescale , 0 .001f , 10 .000f );
10- ImGui::Checkbox (" 真实视角" , this -> settings . cl_demo_predict );
6+ ConvarCheckbox< " sv_cheats " > (" 作弊模式" );
7+ ConvarSliderFloat< " fps_max " > (" FPS上限" , 0 , 1000 );
8+ ConvarSliderFloat< " host_timescale " > (" 游戏速度" , 0 .001f , 10 .000f );
9+ ConvarCheckbox< " cl_demo_predict " > (" 真实视角" );
1110
1211 ImGui::SeparatorText (" CS2控制台" );
1312 if (ImGui::Button (" 解限所有CS2控制台变量" )) {
@@ -39,25 +38,25 @@ bool GameSettingsManager::Window() {
3938}
4039
4140bool GameSettingsManager::SoundMenu () {
42- ImGui::Checkbox (" 游戏窗口失去焦点时静音" , this -> settings . snd_mute_losefocus );
41+ ConvarCheckbox< " snd_mute_losefocus " > (" 游戏窗口失去焦点时静音" );
4342
4443 ImGui::SeparatorText (" 音乐设置" );
45- ImGui::SliderFloat (" 主菜单音量" , this -> settings . snd_menumusic_volume , 0 .0f , 1 .0f , " %.2f " );
46- ImGui::SliderFloat (" 回合开始音量" , this -> settings . snd_roundstart_volume , 0 .0f , 1 .0f , " %.2f " );
47- ImGui::SliderFloat (" 回合开始行动音量" , this -> settings . snd_roundaction_volume , 0 .0f , 1 .0f , " %.2f " );
48- ImGui::SliderFloat (" 回合结束音量" , this -> settings . snd_roundend_volume , 0 .0f , 1 .0f , " %.2f " );
49- ImGui::SliderFloat (" MVP音量" , this -> settings . snd_mvp_volume , 0 .0f , 1 .0f , " %.2f " );
50- ImGui::SliderFloat (" 炸弹/人质音量" , this -> settings . snd_mapobjective_volume , 0 .0f , 1 .0f , " %.2f " );
51- ImGui::SliderFloat (" 十秒警告音量" , this -> settings . snd_tensecondwarning_volume , 0 .0f , 1 .0f , " %.2f " );
52- ImGui::SliderFloat (" 死亡视角音量" , this -> settings . snd_deathcamera_volume , 0 .0f , 1 .0f , " %.2f " );
53- ImGui::Checkbox (" 当双方团队成员都存活时关闭MVP音乐" , this -> settings . snd_mute_mvp_music_live_players );
44+ ConvarSliderFloat< " snd_menumusic_volume " > (" 主菜单音量" , 0 .0f , 1 .0f );
45+ ConvarSliderFloat< " snd_roundstart_volume " > (" 回合开始音量" , 0 .0f , 1 .0f );
46+ ConvarSliderFloat< " snd_roundaction_volume " > (" 回合开始行动音量" , 0 .0f , 1 .0f );
47+ ConvarSliderFloat< " snd_roundend_volume " > (" 回合结束音量" , 0 .0f , 1 .0f );
48+ ConvarSliderFloat< " snd_mvp_volume " > (" MVP音量" , 0 .0f , 1 .0f );
49+ ConvarSliderFloat< " snd_mapobjective_volume " > (" 炸弹/人质音量" , 0 .0f , 1 .0f );
50+ ConvarSliderFloat< " snd_tensecondwarning_volume " > (" 十秒警告音量" , 0 .0f , 1 .0f );
51+ ConvarSliderFloat< " snd_deathcamera_volume " > (" 死亡视角音量" , 0 .0f , 1 .0f );
52+ ConvarCheckbox< " snd_mute_mvp_music_live_players " > (" 当双方团队成员都存活时关闭MVP音乐" );
5453
5554 return true ;
5655}
5756
5857bool GameSettingsManager::DofMenu () {
5958 ImGui::SeparatorText (" 景深控制" );
60- ImGui::Checkbox (" 启用景深" , this -> settings . r_dof_override );
59+ ConvarCheckbox< " r_dof_override " > (" 启用景深" );
6160
6261 bool DOFChange = false ;
6362 DOFChange |= ImGui::SliderFloat (" 聚焦距离" , &this ->FocusDistance , 0 , 5000 );
@@ -67,40 +66,40 @@ bool GameSettingsManager::DofMenu() {
6766 MulNX::Math::DOFParam Param;
6867 MulNX::Math::CalculateDOFParameters (this ->FocusDistance , this ->CrispRadius , this ->BlurDistance , Param);
6968
70- *this ->settings . r_dof_override_near_blurry = Param.NearBlurry ;// 近模糊
71- *this ->settings . r_dof_override_near_crisp = Param.NearCrisp ;// 近清晰
72- *this ->settings . r_dof_override_far_crisp = Param.FarCrisp ;// 远清晰
73- *this ->settings . r_dof_override_far_blurry = Param.FarBlurry ;// 远模糊
69+ *this ->r_dof_override_near_blurry = Param.NearBlurry ;// 近模糊
70+ *this ->r_dof_override_near_crisp = Param.NearCrisp ;// 近清晰
71+ *this ->r_dof_override_far_crisp = Param.FarCrisp ;// 远清晰
72+ *this ->r_dof_override_far_blurry = Param.FarBlurry ;// 远模糊
7473 }
7574
7675 ImGui::SeparatorText (" 调整上方参数,自动计算并应用以下参数:" );
7776
78- ImGui::SliderFloat (" r_dof_override_far_blurry" , this ->settings . r_dof_override_far_blurry , 0 , 5000 );
79- ImGui::SliderFloat (" r_dof_override_far_crisp" , this ->settings . r_dof_override_far_crisp , 0 , 5000 );
80- ImGui::SliderFloat (" r_dof_override_near_crisp" , this ->settings . r_dof_override_near_crisp , 0 , 5000 );
81- ImGui::SliderFloat (" r_dof_override_near_blurry" , this ->settings . r_dof_override_near_blurry , 0 , 5000 );
77+ ImGui::SliderFloat (" r_dof_override_far_blurry" , this ->r_dof_override_far_blurry , 0 , 5000 );
78+ ImGui::SliderFloat (" r_dof_override_far_crisp" , this ->r_dof_override_far_crisp , 0 , 5000 );
79+ ImGui::SliderFloat (" r_dof_override_near_crisp" , this ->r_dof_override_near_crisp , 0 , 5000 );
80+ ImGui::SliderFloat (" r_dof_override_near_blurry" , this ->r_dof_override_near_blurry , 0 , 5000 );
8281 ImGui::Separator ();
83- ImGui::SliderFloat ( " r_dof_override_tilt_to_ground" , this -> settings . r_dof_override_tilt_to_ground , 0 , 5000 );
82+ ConvarSliderFloat< " r_dof_override_tilt_to_ground" >( " r_dof_override_tilt_to_ground" , 0 , 5000 );
8483
8584 return true ;
8685}
8786
8887bool GameSettingsManager::GameHudMenu () {
8988 ImGui::SeparatorText (" 游戏HUD设置" );
9089
91- ImGui::Checkbox (" 显示HUD" , this -> settings . cl_drawhud );
92- ImGui::Checkbox (" 只渲染击杀信息" , this -> settings . cl_draw_only_deathnotices );
93- ImGui::SliderInt (" 展示FPS" , this -> settings . cl_showfps , 0 , 3 , " %d " );
94- ImGui::SliderInt (" 展示Tick" , this -> settings . cl_showtick , 0 , 3 , " %d " );
95- ImGui::SliderInt (" TrueView控制" , this -> settings . cl_trueview_show_status , 0 , 2 );
96- ImGui::SliderInt (" 观战X光" , this -> settings . spec_show_xray , 0 , 100 );
90+ ConvarCheckbox< " cl_drawhud " > (" 显示HUD" );
91+ ConvarCheckbox< " cl_draw_only_deathnotices " > (" 只渲染击杀信息" );
92+ ConvarSliderInt< " cl_showfps " > (" 展示FPS" , 0 , 3 );
93+ ConvarSliderInt< " cl_showtick " > (" 展示Tick" , 0 , 3 );
94+ ConvarSliderInt< " cl_trueview_show_status " > (" TrueView控制" , 0 , 2 );
95+ ConvarSliderInt< " spec_show_xray " > (" 观战X光" , 0 , 100 );
9796
98- ImGui::Checkbox (" 强制雷达渲染" , this -> settings . cl_drawhud_force_radar );
99- ImGui::Checkbox (" 在观战时使用方形雷达" , this -> settings . cl_radar_square_when_spectating );
100- ImGui::Checkbox (" 永远使用方形雷达" , this -> settings . cl_radar_square_always );
101- ImGui::Checkbox (" 雷达在观战时显示所有人" , this -> settings . cl_radar_show_all_players_when_spectating );
97+ ConvarCheckbox< " cl_drawhud_force_radar " > (" 强制雷达渲染" );
98+ ConvarCheckbox< " cl_radar_square_when_spectating " > (" 在观战时使用方形雷达" );
99+ ConvarCheckbox< " cl_radar_square_always " > (" 永远使用方形雷达" );
100+ ConvarCheckbox< " cl_radar_show_all_players_when_spectating " > (" 雷达在观战时显示所有人" );
102101
103- ImGui::Checkbox (" 准星" , this -> settings . crosshair );
102+ ConvarCheckbox< " crosshair " > (" 准星" );
104103 if (ImGui::Button (" 切换Demo进度条UI显示" )) {
105104 this ->AsyncCommand (" demoui" );
106105 }
@@ -109,14 +108,18 @@ bool GameSettingsManager::GameHudMenu() {
109108
110109bool GameSettingsManager::Init () {
111110 this ->SubscribeSync (" Hook/Source2Client002::Inited" , [this ](MulNX::Message& msg) {
112- this ->settings .Init (this ->CS2Con );
113-
114- *this ->settings .cl_trueview_show_status = 0 ;
115- *this ->settings .cl_radar_show_all_players_when_spectating = false ;
116- *this ->settings .cl_radar_square_always = false ;
117- *this ->settings .cl_radar_square_when_spectating = false ;
118- *this ->settings .cl_demo_predict = false ;
119- *this ->settings .cl_spec_show_bindings = false ;
111+
112+ this ->r_dof_override_near_blurry = this ->CS2Con ->GetCvar (" r_dof_override_near_blurry" )->GetPtr <float >();
113+ this ->r_dof_override_near_crisp = this ->CS2Con ->GetCvar (" r_dof_override_near_crisp" )->GetPtr <float >();
114+ this ->r_dof_override_far_crisp = this ->CS2Con ->GetCvar (" r_dof_override_far_crisp" )->GetPtr <float >();
115+ this ->r_dof_override_far_blurry = this ->CS2Con ->GetCvar (" r_dof_override_far_blurry" )->GetPtr <float >();
116+
117+ *this ->CS2Con ->GetCvar (" cl_trueview_show_status" )->GetPtr <int >() = 0 ;
118+ *this ->CS2Con ->GetCvar (" cl_radar_show_all_players_when_spectating" )->GetPtr <bool >() = false ;
119+ *this ->CS2Con ->GetCvar (" cl_radar_square_always" )->GetPtr <bool >() = false ;
120+ *this ->CS2Con ->GetCvar (" cl_radar_square_when_spectating" )->GetPtr <bool >() = false ;
121+ *this ->CS2Con ->GetCvar (" cl_demo_predict" )->GetPtr <bool >() = false ;
122+ *this ->CS2Con ->GetCvar (" cl_spec_show_bindings" )->GetPtr <bool >() = false ;
120123
121124 this ->SendUIRoot (this ->GetName (), [this ](auto &&...) {return this ->Window ();});
122125 this ->UIRegisterCallback (" UI.Sound" , [this ](auto &&...) {return this ->SoundMenu ();});
0 commit comments