Advertisement
Guest User

two column vx style choice

a guest
Sep 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Two Columns VX Style Choices
  3. # Version : 1.1b
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (English Documentation)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_VXStyleChoices] = true
  8. # =============================================================================
  9. # Change Logs :
  10. # -----------------------------------------------------------------------------
  11. # 2013.11.14 - Compatibility patch with my choice help
  12. # - Bugfix. Face graphic erased when clearing message box
  13. # 2013.10.14 - Bugfix. Choice isn't displayed if it isn't followed by texts
  14. # 2013.10.12 - Finished script
  15. # =============================================================================
  16. =begin
  17.  
  18. Introduction :
  19. This script allow you to display choices as VX has
  20.  
  21. How to use :
  22. Put this script below material but above main
  23. Use these script calls to activate VX style choice
  24.  
  25. vx_choice(true) << to activate
  26. vx_choice(false) << to deacitave
  27.  
  28. Terms of use :
  29. Credit me, TheoAllen. You are free to edit this script by your own. As long
  30. as you don't claim it yours. For commercial purpose, don't forget to give me
  31. a free copy of the game.
  32.  
  33. =end
  34. # =============================================================================
  35. # No configuration. Just dont edit below this line
  36. # =============================================================================
  37. class Game_Interpreter
  38.  
  39. def vx_choice(bool)
  40. $game_message.vx_choice = bool
  41. end
  42.  
  43. end
  44.  
  45. class Game_Message
  46. attr_accessor :vx_choice
  47. attr_accessor :two_column
  48.  
  49. alias theo_vxchoice_init initialize
  50. def initialize
  51. theo_vxchoice_init
  52. @vx_choice = false
  53. @two_column = false
  54. end
  55.  
  56. end
  57.  
  58. class Window_Message < Window_Base
  59.  
  60. alias theo_vxchoice_init initialize
  61. def initialize
  62. theo_vxchoice_init
  63. init_vxchoice_member
  64. end
  65.  
  66. def init_vxchoice_member
  67. @need_clear = false
  68. @choice_index = 0
  69. @choice_y = 0
  70. end
  71.  
  72. alias theo_vxchoice_input input_choice
  73. def input_choice
  74. return start_vx_choice if $game_message.vx_choice
  75. return theo_vxchoice_input
  76. end
  77.  
  78. alias theo_vxchoice_new_page new_page
  79. def new_page(text, pos)
  80. theo_vxchoice_new_page(text, pos)
  81. @need_clear = $game_message.texts.size > 3
  82. end
  83.  
  84. alias theo_vxchoice_new_line process_new_line
  85. def process_new_line(text, pos)
  86. theo_vxchoice_new_line(text, pos)
  87. @choice_y = pos[:y]
  88. end
  89.  
  90. def start_vx_choice
  91. open_and_wait unless open?
  92. if @need_clear
  93. input_need_clear
  94. end
  95. @choice_index = 0
  96. update_choice_cursor
  97. ypos = 0
  98. $game_message.choices.each_with_index do |choice, i|
  99. xpos = (contents.width - new_line_x)/2
  100. ix = i % 2
  101. new_x_pos = xpos * ix + new_line_x
  102. draw_text_ex(new_x_pos, @choice_y + ypos, choice)
  103. ypos += line_height * (i % 2)
  104. end
  105. update_vx_choice(new_line_x, @choice_y)
  106. end
  107.  
  108. def padding_x
  109. return 16
  110. end
  111.  
  112. def input_need_clear
  113. input_pause
  114. contents.clear
  115. draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  116. @choice_y = 0
  117. @choice_x = 0
  118. @need_clear = false
  119. end
  120.  
  121. def update_vx_choice(xpos, ypos)
  122. rect_width = (contents.width - new_line_x)/2
  123. cursor_rect.set(xpos, ypos, rect_width, line_height)
  124. if choice_help?
  125. @choice_help.open
  126. update_choice_help
  127. end
  128. wait(10)
  129. until Input.trigger?(:C) || (Input.trigger?(:B) && cancel_enabled?)
  130. update_choice_cursor
  131. Fiber.yield
  132. end
  133. cursor_rect.empty
  134. execute_choice
  135. Input.update
  136. end
  137.  
  138. def cancel_enabled?
  139. $game_message.choice_cancel_type > 0
  140. end
  141.  
  142. def update_choice_cursor
  143. cursor_rect.y = (@choice_index/2) * line_height + @choice_y
  144. cursor_rect.x = (@choice_index%2) * ((contents.width - new_line_x)/2) +
  145. new_line_x
  146. change_choice_index(2) if Input.repeat?(:DOWN)
  147. change_choice_index(-2) if Input.repeat?(:UP)
  148. change_choice_index(1) if Input.repeat?(:RIGHT)
  149. change_choice_index(-1) if Input.repeat?(:LEFT)
  150. end
  151.  
  152. def change_choice_index(amount)
  153. Sound.play_cursor
  154. @choice_index += amount
  155. wrap_index
  156. update_choice_help if choice_help?
  157. end
  158.  
  159. def wrap_index
  160. @choice_index = 0 if @choice_index > $game_message.choices.size - 1
  161. @choice_index = $game_message.choices.size - 1 if @choice_index < 0
  162. end
  163.  
  164. def execute_choice
  165. call_ok_handler if Input.trigger?(:C)
  166. call_cancel_handler if Input.trigger?(:B)
  167. if choice_help?
  168. @choice_help.close
  169. end
  170. end
  171.  
  172. def choice_help?
  173. $imported[:Theo_ChoiceHelp]
  174. end
  175.  
  176. def update_choice_help
  177. @choice_help.set_text($game_message.choice_helps[@choice_index])
  178. end
  179.  
  180. def call_ok_handler
  181. Sound.play_ok
  182. $game_message.choice_proc.call(@choice_index)
  183. end
  184.  
  185. def call_cancel_handler
  186. Sound.play_cancel
  187. $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
  188. end
  189.  
  190. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement