Fix sounds/music volume not saving, partially addresses #448.

This commit is contained in:
UnknownShadow200 2017-06-25 09:10:09 +10:00
parent eadac08d0a
commit 58db2f667a

View file

@ -27,12 +27,10 @@ namespace ClassicalSharp.Gui.Screens {
(g, v) => g.LocalPlayer.ReachDistance = Utils.ParseDecimal(v)), (g, v) => g.LocalPlayer.ReachDistance = Utils.ParseDecimal(v)),
MakeOpt(-1, -50, "Music volume", OnWidgetClick, MakeOpt(-1, -50, "Music volume", OnWidgetClick,
g => g.MusicVolume.ToString(), g => g.MusicVolume.ToString(), SetMusicVolume),
(g, v) => { g.MusicVolume = Int32.Parse(v); g.AudioPlayer.SetMusic(g.MusicVolume); }),
MakeOpt(-1, 0, "Sounds volume", OnWidgetClick, MakeOpt(-1, 0, "Sounds volume", OnWidgetClick,
g => g.SoundsVolume.ToString(), g => g.SoundsVolume.ToString(), SetSoundsVolume),
(g, v) => { g.SoundsVolume = Int32.Parse(v); g.AudioPlayer.SetSounds(g.SoundsVolume); }),
MakeBool(-1, 50, "View bobbing", OptionsKey.ViewBobbing, MakeBool(-1, 50, "View bobbing", OptionsKey.ViewBobbing,
OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v), OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v),
@ -83,5 +81,17 @@ namespace ClassicalSharp.Gui.Screens {
"&fThe default click distance is 5 blocks.", "&fThe default click distance is 5 blocks.",
}; };
} }
void SetMusicVolume(Game g, string v) {
g.MusicVolume = Int32.Parse(v);
Options.Set(OptionsKey.MusicVolume, v);
g.AudioPlayer.SetMusic(g.MusicVolume);
}
void SetSoundsVolume(Game g, string v) {
g.SoundsVolume = Int32.Parse(v);
Options.Set(OptionsKey.SoundsVolume, v);
g.AudioPlayer.SetSounds(g.SoundsVolume);
}
} }
} }