FlipelyFlip

MOG Picture Galery

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