Advertisement
DaxSoft

dsi_cursor

Oct 28th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.05 KB | None | 0 0
  1. =begin
  2. Default cursor icon to selectable window
  3. &beta
  4. =end
  5. Ligni.register(:dsi_cursor, "dax", 0.1, [[:dsi, "dax"]]) {
  6.     # [sprite]
  7.     class Sprite_DSCursor < Sprite
  8.         # [pos]
  9.         attr_accessor :pos
  10.         # [init]
  11.         def initialize
  12.            super("S: #{DS::SETUP[:MENU][:CURSOR][:PICTURE]}")
  13.            @move = false
  14.            @x = 0.0
  15.            @pos = 0.position
  16.            self.visible = false
  17.         end
  18.         # [update]
  19.         def update
  20.             return unless visible
  21.             super
  22.             unless @move
  23.                 @x += DS::SETUP[:MENU][:CURSOR][:SPEED] unless @x >= 5.0
  24.                 @move = true if @x >= 5.0
  25.             else
  26.                 @x -= DS::SETUP[:MENU][:CURSOR][:SPEED]  unless @x <= 0.0
  27.                 @move = false if @x <= 0.0
  28.             end
  29.             self.x = (@pos.x + @x) + DS::SETUP[:MENU][:CURSOR][:POS][0]
  30.             self.y = @pos.y + DS::SETUP[:MENU][:CURSOR][:POS][1]
  31.         end
  32.     end
  33.     # [window_selectable]
  34.     class Window_Selectable < Window_Base
  35.         # sprite_cursor
  36.         attr_accessor :sprite_cursor
  37.         # start
  38.         alias :dsi_cursor_init :initialize
  39.         def initialize(*args, &block)
  40.             dsi_cursor_init(*args, &block)
  41.             @sprite_cursor = Sprite_DSCursor.new
  42.         end  
  43.         # dispose
  44.         alias :dsi_cursor_dis :dispose
  45.         def dispose
  46.             dsi_cursor_dis
  47.             @sprite_cursor.dispose
  48.         end
  49.         # update
  50.         alias :dsi_cursor_upt :update
  51.         def update
  52.             dsi_cursor_upt
  53.             @sprite_cursor.visible = self.active && self.visible
  54.             uptsc
  55.         end
  56.         # [uptsc]
  57.         def uptsc
  58.             return unless @sprite_cursor.visible
  59.             @sprite_cursor.pos.x = self.x + self.cursor_rect.x
  60.             _y = cursor_rect.y - self.oy
  61.             @sprite_cursor.pos.y = self.y + _y + (@sprite_cursor.height)
  62.             @sprite_cursor.update
  63.             @sprite_cursor.z = self.z
  64.         end
  65.     end
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement