TheoAllen

Theo - Choice Help

Nov 14th, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.99 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Choice Helps
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_ChoiceHelp] = true
  8. # =============================================================================
  9. # Change Logs:
  10. # -----------------------------------------------------------------------------
  11. # 2013.11.14 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   ----------------------------------------------------------------------------
  16.   Perkenalan :
  17.   Script ini membuat kamu bisa menampilkan help pada choice.
  18.  
  19.   ----------------------------------------------------------------------------
  20.   Cara penggunaan :
  21.   Pasang script ini dibawah material namun diatas main
  22.   Gunakan script call seperti berikut untuk menentukan helpnya
  23.  
  24.   choice_helps[0] = "blablabla"
  25.   choice_helps[1] = "dasdasdasd"
  26.   choice_helps[2] = "lorem ipsum"
  27.   choice_helps[3] = "another sample text"
  28.  
  29.   Letakkan script call diatas satu slot tepat diatas show text sebelum command
  30.   choice. Index choice dimulai dari 0. Jika ada 4 choice, maka masing2 indexnya
  31.   adalah 0-1-2-3
  32.  
  33.   Jangan lupa untuk membersihkan sisa-sisa help dengan script call seperti
  34.   ini di akhir choice (kecuali kamu set AutoClear ke true)
  35.  
  36.   $game_message.clear_helps
  37.  
  38.   ----------------------------------------------------------------------------
  39.   Terms of use :
  40.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  41.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  42.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  43.  
  44. =end
  45. # =============================================================================
  46. # Sedikit Konfigurasi
  47. # =============================================================================
  48. module Theo
  49.   module Choice
  50.    
  51.     AutoClear = true
  52.   # Buat bersihin sisa-sisa help. (rekomendasi : true)
  53.  
  54.     LineNumber = 1
  55.   # Jumlah baris dalam help window
  56.  
  57.   end
  58. end
  59. # =============================================================================
  60. # Akhir dari konfigurasi
  61. # =============================================================================
  62. class Game_Interpreter
  63.   # --------------------------------------------------------------------------
  64.   # Script call
  65.   # --------------------------------------------------------------------------
  66.   def choice_helps
  67.     $game_message.choice_helps
  68.   end
  69.  
  70. end
  71.  
  72. class Game_Message
  73.   attr_reader :choice_helps
  74.  
  75.   alias theo_choiceh_init initialize
  76.   def initialize
  77.     theo_choiceh_init
  78.     clear_helps
  79.   end
  80.  
  81.   def clear_helps
  82.     @choice_helps = []
  83.   end
  84. end
  85.  
  86. class Window_ChoiceHelp < Window_Help
  87.  
  88.   def initialize(msg_window, choice_window)
  89.     super(Theo::Choice::LineNumber)
  90.     @msg_window = msg_window
  91.     @choice_window = choice_window
  92.     @choice_window.help_window = self
  93.     self.openness = 0
  94.     update
  95.   end
  96.  
  97.   def update
  98.     super
  99.     update_placement
  100.     update_openness
  101.     update_visible
  102.   end
  103.  
  104.   def update_placement
  105.     self.y = 0 if @msg_window.y > 0
  106.     self.y = Graphics.height - height if @msg_window.y <= 0
  107.   end
  108.  
  109.   def update_openness
  110.     self.openness = @choice_window.openness unless vx_choice?
  111.   end
  112.  
  113.   def update_visible
  114.     self.visible = !$game_message.choice_helps.compact.empty?
  115.   end
  116.  
  117.   def choice_window=(window)
  118.     @choice_window = window
  119.     @choice_window.help_window = self
  120.   end
  121.  
  122.   def vx_choice?
  123.     $imported[:Theo_VXStyleChoices] && $game_message.vx_choice
  124.   end
  125.  
  126. end
  127.  
  128. class Window_ChoiceList < Window_Command
  129.  
  130.   def update_help
  131.     @help_window.set_text($game_message.choice_helps[index])
  132.   end
  133.  
  134.   alias theo_choiceh_call_ok call_ok_handler
  135.   def call_ok_handler
  136.     theo_choiceh_call_ok
  137.     clear_helps
  138.   end
  139.  
  140.   alias theo_choiceh_call_cancel call_cancel_handler
  141.   def call_cancel_handler
  142.     theo_choiceh_call_cancel
  143.     clear_helps
  144.   end
  145.  
  146.   def clear_helps
  147.     return unless Theo::Choice::AutoClear
  148.     $game_message.clear_helps
  149.   end
  150.  
  151. end
  152.  
  153. class Window_Message < Window_Base
  154.  
  155.   alias theo_choiceh_init initialize
  156.   def initialize
  157.     theo_choiceh_init
  158.     create_choice_help
  159.   end
  160.  
  161.   def create_choice_help
  162.     @choice_help = Window_ChoiceHelp.new(self, @choice_window)
  163.   end
  164.  
  165.   alias theo_choiceh_update update
  166.   def update
  167.     theo_choiceh_update
  168.     @choice_help.update
  169.   end
  170.  
  171.   alias theo_choiceh_dispose_all dispose_all_windows
  172.   def dispose_all_windows
  173.     theo_choiceh_dispose_all
  174.     @choice_help.dispose
  175.   end
  176.  
  177.   if $imported[:Theo_MessageBallon]
  178.   alias theo_choiceh_recreate_choice recreate_choice
  179.   def recreate_choice
  180.     theo_choiceh_recreate_choice
  181.     @choice_help.choice_window = @choice_window
  182.   end
  183.   end
  184.  
  185. end
Advertisement
Add Comment
Please, Sign In to add comment