Guest User

Untitled

a guest
Jun 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. =begin
  2. Arabic Reading Right to left
  3.  
  4. Author: Bulletxt
  5. Version: 0.5
  6. Date: 12/07/2009
  7. =end
  8.  
  9. # this is an id switch, if ON it will reverse the letters of a word.
  10. # example: "Hello World" will be "olleH dlroW"
  11. REVERSE_LETTERS_OF_WORD = 1
  12.  
  13. # this is an id switch, if ON it will reverse the words of a sentance including
  14. # the letters of the word.
  15. # example: "Hello World" will be "dlroW olleH"
  16. REVERSE_WORDS_OF_SENTANCE_INCLUDING_LETTERS = 2
  17.  
  18.  
  19. # NOTE:
  20. # if REVERSE_LETTERS_OF_WORD and REVERSE_WORDS_OF_SENTANCE_INCLUDING_LETTERS
  21. # switches are both on, the result will be a revert of the words in a sentance
  22. # without reverting the letters of the word.
  23. # example: "Hello World" will be "World Hello"
  24.  
  25. ############################## END CONFIGURATION ###############################
  26.  
  27. class Window_Message < Window_Selectable
  28.  
  29. #--------------------------------------------------------------------------
  30. # * Start Message
  31. #--------------------------------------------------------------------------
  32. def start_message
  33. @text = ""
  34. for i in 0...$game_message.texts.size
  35. @text += " " if i >= $game_message.choice_start
  36. m = $game_message.texts.shift
  37.  
  38.  
  39. m = m.split(//u).reverse.join
  40.  
  41. #"Hello World" will be "olleH dlroW"
  42. m = m.split(/ /).map { |w| w.split(//u).reverse.join}.join(' ') if $game_switches[REVERSE_LETTERS_OF_WORD]
  43.  
  44. #"Hello World" will be "dlroW olleH"
  45. m = m.split(//u).reverse.join if $game_switches[REVERSE_WORDS_OF_SENTANCE_INCLUDING_LETTERS]
  46.  
  47.  
  48. #debug sentance
  49. #p sprintf (m)
  50. @text += m + "\x00"
  51.  
  52. end
  53. @item_max = $game_message.choice_max
  54. convert_special_characters
  55. reset_window
  56. new_page
  57. end
  58.  
  59. #--------------------------------------------------------------------------
  60. # * New Page
  61. #--------------------------------------------------------------------------
  62. def new_page
  63. contents.clear
  64. if $game_message.face_name.empty?
  65. @contents_x = 512
  66. else
  67. name = $game_message.face_name
  68. index = $game_message.face_index
  69. draw_face(name, index, 416, 0)
  70. @contents_x = 406
  71. end
  72. @contents_y = 0
  73. @line_count = 0
  74. @show_fast = false
  75. @line_show_fast = false
  76. @pause_skip = false
  77. contents.font.color = text_color(0)
  78. end
  79. #--------------------------------------------------------------------------
  80. # * New Line
  81. #--------------------------------------------------------------------------
  82. def new_line
  83. if $game_message.face_name.empty?
  84. @contents_x = 512
  85. else
  86. @contents_x = 406
  87. end
  88. @contents_y += WLH
  89. @line_count += 1
  90. @line_show_fast = false
  91. end
  92.  
  93. #--------------------------------------------------------------------------
  94. # * Update Message
  95. #--------------------------------------------------------------------------
  96. def update_message
  97. loop do
  98. c = @text.slice!(/./m) # Get next text character
  99. case c
  100. when nil # There is no text that must be drawn
  101. finish_message # Finish update
  102. break
  103. when "\x00" # New line
  104. new_line
  105. if @line_count >= MAX_LINE # If line count is maximum
  106. unless @text.empty? # If there is more
  107. self.pause = true # Insert number input
  108. break
  109. end
  110. end
  111. when "\x01" # \C[n] (text character color change)
  112. @text.sub!(/\[([0-9]+)\]/, "")
  113. contents.font.color = text_color($1.to_i)
  114. next
  115. when "\x02" # \G (gold display)
  116. @gold_window.refresh
  117. @gold_window.open
  118. when "\x03" # \. (wait 1/4 second)
  119. @wait_count = 15
  120. break
  121. when "\x04" # \| (wait 1 second)
  122. @wait_count = 60
  123. break
  124. when "\x05" # \! (Wait for input)
  125. self.pause = true
  126. break
  127. when "\x06" # \> (Fast display ON)
  128. @line_show_fast = true
  129. when "\x07" # \< (Fast display OFF)
  130. @line_show_fast = false
  131. when "\x08" # \^ (No wait for input)
  132. @pause_skip = true
  133. else # Normal text character
  134. c_width = contents.text_size(c).width
  135.  
  136. @contents_x -= c_width
  137.  
  138. contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
  139.  
  140. end
  141. break unless @show_fast or @line_show_fast
  142. end
  143. end
  144.  
  145. end
Add Comment
Please, Sign In to add comment