From: DeaDDooMER Date: Sun, 10 Sep 2023 14:01:18 +0000 (+0300) Subject: gl: repaint map area on idle X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=8884087574b816e115a2de2b6ba33056c18886c7;p=d2df-editor.git gl: repaint map area on idle --- diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index bf92c22..0c912cf 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -271,6 +271,7 @@ type procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); private + LastDrawTime: UInt64; procedure Draw(); procedure OnIdle(Sender: TObject; var Done: Boolean); procedure RefillRecentMenu (menu: TMenuItem; start: Integer; fmt: AnsiString); @@ -2671,6 +2672,7 @@ var s: String; begin Randomize(); + LastDrawTime := 0; {$IFDEF DARWIN} miApple.Enabled := True; @@ -2891,6 +2893,7 @@ var ObjCount: Word; aX, aY, aX2, aY2, XX, ScaleSz: Integer; begin + LastDrawTime := GetTickCount64(); ID := 0; PID := 0; Width := 0; @@ -6719,8 +6722,15 @@ begin end; procedure TMainForm.OnIdle(Sender: TObject; var Done: Boolean); + const MaxFPS = 60; var f: AnsiString; begin + // TODO: move refresh to user actions (ask to repaint only when something changed) + if GetTickCount64() - LastDrawTime >= 1000 div MaxFPS then + begin + PanelMap.Refresh; + end; + if StartMap <> '' then begin f := StartMap;