Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max music/sound volume #4609

Merged
merged 3 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/fheroes2/dialog/dialog_system_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,31 +270,31 @@ namespace
bool saveSoundVolume = false;
if ( Audio::isValid() ) {
if ( le.MouseClickLeft( musicVolumeRoi ) ) {
conf.SetMusicVolume( ( conf.MusicVolume() + 1 ) % 10 );
conf.SetMusicVolume( ( conf.MusicVolume() + 1 ) % 11 );
saveMusicVolume = true;
}
else if ( le.MouseWheelUp( musicVolumeRoi ) ) {
conf.SetMusicVolume( std::min( conf.MusicVolume() + 1, 9 ) );
conf.SetMusicVolume( conf.MusicVolume() + 1 );
saveMusicVolume = true;
}
else if ( le.MouseWheelDn( musicVolumeRoi ) ) {
conf.SetMusicVolume( std::max( 0, conf.MusicVolume() - 1 ) );
conf.SetMusicVolume( conf.MusicVolume() - 1 );
saveMusicVolume = true;
}
if ( saveMusicVolume ) {
Music::Volume( static_cast<int16_t>( Mixer::MaxVolume() * conf.MusicVolume() / 10 ) );
}

if ( le.MouseClickLeft( soundVolumeRoi ) ) {
conf.SetSoundVolume( ( conf.SoundVolume() + 1 ) % 10 );
conf.SetSoundVolume( ( conf.SoundVolume() + 1 ) % 11 );
saveSoundVolume = true;
}
else if ( le.MouseWheelUp( soundVolumeRoi ) ) {
conf.SetSoundVolume( std::min( conf.SoundVolume() + 1, 9 ) );
conf.SetSoundVolume( conf.SoundVolume() + 1 );
saveSoundVolume = true;
}
else if ( le.MouseWheelDn( soundVolumeRoi ) ) {
conf.SetSoundVolume( std::max( 0, conf.SoundVolume() - 1 ) );
conf.SetSoundVolume( conf.SoundVolume() - 1 );
saveSoundVolume = true;
}
if ( saveSoundVolume ) {
Expand All @@ -321,11 +321,11 @@ namespace
saveHeroSpeed = true;
}
else if ( le.MouseWheelUp( heroSpeedRoi ) ) {
conf.SetHeroesMoveSpeed( std::min( conf.HeroesMoveSpeed() + 1, 10 ) );
conf.SetHeroesMoveSpeed( conf.HeroesMoveSpeed() + 1 );
saveHeroSpeed = true;
}
else if ( le.MouseWheelDn( heroSpeedRoi ) ) {
conf.SetHeroesMoveSpeed( std::max( 1, conf.HeroesMoveSpeed() - 1 ) );
conf.SetHeroesMoveSpeed( conf.HeroesMoveSpeed() - 1 );
saveHeroSpeed = true;
}

Expand All @@ -336,11 +336,11 @@ namespace
saveAISpeed = true;
}
else if ( le.MouseWheelUp( aiSpeedRoi ) ) {
conf.SetAIMoveSpeed( std::min( conf.AIMoveSpeed() + 1, 10 ) );
conf.SetAIMoveSpeed( conf.AIMoveSpeed() + 1 );
saveAISpeed = true;
}
else if ( le.MouseWheelDn( aiSpeedRoi ) ) {
conf.SetAIMoveSpeed( std::max( 0, conf.AIMoveSpeed() - 1 ) );
conf.SetAIMoveSpeed( conf.AIMoveSpeed() - 1 );
saveAISpeed = true;
}

Expand All @@ -351,15 +351,15 @@ namespace
// set scroll speed
bool saveScrollSpeed = false;
if ( le.MouseClickLeft( scrollSpeedRoi ) ) {
conf.SetScrollSpeed( SCROLL_FAST2 > conf.ScrollSpeed() ? conf.ScrollSpeed() + 1 : SCROLL_SLOW );
conf.SetScrollSpeed( conf.ScrollSpeed() % 4 + 1 );
saveScrollSpeed = true;
}
else if ( le.MouseWheelUp( scrollSpeedRoi ) ) {
conf.SetScrollSpeed( std::min( static_cast<int>( conf.ScrollSpeed() ) + 1, static_cast<int>( SCROLL_FAST2 ) ) );
conf.SetScrollSpeed( conf.ScrollSpeed() + 1 );
saveScrollSpeed = true;
}
else if ( le.MouseWheelDn( scrollSpeedRoi ) ) {
conf.SetScrollSpeed( std::max( static_cast<int>( SCROLL_SLOW ), static_cast<int>( conf.ScrollSpeed() ) - 1 ) );
conf.SetScrollSpeed( conf.ScrollSpeed() - 1 );
saveScrollSpeed = true;
}

Expand Down
18 changes: 4 additions & 14 deletions src/fheroes2/system/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ int Settings::ScrollSpeed() const
return scroll_speed;
}

/* set ai speed: 1 - 10 */
/* set ai speed: 0 (don't show) - 10 */
void Settings::SetAIMoveSpeed( int speed )
{
ai_speed = clamp( speed, 0, 10 );
Expand Down Expand Up @@ -646,17 +646,7 @@ void Settings::setFullScreen( const bool enable )
/* set scroll speed: 1 - 4 */
void Settings::SetScrollSpeed( int speed )
{
switch ( speed ) {
case SCROLL_SLOW:
case SCROLL_NORMAL:
case SCROLL_FAST1:
case SCROLL_FAST2:
scroll_speed = speed;
break;
default:
scroll_speed = SCROLL_NORMAL;
break;
}
scroll_speed = clamp( speed, static_cast<int>( SCROLL_SLOW ), static_cast<int>( SCROLL_FAST2 ) );
}

bool Settings::isPriceOfLoyaltySupported() const
Expand Down Expand Up @@ -759,13 +749,13 @@ MusicSource Settings::MusicType() const
/* sound volume: 0 - 10 */
void Settings::SetSoundVolume( int v )
{
sound_volume = std::min( v, 10 );
sound_volume = clamp( v, 0, 10 );
}

/* music volume: 0 - 10 */
void Settings::SetMusicVolume( int v )
{
music_volume = std::min( v, 10 );
music_volume = clamp( v, 0, 10 );
}

/* Set music type: check MusicSource enum */
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/system/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "maps_fileinfo.h"
#include "players.h"

enum
enum : int
{
SCROLL_SLOW = 1,
SCROLL_NORMAL = 2,
Expand Down