Advertisement
Guest User

Picture Gallery MOG

a guest
Feb 21st, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.12 KB | None | 0 0
  1. #==============================================================================
  2. # +++ MOG - Picture Gallery ACE (v2.0) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # Sistema de galeria de imagens.
  8. #==============================================================================
  9. # Para ativar o script use o comando abaixo através de um evento usando o
  10. # comando chamar script. (Call Script)
  11. #
  12. # picture_gallery
  13. #
  14. #==============================================================================
  15. # Para disponibilizar as imagens na galeria você deverá usar o seguinte
  16. # código através do comando chamar script.
  17. #
  18. # enable_picture(ID)
  19. #
  20. # EX enable_picture(10)
  21. #
  22. # Para desativar a imagem use o código abaixo
  23. #
  24. # disable_picture(ID)
  25. #
  26. #==============================================================================
  27. # Você deverá criar uma pasta com o nome "Gallery" onde as imagens deverão
  28. # ser gravadas.
  29. #
  30. # Graphics/Gallery/
  31. #
  32. # A nomeação das imagens devem ser numéricas. (ID da imagem)
  33. # 0.jpg (Imagem não disponível.)
  34. # 1.jpg
  35. # 2.jpg
  36. # 3.jpg
  37. # ...
  38. #
  39. #==============================================================================
  40. # ● Version History
  41. #==============================================================================
  42. # 2.0 - Compatibilidade com resoluções maiores que o padrão normal.
  43. # - Compatibilidade com imagens de qualquer resolução.
  44. # - Velocidade de movimento baseado no tamanho da imagem.
  45. # - Adições de novos comandos e configurações visando melhor
  46. # versatilidade.
  47. #
  48. #==============================================================================
  49. module MOG_PICTURE_GALLERY
  50. #Quantidade maxima de imagens na galeria.
  51. MAX_PICTURES = 40
  52. #Definição da velocidade no movimento da imagem.
  53. SCROLL_SPEED = [3,3]
  54. #Definição da posição do texto de informação.
  55. HELP_POSITION = [0,0]
  56. #Definição do texto da janela de ajuda.
  57. HELP_TEXT = ["Page - ","Pictures"]
  58. #Definição da fonte da janela de ajuda.
  59. HELP_FONT_NAME = "Arial"
  60. HELP_FONT_SIZE = 18
  61. HELP_FONT_BOLD = false
  62. #Definição da posição do cursor da página.
  63. # PAGE_CURSOR_POSITION = [X LEFT,Y LEFT ,X RIGHT,Y RIGHT]
  64. PAGE_CURSOR_POSITION = [0,0,0,0]
  65. #Ativar o Scene Picture Gallery no Menu
  66. PICTURE_GALLERY_MENU_COMMAND = true
  67. #Nome do comando apresentado no menu.
  68. PICTURE_GALLERY_COMMAND_NAME = "Picture Gallery"
  69. end
  70.  
  71. $imported = {} if $imported.nil?
  72. $imported[:mog_picture_gallery] = true
  73.  
  74. #==============================================================================
  75. # ■ Game_System
  76. #==============================================================================
  77. class Game_System
  78.  
  79. attr_accessor :gallery
  80.  
  81. #------------------------------------------------------------------------------
  82. # ● Initialize
  83. #------------------------------------------------------------------------------
  84. alias art_picture_initialize initialize
  85. def initialize
  86. art_picture_initialize
  87. @gallery = []
  88. end
  89. end
  90.  
  91. #==============================================================================
  92. # ■ Game Interpreter
  93. #==============================================================================
  94. class Game_Interpreter
  95.  
  96. #------------------------------------------------------------------------------
  97. # ● Picture Gallery
  98. #------------------------------------------------------------------------------
  99. def picture_gallery
  100. SceneManager.call(Scene_Picture_Gallery)
  101. end
  102.  
  103. #------------------------------------------------------------------------------
  104. # ● Enable Picture
  105. #------------------------------------------------------------------------------
  106. def enable_picture(id, value = true)
  107. $game_system.gallery[id] = value
  108. end
  109.  
  110. #------------------------------------------------------------------------------
  111. # ● Disable Picture
  112. #------------------------------------------------------------------------------
  113. def disable_picture(id, value = false)
  114. $game_system.gallery[id] = value
  115. end
  116.  
  117. end
  118.  
  119. #==============================================================================
  120. # ■ RPG
  121. #==============================================================================
  122. module Cache
  123.  
  124. #------------------------------------------------------------------------------
  125. # ● Gallery
  126. #------------------------------------------------------------------------------
  127. def self.gallery(filename)
  128. load_bitmap("Graphics/Gallery/", filename)
  129. end
  130.  
  131. end
  132.  
  133.  
  134. #==============================================================================
  135. # ■ Window_Base
  136. #==============================================================================
  137. class Window_Base < Window
  138.  
  139. #--------------------------------------------------------------------------
  140. # ● Draw_Thumbnail
  141. #--------------------------------------------------------------------------
  142. def draw_thumbnail(x,y,id)
  143. bitmap = Cache.gallery(id.to_s) rescue nil
  144. return if bitmap == nil
  145. src_rect = Rect.new(0, 0, bitmap.width , bitmap.height )
  146. src_rect2 = Rect.new(x, y, 118, 59)
  147. self.contents.stretch_blt(src_rect2, bitmap, src_rect)
  148. bitmap.dispose
  149. end
  150.  
  151. end
  152.  
  153. #==============================================================================
  154. # ■ Window_Picture
  155. #==============================================================================
  156. class Window_Picture < Window_Selectable
  157.  
  158. #------------------------------------------------------------------------------
  159. # ● Initialize
  160. #------------------------------------------------------------------------------
  161. def initialize(page)
  162. super(0, 64, Graphics.width, Graphics.height - 32)
  163. self.opacity = 0
  164. @index = -1
  165. @page = page
  166. @pic_max = MOG_PICTURE_GALLERY::MAX_PICTURES
  167. @pic_max = 1 if @pic_max <= 0
  168. @pag_max = @pic_max / 9
  169. if @pag_max == page
  170. o = @pag_max * 9
  171. o2 = @pic_max - o
  172. @item_max = o2
  173. else
  174. @item_max = 9
  175. end
  176. @i_max = @item_max
  177. refresh(page)
  178. select(0)
  179. activate
  180. end
  181.  
  182. #------------------------------------------------------------------------------
  183. # ● Refresh
  184. #------------------------------------------------------------------------------
  185. def refresh(page = 0)
  186. if self.contents != nil
  187. self.contents.dispose
  188. self.contents = nil
  189. end
  190. if @item_max > 0
  191. self.contents = Bitmap.new(width - 32, 6 * 89)
  192. for i in 0...@item_max
  193. draw_item(i,page)
  194. end
  195. end
  196. end
  197.  
  198. #------------------------------------------------------------------------------
  199. # ● WX
  200. #------------------------------------------------------------------------------
  201. def wx
  202. (Graphics.width ) / 3
  203. end
  204.  
  205. #------------------------------------------------------------------------------
  206. # ● WY
  207. #------------------------------------------------------------------------------
  208. def wy
  209. (Graphics.height + 64) / 5
  210. end
  211.  
  212. #------------------------------------------------------------------------------
  213. # ● SX
  214. #------------------------------------------------------------------------------
  215. def sx
  216. (Graphics.width / 96).truncate
  217. end
  218.  
  219. #------------------------------------------------------------------------------
  220. # ● SY
  221. #------------------------------------------------------------------------------
  222. def sy
  223. (Graphics.height - 416) / 12
  224. end
  225.  
  226. #------------------------------------------------------------------------------
  227. # ● draw_item
  228. #------------------------------------------------------------------------------
  229. def draw_item(index,page)
  230. np = 9 * page
  231. picture_number = index + 1 + np
  232. x = sx + 16 + index % 3 * wx
  233. y = sy + 12 + index / 3 * wy
  234. s = picture_number
  235. s = 0 if $game_system.gallery[picture_number] == nil
  236. draw_thumbnail(x,y,s)
  237. self.contents.draw_text(x + 30,y + 49, 64, 32, "N - " + picture_number.to_s,1)
  238. end
  239.  
  240. #------------------------------------------------------------------------------
  241. # ● item_rect
  242. #------------------------------------------------------------------------------
  243. def item_rect(index)
  244. rect = Rect.new(0, 0, 0, 0)
  245. rect.width = 150
  246. rect.height = 90
  247. rect.x = sx + (@index % col_max * wx)
  248. rect.y = sy + (@index / col_max * wy)
  249. return rect
  250. end
  251.  
  252. #------------------------------------------------------------------------------
  253. # ● Col Max
  254. #------------------------------------------------------------------------------
  255. def col_max
  256. return 3
  257. end
  258.  
  259. #------------------------------------------------------------------------------
  260. # ● Item Max
  261. #------------------------------------------------------------------------------
  262. def item_max
  263. return @item_max == nil ? 0 : @item_max
  264. end
  265.  
  266. end
  267.  
  268. #==============================================================================
  269. # ■ Window Help
  270. #==============================================================================
  271. class Window_Help < Window_Base
  272.  
  273. #--------------------------------------------------------------------------
  274. # * Set Text
  275. #--------------------------------------------------------------------------
  276. def set_text_pic(text)
  277. if text != @text
  278. @text = text
  279. refresh_pic
  280. end
  281. end
  282.  
  283. #--------------------------------------------------------------------------
  284. # * Refresh
  285. #--------------------------------------------------------------------------
  286. def refresh_pic
  287. contents.clear
  288. draw_text_ex_pic(4, 0, @text)
  289. end
  290.  
  291. #--------------------------------------------------------------------------
  292. # * Draw Text with Control Characters
  293. #--------------------------------------------------------------------------
  294. def draw_text_ex_pic(x, y, text)
  295. reset_font_settings
  296. text = convert_escape_characters(text)
  297. pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  298. contents.font.size = MOG_PICTURE_GALLERY::HELP_FONT_SIZE
  299. contents.font.name = MOG_PICTURE_GALLERY::HELP_FONT_NAME
  300. contents.font.bold = MOG_PICTURE_GALLERY::HELP_FONT_BOLD
  301. process_character(text.slice!(0, 1), text, pos) until text.empty?
  302. end
  303.  
  304. end
  305.  
  306.  
  307. #==============================================================================
  308. # ■ Scene_Picture Gallery
  309. #==============================================================================
  310. class Scene_Picture_Gallery
  311. include MOG_PICTURE_GALLERY
  312.  
  313. #------------------------------------------------------------------------------
  314. # ● Main
  315. #------------------------------------------------------------------------------
  316. def main
  317. setup
  318. execute_dispose
  319. create_image
  320. create_background
  321. create_loading_text
  322. create_window
  323. create_cursor
  324. create_button
  325. execute_loop
  326. execute_dispose
  327. end
  328.  
  329. #------------------------------------------------------------------------------
  330. # ● Create_Loading
  331. #------------------------------------------------------------------------------
  332. def create_loading_text
  333. @loading = Sprite.new
  334. @loading.bitmap = Bitmap.new(100,32)
  335. @loading.z = 300
  336. @loading.bitmap.font.size = 20
  337. @loading.bitmap.font.bold = true
  338. @loading.bitmap.font.name = "Georgia"
  339. @loading.bitmap.draw_text(0,0, 100, 32, "Loading...",1)
  340. @loading.x = (Graphics.width / 2) - 50
  341. @loading.y = (Graphics.height / 2)
  342. Graphics.transition(20)
  343. end
  344.  
  345. #------------------------------------------------------------------------------
  346. # ● Setup
  347. #------------------------------------------------------------------------------
  348. def setup
  349. @max_pictures = MAX_PICTURES
  350. @max_pictures = 1 if @max_pictures <= 0
  351. v = (@max_pictures / 9)
  352. v2 = (v - 1) * 9
  353. v3 = (@max_pictures - v2) - 9
  354. if v3 != 0
  355. @max_pages = (@max_pictures / 9) + 1
  356. else
  357. @max_pages = (@max_pictures / 9)
  358. end
  359. @max_pages = 1 if @max_pages == 0
  360. @aw_center = 0
  361. @aw_left = 0
  362. @aw_right = 0
  363. @slide_type = 0
  364. @page_old = 0
  365. @picture_id = 0
  366. @image_active = false
  367. @old_index = 0
  368. @picures_enabled = 0
  369. @comp = 0
  370. @ex = 0
  371. @ey = 0
  372. @ex_max = 0
  373. @ey_max = 0
  374. @ex_max_zoom = 0
  375. @ey_max_zoom = 0
  376. @move_hor = true
  377. @move_ver = true
  378. @scroll_speed = [0,0]
  379. @pic_center_pos = [0,0]
  380. for i in 0..MAX_PICTURES
  381. @picures_enabled += 1 if $game_system.gallery[i]
  382. end
  383. end
  384.  
  385. #------------------------------------------------------------------------------
  386. # ● create_background
  387. #------------------------------------------------------------------------------
  388. def create_background
  389. @background = Sprite.new
  390. @background.bitmap = Cache.gallery("Background")
  391. @background.z = 0
  392. @background2 = Plane.new
  393. @background2.bitmap = Cache.gallery("Background2")
  394. @background2.z = -1
  395. end
  396.  
  397. #------------------------------------------------------------------------------
  398. # ● Create Window
  399. #------------------------------------------------------------------------------
  400. def create_window
  401. @info = Window_Help.new
  402. @info.x = HELP_POSITION[0]
  403. @info.y = (Graphics.height - 48) + HELP_POSITION[1]
  404. @info.opacity = 0
  405. @wp_page = 0
  406. @wp_page_old = @wp_page
  407. @wp_index = 0
  408. @wp =[]
  409. for i in 0...@max_pages
  410. @wp[i] = Window_Picture.new(i)
  411. end
  412. check_active_window(true)
  413. refresh_info_window(true)
  414. end
  415.  
  416. #------------------------------------------------------------------------------
  417. # ● Create_image
  418. #------------------------------------------------------------------------------
  419. def create_image
  420. @picture = Sprite.new
  421. @picture.bitmap = Cache.gallery("")
  422. @picture.z = 100
  423. @picture.opacity = 0
  424. end
  425.  
  426. #------------------------------------------------------------------------------
  427. # ● Check Active Window
  428. #------------------------------------------------------------------------------
  429. def check_active_window(starting = false)
  430. for i in 0...@max_pages
  431. if i == @wp_page
  432. @wp[@wp_page].active = true
  433. @wp[@wp_page].visible = true
  434. if @slide_type == 0
  435. @wp[@wp_page].x = Graphics.width
  436. else
  437. @wp[@wp_page].x = -Graphics.width
  438. end
  439. elsif i == @page_old and starting == false
  440. @wp[@page_old].active = false
  441. @wp[@page_old].visible = true
  442. @wp[@page_old].visible = false if starting
  443. @wp[@page_old].x = 0
  444. else
  445. @wp[i].active = false
  446. @wp[i].visible = false
  447. end
  448. end
  449. end
  450.  
  451. #------------------------------------------------------------------------------
  452. # ● Create Button
  453. #------------------------------------------------------------------------------
  454. def create_button
  455. @button_image = Cache.gallery("Button")
  456. @button_bitmap = Bitmap.new(@button_image.width, @button_image.height)
  457. @cw = @button_image.width
  458. @ch = @button_image.height / 2
  459. src_rect = Rect.new(0, 0, @cw, @ch)
  460. @button_bitmap .blt(0,0, @button_image, src_rect)
  461. @button = Sprite.new
  462. @button.bitmap = @button_bitmap
  463. @button.x = 2
  464. @button.y = Graphics.height - @ch
  465. @button.z = 250
  466. @button.opacity = 0
  467. @button_fade_time = 0
  468. end
  469.  
  470. #------------------------------------------------------------------------------
  471. # ● Create Cursor
  472. #------------------------------------------------------------------------------
  473. def create_cursor
  474. @cx1 = 0
  475. @cx2 = 0
  476. @cursor_speed = 0
  477. image = Cache.gallery("Cursor")
  478. @bitmap = Bitmap.new(image.width, image.height)
  479. cw = image.width / 2
  480. ch = image.height
  481. src_rect = Rect.new(cw, 0, cw, ch)
  482. @bitmap.blt(0,0, image, src_rect)
  483. @cx3 = Graphics.width - cw
  484. @cx_pos = [PAGE_CURSOR_POSITION[0],
  485. PAGE_CURSOR_POSITION[1] - (ch / 2),
  486. PAGE_CURSOR_POSITION[2] + Graphics.width - cw,
  487. PAGE_CURSOR_POSITION[3] - (ch / 2)
  488. ]
  489. @cursor1 = Sprite.new
  490. @cursor1.bitmap = @bitmap
  491. @cursor1.x = @cx_pos[0] + @cx1
  492. @cursor1.y = @cx_pos[1] + Graphics.height / 2
  493. @cursor1.z = 200
  494. @bitmap2 = Bitmap.new(image.width, image.height)
  495. src_rect2 = Rect.new(0, 0, cw, ch)
  496. @bitmap2.blt(0,0, image, src_rect2)
  497. @cursor2 = Sprite.new
  498. @cursor2.bitmap = @bitmap2
  499. @cursor2.x = @cx_pos[2] + @cx2
  500. @cursor2.y = @cx_pos[3] + Graphics.height / 2
  501. @cursor2.z = 200
  502. image.dispose
  503. if @max_pages == 1
  504. @cursor1.visible = false
  505. @cursor2.visible = false
  506. end
  507. end
  508.  
  509. #------------------------------------------------------------------------------
  510. # ● Execute Loop
  511. #------------------------------------------------------------------------------
  512. def execute_loop
  513. loop do
  514. Graphics.update
  515. Input.update
  516. update
  517. if SceneManager.scene != self
  518. break
  519. end
  520. end
  521. end
  522.  
  523. #------------------------------------------------------------------------------
  524. # ● Execute Dispose
  525. #------------------------------------------------------------------------------
  526. def execute_dispose
  527. return if @background == nil
  528. Graphics.freeze
  529. for i in 0...@max_pages
  530. @wp[i].dispose
  531. end
  532. @info.dispose
  533. if @picture.bitmap != nil
  534. @picture.bitmap.dispose
  535. end
  536. @picture.dispose
  537. @background.bitmap.dispose
  538. @background.dispose
  539. @background = nil
  540. @background2.bitmap.dispose
  541. @background2.dispose
  542. @bitmap.dispose
  543. @bitmap2.dispose
  544. @cursor1.bitmap.dispose
  545. @cursor1.dispose
  546. @cursor2.bitmap.dispose
  547. @cursor2.dispose
  548. @button_bitmap.dispose
  549. @button.bitmap.dispose
  550. @button.dispose
  551. @button_image.dispose
  552. if @loading != nil
  553. @loading.bitmap.dispose
  554. @loading.dispose
  555. end
  556. end
  557.  
  558. #------------------------------------------------------------------------------
  559. # ● Update
  560. #------------------------------------------------------------------------------
  561. def update
  562. @wp.each {|wid| wid.update}
  563. @info.update
  564. if @image_active
  565. update_command_image
  566. else
  567. update_command
  568. end
  569. update_slide
  570. update_image_effect
  571. update_cursor_animation
  572. refresh_info_window
  573. end
  574.  
  575. #------------------------------------------------------------------------------
  576. # ● update_cursor_animation
  577. #------------------------------------------------------------------------------
  578. def update_cursor_animation
  579. @cursor_speed += 1
  580. case @cursor_speed
  581. when 1..20
  582. @cx1 += 1
  583. @cx2 -= 1
  584. when 21..40
  585. @cx1 -= 1
  586. @cx2 += 1
  587. else
  588. @cursor_speed = 0
  589. @cx1 = 0
  590. @cx2 = 0
  591. end
  592. @cursor1.x = @cx_pos[0] + @cx1
  593. @cursor2.x = @cx_pos[2] + @cx2
  594. end
  595.  
  596. #------------------------------------------------------------------------------
  597. # ● Update Image Effect
  598. #------------------------------------------------------------------------------
  599. def update_image_effect
  600. return if @wp[@wp_page].x != 0
  601. @button_fade_time -= 1 if @button_fade_time > 0
  602. if @image_active
  603. @picture.opacity += 15
  604. if @button_fade_time != 0
  605. @button.opacity += 5
  606. else
  607. if @button.y < Graphics.height
  608. @button.opacity -= 10
  609. @button.y += 1
  610. end
  611. end
  612. @wp[@wp_page].contents_opacity -= 15
  613. @info.contents_opacity -= 15
  614. @background.opacity -= 15
  615. @cursor1.opacity -= 15
  616. @cursor2.opacity -= 15
  617. else
  618. @picture.opacity -= 10
  619. @button.opacity -= 15
  620. @wp[@wp_page].contents_opacity += 15
  621. @info.contents_opacity += 15
  622. @background.opacity += 15
  623. @cursor1.opacity += 15
  624. @cursor2.opacity += 15
  625. end
  626. end
  627.  
  628. #------------------------------------------------------------------------------
  629. # ● Refresh Info Window
  630. #------------------------------------------------------------------------------
  631. def refresh_info_window(starting = false)
  632. return if @image_active
  633. return if @wp_page_old == @wp_page and starting == false
  634. @wp_page_old = @wp_page
  635. page = @wp_page + 1
  636. @picture_id = (9 * @wp_page) + @wp[@wp_page].index + 1
  637. p_pages = " " + HELP_TEXT[0] + page.to_s + " / " + @max_pages.to_s
  638. comp = " " + "(" +(@picures_enabled.to_f / @max_pictures.to_f * 100).truncate.to_s + "%)"
  639. p_number = " " + HELP_TEXT[1] + " " + @picures_enabled.to_s + " / " + @max_pictures.to_s
  640. @info.set_text_pic(p_pages + p_number + comp)
  641. end
  642.  
  643. #------------------------------------------------------------------------------
  644. # ● Update Slide
  645. #------------------------------------------------------------------------------
  646. def update_slide
  647. @background2.ox += 1
  648. if @loading != nil
  649. @loading.opacity -= 5
  650. if @loading.opacity <= 0
  651. @loading.bitmap.dispose
  652. @loading.dispose
  653. @loading = nil
  654. end
  655. end
  656. return if @wp[@wp_page].x == 0
  657. slide_speed = 25
  658. @picture.opacity = 0
  659. @background.opacity = 255
  660. if @slide_type == 1
  661. if @wp[@wp_page].x < 0
  662. @wp[@wp_page].x += slide_speed
  663. if @wp[@wp_page].x >= 0
  664. @wp[@wp_page].x = 0
  665. end
  666. end
  667. if @wp[@page_old].x < Graphics.width
  668. @wp[@page_old].x += slide_speed
  669. if @wp[@page_old].x >= Graphics.width
  670. @wp[@page_old].x = Graphics.width
  671. end
  672. end
  673. else
  674. if @wp[@wp_page].x > 0
  675. @wp[@wp_page].x -= slide_speed
  676. if @wp[@wp_page].x <= 0
  677. @wp[@wp_page].x = 0
  678. end
  679. end
  680. if @wp[@page_old].x > -Graphics.width
  681. @wp[@page_old].x -= slide_speed
  682. if @wp[@page_old].x <= -Graphics.width
  683. @wp[@page_old].x = -Graphics.width
  684. end
  685. end
  686. end
  687. if @slide_type == 0
  688. @wp[@wp_page].x = 0 if @wp[@wp_page].x <= 0
  689. else
  690. @wp[@wp_page].x = 0 if @wp[@wp_page].x >= 0
  691. end
  692. end
  693.  
  694. #------------------------------------------------------------------------------
  695. # ● Check_limite
  696. #------------------------------------------------------------------------------
  697. def check_limit
  698. if @wp_page < 0
  699. @wp_page = @max_pages - 1
  700. elsif @wp_page >= @max_pages
  701. @wp_page = 0
  702. end
  703. check_active_window
  704. end
  705.  
  706. #------------------------------------------------------------------------------
  707. # ● Update Command Image
  708. #------------------------------------------------------------------------------
  709. def update_command_image
  710. if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  711. Sound.play_cursor
  712. @image_active = false
  713. @wp[@wp_page].active = true
  714. return
  715. end
  716. if Input.trigger?(Input::R) or Input.trigger?(Input::L)
  717. Sound.play_cursor
  718. execute_zoom
  719. end
  720. update_move_image_hor
  721. update_move_image_ver
  722. end
  723.  
  724. #------------------------------------------------------------------------------
  725. # ● Update Move Image Hor
  726. #------------------------------------------------------------------------------
  727. def update_move_image_hor
  728. if !@move_hor
  729. @picture.x = @pic_center_pos[0]
  730. else
  731. @ex += @scroll_speed[0] if Input.press?(Input::RIGHT)
  732. @ex -= @scroll_speed[0] if Input.press?(Input::LEFT)
  733. @ex = @ex_max + @ex_max_zoom if @ex > @ex_max + @ex_max_zoom
  734. @ex = 0 if @ex < 0
  735. @picture.x = -@ex
  736. end
  737. end
  738.  
  739. #------------------------------------------------------------------------------
  740. # ● Update Move Image Ver
  741. #------------------------------------------------------------------------------
  742. def update_move_image_ver
  743. if !@move_ver
  744. @picture.y = @pic_center_pos[1]
  745. else
  746. @ey += @scroll_speed[1] if Input.press?(Input::DOWN)
  747. @ey -= @scroll_speed[1] if Input.press?(Input::UP)
  748. @ey = @ey_max + @ey_max_zoom if @ey > @ey_max + @ey_max_zoom
  749. @ey = 0 if @ey < 0
  750. @picture.y = -@ey
  751. end
  752. end
  753.  
  754. #------------------------------------------------------------------------------
  755. # ● Execute Zoom
  756. #------------------------------------------------------------------------------
  757. def execute_zoom
  758. if @picture.zoom_x == 1.0
  759. execute_zoom_in
  760. else
  761. cancel_zoom
  762. end
  763. end
  764.  
  765. #------------------------------------------------------------------------------
  766. # ● Cancel Zoom
  767. #------------------------------------------------------------------------------
  768. def cancel_zoom
  769. @ex -= @ex_max_zoom / 2
  770. @ey -= @ey_max_zoom / 2
  771. @picture.zoom_x = 1.0
  772. @picture.zoom_y = 1.0
  773. @ex_max_zoom = 0
  774. @ey_max_zoom = 0
  775. @move_hor = @picture.bitmap.width > Graphics.width ? true : false
  776. @move_ver = @picture.bitmap.height > Graphics.height ? true : false
  777. @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width / 2),
  778. Graphics.height / 2 - (@picture.bitmap.height / 2)]
  779. refresh_button
  780. end
  781.  
  782. #------------------------------------------------------------------------------
  783. # ● Execute Zoom In
  784. #------------------------------------------------------------------------------
  785. def execute_zoom_in
  786. @picture.zoom_x = 1.5
  787. @picture.zoom_y = 1.5
  788. zoom_width = (@picture.bitmap.width + (@picture.bitmap.width / 2)) - Graphics.width
  789. if zoom_width.abs < Graphics.width
  790. @ex_max_zoom = zoom_width > 0 ? zoom_width : 0
  791. @move_hor = @ex_max_zoom > 0 ? true : false
  792. @picture.x = Graphics.width / 2 - (@picture.bitmap.width + (@picture.bitmap.width / 2)) if !@move_hor
  793. else
  794. @ex_max_zoom = (@picture.bitmap.width / 2)
  795. @move_hor = true
  796. end
  797. if @ex != @ex_max
  798. @ex += @ex_max_zoom / 2
  799. else
  800. if @ex_max != 0
  801. @ex += @ex_max_zoom
  802. else
  803. @ex += @ex_max_zoom / 2
  804. end
  805. end
  806. zoom_height = (@picture.bitmap.height + (@picture.bitmap.height / 2)) - Graphics.height
  807. if zoom_height.abs < Graphics.height
  808. @ey_max_zoom = zoom_height > 0 ? zoom_height : 0
  809. @move_ver = @ey_max_zoom > 0 ? true : false
  810. else
  811. @ey_max_zoom = (@picture.bitmap.height / 2)
  812. @move_ver = true
  813. end
  814. if @ey != @ey_max
  815. @ey += @ey_max_zoom / 2
  816. else
  817. if @ey_max != 0
  818. @ey += @ey_max_zoom
  819. else
  820. @ey += @ey_max_zoom / 2
  821. end
  822. end
  823. @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width) + (@picture.bitmap.width / 4) ,
  824. Graphics.height / 2 - (@picture.bitmap.height) + (@picture.bitmap.height / 4)]
  825. refresh_button
  826. end
  827.  
  828. #------------------------------------------------------------------------------
  829. # ● check_avaliable_picture?
  830. #------------------------------------------------------------------------------
  831. def check_avaliable_picture?
  832. @picture_id = (9 * @wp_page) + @wp[@wp_page].index + 1
  833. return false if $game_system.gallery[@picture_id] == nil
  834. return true
  835. end
  836.  
  837. #------------------------------------------------------------------------------
  838. # ● create_bitmap
  839. #------------------------------------------------------------------------------
  840. def create_bitmap
  841. @picture.opacity = 0
  842. @picture.bitmap.dispose
  843. @picture.bitmap = Cache.gallery(@picture_id.to_s) rescue nil
  844. @ex = 0
  845. @ey = 0
  846. @ex_max_zoom = 0
  847. @ey_max_zoom = 0
  848. @picture.zoom_x = 1.0
  849. @picture.zoom_y = 1.0
  850. if @picture.bitmap == nil
  851. @picture.bitmap = Cache.gallery("")
  852. return
  853. end
  854. if @picture.bitmap.width > Graphics.width
  855. @ex_max = @picture.bitmap.width - Graphics.width
  856. @move_hor = true
  857. else
  858. @ex_max = 0
  859. @move_hor = false
  860. end
  861. if @picture.bitmap.height > Graphics.height
  862. @ey_max = @picture.bitmap.height - Graphics.height
  863. @move_ver = true
  864. else
  865. @ey_max = 0
  866. @move_ver = false
  867. end
  868. refresh_button
  869. @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width / 2),
  870. Graphics.height / 2 - (@picture.bitmap.height / 2)]
  871. im_size_x = @picture.bitmap.width
  872. im_size_y = @picture.bitmap.height
  873. @scroll_speed[0] = (im_size_x / 240) + SCROLL_SPEED[0]
  874. @scroll_speed[1] = (im_size_y / 240) + SCROLL_SPEED[1]
  875. @scroll_speed[0] = 1 if @scroll_speed[0] < 0
  876. @scroll_speed[1] = 1 if @scroll_speed[1] < 0
  877. end
  878.  
  879.  
  880. #------------------------------------------------------------------------------
  881. # ● Refresh Button
  882. #------------------------------------------------------------------------------
  883. def refresh_button(type = 0)
  884. @button.bitmap.clear
  885. if @move_hor or @move_ver
  886. src_rect = Rect.new(0, @ch, @cw, @ch)
  887. else
  888. src_rect = Rect.new(0, 0, @cw, @ch)
  889. end
  890. @button_bitmap .blt(0,0, @button_image, src_rect)
  891. @button.y = Graphics.height - (@ch + 2)
  892. @button_fade_time = 120
  893. @button.opacity = 0 unless @button.y == Graphics.height - (@ch + 2)
  894. end
  895.  
  896. #------------------------------------------------------------------------------
  897. # ● Update Command
  898. #------------------------------------------------------------------------------
  899. def update_command
  900. return if @wp[@wp_page].x != 0
  901. if Input.trigger?(Input::B)
  902. Sound.play_cancel
  903. SceneManager.return
  904. return
  905. end
  906. if Input.trigger?(Input::C)
  907. if check_avaliable_picture?
  908. Sound.play_ok
  909. @image_active = true
  910. @wp[@wp_page].active = false
  911. create_bitmap
  912. else
  913. Sound.play_buzzer
  914. end
  915. return
  916. end
  917. if Input.trigger?(Input::L) and @max_pages != 1
  918. Sound.play_cursor
  919. @page_old = @wp_page
  920. @wp_page -= 1
  921. @slide_type = 1
  922. check_limit
  923. return
  924. elsif Input.trigger?(Input::R) and @max_pages != 1
  925. Sound.play_cursor
  926. @page_old = @wp_page
  927. @wp_page += 1
  928. @slide_type = 0
  929. check_limit
  930. return
  931. end
  932. end
  933.  
  934. end
  935.  
  936. if MOG_PICTURE_GALLERY::PICTURE_GALLERY_MENU_COMMAND
  937. #==============================================================================
  938. # ■ Window Menu Command
  939. #==============================================================================
  940. class Window_MenuCommand < Window_Command
  941.  
  942. #------------------------------------------------------------------------------
  943. # ● Add Main Commands
  944. #------------------------------------------------------------------------------
  945. alias mog_picture_gallery_add_main_commands add_main_commands
  946. def add_main_commands
  947. mog_picture_gallery_add_main_commands
  948. add_command(MOG_PICTURE_GALLERY::PICTURE_GALLERY_COMMAND_NAME, :picture, main_commands_enabled)
  949. end
  950. end
  951.  
  952. #==============================================================================
  953. # ■ Scene Menu
  954. #==============================================================================
  955. class Scene_Menu < Scene_MenuBase
  956.  
  957. #------------------------------------------------------------------------------
  958. # ● Create Command Windows
  959. #------------------------------------------------------------------------------
  960. alias mog_picture_gallery_create_command_window create_command_window
  961. def create_command_window
  962. mog_picture_gallery_create_command_window
  963. @command_window.set_handler(:picture, method(:Picture_Gallery))
  964. end
  965.  
  966. #------------------------------------------------------------------------------
  967. # ● Picture Gallery
  968. #------------------------------------------------------------------------------
  969. def Picture_Gallery
  970. SceneManager.call(Scene_Picture_Gallery)
  971. end
  972.  
  973. end
  974.  
  975. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement