mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-27 23:41:14 -04:00
Fix crash when changing FPS limit mode
This commit is contained in:
parent
d798322db4
commit
bf1cdfddf1
@ -23,9 +23,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
MakeOpt(-1, -50, "FPS mode", OnWidgetClick,
|
||||
g => g.FpsLimit.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v);
|
||||
g.SetFpsLimitMethod((FpsLimitMethod)raw);
|
||||
Options.Set(OptionsKey.FpsLimit, v); }),
|
||||
(g, v) => { }),
|
||||
|
||||
MakeOpt(-1, 0, "View distance", OnWidgetClick,
|
||||
g => g.ViewDistance.ToString(),
|
||||
@ -36,20 +34,32 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
MakeOpt(1, -50, "Names", OnWidgetClick,
|
||||
g => g.Entities.NamesMode.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse(typeof(NameMode), v);
|
||||
g.Entities.NamesMode = (NameMode)raw;
|
||||
Options.Set(OptionsKey.NamesMode, v); }),
|
||||
(g, v) => {
|
||||
object rawNames = Enum.Parse(typeof(NameMode), v);
|
||||
g.Entities.NamesMode = (NameMode)rawNames;
|
||||
Options.Set(OptionsKey.NamesMode, v);
|
||||
}),
|
||||
|
||||
MakeOpt(1, 0, "Shadows", OnWidgetClick,
|
||||
g => g.Entities.ShadowMode.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse(typeof(EntityShadow), v);
|
||||
g.Entities.ShadowMode = (EntityShadow)raw;
|
||||
Options.Set(OptionsKey.EntityShadow, v); }),
|
||||
(g, v) => {
|
||||
object rawShadows = Enum.Parse(typeof(EntityShadow), v);
|
||||
g.Entities.ShadowMode = (EntityShadow)rawShadows;
|
||||
Options.Set(OptionsKey.EntityShadow, v);
|
||||
}),
|
||||
|
||||
MakeBack(false, titleFont,
|
||||
(g, w) => g.Gui.SetNewScreen(new OptionsGroupScreen(g))),
|
||||
null, null,
|
||||
};
|
||||
|
||||
// NOTE: we need to override the default setter here, because it recreates the graphics context
|
||||
ButtonWidget btn = (ButtonWidget)widgets[0];
|
||||
btn.SetValue = (g, v) => {
|
||||
object rawFps = Enum.Parse(typeof(FpsLimitMethod), v);
|
||||
g.SetFpsLimitMethod((FpsLimitMethod)rawFps);
|
||||
Options.Set(OptionsKey.FpsLimit, v);
|
||||
};
|
||||
}
|
||||
|
||||
void SetSmoothLighting(Game g, bool v) {
|
||||
|
@ -224,6 +224,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
string value = button.GetValue(game);
|
||||
int enumValue = (int)Enum.Parse(type, value, true);
|
||||
enumValue++;
|
||||
|
||||
// go back to first value
|
||||
if (!Enum.IsDefined(type, enumValue))
|
||||
enumValue = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user