Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion change-refresh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function changeRefresh(width, height, rate, display)
options.pause > 0 and not mp.get_property_bool("pause")
and not ( tostring(var.current_height) == height and
tostring(var.current_width) == width and
tostring(math.floor(mp.get_property_number('display-fps'))) == rate
tostring(math.floor(mp.get_property_number('display-fps') + 0.5)) == rate
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little risky, the framerate of the video is also rounded down, because that is what nircmd expects. Rounding up here could cause comparison issues. Shouldn't this be solved by removing 60 from the list of valid rates in your config options? If the highest is 59 then it should detect that the display is already at this rate and not try to change anything.

)
then
mp.set_property_bool("pause", true)
Expand Down Expand Up @@ -482,6 +482,20 @@ function toggleFpsType()
return
end

--toggles between auto being on or off
function toggleAuto()
if options.auto then
options.auto = false
osdMessage("[Change-Refresh] auto fps change is disabled")
msg.info("now disabled auto fps change")
else
options.auto = true
osdMessage("[Change-Refresh] auto fps change is enabled")
msg.info("now enabled auto fps change")
end
return
end

Comment on lines +485 to +498
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested how this interacts with script-opt on_update changes to the auto option?

--runs the script automatically on startup if option is enabled
function autoChange()
if options.auto then
Expand Down Expand Up @@ -520,6 +534,9 @@ mp.add_key_binding("", 'toggle-fps-type', toggleFpsType)
--set the current resolution and refresh rate as the default
mp.add_key_binding("", "set-default-refresh", setDefault)

--switches between auto changing fps or not
mp.add_key_binding("", 'toggle-auto', toggleAuto)

--sends a command to switch to the specified display rate
--syntax is: script-message change-refresh [width] [height] [rate] [display]
mp.register_script_message("change-refresh", scriptMessage)
Expand Down