Merge pull request #3852 from myk002/myk_overlay

[overlay] support dynamic onupdate frequency adjustments
develop
Myk 2023-10-07 19:15:30 -07:00 committed by GitHub
commit c287fcca06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

@ -61,6 +61,7 @@ Template for new versions:
## Fixes ## Fixes
## Misc Improvements ## Misc Improvements
- `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates
## Documentation ## Documentation

@ -135,7 +135,10 @@ The ``overlay.OverlayWidget`` superclass defines the following class attributes:
seconds) that your widget can take to react to changes in information and seconds) that your widget can take to react to changes in information and
not annoy the player. Set to 0 to be called at the maximum rate. Be aware not annoy the player. Set to 0 to be called at the maximum rate. Be aware
that running more often than you really need to will impact game FPS, that running more often than you really need to will impact game FPS,
especially if your widget can run while the game is unpaused. especially if your widget can run while the game is unpaused. If you change
the value of this attribute dynamically, it may not be noticed until the
previous timeout expires. However, if you need a burst of high-frequency
updates, set it to ``0`` and it will be noticed immediately.
Registering a widget with the overlay framework Registering a widget with the overlay framework
*********************************************** ***********************************************

@ -433,8 +433,12 @@ end
-- reduces the next call by a small random amount to introduce jitter into the -- reduces the next call by a small random amount to introduce jitter into the
-- widget processing timings -- widget processing timings
local function do_update(name, db_entry, now_ms, vs) local function do_update(name, db_entry, now_ms, vs)
if db_entry.next_update_ms > now_ms then return end
local w = db_entry.widget local w = db_entry.widget
if w.overlay_onupdate_max_freq_seconds ~= 0 and
db_entry.next_update_ms > now_ms
then
return
end
db_entry.next_update_ms = get_next_onupdate_timestamp(now_ms, w) db_entry.next_update_ms = get_next_onupdate_timestamp(now_ms, w)
if detect_frame_change(w, function() return w:overlay_onupdate(vs) end) then if detect_frame_change(w, function() return w:overlay_onupdate(vs) end) then
if register_trigger_lock_screen(w:overlay_trigger(), name) then if register_trigger_lock_screen(w:overlay_trigger(), name) then