Advertisement
Raizen

Untitled

Apr 26th, 2014
381
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. for n in 0...@gallery.size
  140. @number[n] = n
  141. @gallery_pic[n] = Sprite.new
  142. @gallery_pic[n].bitmap = Cache.gallery(@gallery[n])
  143. @gallery_pic[n].x = 130*n - 170
  144. @gallery_pic[n].y = 325
  145. @gallery_pic[n].zoom_x = 108.8/@gallery_pic[n].width
  146. @gallery_pic[n].zoom_y = 83.2/@gallery_pic[n].height
  147. end
  148. @preview = Sprite.new
  149. @preview.bitmap = Cache.gallery(@gallery[3])
  150. @preview.zoom_x = 299.2/@preview.width
  151. @preview.zoom_y = 228.8/@preview.height
  152. @preview.x = 120
  153. @preview.y = 55
  154. end
  155. #--------------------------------------------------------------------------
  156. # * finalização do processo
  157. #--------------------------------------------------------------------------
  158. def terminate
  159. super
  160. @gallery_pic.each {|gallery| gallery.bitmap.dispose ; gallery.dispose}
  161. @front.bitmap.dispose
  162. @background.bitmap.dispose
  163. @front.dispose
  164. @background.dispose
  165. if @preview
  166. @preview.bitmap.dispose
  167. @preview.dispose
  168. end
  169. end
  170. #--------------------------------------------------------------------------
  171. # * Atualização da tela
  172. #--------------------------------------------------------------------------
  173. def update
  174. super
  175. for n in 0...@gallery_pic.size
  176. if n > 0 && n < @gallery_pic.size - 1
  177. if @gallery_pic[@number[n]].x > 130 * n - 170
  178. @gallery_pic[@number[n]].x -= 13
  179. elsif @gallery_pic[@number[n]].x < 130 * n - 170
  180. @gallery_pic[@number[n]].x += 13
  181. end
  182. else
  183. @gallery_pic[@number[n]].x = 130 * n - 170
  184. end
  185. if n == 3
  186. @gallery_pic[@number[n]].y -= 4 if @gallery_pic[@number[n]].y > 305
  187. else
  188. @gallery_pic[@number[n]].y += 4 if @gallery_pic[@number[n]].y < 325
  189. end
  190. end
  191. return_scene && Sound.play_cancel if Input.trigger?(:B)
  192. if Input.trigger?(:RIGHT)
  193. @number.rotate!(1)
  194. Sound.play_cursor
  195. @preview.bitmap = Cache.gallery(@gallery[@number[3]])
  196. @preview.zoom_x = 299.2/@preview.width
  197. @preview.zoom_y = 228.8/@preview.height
  198. end
  199. if Input.trigger?(:LEFT)
  200. @number.rotate!(-1)
  201. Sound.play_cursor
  202. @preview.bitmap = Cache.gallery(@gallery[@number[3]])
  203. @preview.zoom_x = 299.2/@preview.width
  204. @preview.zoom_y = 228.8/@preview.height
  205. end
  206. if Input.trigger?(:C)
  207. $gallery_crm_pic = @gallery[@number[3]]
  208. $current_pic = @number.first
  209. Sound.play_ok
  210. SceneManager.call(Scene_Show_Gal)
  211. end
  212. end
  213. end
  214.  
  215. #==============================================================================
  216. # ** Scene_Show_Gal
  217. #------------------------------------------------------------------------------
  218. # Esta classe executa a imagem após a escolha
  219. #==============================================================================
  220.  
  221. #--------------------------------------------------------------------------
  222. # * Inicialização do processo
  223. # * Carregamento de Imagens (pode demorar caso seja muito grande a imagem)
  224. #--------------------------------------------------------------------------
  225.  
  226. class Scene_Show_Gal < Scene_Base
  227. def start
  228. super
  229. @pic = Sprite.new
  230. @pic.bitmap = Cache.gallery($gallery_crm_pic)
  231. @pic.x = Graphics.width/2 - @pic.width/2
  232. @pic.y = Graphics.height/2 - @pic.height/2
  233. @all_zoom = false
  234. @get_i = ["superior2", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"]
  235. @images = Array.new
  236. @reset = 0
  237. for n in 1..4
  238. @images[n] = Sprite.new
  239. @images[n].bitmap = Cache.gallery(@get_i[n])
  240. @images[n].x = CRM_Gallery::Cur_X
  241. @images[n].y = CRM_Gallery::Cur_Y
  242. @images[n].opacity = 100
  243. end
  244. @images[0] = Sprite.new
  245. @images[0].bitmap = Cache.gallery(@get_i[0])
  246. @images[0].opacity = 170
  247. update
  248. end
  249.  
  250. #--------------------------------------------------------------------------
  251. # * Atualização da tela
  252. #--------------------------------------------------------------------------
  253. def update
  254. super
  255. return_scene && Sound.play_cancel if Input.trigger?(:B)
  256. for n in 1..4
  257. @reset >= CRM_Gallery::Time*3 ? @images[n].opacity = 0 : @images[n].opacity = 100
  258. end
  259. @reset >= CRM_Gallery::Time*3 ? @images[0].opacity = 0 : @images[0].opacity = 170
  260. unless @all_zoom
  261. if Input.press?(:UP) && @pic.y < -3
  262. @pic.y += 4
  263. @images[2].opacity = 255
  264. end
  265. if Input.press?(:DOWN) && @pic.y > Graphics.height - @pic.height
  266. @pic.y -= 4
  267. @images[1].opacity = 255
  268. end
  269. if Input.press?(:RIGHT) && @pic.x > Graphics.width - @pic.width
  270. @pic.x -= 4
  271. @images[3].opacity = 255
  272. end
  273. if Input.press?(:LEFT) && @pic.x < 0
  274. @pic.x += 4
  275. @images[4].opacity = 255
  276. end
  277. if Input.trigger?(:C)
  278. @all_zoom = true
  279. Sound.play_ok
  280. @pic.zoom_x = Graphics.width.to_f / @pic.width
  281. @pic.zoom_y = Graphics.height.to_f / @pic.height
  282. @pic.x = 0
  283. @pic.y = 0
  284. end
  285. else
  286. if Input.trigger?(:C)
  287. @all_zoom = false
  288. Sound.play_ok
  289. @pic.zoom_x = 1
  290. @pic.zoom_y = 1
  291. @pic.x = Graphics.width/2 - @pic.width/2
  292. @pic.y = Graphics.height/2 - @pic.height/2
  293. end
  294. end
  295. @images.each {|image| image.opacity == 255 ? @reset = 0 : @reset += 1}
  296. end
  297. #--------------------------------------------------------------------------
  298. # * Finalizando o processo
  299. #--------------------------------------------------------------------------
  300. def terminate
  301. super
  302. @pic.bitmap.dispose
  303. @pic.dispose
  304. @images.each {|image| image.bitmap.dispose ; image.dispose}
  305. end
  306. end
  307.  
  308. if CRM_Gallery::Add
  309. #==============================================================================
  310. # ** Scene_Menu
  311. #------------------------------------------------------------------------------
  312. # Esta classe executa o processamento da tela de menu.
  313. #==============================================================================
  314.  
  315. class Scene_Menu < Scene_MenuBase
  316. def create_command_window
  317. @command_window = Window_MenuCommand.new
  318. @command_window.set_handler(:item, method(:command_item))
  319. @command_window.set_handler(:skill, method(:command_personal))
  320. @command_window.set_handler(:equip, method(:command_personal))
  321. @command_window.set_handler(:status, method(:command_personal))
  322. @command_window.set_handler(:gallery, method(:command_gallery))
  323. @command_window.set_handler(:formation, method(:command_formation))
  324. @command_window.set_handler(:save, method(:command_save))
  325. @command_window.set_handler(:game_end, method(:command_game_end))
  326. @command_window.set_handler(:cancel, method(:return_scene))
  327. end
  328. def command_gallery
  329. SceneManager.call(Scene_CRM_Gallery)
  330. end
  331. end
  332. $current_pic = 0
  333. #==============================================================================
  334. # ** Window_MenuCommand
  335. #------------------------------------------------------------------------------
  336. # Esta janela exibe os comandos do menu.
  337. #==============================================================================
  338. class Window_MenuCommand < Window_Command
  339. alias raizen_add_main_commands add_main_commands
  340. def add_main_commands
  341. raizen_add_main_commands
  342. add_command(CRM_Gallery::Name, :gallery, main_commands_enabled)
  343. end
  344. end
  345. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement