Advertisement
Black_Mage

Popup Window RMXP Script

Mar 5th, 2014
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. # Window Popup By Black Mage (Credit required to use)
  2. # https://burningwizard.wordpress.com/2014/03/05/rgss-popup-window-script/
  3.  
  4. class Window_Popup < Window_Base
  5.  
  6. # The initialize method.
  7. # Called when the Window_About window is created.
  8. def initialize(popup,width,name)
  9. @name = name
  10. @text = popup
  11. # First set the window size by calling the initialize
  12. # method of window base with a size of 640 * 480
  13. super(640-width, 0, width, 64)
  14. # Then create the contents bitmap. The width and
  15. # height are set to window width - 32 and height - 32
  16. self.contents = Bitmap.new(width - 32, height - 32)
  17. self.opacity = 0
  18. @countdown = 110
  19. # Call the refresh method to draw text
  20. $appear = true
  21. refresh
  22. update
  23. end
  24.  
  25. # The refresh method.
  26. # Called to draw stuff on the contentsbitmap.
  27. def refresh
  28. # Clear any existing contents.
  29. self.contents.clear
  30. # Drawing something
  31. self.contents_opacity = 0
  32. self.contents.clear
  33. self.contents.font.color = normal_color
  34. x = y = 0
  35.  
  36. if @name == ""
  37. else
  38. bitmap = RPG::Cache.icon(@name)
  39. self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24))
  40. x += 32
  41. end
  42.  
  43. # If waiting for a message to be displayed
  44. text = @text
  45. # Control text processing
  46. text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  47.  
  48. text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  49. $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  50. end
  51. text.gsub!(/\\[Ii]\[([0-9]+)\]/) do
  52. $data_items[$1.to_i] != nil ? $data_items[$1.to_i].name : ""
  53. end
  54. text.gsub!(/\\[Ww]\[([0-9]+)\]/) do
  55. $data_weapons[$1.to_i] != nil ? $data_weapons[$1.to_i].name : ""
  56. end
  57. text.gsub!(/\\[Aa]\[([0-9]+)\]/) do
  58. $data_armors[$1.to_i] != nil ? $data_armors[$1.to_i].name : ""
  59. end
  60. # Change "\\\\" to "\000" for convenience
  61. text.gsub!(/\\\\/) { "\000" }
  62. # Get 1 text character in c (loop until unable to get text)
  63. while ((c = text.slice!(/./m)) != nil)
  64. # If \\
  65. if c == "\000"
  66. # Return to original text
  67. c = "\\"
  68. end
  69. if c == "\n"
  70. c = " "
  71. end
  72.  
  73. # Draw text
  74. self.contents.draw_text(x, 0, 600, 32, c)
  75. x += self.contents.text_size(c).width
  76.  
  77. end
  78. end
  79.  
  80. def update
  81. @countdown -= 1 if @countdown > 0
  82. if $appear == true
  83. self.opacity += 10
  84. self.contents_opacity += 10
  85. if @countdown == 85
  86. $appear = false
  87. $stop = true
  88. end
  89. end
  90. if $stop == true
  91. if @countdown == 25
  92. $stop = false
  93. $disappear = true
  94. end
  95. end
  96. if $disappear == true
  97. self.opacity -= 10
  98. self.contents_opacity -= 10
  99. if @countdown ==0
  100. $disappear = false
  101. end
  102. end
  103. end
  104.  
  105. #This end closes the class definition block
  106. end
  107.  
  108. class Spriteset_Map
  109. alias popup_update update
  110. def update
  111. popup_update
  112. if !$popup.nil? && $appear == true
  113. $popup.update
  114. end
  115. if !$popup.nil? && $stop == true
  116. $popup.update
  117. end
  118. if !$popup.nil? && $disappear == true
  119. $popup.update
  120. end
  121. end
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement