optimized frame limit sleep

* calculate idealFrameTime only when needed
* only create a new Stopwatch when needed
* disallow wait times > 1 second
This commit is contained in:
Matthias Mailänder
2014-01-11 09:14:31 +01:00
parent dd6b1f877d
commit 589f5297d9
2 changed files with 17 additions and 6 deletions

View File

@@ -156,6 +156,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
int.TryParse(frameLimitTextfield.Text, out fps);
ds.MaxFramerate = fps.Clamp(20, 200);
frameLimitTextfield.Text = ds.MaxFramerate.ToString();
Game.SetIdealFrameTime(ds.MaxFramerate);
};
frameLimitTextfield.OnEnterKey = () => { frameLimitTextfield.YieldKeyboardFocus(); return true; };
frameLimitTextfield.IsDisabled = () => !ds.CapFramerate;
@@ -181,6 +182,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
gs.ShowShellmap = dgs.ShowShellmap;
ds.CapFramerate = dds.CapFramerate;
Game.SetIdealFrameTime(ds.MaxFramerate);
ds.MaxFramerate = dds.MaxFramerate;
ds.Language = dds.Language;
ds.Mode = dds.Mode;