Advertisement
Vlue

Animated Icons

Apr 25th, 2014
1,854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.97 KB | None | 0 0
  1. #Animated Icons v1.1
  2. #----------#
  3. #Features: This script let's you set up and use animated icons! Woot!
  4. #
  5. #Usage:   Set up the frames below and set your icons. Animated!
  6. #
  7. #----------#
  8. #-- Script by: V.M of D.T
  9. #
  10. #- Questions or comments can be:
  11. #    posted on the thread for the script
  12. #    given by email: sumptuaryspade@live.ca
  13. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  14. #
  15. #--- Free to use in any project, commercial or non-commercial, with credit given
  16. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  17.  
  18. # Base_index => [icon_index1, icon_index2, icon_index3, ... ],
  19. ANIMATED_ICONS = {
  20.  528 => [528, 529, 530, 531, 532, 533, 534, 535, 528, 528, 528],
  21.  544 => [544, 545, 546, 547, 546, 545, 544, 544, 544, 544],
  22.  560 => [560, 561, 562, 563, 564, 565, 566, 560, 560],
  23.  576 => [576, 577, 578, 579, 580, 581, 580, 579, 578, 577, 576, 576],
  24.  592 => [592, 593, 594, 595, 596, 596, 594, 592, 593, 592, 593, 592, 592, 592, 592],
  25.  608 => [608,609,610,611,612,613,608,608,608,608,608,608,608,608],
  26.  536 => [536,537,538,539,540,541,542,536,536,536,536,536,536,536],
  27.  548 => [548,549,550,551,549,551,548,550,551,548,549,550],
  28.  552 => [552,553,554,555,553,555,552,554,555,552,553,554],
  29.  556 => [556,557,558,559,557,559,556,558,559,556,557,558],
  30.  567 => [567,567,569,569,570,570,569,569,567,567,569,569,570,568,570,568,570,
  31.           568,570,568,570,568,569,567],
  32.  571 => [571,572,573,574,574,574,574,574]
  33. }
  34.  
  35. SIMPLE_REFRESH = true
  36.  
  37. class Window_Base < Window
  38.   alias animicon_init initialize
  39.   alias animicon_update update
  40.   alias animicon_draw_icon draw_icon
  41.   def initialize(*args)
  42.     animicon_init(*args)
  43.     @icon_timer = 0
  44.     @icons = []
  45.   end
  46.   def refresh
  47.   end
  48.   def update(*args)
  49.     animicon_update(*args)
  50.     if contents.refresh_icons
  51.       @icons = []
  52.       contents.refresh_icons = false
  53.     end
  54.     if Graphics.frame_count % 10 == 0
  55.       @icon_timer += 1
  56.       redraw_icons if !@icons.empty? && SIMPLE_REFRESH
  57.       refresh unless SIMPLE_REFRESH
  58.     end
  59.   end
  60.   def draw_icon(icon_index, x, y, enabled = true)
  61.     if !ANIMATED_ICONS.include?(icon_index)
  62.       animicon_draw_icon(icon_index, x, y, enabled)
  63.     else
  64.       @icons.push([icon_index,x,y,enabled])
  65.       index = ANIMATED_ICONS[icon_index][@icon_timer % ANIMATED_ICONS[icon_index].size]
  66.       animicon_draw_icon(index, x, y, enabled)
  67.     end
  68.   end
  69.   def redraw_icons
  70.     @icons.each do |array|
  71.       index = ANIMATED_ICONS[array[0]][@icon_timer % ANIMATED_ICONS[array[0]].size]
  72.       contents.clear_rect(Rect.new(array[1],array[2],24,24))
  73.       animicon_draw_icon(index,array[1],array[2],array[3])
  74.     end
  75.   end
  76. end
  77.  
  78. class Window_Selectable < Window_Base
  79.   alias anim_draw_all_items draw_all_items
  80.   def draw_all_items
  81.     @icons = []
  82.     anim_draw_all_items
  83.   end
  84. end
  85.  
  86. class Bitmap
  87.   attr_accessor :refresh_icons
  88.   alias anim_clear clear
  89.   def clear
  90.     anim_clear
  91.     @refresh_icons = true
  92.   end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement