Found and fixed a couple bugs. For one, if you change the volume and then hit cancel instead of OK, the volume will not instantly revert to the original value, You will have to reopen the options dialog and tick the volume one more time to get the volume to adjust appropriately.
Also, if you turn the volume all the way down and keep pressing, you will get one extra black bar that goes past the intended range (there's also a weird double-adding blue bar issue at the top of the range).
The first bug can be fixed by scrolling to line 290 where this function is defined:
Spoiler: code
def command_ok
case @window_command.index
when 0
$game_options.save_options
$game_options.clear_memorize
return_scene
when 1
$game_options.copy_memorize
$game_options.clear_memorize
return_scene
end
end
And adding one line like so:
Spoiler: code
def command_ok
case @window_command.index
when 0
$game_options.save_options
$game_options.clear_memorize
return_scene
when 1
$game_options.copy_memorize
$game_options.clear_memorize
$game_map.autoplay if $game_map && $game_map.map_id > 0
return_scene
end
end
The other issue can be fixed by going to line 420 where we see:
Spoiler: code
def refresh(temp_value)
contents.clear
temp_value *= 100
temp_value.to_i.times do |i|
rect = Rect.new(4+i*4,6,2,8)
contents.fill_rect(rect, Color.new(75,100,255))
end
(100-temp_value).to_i.times do |i|
rect = Rect.new(396-i*4,6,2,8)
contents.fill_rect(rect, Color.new(0,0,0))
end
draw_text(0,0,contents.width,24,temp_value.to_i.to_s + "%",2)
end
Simply change the 396 to 400 and both instances of ".to_i" with ".round" like so:
Spoiler: code
def refresh(temp_value)
contents.clear
temp_value *= 100
temp_value.round.times do |i|
rect = Rect.new(4+i*4,6,2,8)
contents.fill_rect(rect, Color.new(75,100,255))
end
(100-temp_value).round.times do |i|
rect = Rect.new(400-i*4,6,2,8)
contents.fill_rect(rect, Color.new(0,0,0))
end
draw_text(0,0,contents.width,24,temp_value.to_i.to_s + "%",2)
end
I was quite surprised myself to find that the .to_round was necessary, but due to some nuances of floating point arithmetic (which you can read about here:
http://floating-point-gui.de/), we get new weird errors if we only change 396 to 400. .round turns 1.999999 into 2 where .to_i turns it into 1.
Anyway, thanks so much for making this script! I've had a couple playtesters request volume controls, so i was thrilled to see this up for free and allowed in commercial games. Thanks!