Skip to content

Commit 45bac4b

Browse files
authored
[GEN][ZH] Fix and remove Scroll Speed limits (#1262)
1 parent 27f7063 commit 45bac4b

File tree

2 files changed

+40
-22
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus

2 files changed

+40
-22
lines changed

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,13 @@ Real OptionPreferences::getScrollFactor(void)
336336
return TheGlobalData->m_keyboardDefaultScrollFactor;
337337

338338
Int factor = atoi(it->second.str());
339-
if (factor < 0)
340-
factor = 0;
341-
if (factor > 100)
342-
factor = 100;
343-
339+
340+
// TheSuperHackers @tweak xezon 11/07/2025
341+
// No longer caps the upper limit to 100, because the options setting can go beyond that.
342+
// No longer caps the lower limit to 0, because that would mean standstill.
343+
if (factor < 1)
344+
factor = 1;
345+
344346
return factor/100.0f;
345347
}
346348

@@ -818,13 +820,12 @@ static void setDefaults( void )
818820

819821
//-------------------------------------------------------------------------------------------------
820822
// // scroll speed val
821-
Int valMin, valMax;
822-
// GadgetSliderGetMinMax(sliderScrollSpeed,&valMin, &valMax);
823-
// GadgetSliderSetPosition(sliderScrollSpeed, ((valMax - valMin) / 2 + valMin));
824823
Int scrollPos = (Int)(TheGlobalData->m_keyboardDefaultScrollFactor*100.0f);
825824
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
826825

827826

827+
Int valMin, valMax;
828+
828829
//-------------------------------------------------------------------------------------------------
829830
// slider music volume
830831
GadgetSliderGetMinMax(sliderMusicVolume,&valMin, &valMax);
@@ -1129,7 +1130,7 @@ static void saveOptions( void )
11291130
//-------------------------------------------------------------------------------------------------
11301131
// scroll speed val
11311132
val = GadgetSliderGetPosition(sliderScrollSpeed);
1132-
if(val != -1)
1133+
if(val > 0)
11331134
{
11341135
TheWritableGlobalData->m_keyboardScrollFactor = val/100.0f;
11351136
DEBUG_LOG(("Scroll Spped val %d, keyboard scroll factor %f", val, TheGlobalData->m_keyboardScrollFactor));
@@ -1768,9 +1769,17 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
17681769
GadgetCheckBoxSetChecked(checkAlternateMouse, TheGlobalData->m_useAlternateMouse);
17691770

17701771
// set scroll speed slider
1772+
// TheSuperHackers @tweak xezon 11/07/2025 No longer sets the slider position if the user setting
1773+
// is set beyond the slider limits. This gives the user more freedom to customize the scroll
1774+
// speed. The slider value remains 0.
17711775
Int scrollPos = (Int)(TheGlobalData->m_keyboardScrollFactor*100.0f);
1772-
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
1773-
DEBUG_LOG(("Scroll SPeed %d", scrollPos));
1776+
Int scrollMin, scrollMax;
1777+
GadgetSliderGetMinMax( sliderScrollSpeed, &scrollMin, &scrollMax );
1778+
if (scrollPos >= scrollMin && scrollPos <= scrollMax)
1779+
{
1780+
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
1781+
}
1782+
DEBUG_LOG(("Scroll Speed %d", scrollPos));
17741783

17751784
// set the send delay check box
17761785
GadgetCheckBoxSetChecked(checkSendDelay, TheGlobalData->m_firewallSendDelay);

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,13 @@ Real OptionPreferences::getScrollFactor(void)
368368
return TheGlobalData->m_keyboardDefaultScrollFactor;
369369

370370
Int factor = atoi(it->second.str());
371-
if (factor < 0)
372-
factor = 0;
373-
if (factor > 100)
374-
factor = 100;
375-
371+
372+
// TheSuperHackers @tweak xezon 11/07/2025
373+
// No longer caps the upper limit to 100, because the options setting can go beyond that.
374+
// No longer caps the lower limit to 0, because that would mean standstill.
375+
if (factor < 1)
376+
factor = 1;
377+
376378
return factor/100.0f;
377379
}
378380

@@ -864,13 +866,12 @@ static void setDefaults( void )
864866

865867
//-------------------------------------------------------------------------------------------------
866868
// // scroll speed val
867-
Int valMin, valMax;
868-
// GadgetSliderGetMinMax(sliderScrollSpeed,&valMin, &valMax);
869-
// GadgetSliderSetPosition(sliderScrollSpeed, ((valMax - valMin) / 2 + valMin));
870869
Int scrollPos = (Int)(TheGlobalData->m_keyboardDefaultScrollFactor*100.0f);
871870
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
872871

873872

873+
Int valMin, valMax;
874+
874875
//-------------------------------------------------------------------------------------------------
875876
// slider music volume
876877
GadgetSliderGetMinMax(sliderMusicVolume,&valMin, &valMax);
@@ -1189,7 +1190,7 @@ static void saveOptions( void )
11891190
//-------------------------------------------------------------------------------------------------
11901191
// scroll speed val
11911192
val = GadgetSliderGetPosition(sliderScrollSpeed);
1192-
if(val != -1)
1193+
if(val > 0)
11931194
{
11941195
TheWritableGlobalData->m_keyboardScrollFactor = val/100.0f;
11951196
DEBUG_LOG(("Scroll Spped val %d, keyboard scroll factor %f", val, TheGlobalData->m_keyboardScrollFactor));
@@ -1838,9 +1839,17 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
18381839
GadgetCheckBoxSetChecked( checkDoubleClickAttackMove, TheGlobalData->m_doubleClickAttackMove );
18391840

18401841
// set scroll speed slider
1842+
// TheSuperHackers @tweak xezon 11/07/2025 No longer sets the slider position if the user setting
1843+
// is set beyond the slider limits. This gives the user more freedom to customize the scroll
1844+
// speed. The slider value remains 0.
18411845
Int scrollPos = (Int)(TheGlobalData->m_keyboardScrollFactor*100.0f);
1842-
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
1843-
DEBUG_LOG(("Scroll SPeed %d", scrollPos));
1846+
Int scrollMin, scrollMax;
1847+
GadgetSliderGetMinMax( sliderScrollSpeed, &scrollMin, &scrollMax );
1848+
if (scrollPos >= scrollMin && scrollPos <= scrollMax)
1849+
{
1850+
GadgetSliderSetPosition( sliderScrollSpeed, scrollPos );
1851+
}
1852+
DEBUG_LOG(("Scroll Speed %d", scrollPos));
18441853

18451854
// set the send delay check box
18461855
GadgetCheckBoxSetChecked(checkSendDelay, TheGlobalData->m_firewallSendDelay);

0 commit comments

Comments
 (0)