mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-29 16:43:00 -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,
|
MakeOpt(-1, -50, "FPS mode", OnWidgetClick,
|
||||||
g => g.FpsLimit.ToString(),
|
g => g.FpsLimit.ToString(),
|
||||||
(g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v);
|
(g, v) => { }),
|
||||||
g.SetFpsLimitMethod((FpsLimitMethod)raw);
|
|
||||||
Options.Set(OptionsKey.FpsLimit, v); }),
|
|
||||||
|
|
||||||
MakeOpt(-1, 0, "View distance", OnWidgetClick,
|
MakeOpt(-1, 0, "View distance", OnWidgetClick,
|
||||||
g => g.ViewDistance.ToString(),
|
g => g.ViewDistance.ToString(),
|
||||||
@ -36,20 +34,32 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
MakeOpt(1, -50, "Names", OnWidgetClick,
|
MakeOpt(1, -50, "Names", OnWidgetClick,
|
||||||
g => g.Entities.NamesMode.ToString(),
|
g => g.Entities.NamesMode.ToString(),
|
||||||
(g, v) => { object raw = Enum.Parse(typeof(NameMode), v);
|
(g, v) => {
|
||||||
g.Entities.NamesMode = (NameMode)raw;
|
object rawNames = Enum.Parse(typeof(NameMode), v);
|
||||||
Options.Set(OptionsKey.NamesMode, v); }),
|
g.Entities.NamesMode = (NameMode)rawNames;
|
||||||
|
Options.Set(OptionsKey.NamesMode, v);
|
||||||
|
}),
|
||||||
|
|
||||||
MakeOpt(1, 0, "Shadows", OnWidgetClick,
|
MakeOpt(1, 0, "Shadows", OnWidgetClick,
|
||||||
g => g.Entities.ShadowMode.ToString(),
|
g => g.Entities.ShadowMode.ToString(),
|
||||||
(g, v) => { object raw = Enum.Parse(typeof(EntityShadow), v);
|
(g, v) => {
|
||||||
g.Entities.ShadowMode = (EntityShadow)raw;
|
object rawShadows = Enum.Parse(typeof(EntityShadow), v);
|
||||||
Options.Set(OptionsKey.EntityShadow, v); }),
|
g.Entities.ShadowMode = (EntityShadow)rawShadows;
|
||||||
|
Options.Set(OptionsKey.EntityShadow, v);
|
||||||
|
}),
|
||||||
|
|
||||||
MakeBack(false, titleFont,
|
MakeBack(false, titleFont,
|
||||||
(g, w) => g.Gui.SetNewScreen(new OptionsGroupScreen(g))),
|
(g, w) => g.Gui.SetNewScreen(new OptionsGroupScreen(g))),
|
||||||
null, null,
|
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) {
|
void SetSmoothLighting(Game g, bool v) {
|
||||||
|
@ -224,6 +224,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
string value = button.GetValue(game);
|
string value = button.GetValue(game);
|
||||||
int enumValue = (int)Enum.Parse(type, value, true);
|
int enumValue = (int)Enum.Parse(type, value, true);
|
||||||
enumValue++;
|
enumValue++;
|
||||||
|
|
||||||
// go back to first value
|
// go back to first value
|
||||||
if (!Enum.IsDefined(type, enumValue))
|
if (!Enum.IsDefined(type, enumValue))
|
||||||
enumValue = 0;
|
enumValue = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user