Mouse Wheel Scroll
Authors: KK20
Version: 1.0
Type: Input Add-on
Key Term: Misc System
IntroductionThis script allows the use of scrolling the mouse wheel. It was written as an extension to Blizzard's Mouse Controller:
http://forum.chaos-project.com/index.php/topic,4710.0.htmlNote that this script is not necessarily complete. It is up to you, the developer, to make use of this script's features. I only added the ability to scroll through Window_Selectable contents.
Features
- Players can scroll the mouse wheel
- Additional configuration option to allow the cursor to be visible at all times
- Windows_Selectable#update allows the ability to scroll through the windows via mouse wheel
ScreenshotsNone.
DemoNone.
Script
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Mouse Wheel Scroll for Mouse Controller
# Version: 1.0
# Type: Custom Input System
# Date: July 4 2016
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# Requires Blizzard's Mouse Controller
# http://forum.chaos-project.com/index.php/topic,4710.0.html
# Be sure the Mouse Controller is placed above this script.
#
# Features:
#
# - allows the ability to scroll the mouse wheel
# - adds an option to keep the mouse cursor constantly displayed on screen
#
# Instructions:
#
# Add the file MouseWheel.dll to your game project. Configure below.
#
# - Script Calls:
#
# The following commands are possible:
# Input.scroll_up? Returns TRUE if the wheel scrolled up
# Input.scroll_down? Returns TRUE if the wheel scrolled down
# Input.scroll? Returns TRUE if the wheel scrolled
# Input.wheel_delta Returns the number of times the wheel scrolled this
# frame (Positive for up, Negative for down)
#
# Side Note:
#
# Feel free to use this script in any way you want. If you would like the
# mouse wheel scrolling for another mouse script, you may modify this script
# accordingly.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#===============================================================================
# Mouse
#===============================================================================
class Mouse
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# If true, the Windows cursor will always be displayed over the game window.
# If HIDE_WINDOWS_CURSOR is true, this option will be ignored.
ALWAYS_VISIBLE = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
StartWheel = Win32API.new('MouseWheel', 'Initialize', 'i', 'i')
StartWheel.call(HIDE_WINDOWS_CURSOR ? 0 : (ALWAYS_VISIBLE ? 1 : 0))
WheelDelta = Win32API.new('MouseWheel', 'WheelDelta', '', 'i')
attr_reader :delta
alias init_mouse_scroll initialize
def initialize
@delta = 0
init_mouse_scroll
end
alias update_for_mouse_scroll update
def update
@delta = WheelDelta.call
update_for_mouse_scroll
end
end
#===============================================================================
# Input
#===============================================================================
module Input
def self.scroll_up?
$mouse.delta > 0
end
def self.scroll_down?
$mouse.delta < 0
end
def self.scroll?
$mouse.delta != 0
end
def self.wheel_delta
$mouse.delta
end
end
#===============================================================================
# Window_Selectable
#===============================================================================
class Window_Selectable
alias update_for_mouse_wheel update
def update
if self.active
if Input.scroll_up?
self.top_row -= 1
elsif Input.scroll_down? &&
self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
self.top_row += 1
end
end
update_for_mouse_wheel
end
end
InstructionsRequires Blizzard's Mouse Controller script (link above). The Controller should be placed above this add-on in the script list.
Download the required DLL here (includes source code):
DownloadAll other instructions in script.
CompatibilityRequires Blizzard's Mouse Controller.
Credits and Thanks
- KK20 - Script and DLL
- Blizzard - Assistance with making DLL
Author's NotesPerformance might be slow on terrible computers. I would appreciate it if people can test this for me.
If you wish to adapt this script to other existing mouse controller scripts, you are free to do so.