mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-28 07:55:38 -04:00
Fix crashing when trying to change FPS mode in classic options menu, fixes #402 (Thanks mwspiker)
This commit is contained in:
parent
e542015a69
commit
54ec28136f
@ -50,9 +50,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
MakeOpt(1, 0, "FPS mode", OnWidgetClick,
|
MakeOpt(1, 0, "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); }),
|
|
||||||
|
|
||||||
!game.ClassicHacks ? null :
|
!game.ClassicHacks ? null :
|
||||||
MakeBool(0, 60, "Hacks enabled", OptionsKey.HacksEnabled,
|
MakeBool(0, 60, "Hacks enabled", OptionsKey.HacksEnabled,
|
||||||
@ -67,6 +65,11 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
MakeBack(400, "Done", 25, titleFont, (g, w) => g.Gui.SetNewScreen(new PauseScreen(g))),
|
MakeBack(400, "Done", 25, titleFont, (g, w) => g.Gui.SetNewScreen(new PauseScreen(g))),
|
||||||
null, null,
|
null, null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NOTE: we need to override the default setter here, because changing FPS limit method
|
||||||
|
// recreates the graphics context on some backends (such as Direct3D9)
|
||||||
|
ButtonWidget btn = (ButtonWidget)widgets[7];
|
||||||
|
btn.SetValue = SetFPSLimitMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeValidators() {
|
void MakeValidators() {
|
||||||
|
@ -57,16 +57,6 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
btn.SetValue = SetFPSLimitMethod;
|
btn.SetValue = SetFPSLimitMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFPSLimitMethod(Game g, string v) {
|
|
||||||
object rawFps = Enum.Parse(typeof(FpsLimitMethod), v);
|
|
||||||
g.SetFpsLimitMethod((FpsLimitMethod)rawFps);
|
|
||||||
Options.Set(OptionsKey.FpsLimit, v);
|
|
||||||
|
|
||||||
// NOTE: OpenGL backend doesn't recreate context, so cheat and act like recreated anyways
|
|
||||||
ContextLost();
|
|
||||||
ContextRecreated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSmoothLighting(Game g, bool v) {
|
void SetSmoothLighting(Game g, bool v) {
|
||||||
g.SmoothLighting = v;
|
g.SmoothLighting = v;
|
||||||
ChunkMeshBuilder builder = g.MapRenderer.DefaultMeshBuilder();
|
ChunkMeshBuilder builder = g.MapRenderer.DefaultMeshBuilder();
|
||||||
|
@ -254,5 +254,15 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
widgets[okayIndex].Dispose();
|
widgets[okayIndex].Dispose();
|
||||||
widgets[okayIndex] = null;
|
widgets[okayIndex] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void SetFPSLimitMethod(Game g, string v) {
|
||||||
|
object rawFps = Enum.Parse(typeof(FpsLimitMethod), v);
|
||||||
|
g.SetFpsLimitMethod((FpsLimitMethod)rawFps);
|
||||||
|
Options.Set(OptionsKey.FpsLimit, v);
|
||||||
|
|
||||||
|
// NOTE: OpenGL backend doesn't recreate context, so cheat and act like recreated anyways
|
||||||
|
ContextLost();
|
||||||
|
ContextRecreated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user