dsiver144

[DRKS] Animated Custom Menu

Apr 18th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.54 KB | None | 0 0
  1. #===============================================================================
  2. # Script : Dark Animated Custom Menu.
  3. # Author : Dark Sky ( Nhat Nguyen )
  4. # Released on : April 19th 2016
  5. # Forum : TaoTroChoi.com
  6. #-------------------------------------------------------------------------------
  7. # Version: 1.0 -> Release!
  8. #===============================================================================
  9. module Dark_CustomMenu2
  10. Command_Font = "Impact"
  11. end
  12. include Dark_CustomMenu2
  13. #==============================================================================
  14. # ** Scene_Menu
  15. #------------------------------------------------------------------------------
  16. # This class performs the menu screen processing.
  17. #==============================================================================
  18. class Scene_Menu < Scene_MenuBase
  19. #--------------------------------------------------------------------------
  20. # * Start Processing
  21. #--------------------------------------------------------------------------
  22. def start
  23. super
  24. create_sprites
  25. create_command_window
  26. create_gold_window
  27. create_status_window
  28. end
  29. #--------------------------------------------------------------------------
  30. # * Create Sprites
  31. #--------------------------------------------------------------------------
  32. def create_sprites
  33. @sprites = {}
  34. @sprites[:bg] = Sprite.new
  35. @sprites[:bg].bitmap = Cache.picture("D_Background")
  36. @sprites[:bg].viewport = @viewport
  37. @sprites[:bg].z = 0
  38. @sprites[:fog] = Plane.new
  39. @sprites[:fog].bitmap = Cache.picture("D_Fog")
  40. @sprites[:fog].viewport = @viewport
  41. @sprites[:fog].opacity = 20
  42. @sprites[:fog].z = 10
  43. @sprites[:menu_main] = Sprite.new
  44. @sprites[:menu_main].bitmap = Cache.picture("D_Background3")
  45. @sprites[:menu_main].viewport = @viewport
  46. @sprites[:menu_main].z = 15
  47. @sprites[:menu_title] = Sprite.new
  48. @sprites[:menu_title].bitmap = Cache.picture("D_Background2")
  49. @sprites[:menu_title].viewport = @viewport
  50. @sprites[:menu_title].z = 20
  51. end
  52. #--------------------------------------------------------------------------
  53. # * Update
  54. #--------------------------------------------------------------------------
  55. alias dark_animated_menu_custom_update update
  56. def update
  57. dark_animated_menu_custom_update
  58. @sprites[:fog].ox += 1
  59. if @menu
  60. @menu.update
  61. end
  62. end
  63. #--------------------------------------------------------------------------
  64. # * Create Command Window
  65. #--------------------------------------------------------------------------
  66. alias dark_animated_menu_custom_create_command_window create_command_window
  67. def create_command_window
  68. dark_animated_menu_custom_create_command_window()
  69. @command_window.opacity = 0
  70. @command_window.viewport = @viewport
  71. @command_window.y += 30
  72. @command_window.visible = false
  73. @command_window.back_opacity = 0
  74. @menu = DarkMenu.new(@command_window.list,@command_window,@viewport)
  75. end
  76. #--------------------------------------------------------------------------
  77. # * Create Gold Window
  78. #--------------------------------------------------------------------------
  79. def create_gold_window
  80. @gold_window = Window_Gold.new
  81. @gold_window.x = -34
  82. @gold_window.y = Graphics.height - @gold_window.height + 12
  83. @gold_window.opacity = 0
  84. @gold_window.back_opacity = 0
  85. @gold_window.viewport = @viewport
  86. end
  87. #--------------------------------------------------------------------------
  88. # * Create Status Window
  89. #--------------------------------------------------------------------------
  90. def create_status_window
  91. @status_window = Window_MenuStatus.new(@command_window.width, 0)
  92. @status_window.viewport = @viewport
  93. @status_window.opacity = 0
  94. @status_window.back_opacity = 200
  95. @status_window.x += 60
  96. @status_window.y += 40
  97. end
  98. #--------------------------------------------------------------------------
  99. # * Terminate
  100. #--------------------------------------------------------------------------
  101. alias dark_animated_menu_custom_terminate terminate
  102. def terminate
  103. dark_animated_menu_custom_terminate
  104. @sprites.values.each do |sprite|
  105. sprite.bitmap.dispose
  106. sprite.dispose
  107. end
  108. @menu.dispose_sprites
  109. end
  110. end
  111.  
  112. #==============================================================================
  113. # ** DarkMenu
  114. #==============================================================================
  115. class DarkMenu
  116. attr_accessor :list
  117. #--------------------------------------------------------------------------
  118. # * Initialize
  119. #--------------------------------------------------------------------------
  120. def initialize(list,window,viewport)
  121. @list = list
  122. @size = list.size
  123. @viewport = viewport
  124. @index = window.index
  125. @window = window
  126. @command_sprites = []
  127. @cur_index = 0
  128. for i in 0..(@list.size - 1)
  129. @command_sprites.push(Sprite_Menu_Command.new(@list[i][:name],window,i,viewport))
  130. end
  131. end
  132. #--------------------------------------------------------------------------
  133. # * Dispose
  134. #--------------------------------------------------------------------------
  135. def dispose_sprites
  136. p "Menu Sprite Disposed!"
  137. @command_sprites.each do |sprite|
  138. sprite.bitmap.dispose
  139. sprite.dispose
  140. end
  141. @command_sprites.clear
  142. end
  143. #--------------------------------------------------------------------------
  144. # * Update
  145. #--------------------------------------------------------------------------
  146. def update
  147. @command_sprites.each do |sprite|
  148. sprite.update
  149. end
  150. end
  151. end
  152. #--------------------------------------------------------------------------
  153. # Window_Command
  154. #--------------------------------------------------------------------------
  155. class Window_Command < Window_Selectable
  156. attr_accessor :list
  157. end
  158. #--------------------------------------------------------------------------
  159. # Sprite_Menu_Command
  160. #--------------------------------------------------------------------------
  161. class Sprite_Menu_Command < Sprite
  162. def initialize(name,window,index,viewport)
  163. super(viewport)
  164. @name = name
  165. @menu_index = window.index
  166. @window = window
  167. @index = index
  168. @contents = Sprite.new
  169. if @index == @menu_index
  170. self.bitmap = Cache.picture("D_Selected")
  171. else
  172. self.bitmap = Cache.picture("D_Selection")
  173. end
  174. @contents.bitmap = Bitmap.new(self.bitmap.width,self.bitmap.height)
  175. self.viewport = viewport
  176. self.y = 70 + index*40
  177. self.z = 40
  178. self.opacity = 255 - (@menu_index - @index).abs*40
  179. @contents.viewport = viewport
  180. @contents.bitmap.font.name = [Command_Font]
  181. @contents.bitmap.font.outline = false
  182. @contents.x = self.x
  183. @contents.y = self.y
  184. @contents.z = 50
  185. @contents.opacity = self.opacity
  186. @slicer = Sprite.new
  187. @slicer.bitmap = Cache.picture("D_Slicer")
  188. @slicer.viewport = viewport
  189. @slicer.z = 60
  190. @slicer.x = self.x
  191. @slicer.y = self.y
  192. @slicer.opacity = 0
  193. @target_opacity = 255 - (@menu_index - @index).abs*40
  194. @chosing = false
  195. end
  196. def update_opacity
  197. self.opacity += @target_opacity*0.08 if @target_opacity != self.opacity && @target_opacity - self.opacity > 0
  198. self.opacity -= @target_opacity*0.08 if @target_opacity != self.opacity && @target_opacity - self.opacity < 0
  199. end
  200. def update_chosing
  201. if @chosing == true
  202. @slicer.ox += 5
  203. @slicer.bitmap.rect.set(0,0,162,35)
  204. if @slicer.ox > 200
  205. @slicer.ox = 0
  206. end
  207. @slicer.opacity = 255 - @slicer.ox
  208. else
  209. @slicer.opacity = 0
  210. end
  211. end
  212. def update
  213. super
  214. update_chosing
  215. update_opacity
  216. @contents.bitmap.clear
  217. @contents.bitmap.draw_text(10,0,100,32,@name)
  218. @target_opacity = (255 - (@window.index - @index).abs*40)
  219. if @index == @window.index
  220. @chosing = true
  221. self.bitmap = Cache.picture("D_Selected")
  222. else
  223. @chosing = false
  224. self.bitmap = Cache.picture("D_Selection")
  225. end
  226. @contents.opacity = self.opacity
  227. end
  228. def dispose
  229. super
  230. @contents.bitmap.dispose
  231. @contents.dispose
  232. @slicer.bitmap.dispose
  233. @slicer.dispose
  234. end
  235. end
  236.  
  237. #==============================================================================
  238. # ** Window_Gold
  239. #------------------------------------------------------------------------------
  240. # This window displays the party's gold.
  241. #==============================================================================
  242.  
  243. class Window_Gold < Window_Base
  244. #--------------------------------------------------------------------------
  245. # * Draw Number (Gold Etc.) with Currency Unit
  246. #--------------------------------------------------------------------------
  247. def draw_currency_value(value, unit, x, y, width)
  248. cx = text_size(unit).width
  249. change_color(normal_color)
  250. draw_text(x, y, width - cx - 2, line_height, value, 2)
  251. change_color(crisis_color)
  252. draw_text(x, y, width, line_height, unit, 2)
  253. end
  254. #--------------------------------------------------------------------------
  255. # * Refresh
  256. #--------------------------------------------------------------------------
  257. def refresh
  258. contents.clear
  259. contents.font.outline = false
  260. draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
  261. end
  262. end
  263. #==============================================================================
  264. # ** Window_MenuStatus
  265. #------------------------------------------------------------------------------
  266. # This window displays party member status on the menu screen.
  267. #==============================================================================
  268.  
  269. class Window_MenuStatus < Window_Selectable
  270. #--------------------------------------------------------------------------
  271. # * Public Instance Variables
  272. #--------------------------------------------------------------------------
  273. attr_reader :pending_index # Pending position (for formation)
  274. #--------------------------------------------------------------------------
  275. # * Object Initialization
  276. #--------------------------------------------------------------------------
  277. alias dark_animated_custom_menu_init_asd initialize
  278. def initialize(*args)
  279. dark_animated_custom_menu_init_asd(*args)
  280. @sprites = {}
  281. @sprites[:select] = Sprite.new
  282. @sprites[:select].bitmap = Cache.picture("D_Selection2")
  283. @sprites[:select].z = 999
  284. @sprites[:select].visible = self.active
  285. end
  286. #--------------------------------------------------------------------------
  287. # * Dispose
  288. #--------------------------------------------------------------------------
  289. alias dark_animated_custom_menu_dispose dispose
  290. def dispose
  291. dark_animated_custom_menu_dispose
  292. @sprites.values.each do |sprite|
  293. sprite.bitmap.dispose
  294. sprite.dispose
  295. end
  296. end
  297. #--------------------------------------------------------------------------
  298. # * Get Window Width
  299. #--------------------------------------------------------------------------
  300. def window_width
  301. 310
  302. end
  303. #--------------------------------------------------------------------------
  304. # * Get Window Height
  305. #--------------------------------------------------------------------------
  306. def window_height
  307. 400
  308. end
  309. #--------------------------------------------------------------------------
  310. # * Get Number of Items
  311. #--------------------------------------------------------------------------
  312. def item_max
  313. $game_party.members.size
  314. end
  315. #--------------------------------------------------------------------------
  316. # * Get Item Width
  317. #--------------------------------------------------------------------------
  318. def item_width
  319. 300
  320. end
  321. #--------------------------------------------------------------------------
  322. # * Get Item Height
  323. #--------------------------------------------------------------------------
  324. def item_height
  325. 100
  326. end
  327. #--------------------------------------------------------------------------
  328. # * Draw Item
  329. #--------------------------------------------------------------------------
  330. def draw_item(index)
  331. actor = $game_party.members[index]
  332. enabled = $game_party.battle_members.include?(actor)
  333. rect = item_rect(index)
  334. draw_item_background(index)
  335. draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
  336. draw_actor_simple_status(actor, rect.x + 10, rect.y + line_height / 2)
  337. end
  338. #--------------------------------------------------------------------------
  339. # * Draw Simple Status
  340. #--------------------------------------------------------------------------
  341. def draw_actor_simple_status(actor, x, y)
  342. contents.font.size = 18
  343. draw_actor_name(actor, x + 90, y)
  344. draw_actor_level(actor, x + 90, y + line_height * 1)
  345. reset_font_settings
  346. draw_actor_icons(actor, x, y + line_height * 2)
  347. draw_actor_hp(actor, x + 150, y + line_height * 1)
  348. draw_actor_mp(actor, x + 150, y + line_height * 2)
  349. contents.font.size = 16
  350. draw_actor_class(actor, x + 155, y)
  351. reset_font_settings
  352. end
  353. #--------------------------------------------------------------------------
  354. # * Update
  355. #--------------------------------------------------------------------------
  356. def update
  357. super
  358. cursor_rect.width = 0
  359. cursor_rect.height = 0
  360. rect = cursor_rect
  361. @sprites[:select].y = self.y + rect.y - self.oy + 10
  362. @sprites[:select].visible = self.active
  363. @sprites[:select].x = self.x
  364. end
  365. end
Advertisement
Add Comment
Please, Sign In to add comment