Raizen

Untitled

Apr 26th, 2014
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.56 KB | None | 0 0
  1. #==================================================================
  2. # CRM Art Gallery
  3. # Author: Raizen
  4. # Comuninity : http://centrorpg.com/
  5. # Compatibility: RMVXA
  6. #==================================================================
  7.  
  8. # Instructions:
  9.  
  10. # Really easy and simple to use and modify, to modify the images,
  11. # Go to Graphics/Gallery inside your project folder and trade the images
  12. # inside, with images of the same name.
  13. # In case you have erased any of the images, here is a relation of
  14. # the images' name needed.
  15.  
  16. # To call the art gallery.
  17. # Script Call: SceneManager.call(Scene_CRM_Gallery)
  18.  
  19. =begin
  20. Image Names
  21.  
  22. => superior
  23. => superior2
  24. => ArrowDown
  25. => ArrowLeft
  26. => ArrowUp
  27. => ArrowRight
  28. => background
  29.  
  30.  
  31. =end
  32.  
  33. #====================================================================
  34.  
  35. # Here you configure the script according to the images you wish.
  36.  
  37. module CRM_Gallery
  38.  
  39.  
  40. # Put the images' name inside "" in the order you wish to appear in the gallery,
  41. # with the switch you want to use to unlock the image.
  42.  
  43. # You can use any size of Image, they are automatically resized to fit the screen.
  44.  
  45. # Following this pattern,
  46.  
  47. # 'Image Name' => Switch number.
  48.  
  49. Gallery = {
  50. 'Imagem (1)' => 1 ,
  51. 'Imagem (2)' => 2 ,
  52. 'Imagem (3)' => 3 ,
  53. 'Imagem (4)' => 4 ,
  54. 'Imagem (5)' => 5 ,
  55. 'Imagem (6)' => 6 ,
  56. 'Imagem (7)' => 7 ,
  57. 'Imagem (8)' => 8 ,
  58. }
  59.  
  60.  
  61. # Here the cursor position for image moving.
  62. # X
  63. Cur_X = 182
  64. # Y
  65. Cur_Y = 230
  66.  
  67. # Time it will take in frames to erase the cursors and superior image.
  68. # (60 frames = 1 second)
  69. Time = 200
  70.  
  71.  
  72. # Add the gallery to the default Menu?
  73. # (false if true is not compatible with the menu being used)
  74.  
  75. Add = true
  76.  
  77. # Name on the Menu
  78.  
  79. Name = "Gallery"
  80. # =============================================================================
  81. # =========================Here starts the script===============================
  82. # =============================================================================
  83.  
  84. end
  85. #==============================================================================
  86. # ** Cache
  87. #------------------------------------------------------------------------------
  88. # Este modulo carrega cada gráfico, cria um objeto de Bitmap e retém ele.
  89. # Para acelerar o carregamento e preservar memória, este módulo matém o
  90. # objeto de Bitmap em uma Hash interna, permitindo que retorne objetos
  91. # pré-existentes quando mesmo Bitmap é requerido novamente.
  92. #==============================================================================
  93.  
  94.  
  95. module Cache
  96. #--------------------------------------------------------------------------
  97. # * Carregamento dos gráficos de animação
  98. # filename : nome do arquivo
  99. # hue : informações da alteração de tonalidade
  100. #--------------------------------------------------------------------------
  101. def self.gallery(filename)
  102. load_bitmap("Graphics/Gallery/", filename)
  103. end
  104. end
  105. #==============================================================================
  106. # ** Scene_CRM_Gallery
  107. #------------------------------------------------------------------------------
  108. # Esta classe executa a preview das imagens
  109. #==============================================================================
  110.  
  111. class Scene_CRM_Gallery < Scene_Base
  112. #--------------------------------------------------------------------------
  113. # * Inicialização do processo
  114. # * Carregamento de Imagens (pode demorar caso tenha muitas imagens)
  115. #--------------------------------------------------------------------------
  116. def start
  117. super
  118. @background = Sprite.new
  119. @background.bitmap = Cache.gallery("background")
  120. @front = Sprite.new
  121. @front.bitmap = Cache.gallery("superior")
  122. @front.z = 20
  123. @gallery = Array.new
  124. @gallery_pic = Array.new
  125. @number = Array.new
  126. @current_gallery = CRM_Gallery::Gallery
  127. @current_gallery = @current_gallery.flatten.rotate!($current_pic*2)
  128. until @gallery.size > 6
  129. for n in 0...@current_gallery.size/2
  130. @gallery.push(@current_gallery[n*2]) if $game_switches[@current_gallery[(n*2)+1]]
  131. n += 1
  132. end
  133. if @gallery.size == 0
  134. terminate
  135. return_scene
  136. return
  137. end
  138. end
  139. @number[n] = n
  140. @gallery_pic[n] = Sprite.new
  141. @gallery_pic[n].bitmap = Cache.gallery(@gallery[n])
  142. @gallery_pic[n].x = 130*n - 170
  143. @gallery_pic[n].y = 325
  144. @gallery_pic[n].zoom_x = 108.8/@gallery_pic[n].width
  145. @gallery_pic[n].zoom_y = 83.2/@gallery_pic[n].height
  146. end
  147. @preview = Sprite.new
  148. @preview.bitmap = Cache.gallery(@gallery[3])
  149. @preview.zoom_x = 299.2/@preview.width
  150. @preview.zoom_y = 228.8/@preview.height
  151. @preview.x = 120
  152. @preview.y = 55
  153. end
  154. #--------------------------------------------------------------------------
  155. # * finalização do processo
  156. #--------------------------------------------------------------------------
  157. def terminate
  158. super
  159. @gallery_pic.each {|gallery| gallery.bitmap.dispose ; gallery.dispose}
  160. @front.bitmap.dispose
  161. @background.bitmap.dispose
  162. @front.dispose
  163. @background.dispose
  164. if @preview
  165. @preview.bitmap.dispose
  166. @preview.dispose
  167. end
  168. end
  169. #--------------------------------------------------------------------------
  170. # * Atualização da tela
  171. #--------------------------------------------------------------------------
  172. def update
  173. super
  174. for n in 0...@gallery_pic.size
  175. if n > 0 && n < @gallery_pic.size - 1
  176. if @gallery_pic[@number[n]].x > 130 * n - 170
  177. @gallery_pic[@number[n]].x -= 13
  178. elsif @gallery_pic[@number[n]].x < 130 * n - 170
  179. @gallery_pic[@number[n]].x += 13
  180. end
  181. else
  182. @gallery_pic[@number[n]].x = 130 * n - 170
  183. end
  184. if n == 3
  185. @gallery_pic[@number[n]].y -= 4 if @gallery_pic[@number[n]].y > 305
  186. else
  187. @gallery_pic[@number[n]].y += 4 if @gallery_pic[@number[n]].y < 325
  188. end
  189. end
  190. return_scene && Sound.play_cancel if Input.trigger?(:B)
  191. if Input.trigger?(:RIGHT)
  192. @number.rotate!(1)
  193. Sound.play_cursor
  194. @preview.bitmap = Cache.gallery(@gallery[@number[3]])
  195. @preview.zoom_x = 299.2/@preview.width
  196. @preview.zoom_y = 228.8/@preview.height
  197. end
  198. if Input.trigger?(:LEFT)
  199. @number.rotate!(-1)
  200. Sound.play_cursor
  201. @preview.bitmap = Cache.gallery(@gallery[@number[3]])
  202. @preview.zoom_x = 299.2/@preview.width
  203. @preview.zoom_y = 228.8/@preview.height
  204. end
  205. if Input.trigger?(:C)
  206. $gallery_crm_pic = @gallery[@number[3]]
  207. $current_pic = @number.first
  208. Sound.play_ok
  209. SceneManager.call(Scene_Show_Gal)
  210. end
  211. end
  212. end
  213.  
  214. #==============================================================================
  215. # ** Scene_Show_Gal
  216. #------------------------------------------------------------------------------
  217. # Esta classe executa a imagem após a escolha
  218. #==============================================================================
  219.  
  220. #--------------------------------------------------------------------------
  221. # * Inicialização do processo
  222. # * Carregamento de Imagens (pode demorar caso seja muito grande a imagem)
  223. #--------------------------------------------------------------------------
  224.  
  225. class Scene_Show_Gal < Scene_Base
  226. def start
  227. super
  228. @pic = Sprite.new
  229. @pic.bitmap = Cache.gallery($gallery_crm_pic)
  230. @pic.x = Graphics.width/2 - @pic.width/2
  231. @pic.y = Graphics.height/2 - @pic.height/2
  232. @all_zoom = false
  233. @get_i = ["superior2", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"]
  234. @images = Array.new
  235. @reset = 0
  236. for n in 1..4
  237. @images[n] = Sprite.new
  238. @images[n].bitmap = Cache.gallery(@get_i[n])
  239. @images[n].x = CRM_Gallery::Cur_X
  240. @images[n].y = CRM_Gallery::Cur_Y
  241. @images[n].opacity = 100
  242. end
  243. @images[0] = Sprite.new
  244. @images[0].bitmap = Cache.gallery(@get_i[0])
  245. @images[0].opacity = 170
  246. update
  247. end
  248.  
  249. #--------------------------------------------------------------------------
  250. # * Atualização da tela
  251. #--------------------------------------------------------------------------
  252. def update
  253. super
  254. return_scene && Sound.play_cancel if Input.trigger?(:B)
  255. for n in 1..4
  256. @reset >= CRM_Gallery::Time*3 ? @images[n].opacity = 0 : @images[n].opacity = 100
  257. end
  258. @reset >= CRM_Gallery::Time*3 ? @images[0].opacity = 0 : @images[0].opacity = 170
  259. unless @all_zoom
  260. if Input.press?(:UP) && @pic.y < -3
  261. @pic.y += 4
  262. @images[2].opacity = 255
  263. end
  264. if Input.press?(:DOWN) && @pic.y > Graphics.height - @pic.height
  265. @pic.y -= 4
  266. @images[1].opacity = 255
  267. end
  268. if Input.press?(:RIGHT) && @pic.x > Graphics.width - @pic.width
  269. @pic.x -= 4
  270. @images[3].opacity = 255
  271. end
  272. if Input.press?(:LEFT) && @pic.x < 0
  273. @pic.x += 4
  274. @images[4].opacity = 255
  275. end
  276. if Input.trigger?(:C)
  277. @all_zoom = true
  278. Sound.play_ok
  279. @pic.zoom_x = Graphics.width.to_f / @pic.width
  280. @pic.zoom_y = Graphics.height.to_f / @pic.height
  281. @pic.x = 0
  282. @pic.y = 0
  283. end
  284. else
  285. if Input.trigger?(:C)
  286. @all_zoom = false
  287. Sound.play_ok
  288. @pic.zoom_x = 1
  289. @pic.zoom_y = 1
  290. @pic.x = Graphics.width/2 - @pic.width/2
  291. @pic.y = Graphics.height/2 - @pic.height/2
  292. end
  293. end
  294. @images.each {|image| image.opacity == 255 ? @reset = 0 : @reset += 1}
  295. end
  296. #--------------------------------------------------------------------------
  297. # * Finalizando o processo
  298. #--------------------------------------------------------------------------
  299. def terminate
  300. super
  301. @pic.bitmap.dispose
  302. @pic.dispose
  303. @images.each {|image| image.bitmap.dispose ; image.dispose}
  304. end
  305. end
  306.  
  307. if CRM_Gallery::Add
  308. #==============================================================================
  309. # ** Scene_Menu
  310. #------------------------------------------------------------------------------
  311. # Esta classe executa o processamento da tela de menu.
  312. #==============================================================================
  313.  
  314. class Scene_Menu < Scene_MenuBase
  315. def create_command_window
  316. @command_window = Window_MenuCommand.new
  317. @command_window.set_handler(:item, method(:command_item))
  318. @command_window.set_handler(:skill, method(:command_personal))
  319. @command_window.set_handler(:equip, method(:command_personal))
  320. @command_window.set_handler(:status, method(:command_personal))
  321. @command_window.set_handler(:gallery, method(:command_gallery))
  322. @command_window.set_handler(:formation, method(:command_formation))
  323. @command_window.set_handler(:save, method(:command_save))
  324. @command_window.set_handler(:game_end, method(:command_game_end))
  325. @command_window.set_handler(:cancel, method(:return_scene))
  326. end
  327. def command_gallery
  328. SceneManager.call(Scene_CRM_Gallery)
  329. end
  330. end
  331. $current_pic = 0
  332. #==============================================================================
  333. # ** Window_MenuCommand
  334. #------------------------------------------------------------------------------
  335. # Esta janela exibe os comandos do menu.
  336. #==============================================================================
  337. class Window_MenuCommand < Window_Command
  338. alias raizen_add_main_commands add_main_commands
  339. def add_main_commands
  340. raizen_add_main_commands
  341. add_command(CRM_Gallery::Name, :gallery, main_commands_enabled)
  342. end
  343. end
  344. end
Advertisement
Add Comment
Please, Sign In to add comment