[XP] Mouse Wheel Scroll

Started by KK20, July 04, 2016, 04:40:27 am

Previous topic - Next topic

KK20

July 04, 2016, 04:40:27 am Last Edit: March 25, 2017, 01:04:42 am by KK20
Mouse Wheel Scroll
Authors: KK20
Version: 1.0
Type: Input Add-on
Key Term: Misc System



Introduction

This 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.html

Note 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




Screenshots

None.


Demo

None.


Script

Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 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



Instructions

Requires 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): Download
All other instructions in script.


Compatibility

Requires Blizzard's Mouse Controller.



Credits and Thanks


  • KK20 - Script and DLL

  • Blizzard - Assistance with making DLL




Author's Notes

Performance 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.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo


http://imgur.com/3Y8otkW

it seems... not compatible with my Windows 7 Ultimate (Service Pack 1)

Script used :

RTP
Custom Control (Ripped from Tons)
Mouse Controller
Mouse Wheel Scroll


Blizzard

KK20, you should probably check my linker settings in XPA_Window. Mine works on XP SP3 and higher.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

KK20

But does this only apply to this script or all my DLLs? I wonder if it has anything to do with the window events or creating a thread.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Blizzard

Likely all DLLs if you are using the same compilation settings. I set up mine to use the minimum of dependencies and to link to static libs so no extra stuff is needed. Handling window events and creating a thread shouldn't be a problem. Though, it might not be a bad idea to run Game.exe as admin to see if that is the problem.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

KK20

August 29, 2016, 04:42:14 pm #5 Last Edit: August 30, 2016, 01:28:57 am by KK20
I just installed a Win7Ultimatex64 VM to test it out. I think I uploaded the wrong version of the DLL, one that was using some optimization [-O2] (this is set by default :\ ). On my Windows10, it just gave me a critical error.

Anyways, the version I've been using for my tests is here: -removed-

Worked on my end.
I'll update the dropbox link when I get back home.
Edit: Done.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

LiTTleDRAgo