Advertisement
TheSixth

Choice Window Images by Sixth

Jan 24th, 2016
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.79 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Choice Window Images
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.0
  6. # * Updated: 24/01/2016
  7. # * Requires: --------
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (24/01/2016)
  12. #   - Initial release.
  13. #-------------------------------------------------------------------------------
  14. # * < Description >
  15. #-------------------------------------------------------------------------------
  16. # * This script will let you set up images for your choices in the choice
  17. #   window. These images will show up when the choice window is opened and will
  18. #   be hidden when the choice window is closed.
  19. # * The images are tied with the choice window's selection cursor, so the image
  20. #   displayed will depend on the selected option in the choice window.
  21. #   In short, only one image will be displayed, and that is based on the
  22. #   cursor's position. The shown image is updated in real time, so the player
  23. #   can see the changes immediately.
  24. #-------------------------------------------------------------------------------
  25. # * < Script Calls >
  26. #-------------------------------------------------------------------------------
  27. # * To set up the images for a "Show Choices" command, use this script call
  28. #   BEFORE the "Show Choices" command:
  29. #
  30. #     set_choice_pics(image_settings)
  31. #
  32. #   The 'image_settings' are your settings for your images.
  33. #   Who would have guessed it, right? :D
  34. #
  35. #   Okay, here is how one image setting looks:
  36. #
  37. #     ["filename",x,y]
  38. #
  39. #   The "filename" is the name of the image file you want to use.
  40. #   The x and y is the X and Y positions of the image (no kidding! :P).
  41. #  
  42. #   So, this is one image setting, and you can enter as many as you want.
  43. #   Each of them must be separated by commas!
  44. #   Keep in mind that the maximum choices you can show is 4 unless you use
  45. #   custom scripts to change that, so there is not much point to add more than
  46. #   4 image settings if you do not use scripts to increase that number.
  47. #
  48. #   Examples:
  49. #
  50. #     set_choice_pics(["Yes",250,200],["No",250,200])
  51. #   This would show the "Yes" image when the cursor is on the first choice, and
  52. #   would show the "No" image when the cursor is on the second choice.
  53. #   If there are more than 2 choices, nothing will be shown for the rest of
  54. #   them.
  55. #
  56. #     img1 = ["Easy",120,140]
  57. #     img2 = ["Normal",120,170]
  58. #     img3 = ["Hard",120,200]
  59. #     img4 = ["Insane",120,230]
  60. #     set_choice_pics(img1,img2,img3,img4)
  61. #   This would set 4 images for the first 4 choices.
  62. #   You see, I set up the image settings separately, one on each lines, and
  63. #   pass these settings to the script call as 'img1', 'img2', and so on.
  64. #   This is to keep it organized and because I don't like long script calls
  65. #   horizontally (some parts might get cut in the event command editor when
  66. #   viewing them on the command list).
  67. #   You don't have to use 'img1', 'img2', etc for their names, those are just
  68. #   examples, you can name them however you like, just make sure to use the
  69. #   same names in the 'set_choice_pics' call!
  70. #
  71. #   NOTE1:
  72. #   All images used in these script calls must be in the "Graphics/Pictures"
  73. #   folder of your game!
  74. #   NOTE2:
  75. #   You must set up these images before ALL of your choice selections if you
  76. #   want to show images for your choices, because the settings will get cleared
  77. #   automatically when the choice window is closed!
  78. #   If there is no image settings set up before a "Show Choices" command,
  79. #   there will be no images shown for your choices!
  80. #   NOTE3:
  81. #   You don't have to use this script call exactly before the "Show Choices"
  82. #   command. Once you useed this script call, it will be active all the time
  83. #   until the choice window opens. When that happens, the settings will be
  84. #   cleared the moment the choice window is closed.
  85. #-------------------------------------------------------------------------------
  86. # * < Installation >
  87. #-------------------------------------------------------------------------------
  88. # * Place this scipt below Materials but above Main!
  89. #-------------------------------------------------------------------------------
  90. # * < Compatibility Info >
  91. #-------------------------------------------------------------------------------
  92. # * No known incompatibilities.
  93. #-------------------------------------------------------------------------------
  94. # * < Known Issues >
  95. #-------------------------------------------------------------------------------
  96. # * No known issues.
  97. #-------------------------------------------------------------------------------
  98. # * < Terms of Use >
  99. #-------------------------------------------------------------------------------
  100. # * Free to use for whatever purposes you want.
  101. # * Credit me (Sixth) in your game, pretty please! :P
  102. # * Posting modified versions of this script is allowed as long as you notice me
  103. #   about it with a link to it!
  104. #===============================================================================
  105. $imported = {} if $imported.nil?
  106. $imported["SixthChoiceWinPics"] = true
  107. #===============================================================================
  108. # No Settings! o.o
  109. #===============================================================================
  110. class Game_Interpreter
  111.  
  112.   def set_choice_pics(*imgs)
  113.     $game_message.choice_pics = imgs
  114.   end
  115.  
  116. end
  117.  
  118. class Game_Message
  119.  
  120.   attr_accessor :choice_pics
  121.  
  122. end
  123.  
  124. class Window_ChoiceList < Window_Command
  125.  
  126.   def open
  127.     super
  128.     show_choice_pics if $game_message.choice_pics
  129.   end
  130.  
  131.   def close
  132.     super
  133.     hide_choice_pics if @imgs
  134.   end
  135.  
  136.   def show_choice_pics
  137.     @imgs = []
  138.     $game_message.choice_pics.each_with_index do |img,i|
  139.       @imgs[i] = Sprite.new
  140.       @imgs[i].visible = i == @index ? true : false
  141.       @imgs[i].bitmap = Cache.picture(img[0])
  142.       @imgs[i].x = img[1]
  143.       @imgs[i].y = img[2]
  144.       @imgs[i].z = self.z - 1
  145.     end
  146.   end
  147.  
  148.   def hide_choice_pics
  149.     @imgs.each {|img| img.bitmap.dispose; img.dispose}
  150.     @imgs = nil
  151.     $game_message.choice_pics = nil
  152.   end
  153.  
  154.   def update
  155.     super
  156.     update_choice_pics if @imgs
  157.   end
  158.  
  159.   def update_choice_pics
  160.     @imgs.each_with_index do |img,i|
  161.       if i == @index
  162.         img.visible = true if !img.visible
  163.       else
  164.         img.visible = false if img.visible
  165.       end
  166.     end
  167.   end
  168.  
  169. end
  170. #==============================================================================
  171. # !!END OF SCRIPT - OHH, NOES!!
  172. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement