Advertisement
FlipelyFlip

MOG_Picture_Gallery

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