Advertisement
Guest User

Window_BattleMessage *

a guest
Sep 14th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_BattleMessage
  3. #------------------------------------------------------------------------------
  4. # Message window displayed during battle. In addition to the normal message
  5. # window functions, it also has a battle progress narration function.
  6. #==============================================================================
  7.  
  8. class Window_BattleMessage < Window_Message
  9. #--------------------------------------------------------------------------
  10. # * Object Initialization
  11. #--------------------------------------------------------------------------
  12. def initialize
  13. super
  14. self.openness = 255
  15. @lines = []
  16. refresh
  17. end
  18. #--------------------------------------------------------------------------
  19. # * Dispose
  20. #--------------------------------------------------------------------------
  21. def dispose
  22. super
  23. end
  24. #--------------------------------------------------------------------------
  25. # * Frame Update
  26. #--------------------------------------------------------------------------
  27. def update
  28. super
  29. end
  30. #--------------------------------------------------------------------------
  31. # * Open Window (disabled)
  32. #--------------------------------------------------------------------------
  33. def open
  34. end
  35. #--------------------------------------------------------------------------
  36. # * Close Window (disabled)
  37. #--------------------------------------------------------------------------
  38. def close
  39. end
  40. #--------------------------------------------------------------------------
  41. # * Set Window Background and Position
  42. #--------------------------------------------------------------------------
  43. def reset_window
  44. @background = $game_message.background
  45. @position = $game_message.position
  46. if @background == 0 # Normal window
  47. self.opacity = 255
  48. else # Dim Background and Make it Transparent
  49. self.opacity = 0
  50. end
  51. case @position
  52. when 0 # Top
  53. self.y = 0
  54. when 1 # Middle
  55. self.y = 144
  56. when 2 # Bottom
  57. self.y = 288
  58. end
  59. end
  60. #--------------------------------------------------------------------------
  61. # * Clear
  62. #--------------------------------------------------------------------------
  63. def clear
  64. @lines.clear
  65. refresh
  66. end
  67. #--------------------------------------------------------------------------
  68. # * Get Row Count
  69. #--------------------------------------------------------------------------
  70. def line_number
  71. return @lines.size
  72. end
  73. #--------------------------------------------------------------------------
  74. # * Go Back One Line
  75. #--------------------------------------------------------------------------
  76. def back_one
  77. @lines.pop
  78. refresh
  79. end
  80. #--------------------------------------------------------------------------
  81. # * Return to Designated Line
  82. # line_number : Line number
  83. #--------------------------------------------------------------------------
  84. def back_to(line_number)
  85. while @lines.size > line_number
  86. @lines.pop
  87. end
  88. refresh
  89. end
  90. #--------------------------------------------------------------------------
  91. # * Add Text
  92. # text : Text to be added
  93. #--------------------------------------------------------------------------
  94. def add_instant_text(text)
  95. @lines.push(text)
  96. refresh
  97. end
  98. #--------------------------------------------------------------------------
  99. # * Replace Text
  100. # text : Text to be replaced
  101. # Replaces the last line with different text.
  102. #--------------------------------------------------------------------------
  103. def replace_instant_text(text)
  104. @lines.pop
  105. @lines.push(text)
  106. refresh
  107. end
  108. #--------------------------------------------------------------------------
  109. # * Get Text From Last Line
  110. #--------------------------------------------------------------------------
  111. def last_instant_text
  112. return @lines[-1]
  113. end
  114. #--------------------------------------------------------------------------
  115. # * Refresh
  116. #--------------------------------------------------------------------------
  117. def refresh
  118. self.contents.clear
  119. for i in 0...@lines.size
  120. draw_line(i)
  121. end
  122. end
  123. #--------------------------------------------------------------------------
  124. # * Draw Line
  125. # index : Line number
  126. #--------------------------------------------------------------------------
  127. def draw_line(index)
  128. rect = Rect.new(0, 0, 0, 0)
  129. rect.x += 4
  130. rect.y += index * WLH
  131. rect.width = contents.width - 8
  132. rect.height = WLH
  133. self.contents.clear_rect(rect)
  134. self.contents.font.color = normal_color
  135. self.contents.draw_text(rect, @lines[index])
  136. end
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement