Window Cursor Sprite

Introduction

This is a neat little extra to add to your game, it allows you to set cursors to any and all of your selectable windows. The customization is super simple, wether you want to use one constant cursor throughout all of your window scenes, or you want all of your windows to each have their own special cursor, its up to you! Since there are many cursors of all shapes and sizes, its easy to line up the coordinates just how you need them without EVER having to edit/hardcode it into the script! Lastly (although I chose to leave mine on) you can even decide if you'd like to hide the actual Cursor Rect from your windowskin while using this script.

Instructions

Place this script anywhere below SDK (XP if using) and above 'main' at the bottom of your scripts page. You can set which directory you would like to list your cursor images in the settings module (its "Graphics/Windowskins/Cursors/" by default). The settings module prettymuch explains itself, its the easiest thing in the world.

Sceenshots

XP Version Spoiler
Image

VX Version Spoiler
Image


Script

'Window.CursorSprite' (XP w/ SDK) Spoiler
  1. #===============================================================================
  2. # ** Window Cursor Sprite                                                          (by Kain Nobel)
  3. #===============================================================================
  4.  
  5. #-------------------------------------------------------------------------------
  6. # * SDK Log
  7. #-------------------------------------------------------------------------------
  8. SDK.log('Window.CursorSprite', 'Kain Nobel', 2.5, '12.02.2008')
  9. #-------------------------------------------------------------------------------
  10. # * SDK Enabled Test - BEGIN
  11. #-------------------------------------------------------------------------------
  12. if SDK.enabled?('Window.CursorSprite')
  13.  
  14. #===============================================================================
  15. # ** Window::Cursor
  16. #===============================================================================
  17.  
  18. module Window::Cursor
  19.   #-----------------------------------------------------------------------------
  20.   # * Directory = "Graphics/..."
  21.   #-----------------------------------------------------------------------------
  22.   Directory = "Graphics/Windowskins/Cursors"
  23.   #-----------------------------------------------------------------------------
  24.   # * Hide_Cursor_Rect
  25.   #-----------------------------------------------------------------------------
  26.   Hide_SRCRect = false
  27.   #-----------------------------------------------------------------------------
  28.   # * Enabled    = {"Window_???" => true/false}
  29.   #-----------------------------------------------------------------------------
  30.   Enabled = {}
  31.   Enabled.default = true
  32.   #-----------------------------------------------------------------------------
  33.   # * Filenames = {"Window_???" => "filename"}
  34.   #-----------------------------------------------------------------------------
  35.   Filenames = {}
  36.   Filenames.default = "Cursor"
  37.   #-----------------------------------------------------------------------------
  38.   # * Delay       = {"Window_???" => (Integer)} (*Note : Set as 1 or higher)
  39.   #-----------------------------------------------------------------------------
  40.   Delay = {}
  41.   Delay.default = 5
  42.   #-----------------------------------------------------------------------------
  43.   # * OX     = {"Filename" => (Integer)}
  44.   #-----------------------------------------------------------------------------
  45.   OX = {}
  46.   OX.default = 0
  47.   #-----------------------------------------------------------------------------
  48.   # * OY     = {"Filename" => (Integer)}
  49.   #-----------------------------------------------------------------------------
  50.   OY = {}
  51.   OY.default = 16
  52.   #-----------------------------------------------------------------------------
  53.   # * Mirror = {"Filename" => true/false}
  54.   #-----------------------------------------------------------------------------
  55.   Mirror = {}
  56.   Mirror.default = false
  57.   #-----------------------------------------------------------------------------
  58.   # * Angle = {"Filename" => (Numeric)} (*Note: Anything between 0 and 360)
  59.   #-----------------------------------------------------------------------------
  60.   Angle = {}
  61.   Angle.default = 0
  62.   #-----------------------------------------------------------------------------
  63.   # * Opaq    = {"Filename" => (Integer)}
  64.   #-----------------------------------------------------------------------------
  65.   Opaq = {}
  66.   Opaq.default = 200
  67.   #-----------------------------------------------------------------------------
  68.   # * MissingError = true/false
  69.   #-----------------------------------------------------------------------------
  70.   MissingError = true
  71. end
  72.  
  73. #===============================================================================
  74. # ** Window_Selectable
  75. #===============================================================================
  76.  
  77. class Window_Selectable < Window_Base
  78.   #-----------------------------------------------------------------------------
  79.   # * Public Instance Variables
  80.   #-----------------------------------------------------------------------------
  81.   attr_accessor :cursor_image
  82.   #-----------------------------------------------------------------------------
  83.   # * Alias Listings
  84.   #-----------------------------------------------------------------------------
  85.   alias_method :cursor_winselect_initialize,   :initialize
  86.   alias_method :cursor_winselect_dispose,        :dispose
  87.   alias_method :cursor_winselect_update,         :update
  88.   #-----------------------------------------------------------------------------
  89.   # * Object Initialization
  90.   #-----------------------------------------------------------------------------
  91.   def initialize(*arguments)
  92.      cursor_winselect_initialize(*arguments)
  93.      if cursor_sprite_enabled?
  94.         @cursor_sprite = Sprite_CursorSelectable.new(self)
  95.      end
  96.      @cursor_image = cursor_sprite_image?
  97.   end
  98.   #-----------------------------------------------------------------------------
  99.   # * X = (n)
  100.   #-----------------------------------------------------------------------------
  101.   def x=(n)
  102.      super
  103.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  104.         @cursor_sprite.x = cursor_sprite_x?
  105.      end
  106.   end
  107.   #-----------------------------------------------------------------------------
  108.   # * Y = (n)
  109.   #-----------------------------------------------------------------------------
  110.   def y=(n)
  111.      super
  112.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  113.         @cursor_sprite.y = cursor_sprite_y?
  114.      end
  115.   end
  116.   #-----------------------------------------------------------------------------
  117.   # * Dispose
  118.   #-----------------------------------------------------------------------------
  119.   def dispose
  120.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  121.         @cursor_sprite.dispose
  122.      end
  123.      cursor_winselect_dispose
  124.   end
  125.   #-----------------------------------------------------------------------------
  126.   # * Update
  127.   #-----------------------------------------------------------------------------
  128.   def update
  129.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  130.         @cursor_sprite.update
  131.      end
  132.      cursor_winselect_update
  133.   end
  134.   #-----------------------------------------------------------------------------
  135.   # * Cursor Sprite Enabled ?
  136.   #-----------------------------------------------------------------------------
  137.   def cursor_sprite_enabled?
  138.      return Window::Cursor::Enabled[self.class.to_s]
  139.   end
  140.   #-----------------------------------------------------------------------------
  141.   # * Cursor Sprite Image ?
  142.   #-----------------------------------------------------------------------------
  143.   def cursor_sprite_image?
  144.      return Window::Cursor::Filenames[self.class.to_s]
  145.   end
  146.   #-----------------------------------------------------------------------------
  147.   # * Cursor Sprite X ?
  148.   #-----------------------------------------------------------------------------
  149.   def cursor_sprite_x?
  150.      return self.cursor_rect.x + self.x + Window::Cursor::OX[@cursor_image]
  151.   end
  152.   #-----------------------------------------------------------------------------
  153.   # * Cursor Sprite Y ?
  154.   #-----------------------------------------------------------------------------
  155.   def cursor_sprite_y?
  156.      return self.cursor_rect.y + self.y + Window::Cursor::OY[@cursor_image]
  157.   end
  158.   #-----------------------------------------------------------------------------
  159.   # * Cursor Sprite Visible ?
  160.   #-----------------------------------------------------------------------------
  161.   def cursor_sprite_visible?
  162.      return false unless self.index >= 0 && cursor_sprite_enabled?
  163.      return (self.visible && self.opacity > 0)
  164.   end
  165.   #-----------------------------------------------------------------------------
  166.   # * Cursor Sprite Opacity ?
  167.   #-----------------------------------------------------------------------------
  168.   def cursor_sprite_opacity?
  169.      opacity = [Window::Cursor::Opaq[self.class.to_s], 1].max
  170.      return (self.active && self.index >= 0 ? opacity : opacity / 2)
  171.   end
  172.   #-----------------------------------------------------------------------------
  173.   # * Cursor Sprite Delay ?
  174.   #-----------------------------------------------------------------------------
  175.   def cursor_sprite_delay?
  176.      return [Window::Cursor::Delay[self.class.to_s], 1].max
  177.   end
  178. end
  179.  
  180. #===============================================================================
  181. # ** Sprite_CursorSelectable
  182. #===============================================================================
  183.  
  184. class Sprite_CursorSelectable < Sprite
  185.   #-----------------------------------------------------------------------------
  186.   # * Object Initialization
  187.   #-----------------------------------------------------------------------------
  188.   def initialize(window)
  189.      super()
  190.      @window = window
  191.      self.x = @window.cursor_sprite_x?
  192.      self.y = @window.cursor_sprite_y?
  193.      update
  194.   end
  195.   #-----------------------------------------------------------------------------
  196.   # * Update Bitmap
  197.   #-----------------------------------------------------------------------------
  198.   def update_bitmap
  199.      unless self.bitmap.nil? || self.bitmap.disposed?
  200.         self.bitmap.dispose
  201.         self.bitmap = nil
  202.      end
  203.      @cursor_image = @window.cursor_image
  204.      self.bitmap = RPG::Cache.window_cursor(@cursor_image)
  205.      self.mirror = Window::Cursor::Mirror[@cursor_image]
  206.      self.angle  = Window::Cursor::Angle[@cursor_image]
  207.   end
  208.   #-----------------------------------------------------------------------------
  209.   # * Update : X
  210.   #-----------------------------------------------------------------------------
  211.   def update_x
  212.      ox, delay = @window.cursor_sprite_x?, @window.cursor_sprite_delay?
  213.      n = [(self.x < ox ? (ox - self.x) : (self.x - ox)) / delay, 1].max
  214.      self.x += (self.x < ox ? n : -n)
  215.   end
  216.   #-----------------------------------------------------------------------------
  217.   # * Update : Y
  218.   #-----------------------------------------------------------------------------
  219.   def update_y
  220.      oy, delay = @window.cursor_sprite_y?, @window.cursor_sprite_delay?
  221.      n = [(self.y < oy ? (oy - self.y) : (self.y - oy)) / delay, 1].max
  222.      self.y += (self.y < oy ? n : -n)
  223.   end
  224.   #-----------------------------------------------------------------------------
  225.   # * Update
  226.   #-----------------------------------------------------------------------------
  227.   def update
  228.      super
  229.      update_bitmap if @cursor_image != @window.cursor_image
  230.      update_x        if self.x != @window.cursor_sprite_x?
  231.      update_y        if self.y != @window.cursor_sprite_y?
  232.      self.opacity = @window.cursor_sprite_opacity?
  233.      self.visible = @window.cursor_sprite_visible?
  234.      self.z = (@window.z + 5)
  235.   end
  236. end
  237.  
  238. #===============================================================================
  239. # ** Scene_File
  240. #===============================================================================
  241.  
  242. class Scene_File < SDK::Scene_Base
  243.   #-----------------------------------------------------------------------------
  244.   # * Alias Listings
  245.   #-----------------------------------------------------------------------------
  246.   alias_method :cursor_scnfile_mainsprite, :main_sprite
  247.   alias_method :cursor_scnfile_update,        :update
  248.   #-----------------------------------------------------------------------------
  249.   # ** Main Sprite
  250.   #-----------------------------------------------------------------------------
  251.   def main_sprite
  252.      cursor_scnfile_mainsprite
  253.      if Window::Cursor::Enabled["Window_SaveFile"]
  254.         @cursor_sprite = Sprite.new
  255.         @cursor_image = Window::Cursor::Filenames["Window_SaveFile"]
  256.         @cursor_sprite.bitmap = RPG::Cache.window_cursor(@cursor_image)
  257.         @cursor_sprite.mirror = Window::Cursor::Mirror[@cursor_image]
  258.         @cursor_sprite.angle  = Window::Cursor::Angle[@cursor_image]
  259.      end
  260.   end
  261.   #-----------------------------------------------------------------------------
  262.   # * Selected Window?
  263.   #-----------------------------------------------------------------------------
  264.   def selected_window?
  265.      for i in 0...@savefile_windows.size
  266.         if @savefile_windows[i].selected == true
  267.            return @savefile_windows[i]
  268.         end
  269.      end
  270.   end
  271.   #-----------------------------------------------------------------------------
  272.   # * Update
  273.   #-----------------------------------------------------------------------------
  274.   def update
  275.      cursor_scnfile_update
  276.      w, c = selected_window?, @cursor_sprite
  277.      oy = w.cursor_rect.y + w.y + Window::Cursor::OY[@cursor_image]
  278.      c.x = w.cursor_rect.x + w.x + Window::Cursor::OX[@cursor_image]
  279.      c.z = (w.z + 5)
  280.      if c.y != oy
  281.         @cs_delay ||= Window::Cursor::Delay["Window_SaveFile"]
  282.         n = [(c.y < oy ? (oy - c.y) : (c.y - oy)) / @cs_delay, 1].max
  283.         c.y += (c.y < oy ? n : -n)
  284.      end
  285.   end
  286. end
  287.  
  288. #===============================================================================
  289. # ** RPG::Cache
  290. #===============================================================================
  291.  
  292. module RPG::Cache
  293.   #-----------------------------------------------------------------------------
  294.   # * Alias Listings
  295.   #-----------------------------------------------------------------------------
  296.   class << self
  297.      alias_method :cursor_rpgcache_windowskin, :windowskin
  298.   end
  299.   #-----------------------------------------------------------------------------
  300.   # * RPG::Cache.windowskin
  301.   #-----------------------------------------------------------------------------
  302.   def self.windowskin(filename)
  303.      bitmap = cursor_rpgcache_windowskin(filename)
  304.      if Window::Cursor::Hide_SRCRect
  305.         bitmap.fill_rect(128, 64, 32, 32, Color.new(0,0,0,0))
  306.      end
  307.      return bitmap
  308.   end
  309.   #-----------------------------------------------------------------------------
  310.   # * RPG::Cache.window_cursor(filename)
  311.   #-----------------------------------------------------------------------------
  312.   def self.window_cursor(filename)
  313.      directory = Window::Cursor::Directory
  314.      if directory.length > 0
  315.         unless directory[-1] == "/"
  316.            directory += "/"
  317.         end
  318.      end
  319.      begin
  320.         unless Dir.exists?(directory)
  321.            Dir.mkdir(directory)
  322.         end
  323.         self.load_bitmap(directory, filename)
  324.      rescue
  325.         if Window::Cursor::MissingError
  326.            self.load_bitmap(directory, filename)
  327.         end
  328.      end
  329.   end
  330. end
  331.  
  332. #-------------------------------------------------------------------------------
  333. # * SDK Enabled Test - END
  334. #-------------------------------------------------------------------------------
  335. end
Expand to see the code.

'Window.CursorSprite (XP w/o SDK) Spoiler
Its the same as above, just replace Scene_File in the SDK Version with...

  1. #===============================================================================
  2. # ** Scene_File
  3. #===============================================================================
  4.  
  5. class Scene_File
  6.   #-----------------------------------------------------------------------------
  7.   # * Alias Listings
  8.   #-----------------------------------------------------------------------------
  9.   alias_method :cursor_scnfile_main,           :main
  10.   alias_method :cursor_scnfile_update,        :update
  11.   #-----------------------------------------------------------------------------
  12.   # ** Main Sprite
  13.   #-----------------------------------------------------------------------------
  14.   def main
  15.      if Window::Cursor::Enabled["Window_SaveFile"]
  16.         @cursor_sprite = Sprite.new
  17.         @cursor_image = Window::Cursor::Filenames["Window_SaveFile"]
  18.         @cursor_sprite.bitmap = RPG::Cache.window_cursor(@cursor_image)
  19.         @cursor_sprite.mirror = Window::Cursor::Mirror[@cursor_image]
  20.         @cursor_sprite.angle  = Window::Cursor::Angle[@cursor_image]
  21.      end
  22.      cursor_scnfile_main
  23.   end
  24.   #-----------------------------------------------------------------------------
  25.   # * Selected Window?
  26.   #-----------------------------------------------------------------------------
  27.   def selected_window?
  28.      for i in 0...@savefile_windows.size
  29.         if @savefile_windows[i].selected == true
  30.            return @savefile_windows[i]
  31.         end
  32.      end
  33.   end
  34.   #-----------------------------------------------------------------------------
  35.   # * Update
  36.   #-----------------------------------------------------------------------------
  37.   def update
  38.      cursor_scnfile_update
  39.      w, c = selected_window?, @cursor_sprite
  40.      oy = w.cursor_rect.y + w.y + Window::Cursor::OY[@cursor_image]
  41.      c.x = w.cursor_rect.x + w.x + Window::Cursor::OX[@cursor_image]
  42.      c.z = (w.z + 5)
  43.      if c.y != oy
  44.         @cs_delay ||= Window::Cursor::Delay["Window_SaveFile"]
  45.         n = [(c.y < oy ? (oy - c.y) : (c.y - oy)) / @cs_delay, 1].max
  46.         c.y += (c.y < oy ? n : -n)
  47.      end
  48.   end
  49. end
Expand to see the code.


...Then delete the SDK.log, SDK.enabled? test and the last 'end' in the script.

'Window.CursorSprite' (VX) Spoiler
  1. #===============================================================================
  2. # ** Window Cursor Sprite
  3. #===============================================================================
  4. # Written by  : Kain Nobel
  5. # Version       : 2.5
  6. # Last Update : 12.02.2008
  7. #===============================================================================
  8.  
  9. #===============================================================================
  10. # ** Window::Cursor
  11. #===============================================================================
  12.  
  13. module Window::Cursor
  14.   #-----------------------------------------------------------------------------
  15.   # * Directory = "Graphics/..."
  16.   #-----------------------------------------------------------------------------
  17.   Directory = "Graphics/System"
  18.   #-----------------------------------------------------------------------------
  19.   # * Enabled    = {"Window_???" => true/false}
  20.   #-----------------------------------------------------------------------------
  21.   Enabled = {}
  22.   Enabled.default = true
  23.   #-----------------------------------------------------------------------------
  24.   # * Hide_Cursor_Rect
  25.   #-----------------------------------------------------------------------------
  26.   Hide_SRCRect = true
  27.   #-----------------------------------------------------------------------------
  28.   # * Filenames = {"Window_???" => "filename"}
  29.   #-----------------------------------------------------------------------------
  30.   Filenames = {}
  31.   Filenames.default = "Cursor"
  32.   #-----------------------------------------------------------------------------
  33.   # * Delay       = {"Window_???" => (Integer)} (*Note : Set as 1 or higher)
  34.   #-----------------------------------------------------------------------------
  35.   Delay = {}
  36.   Delay.default = 5
  37.   #-----------------------------------------------------------------------------
  38.   # * OX     = {"Filename" => (Integer)}
  39.   #-----------------------------------------------------------------------------
  40.   OX = {}
  41.   OX.default = 0
  42.   #-----------------------------------------------------------------------------
  43.   # * OY     = {"Filename" => (Integer)}
  44.   #-----------------------------------------------------------------------------
  45.   OY = {}
  46.   OY.default = 16
  47.   #-----------------------------------------------------------------------------
  48.   # * Mirror = {"Filename" => true/false}
  49.   #-----------------------------------------------------------------------------
  50.   Mirror = {}
  51.   Mirror.default = false
  52.   #-----------------------------------------------------------------------------
  53.   # * Angle = {"Filename" => (Numeric)} (*Note: Anything between 0 and 360)
  54.   #-----------------------------------------------------------------------------
  55.   Angle = {}
  56.   Angle.default = 0
  57.   #-----------------------------------------------------------------------------
  58.   # * Opaq    = {"Filename" => (Integer)}
  59.   #-----------------------------------------------------------------------------
  60.   Opaq = {}
  61.   Opaq.default = 200
  62.   #-----------------------------------------------------------------------------
  63.   # * MissingError = true/false
  64.   #-----------------------------------------------------------------------------
  65.   MissingError = true
  66. end
  67.  
  68. #===============================================================================
  69. # ** Window_Selectable
  70. #===============================================================================
  71.  
  72. class Window_Selectable < Window_Base
  73.   #-----------------------------------------------------------------------------
  74.   # * Public Instance Variables
  75.   #-----------------------------------------------------------------------------
  76.   attr_accessor :cursor_image
  77.   #-----------------------------------------------------------------------------
  78.   # * Alias Listings
  79.   #-----------------------------------------------------------------------------
  80.   alias_method :cursor_winselect_initialize,   :initialize
  81.   alias_method :cursor_winselect_dispose,        :dispose
  82.   alias_method :cursor_winselect_update,         :update
  83.   #-----------------------------------------------------------------------------
  84.   # * Object Initialization
  85.   #-----------------------------------------------------------------------------
  86.   def initialize(*arguments)
  87.      cursor_winselect_initialize(*arguments)
  88.      if cursor_sprite_enabled?
  89.         @cursor_sprite = Sprite_CursorSelectable.new(self)
  90.      end
  91.      @cursor_image = cursor_sprite_image?
  92.   end
  93.   #-----------------------------------------------------------------------------
  94.   # * X = (n)
  95.   #-----------------------------------------------------------------------------
  96.   def x=(n)
  97.      super
  98.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  99.         @cursor_sprite.x = cursor_sprite_x?
  100.      end
  101.   end
  102.   #-----------------------------------------------------------------------------
  103.   # * Y = (n)
  104.   #-----------------------------------------------------------------------------
  105.   def y=(n)
  106.      super
  107.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  108.         @cursor_sprite.y = cursor_sprite_y?
  109.      end
  110.   end
  111.   #-----------------------------------------------------------------------------
  112.   # * Dispose
  113.   #-----------------------------------------------------------------------------
  114.   def dispose
  115.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  116.         @cursor_sprite.dispose
  117.      end
  118.      cursor_winselect_dispose
  119.   end
  120.   #-----------------------------------------------------------------------------
  121.   # * Update
  122.   #-----------------------------------------------------------------------------
  123.   def update
  124.      unless @cursor_sprite.nil? || @cursor_sprite.disposed?
  125.         @cursor_sprite.update
  126.      end
  127.      cursor_winselect_update
  128.   end
  129.   #-----------------------------------------------------------------------------
  130.   # * Cursor Sprite Enabled ?
  131.   #-----------------------------------------------------------------------------
  132.   def cursor_sprite_enabled?
  133.      return Window::Cursor::Enabled[self.class.to_s]
  134.   end
  135.   #-----------------------------------------------------------------------------
  136.   # * Cursor Sprite Image ?
  137.   #-----------------------------------------------------------------------------
  138.   def cursor_sprite_image?
  139.      return Window::Cursor::Filenames[self.class.to_s]
  140.   end
  141.   #-----------------------------------------------------------------------------
  142.   # * Cursor Sprite X ?
  143.   #-----------------------------------------------------------------------------
  144.   def cursor_sprite_x?
  145.      return self.cursor_rect.x + self.x + Window::Cursor::OX[@cursor_image]
  146.   end
  147.   #-----------------------------------------------------------------------------
  148.   # * Cursor Sprite Y ?
  149.   #-----------------------------------------------------------------------------
  150.   def cursor_sprite_y?
  151.      return self.cursor_rect.y + self.y + Window::Cursor::OY[@cursor_image]
  152.   end
  153.   #-----------------------------------------------------------------------------
  154.   # * Cursor Sprite Visible ?
  155.   #-----------------------------------------------------------------------------
  156.   def cursor_sprite_visible?
  157.      return false unless self.index >= 0 && cursor_sprite_enabled?
  158.      return (self.visible && self.opacity > 0)
  159.   end
  160.   #-----------------------------------------------------------------------------
  161.   # * Cursor Sprite Opacity ?
  162.   #-----------------------------------------------------------------------------
  163.   def cursor_sprite_opacity?
  164.      opacity = [Window::Cursor::Opaq[self.class.to_s], 1].max
  165.      return (self.active && self.index >= 0 ? opacity : opacity / 2)
  166.   end
  167.   #-----------------------------------------------------------------------------
  168.   # * Cursor Sprite Delay ?
  169.   #-----------------------------------------------------------------------------
  170.   def cursor_sprite_delay?
  171.      return [Window::Cursor::Delay[self.class.to_s], 1].max
  172.   end
  173. end
  174.  
  175. #===============================================================================
  176. # ** Sprite_CursorSelectable
  177. #===============================================================================
  178.  
  179. class Sprite_CursorSelectable < Sprite
  180.   #-----------------------------------------------------------------------------
  181.   # * Object Initialization
  182.   #-----------------------------------------------------------------------------
  183.   def initialize(window)
  184.      super()
  185.      @window = window
  186.      self.x = @window.cursor_sprite_x?
  187.      self.y = @window.cursor_sprite_y?
  188.      update
  189.   end
  190.   #-----------------------------------------------------------------------------
  191.   # * Update Bitmap
  192.   #-----------------------------------------------------------------------------
  193.   def update_bitmap
  194.      unless self.bitmap.nil? || self.bitmap.disposed?
  195.         self.bitmap.dispose
  196.         self.bitmap = nil
  197.      end
  198.      @cursor_image = @window.cursor_image
  199.      self.bitmap = Cache.window_cursor(@cursor_image)
  200.      self.mirror = Window::Cursor::Mirror[@cursor_image]
  201.      self.angle  = Window::Cursor::Angle[@cursor_image]
  202.   end
  203.   #-----------------------------------------------------------------------------
  204.   # * Update : X
  205.   #-----------------------------------------------------------------------------
  206.   def update_x
  207.      ox, delay = @window.cursor_sprite_x?, @window.cursor_sprite_delay?
  208.      n = [(self.x < ox ? (ox - self.x) : (self.x - ox)) / delay, 1].max
  209.      self.x += (self.x < ox ? n : -n)
  210.   end
  211.   #-----------------------------------------------------------------------------
  212.   # * Update : Y
  213.   #-----------------------------------------------------------------------------
  214.   def update_y
  215.      oy, delay = @window.cursor_sprite_y?, @window.cursor_sprite_delay?
  216.      n = [(self.y < oy ? (oy - self.y) : (self.y - oy)) / delay, 1].max
  217.      self.y += (self.y < oy ? n : -n)
  218.   end
  219.   #-----------------------------------------------------------------------------
  220.   # * Update
  221.   #-----------------------------------------------------------------------------
  222.   def update
  223.      super
  224.      update_bitmap if @cursor_image != @window.cursor_image
  225.      update_x        if self.x != @window.cursor_sprite_x?
  226.      update_y        if self.y != @window.cursor_sprite_y?
  227.      self.opacity = @window.cursor_sprite_opacity?
  228.      self.visible = @window.cursor_sprite_visible?
  229.      self.z = (@window.z + 5)
  230.   end
  231. end
  232.  
  233. #===============================================================================
  234. # ** Scene_File
  235. #===============================================================================
  236.  
  237. class Scene_File < Scene_Base
  238.   #-----------------------------------------------------------------------------
  239.   # * Alias Listings
  240.   #-----------------------------------------------------------------------------
  241.   alias_method :cursor_scnfile_start,         :start
  242.   alias_method :cursor_scnfile_terminate,   :terminate
  243.   alias_method :cursor_scnfile_update,        :update
  244.   #-----------------------------------------------------------------------------
  245.   # ** Main Sprite
  246.   #-----------------------------------------------------------------------------
  247.   def start
  248.      cursor_scnfile_start
  249.      if Window::Cursor::Enabled["Window_SaveFile"]
  250.         @cursor_sprite = Sprite.new
  251.         @cursor_image = Window::Cursor::Filenames["Window_SaveFile"]
  252.         begin
  253.            @cursor_sprite.bitmap = Cache.window_cursor(@cursor_image)
  254.            @cursor_sprite.mirror = Window::Cursor::Mirror[@cursor_image]
  255.            @cursor_sprite.angle  = Window::Cursor::Angle[@cursor_image]
  256.         rescue
  257.            if Window::Cursor::MissingError
  258.               @cursor_sprite.bitmap = Cache.window_cursor(@cursor_image)
  259.            end
  260.         end
  261.      end
  262.   end
  263.   #-----------------------------------------------------------------------------
  264.   # * Selected Window?
  265.   #-----------------------------------------------------------------------------
  266.   def selected_window?
  267.      for i in 0...@savefile_windows.size
  268.         if @savefile_windows[i].selected == true
  269.            return @savefile_windows[i]
  270.         end
  271.      end
  272.   end
  273.   #-----------------------------------------------------------------------------
  274.   # * Terminate
  275.   #-----------------------------------------------------------------------------
  276.   def terminate
  277.      cursor_scnfile_terminate
  278.      @cursor_sprite.dispose
  279.   end
  280.   #-----------------------------------------------------------------------------
  281.   # * Update
  282.   #-----------------------------------------------------------------------------
  283.   def update
  284.      cursor_scnfile_update
  285.      w, c = selected_window?, @cursor_sprite
  286.      oy = w.cursor_rect.y + w.y + Window::Cursor::OY[@cursor_image]
  287.      c.x = w.cursor_rect.x + w.x + Window::Cursor::OX[@cursor_image]
  288.      c.z = (w.z + 5)
  289.      if c.y != oy
  290.         @cs_delay ||= Window::Cursor::Delay["Window_SaveFile"]
  291.         n = [(c.y < oy ? (oy - c.y) : (c.y - oy)) / @cs_delay, 1].max
  292.         c.y += (c.y < oy ? n : -n)
  293.      end
  294.   end
  295. end
  296.  
  297. #===============================================================================
  298. # ** Cache
  299. #===============================================================================
  300.  
  301. module Cache
  302.   #-----------------------------------------------------------------------------
  303.   # * Alias Listings
  304.   #-----------------------------------------------------------------------------
  305.   class << self
  306.      alias_method :cursor_cache_system, :system
  307.   end
  308.   #-----------------------------------------------------------------------------
  309.   # * Cache.system
  310.   #-----------------------------------------------------------------------------
  311.   def self.system(filename)
  312.      bitmap = cursor_cache_system(filename)
  313.      if Window::Cursor::Hide_SRCRect && filename == "Window"
  314.         bitmap.clear_rect(64, 64, 32, 32)
  315.      end
  316.      return bitmap
  317.   end
  318.   #-----------------------------------------------------------------------------
  319.   # * Cache.window_cursor(filename)
  320.   #-----------------------------------------------------------------------------
  321.   def self.window_cursor(filename)
  322.      directory = Window::Cursor::Directory
  323.      if directory.length > 0
  324.         unless directory[-1] == "/"
  325.            directory += "/"
  326.         end
  327.      end
  328.      begin
  329.         unless Dir.exists?(directory)
  330.            Dir.mkdir(directory)
  331.         end
  332.         self.load_bitmap(directory, filename)
  333.      rescue
  334.         if Window::Cursor::MissingError
  335.            self.load_bitmap(directory, filename)
  336.         end
  337.      end
  338.   end
  339. end
Expand to see the code.


http://i224.photobucket.com/albums/dd28 ... cursor.png[/img]
I believe credit goes to gRaJiVa for the finger?

Author's Notes

Free to use in commercial and non-commercial games, please remember to credit me and have fun :thumb:
Very cool your script Kain ^ ^
I see that you are very good in that area of programming in RGSS, you have classes created for you?
But back into the topic, that your script is quite simple, which makes the game more and more legal and professional, parabens Kain and continue posting your scripts, because I love them ^ ^
Great script, can you make it animated cursor :D
Yes, I was thinking of doing animated cursor so I'll be happy to implement it :)

Glad you both like it so far!
I hope its okay I'm making a day early bump, its just a tiny update I forgot to do with the script so go ahead and update your copies...

If you're in battle, you may notice the cursor remains after the actor command window is gone (or you've probably experienced this in other scenes maybe, a cursor on an otherwise invisible window).

Either copy the updated script above, or just simply search for "def cursor_sprite_visible?" and change the definition to...

  def cursor_sprite_visible?
    return false unless self.index >= 0 && cursor_sprite_enabled?
    return (self.visible && self.opacity > 0)
  end
Expand to see the code.


Enjoy! :thumb:

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=59350