pigu_6

Yanfly|Gab Window

Nov 24th, 2012
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.84 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Gab Window v1.00
  4. # -- Last Updated: 2012.01.23
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-GabWindow"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.23 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # Sometimes there's random jibber jabber that does not warrant a message box.
  22. # The Gab Window fulfills that jibber jabber by placing such text outside of
  23. # the message window box and at the corner of the screen. The gab text will
  24. # appear briefly and then disappear, not showing up again until the gab text is
  25. # updated with something else.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Script Calls - These commands are used with script calls.
  35. # -----------------------------------------------------------------------------
  36. # These script calls can only be used from a map. The Gab Window will not
  37. # appear in battle or anywhere else.
  38. #
  39. # gab(string)
  40. # This will cause the Gab Window to appear with the string shown. Text codes
  41. # can be used inside the string. When using text codes, remember to use "\\"
  42. # for a single slash.
  43. #
  44. # gab(string, actor_id)
  45. # This will cause the Gab Window to appear with the string and the actor's
  46. # sprite. Text codes can be used inside the string. When using text codes,
  47. # remember to use "\\" for a single slash. There are special ID's that
  48. # can be used in place of the actor_id:
  49. # 0 - Party Leader
  50. # -1 - 1st non-leader member.
  51. # -2 - 2nd non-leader member. So on.
  52. #
  53. # gab(string, char_name, char_index)
  54. # This will cause the Gab Window to appear with the string shown and a sprite
  55. # using char_name as the filename of the character sprite and char_index as the
  56. # index of the character sprite. Text codes can be used inside the string. When
  57. # using text codes, remember to use "\\" for a single slash.
  58. #
  59. # clear_gab
  60. # This will cause the gab window to clear itself and immediately go invisible.
  61. # This will also allow a previously used gab prior to the clearing to reappear
  62. # immediately if followed up by another gab.
  63. #
  64. #==============================================================================
  65. # ▼ Compatibility
  66. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  67. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  68. # it will run with RPG Maker VX without adjusting.
  69. #
  70. # This script is compatible with Yanfly Engine Ace - Ace Message System v1.04+.
  71. # The positioning of these two scripts relative to each other does not matter.
  72. #
  73. #==============================================================================
  74.  
  75. module YEA
  76. module GAB_WINDOW
  77.  
  78. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  79. # - Gab Settings -
  80. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  81. # These are the general settings used involving the Gab Window. Here, you
  82. # can change the Y location of the window (remember, it's two lines tall),
  83. # default font size, the position of the character sprites, and the amount
  84. # of time the Gab Window will remain fully visible before fading.
  85. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  86. Y_LOCATION = 36 # This sets the Y location of the gab window.
  87. FONT_SIZE = 18 # This is the font size used for the gab window.
  88.  
  89. CHAR_X_POS = 24 # This sets the X location of the character shown.
  90. CHAR_Y_POS = 40 # This sets the Y location of the character shown.
  91.  
  92. BASE_TIME = 60 # Minimum frames the window will stay visible for.
  93. TIME_PER_TEXT = 4 # Frames added per text character.
  94.  
  95. HIDE_SWITCH = 25 # If switch is ON, Gab Window will not appear.
  96.  
  97. end # GAB_WINDOW
  98. end # YEA
  99.  
  100. #==============================================================================
  101. # ▼ Editting anything past this point may potentially result in causing
  102. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  103. # halitosis so edit at your own risk.
  104. #==============================================================================
  105.  
  106. #==============================================================================
  107. # ■ Switch
  108. #==============================================================================
  109.  
  110. module Switch
  111.  
  112. #--------------------------------------------------------------------------
  113. # self.hide_gab_window
  114. #--------------------------------------------------------------------------
  115. def self.hide_gab_window
  116. return false if YEA::GAB_WINDOW::HIDE_SWITCH <= 0
  117. return $game_switches[YEA::GAB_WINDOW::HIDE_SWITCH]
  118. end
  119.  
  120. end # Switch
  121.  
  122. #==============================================================================
  123. # ■ Game_Interpreter
  124. #==============================================================================
  125.  
  126. class Game_Interpreter
  127.  
  128. #--------------------------------------------------------------------------
  129. # new method: gab
  130. #--------------------------------------------------------------------------
  131. def gab(text, case1 = nil, case2 = nil)
  132. return unless SceneManager.scene_is?(Scene_Map)
  133. if case1.is_a?(Integer)
  134. case1 = $game_party.members[case1.abs].id if case1 <= 0
  135. actor = $game_actors[case1]
  136. if !actor.nil?
  137. case1 = actor.character_name
  138. case2 = actor.character_index
  139. end
  140. elsif case1.is_a?(String)
  141. case2 = 0 if case2.nil?
  142. end
  143. SceneManager.scene.setup_gab_window(text, case1, case2)
  144. end
  145.  
  146. #--------------------------------------------------------------------------
  147. # new method: clear_gab
  148. #--------------------------------------------------------------------------
  149. def clear_gab
  150. return unless SceneManager.scene_is?(Scene_Map)
  151. SceneManager.scene.clear_gab
  152. end
  153.  
  154. end # Game_Interpreter
  155.  
  156. #==============================================================================
  157. # ■ Window_Gab
  158. #==============================================================================
  159.  
  160. class Window_Gab < Window_Base
  161.  
  162. #--------------------------------------------------------------------------
  163. # initialize
  164. #--------------------------------------------------------------------------
  165. def initialize
  166. dx = -standard_padding
  167. dy = YEA::GAB_WINDOW::Y_LOCATION
  168. super(dx, dy, Graphics.width + standard_padding, fitting_height(2))
  169. setup_message_font if $imported["YEA-MessageSystem"]
  170. clear
  171. end
  172.  
  173. #--------------------------------------------------------------------------
  174. # clear
  175. #--------------------------------------------------------------------------
  176. def clear
  177. self.opacity = 0
  178. self.contents_opacity = 0
  179. @opacity_timer = 0
  180. clear_settings
  181. end
  182.  
  183. #--------------------------------------------------------------------------
  184. # clear_settings
  185. #--------------------------------------------------------------------------
  186. def clear_settings
  187. @text = ""
  188. @graphic = nil
  189. @index = nil
  190. end
  191.  
  192. #--------------------------------------------------------------------------
  193. # reset_font_settings
  194. #--------------------------------------------------------------------------
  195. def reset_font_settings
  196. super
  197. contents.font.size = YEA::GAB_WINDOW::FONT_SIZE
  198. end
  199.  
  200. #--------------------------------------------------------------------------
  201. # setup
  202. #--------------------------------------------------------------------------
  203. def setup(text, graphic, index)
  204. return if settings_match?(text, graphic, index)
  205. @text = text
  206. @graphic = graphic
  207. @index = index
  208. @opacity_timer = YEA::GAB_WINDOW::BASE_TIME
  209. @opacity_timer += YEA::GAB_WINDOW::TIME_PER_TEXT * @text.size
  210. refresh
  211. end
  212.  
  213. #--------------------------------------------------------------------------
  214. # settings_match?
  215. #--------------------------------------------------------------------------
  216. def settings_match?(text, graphic, index)
  217. return false if @text != text
  218. return false if @graphic != graphic
  219. return false if @index != index
  220. return true
  221. end
  222.  
  223. #--------------------------------------------------------------------------
  224. # update
  225. #--------------------------------------------------------------------------
  226. def update
  227. super
  228. self.visible = show_window?
  229. update_contents_opacity
  230. end
  231.  
  232. #--------------------------------------------------------------------------
  233. # show_window?
  234. #--------------------------------------------------------------------------
  235. def show_window?
  236. return false if $game_message.visible && $game_message.position == 0
  237. return !Switch.hide_gab_window
  238. end
  239.  
  240. #--------------------------------------------------------------------------
  241. # update_contents_opacity
  242. #--------------------------------------------------------------------------
  243. def update_contents_opacity
  244. if @opacity_timer > 0 && self.contents_opacity >= 255
  245. return @opacity_timer -= 1
  246. end
  247. self.contents_opacity += @opacity_timer > 0 ? 16 : -4
  248. end
  249.  
  250. #--------------------------------------------------------------------------
  251. # refresh
  252. #--------------------------------------------------------------------------
  253. def refresh
  254. contents.clear
  255. draw_background_colour
  256. draw_graphic
  257. draw_text_ex(48, line_height / 2, @text)
  258. end
  259.  
  260. #--------------------------------------------------------------------------
  261. # draw_background_colour
  262. #--------------------------------------------------------------------------
  263. def draw_background_colour
  264. temp_rect = contents.rect.clone
  265. temp_rect.width *= 0.667
  266. back_colour1 = Color.new(0, 0, 0, 192)
  267. back_colour2 = Color.new(0, 0, 0, 0)
  268. contents.gradient_fill_rect(temp_rect, back_colour1, back_colour2)
  269. end
  270.  
  271. #--------------------------------------------------------------------------
  272. # draw_graphic
  273. #--------------------------------------------------------------------------
  274. def draw_graphic
  275. char_name = @graphic
  276. char_index = @index
  277. dx = YEA::GAB_WINDOW::CHAR_X_POS
  278. dy = YEA::GAB_WINDOW::CHAR_Y_POS
  279. draw_character(char_name, char_index, dx, dy)
  280. end
  281.  
  282. end # Window_Gab
  283.  
  284. #==============================================================================
  285. # ■ Scene_Map
  286. #==============================================================================
  287.  
  288. class Scene_Map < Scene_Base
  289.  
  290. #--------------------------------------------------------------------------
  291. # alias method: create_all_windows
  292. #--------------------------------------------------------------------------
  293. alias scene_map_create_all_windows_gab create_all_windows
  294. def create_all_windows
  295. scene_map_create_all_windows_gab
  296. create_gab_window
  297. end
  298.  
  299. #--------------------------------------------------------------------------
  300. # new method: create_gab_window
  301. #--------------------------------------------------------------------------
  302. def create_gab_window
  303. @gab_window = Window_Gab.new
  304. end
  305.  
  306. #--------------------------------------------------------------------------
  307. # new method: setup_gab_window
  308. #--------------------------------------------------------------------------
  309. def setup_gab_window(text, graphic = nil, index = nil)
  310. @gab_window.setup(text, graphic, index)
  311. end
  312.  
  313. #--------------------------------------------------------------------------
  314. # new method: clear_gab
  315. #--------------------------------------------------------------------------
  316. def clear_gab
  317. @gab_window.clear
  318. end
  319.  
  320. #--------------------------------------------------------------------------
  321. # alias method: pre_transfer
  322. #--------------------------------------------------------------------------
  323. alias scene_map_pre_transfer_gab pre_transfer
  324. def pre_transfer
  325. scene_map_pre_transfer_gab
  326. clear_gab
  327. end
  328.  
  329. end # Scene_Map
  330.  
  331. #==============================================================================
  332. #
  333. # ▼ End of File
  334. #
  335. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment