09-04-2023, 10:35 PM (This post was last modified: 09-21-2023, 02:34 PM by DerVVulfman.)
ALEWORKS INPUT MOUSE SPRITE ADD-ON
<For use with Aleworks Input Mouse 2.03> Version: 1.2
Introduction
This script is an add-on to vgvgf's AleWorks Input Module (or AIM for short).
While the AIM system was relatively complete and let one use their system's mouse, entering full-screen mode with RPGMaker XP would eliminate the mouse sprite. Essentially, you would only have the default system sprite while in a windowed mode.
This system does not allow you to use the system mouse while in full-screen mode. Rather, it erases/hides the system mouse sprite upon execution, and replaces the sprite with one within a new Graphics\Mouse folder which can be cached. Said sprite will be visible in both full-screen and windowed modes.
Features
Hides the old mouse cursor
Creates a new Sprite_Mouse class which generates a new mouse cursor
The new mouse will be visible in both full-screen and windowed modes
Tracks the mouse within the Input module for simple menu use
Screenshots
A screenshot? It would show just a mouse cursor IN the game window.
Script
"script"
Code:
#==============================================================================
# ** ALEWORKS INPUT MOUSE SPRITE ADD-ON
#------------------------------------------------------------------------------
# by DerVVulfman
# Version 1.2 (2023/09/21) YYYY/MM/DD
# RPGMaker XP & VGVGF'S AIM 2.03 REQUIRED (not AWorks)
#==============================================================================
#
# PURPOSE & FUNCTION
#
# This script is an add-on to VGVGF's AleWorks Input Module (or AIM for short).
#
# While the AIM system was relatively complete and let one use their system's
# mouse, entering full-screen mode with RPGMaker XP would eliminate the mouse
# sprite. Essentially, you would only have the default system sprite while in
# a windowed mode.
#
# This system does not allow you to use the system mouse while in full-screen
# mode. Rather, it erases/hides the system mouse sprite upon execution, and
# replaces the sprite with one within a new Graphics\Mouse folder which can be
# cached. Said sprite will be visible in both full-screen and windowed modes.
#
#
#==============================================================================
#=============================================================================
# ** Module Aleworks Config (Named after the system)
#=============================================================================
module Aleworks
# Default Cursor in Mouse folder
BASE_MOUSE_CURSOR = "Cursor"
# Z-Depth of cursor
MOUSE_CURSOR_DEPTH = 12000
end
#==============================================================================
# ** Input
#------------------------------------------------------------------------------
# A module that handles input data from a gamepad or keyboard. This update
# adds old mouse sprite removal and tracking for users of vgvgf's AIM 2.03.
#==============================================================================
module Input
#-------------------------------------------------------------------------
# * APIs Definitions
#-------------------------------------------------------------------------
@cursor_show = Win32API.new('user32', 'ShowCursor', 'L', 'i')
#-------------------------------------------------------------------------
# * Alias Listings
#-------------------------------------------------------------------------
class << Input
alias old_update update unless $@
end
#--------------------------------------------------------------------------
# * Hide the PC's default mouse using the Win32API call
#--------------------------------------------------------------------------
def Input.hide_os_mouse
@cursor_show.call(0)
end
#--------------------------------------------------------------------------
# * Frame Update (handling the update of the custom mouse sprite)
#--------------------------------------------------------------------------
def self.update
old_update
$mouse_sprite.update
end
end
#==============================================================================
# ** RPG::Cache
#------------------------------------------------------------------------------
# Data class that handles the creation and retention of bitmaps within the
# RPG module.
#==============================================================================
module RPG::Cache
#--------------------------------------------------------------------------
# * Load Cached Resource (mouse)
# filename : filename
# hue : hue
#--------------------------------------------------------------------------
def self.mouse(filename, hue=0)
begin
# Load filename as normal
self.load_bitmap("Graphics/Mouse/", filename, hue)
rescue
# Load/create 32x32 blank if filename not found
self.load_bitmap("Graphics/Mouse/", "", hue)
end
end
end
#==============================================================================
# ** Sprite_Mouse
#------------------------------------------------------------------------------
# This sprite is used to display the mouse.
#==============================================================================
class Sprite_Mouse < RPG::Sprite
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
#--------------------------------------------------------------------------
def initialize
super
update_icon_bitmap(Aleworks::BASE_MOUSE_CURSOR)
Input.hide_os_mouse
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose unless self.bitmap.nil?
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_visible?
return if Input.mouse_x?.nil?
return if Input.mouse_y?.nil?
self.x = Input.mouse_x?
self.y = Input.mouse_y?
self.z = Aleworks::MOUSE_CURSOR_DEPTH
update_icon
end
#--------------------------------------------------------------------------
# * Frame Update (when mouse arrow is/isn't in the window)
#--------------------------------------------------------------------------
def update_visible?
visible = true
visible = false if Input.mouse_x?.nil? || Input.mouse_y?.nil?
self.visible = visible
end
#--------------------------------------------------------------------------
# * Frame Update (When detecting if mouse over map event)
#--------------------------------------------------------------------------
def update_icon
update_icon_bitmap(Aleworks::BASE_MOUSE_CURSOR)
end
#--------------------------------------------------------------------------
# * Frame Update (When changing mouse cursor)
#--------------------------------------------------------------------------
def update_icon_bitmap(mouse_cursor)
cursor = mouse_cursor
return if @old_cursor == cursor
@old_cursor = cursor
self.bitmap = RPG::Cache.mouse(cursor)
end
end
# Just add the mouse globally
$mouse_sprite = Sprite_Mouse.new
Instructions
Generally, place this below vgvgf's Aleworks collection of scripts and above Main for this to work.
REQUIRES: You include a .png file within a new Graphics\Mouse folder, and have its name match that within the script's configuration.
FAQ
This is stripped down from other works that I have, and quite similar to the MKXP mouse script from last week. However, it uses Win32API calls that MKXP cannot support.
Compatibility
For use specifically with the Aleworks Input package, and not the AWorks system which requires an accompanying .dll.
Credits and Thanks
To Aleworks/vgvgf who made the initial system, but had not introduced a separate mouse sprite generating system.
Terms and Conditions
Free for use.... PERIOD!
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
A minor issue with the mouse cursor that existed with the script was that the cursor would be stuck on an edge of the screen when you moved your mouse away from the gaming window. It was essentially... UGLY. And I thought, why not just hide the mouse sprite?
The new update adds a visibility routine that hides the mouse sprite when the mouse is off-screen, and returns its visible state when the mouse returns to the gaming window.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
A simple, error-preventing change was made to the system, one which also allows a bit more freedom to anyone adapting this script for their use. This change is that the cache system's method that loads the mouse cursor has been updated to accommodate two factors.
First, the mouse cache method now recognizes an optional hue parameter. Like the Pictures, Characters, and Battlers cache values, the mouse too can be loaded into memory with a hue shift from 0-360. This could be useful for those who adapt the script to change the mouse's appearance according to the end-user's whims. But it is solely optional, and not including a hue value within the command to load the cursor will result in the graphic loaded pure.
And second, the mouse cache method will not crash the project if the end-user neglects to supply the actual cursor graphic for the mouse, or supplies incorrect filenames if the mouse cursor graphic is meant to change. If an error in loading the cursor graphic occurs, the system will instead generate and store away a 32x32px blank image in its place.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)