设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2683|回复: 6
打印 上一主题 下一主题

[已经过期] 关于标题界面CG图鉴的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
110
在线时间
39 小时
注册时间
2007-2-1
帖子
31
跳转到指定楼层
1
发表于 2015-5-23 19:40:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
我在标题界面加了一个CG图鉴,用了下面这个脚本,但是每次打开游戏所有的CG都重置为未解锁状态,
如何才能让这些CG随着游戏进度解锁呢,就是能让它读取游戏最新的存档,希望大神支招!
  1. #==============================================================================
  2. # +++ MOG - Picture Gallery ACE (v1.2) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # http://www.atelier-rgss.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. # SceneManager.call(Scene_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. # $game_system.gallery[ID] = true
  19. #
  20. # EX   $game_system.gallery[10] = true
  21. #
  22. #==============================================================================
  23. # Você deverá criar uma pasta com o nome "Gallery" onde as imagens deverão
  24. # ser gravadas.
  25. #
  26. # Graphics/Gallery/
  27. #
  28. # A nomeação das imagens devem ser numéricas. (ID da imagem)
  29. # 0.jpg    (Imagem não disponível.)
  30. # 1.jpg
  31. # 2.jpg
  32. # 3.jpg
  33. # ...
  34. #
  35. # Prefira usar imagens com resoluções igual ou maior a 544x416 pixels.
  36. #==============================================================================
  37. # Histórico
  38. #
  39. # 1.1 - Opção de adicionar o command Picture Gallery no Menu principal.
  40. # 1.2 - Compatibilidade com o sistema de cursor.
  41. #
  42. #==============================================================================
  43. module MOG_PICTURE_GALLERY
  44.        #Quantidade maxima de imagens na galeria.
  45.        MAX_PICTURES = 40    #最大图片数
  46.        #Ativar o Scene Picture Gallery no Menu
  47.        PICTURE_GALLERY_MENU_COMMAND = true
  48.        #Nome do comando apresentado no menu.
  49.        PICTURE_GALLERY_COMMAND_NAME = "CG欣赏"
  50. end  

  51. #==============================================================================
  52. # ■ Game_System
  53. #==============================================================================
  54. class Game_System
  55.   
  56. attr_accessor :gallery

  57. #------------------------------------------------------------------------------
  58. # ● Initialize
  59. #------------------------------------------------------------------------------   
  60. alias art_picture_initialize initialize
  61. def initialize
  62.       art_picture_initialize
  63.       @gallery = []
  64. end  
  65. end

  66. #==============================================================================
  67. # ■ RPG
  68. #==============================================================================
  69. module Cache   
  70.    def self.gallery(filename)
  71.        load_bitmap("Graphics/Gallery/", filename) #路径
  72.     end
  73. end


  74. #==============================================================================
  75. # ■ Window_Base
  76. #==============================================================================
  77. class Window_Base < Window
  78.   
  79.   #--------------------------------------------------------------------------
  80.   # ● Draw_Thumbnail
  81.   #--------------------------------------------------------------------------  
  82.   def draw_thumbnail(x,y,id)
  83.       bitmap = Cache.gallery(id.to_s) rescue nil
  84.       return if bitmap == nil
  85.       src_rect = Rect.new(0, 0, bitmap.width , bitmap.height )
  86.       src_rect2 = Rect.new(x, y, 118, 59)  
  87.       self.contents.stretch_blt(src_rect2, bitmap, src_rect)
  88.       bitmap.dispose
  89.   end
  90. end  

  91. #==============================================================================
  92. # ■ Window_Picture
  93. #==============================================================================
  94. class Window_Picture < Window_Selectable
  95.   
  96. #------------------------------------------------------------------------------
  97. # ● Initialize
  98. #------------------------------------------------------------------------------   
  99.   def initialize(page)
  100.       super(0, 64, 544, 370)
  101.       self.opacity = 0
  102.       [url=home.php?mod=space&uid=370741]@Index[/url] = -1
  103.       @page = page
  104.       @pic_max = MOG_PICTURE_GALLERY::MAX_PICTURES
  105.       @pic_max = 1 if @pic_max <= 0
  106.       @pag_max = @pic_max / 9
  107.       if @pag_max == page
  108.          o = @pag_max * 9
  109.          o2 =  @pic_max - o
  110.          @item_max = o2
  111.       else
  112.          @item_max = 9
  113.       end
  114.       @i_max =  @item_max
  115.       refresh(page)
  116.       select(0)
  117.       activate
  118.   end

  119. #------------------------------------------------------------------------------
  120. # ● Refresh
  121. #------------------------------------------------------------------------------   
  122.   def refresh(page = 0)
  123.       if self.contents != nil
  124.          self.contents.dispose
  125.          self.contents = nil
  126.       end
  127.       if @item_max > 0
  128.          self.contents = Bitmap.new(width - 32, 6 * 89)
  129.          for i in 0...@item_max
  130.             draw_item(i,page)
  131.          end
  132.       end
  133.   end
  134.   
  135. #------------------------------------------------------------------------------
  136. # ● draw_item
  137. #------------------------------------------------------------------------------   
  138.   def draw_item(index,page)
  139.       np = 9 * page
  140.       picture_number = index + 1 + np
  141.       x = 16 + index % 3 * 183
  142.       y = 12 + index / 3 * 89
  143.       s = picture_number
  144.       s = 0 if $game_system.gallery[picture_number] == nil
  145.       draw_thumbnail(x,y,s)
  146.       self.contents.draw_text(x + 30,y + 49, 64, 32, "NO." + picture_number.to_s,1)
  147.   end
  148.   
  149. #------------------------------------------------------------------------------
  150. # ● item_rect
  151. #------------------------------------------------------------------------------     
  152.   def item_rect(index)
  153.       rect = Rect.new(0, 0, 0, 0)
  154.       rect.width = 150
  155.       rect.height = 90
  156.       rect.x = @index % col_max * (rect.width + 32)
  157.       rect.y = @index / col_max * 90
  158.       return rect
  159.   end  
  160.    
  161. #------------------------------------------------------------------------------
  162. # ● Col Max
  163. #------------------------------------------------------------------------------      
  164.   def col_max
  165.       return 3
  166.   end
  167.    
  168. #------------------------------------------------------------------------------
  169. # ● Item Max
  170. #------------------------------------------------------------------------------         
  171.   def item_max
  172.       return @item_max == nil ? 0 : @item_max
  173.   end  
  174.   
  175. end

  176. #==============================================================================
  177. # ■ Scene_ArtPictures
  178. #==============================================================================
  179. class Scene_Picture_Gallery
  180. include MOG_PICTURE_GALLERY
  181.   
  182. #------------------------------------------------------------------------------
  183. # ● Main
  184. #------------------------------------------------------------------------------     
  185. def main
  186.      setup
  187.      create_image     
  188.      create_background     
  189.      create_loading_text         
  190.      create_window
  191.      create_cursor
  192.      create_button
  193.      execute_loop
  194.      execute_dispose
  195. end

  196. #------------------------------------------------------------------------------
  197. # ● Create_Loading
  198. #------------------------------------------------------------------------------      
  199. def create_loading_text
  200.      [url=home.php?mod=space&uid=68757]@loading[/url] = Sprite.new
  201.      @loading.bitmap = Bitmap.new(100,32)
  202.      @loading.z = 300
  203.      @loading.bitmap.font.size = 20
  204.      @loading.bitmap.font.bold = true
  205.      @loading.bitmap.font.name = "Georgia"  
  206.      @loading.bitmap.draw_text(0,0, 100, 32, "Loading...",1)
  207.      @loading.x = (544 / 2) - 50
  208.      @loading.y = (416 / 2)
  209.      Graphics.transition(20)
  210. end  

  211. #------------------------------------------------------------------------------
  212. # ● Setup
  213. #------------------------------------------------------------------------------      
  214. def setup
  215.      @max_pictures = MAX_PICTURES
  216.      @max_pictures = 1 if @max_pictures <= 0
  217.      v = (@max_pictures / 9)
  218.      v2 = (v - 1) * 9
  219.      v3 = (@max_pictures - v2) - 9
  220.      if v3 != 0
  221.         @max_pages = (@max_pictures / 9) + 1
  222.      else
  223.         @max_pages = (@max_pictures / 9)
  224.      end  
  225.      @max_pages = 1 if @max_pages == 0
  226.      @aw_center = 0
  227.      @aw_left = 0
  228.      @aw_right = 0
  229.      @slide_type = 0
  230.      @page_old = 0
  231.      @picture_id = 0
  232.      @image_active = false
  233.      @old_index = 0
  234.      @picures_enabled = 0
  235.      @comp = 0
  236.      @ex = 0
  237.      @ey = 0
  238.      @ex_max = 0
  239.      @ey_max = 0
  240.      @ex_max_zoom = 0
  241.      @ey_max_zoom = 0
  242.      for i in 0..MAX_PICTURES
  243.          @picures_enabled += 1 if $game_system.gallery[i]
  244.      end  
  245. end  
  246.    
  247. #------------------------------------------------------------------------------
  248. # ● create_background
  249. #------------------------------------------------------------------------------        
  250. def create_background
  251.      @background = Sprite.new
  252.      @background.bitmap = Cache.gallery("Background")  
  253.      @background.z = 0
  254.      @background2 = Plane.new
  255.      @background2.bitmap = Cache.gallery("Background2")      
  256.      @background2.z = -1
  257. end

  258. #------------------------------------------------------------------------------
  259. # ● Create Window
  260. #------------------------------------------------------------------------------      
  261. def create_window
  262.      @info = Window_Help.new
  263.      @info.y = 360
  264.      @info.opacity = 0
  265.      @wp_page = 0
  266.      @wp_page_old = @wp_page
  267.      @wp_index = 0
  268.      @wp =[]
  269.      for i in 0...@max_pages
  270.          @wp[i] = Window_Picture.new(i)
  271.      end  
  272.      check_active_window(true)
  273.      refresh_info_window(true)
  274.      #@wp[@wp_page].x = 0
  275. end

  276. #------------------------------------------------------------------------------
  277. # ● Create_image
  278. #------------------------------------------------------------------------------        
  279. def create_image
  280.      @picture = Sprite.new
  281.      @picture.bitmap = Cache.gallery("")
  282.      @picture.z = 100
  283.      @picture.opacity = 0
  284. end

  285. #------------------------------------------------------------------------------
  286. # ● Check Active Window
  287. #------------------------------------------------------------------------------      
  288. def check_active_window(starting = false)
  289.      for i in 0...@max_pages
  290.         if i == @wp_page
  291.             @wp[@wp_page].active = true
  292.             @wp[@wp_page].visible = true
  293.             if @slide_type == 0   
  294.                @wp[@wp_page].x = 544
  295.             else
  296.                @wp[@wp_page].x = -544
  297.             end   
  298.          elsif i == @page_old  and starting == false
  299.             @wp[@page_old].active = false
  300.             @wp[@page_old].visible = true
  301.             @wp[@page_old].visible = false if starting
  302.             @wp[@page_old].x = 0     
  303.          else   
  304.             @wp[i].active = false
  305.             @wp[i].visible = false
  306.          end   
  307.      end  
  308. end

  309. #------------------------------------------------------------------------------
  310. # ● Create Button
  311. #------------------------------------------------------------------------------      
  312. def create_button
  313.      @button_image = Cache.gallery("Button")
  314.      @button_bitmap =  Bitmap.new(@button_image.width, @button_image.height)
  315.      @cw = @button_image.width
  316.      @ch = @button_image.height / 2
  317.      src_rect = Rect.new(0, 0, @cw, @ch)
  318.      @button_bitmap .blt(0,0, @button_image, src_rect)           
  319.      [url=home.php?mod=space&uid=268194]@Button[/url] = Sprite.new
  320.      @button.bitmap = @button_bitmap
  321.      @button.y = 443
  322.      @button.z = 250
  323.      @button.opacity = 0
  324.      @button_fade_time = 0
  325. end

  326. #------------------------------------------------------------------------------
  327. # ● Create Cursor
  328. #------------------------------------------------------------------------------      
  329. def create_cursor
  330.      @cx1 = 0
  331.      @cx2 = 0
  332.      @cursor_speed = 0
  333.      image = Cache.gallery("Cursor")
  334.      @bitmap = Bitmap.new(image.width, image.height)
  335.      cw = image.width / 2
  336.      ch = image.height
  337.      src_rect = Rect.new(cw, 0, cw, ch)
  338.      @bitmap.blt(0,0, image, src_rect)     
  339.      @cursor1 = Sprite.new
  340.      @cursor1.bitmap = @bitmap
  341.      @cursor1.x = 0 + @cx1
  342.      @cursor1.y = 190
  343.      @cursor1.z = 200
  344.      @bitmap2 = Bitmap.new(image.width, image.height)
  345.      src_rect2 = Rect.new(0, 0, cw, ch)
  346.      @bitmap2.blt(0,0, image, src_rect2)         
  347.      @cursor2 = Sprite.new
  348.      @cursor2.bitmap = @bitmap2
  349.      @cursor2.x = 514 + @cx2
  350.      @cursor2.y = 190
  351.      @cursor2.z = 200
  352.      image.dispose
  353.      if @max_pages == 1
  354.         @cursor1.visible = false
  355.         @cursor2.visible = false
  356.      end   
  357. end

  358. #------------------------------------------------------------------------------
  359. # ● Execute Loop
  360. #------------------------------------------------------------------------------     
  361. def execute_loop
  362.      loop do
  363.           Graphics.update
  364.           Input.update
  365.           update
  366.           if SceneManager.scene != self
  367.               break
  368.           end
  369.      end
  370. end

  371. #------------------------------------------------------------------------------
  372. # ● Execute Dispose
  373. #------------------------------------------------------------------------------      
  374. def execute_dispose
  375.      Graphics.freeze
  376.      for i in 0...@max_pages
  377.          @wp[i].dispose
  378.      end   
  379.      @info.dispose
  380.      if @picture.bitmap != nil
  381.         @picture.bitmap.dispose
  382.      end
  383.      @picture.dispose
  384.      @background.bitmap.dispose
  385.      @background.dispose
  386.      @background2.bitmap.dispose
  387.      @background2.dispose     
  388.      @bitmap.dispose
  389.      @bitmap2.dispose
  390.      @cursor1.bitmap.dispose
  391.      @cursor1.dispose     
  392.      @cursor2.bitmap.dispose
  393.      @cursor2.dispose
  394.      @button_bitmap.dispose
  395.      @button.bitmap.dispose
  396.      @button.dispose
  397.      @button_image.dispose
  398.      if @loading != nil
  399.         @loading.bitmap.dispose
  400.         @loading.dispose
  401.      end   
  402. end

  403. #------------------------------------------------------------------------------
  404. # ● Update
  405. #------------------------------------------------------------------------------      
  406. def update
  407.      @wp.each {|wid| wid.update}
  408.      @info.update
  409.      if @image_active  
  410.         update_command_image
  411.      else   
  412.         update_command
  413.      end   
  414.      update_slide
  415.      update_image_effect
  416.      update_cursor_animation
  417.      refresh_info_window
  418. end  
  419.   
  420. #------------------------------------------------------------------------------
  421. # ● update_cursor_animation
  422. #------------------------------------------------------------------------------        
  423. def update_cursor_animation
  424.      @cursor_speed += 1
  425.      case @cursor_speed
  426.         when 1..20
  427.            @cx1 += 1
  428.            @cx2 -= 1
  429.         when 21..40
  430.            @cx1 -= 1
  431.            @cx2 += 1         
  432.         else  
  433.         @cursor_speed = 0
  434.         @cx1 = 0
  435.         @cx2 = 0
  436.      end
  437.      @cursor1.x = 0 + @cx1
  438.      @cursor2.x = 514 + @cx2
  439. end
  440.    
  441. #------------------------------------------------------------------------------
  442. # ● Update Image Effect
  443. #------------------------------------------------------------------------------      
  444. def update_image_effect
  445.      return if @wp[@wp_page].x != 0
  446.      @button_fade_time -= 1 if @button_fade_time > 0
  447.      if @image_active
  448.         @picture.opacity += 15
  449.         if @button_fade_time != 0
  450.            @button.opacity += 5
  451.         else   
  452.            if @button.y < 416   
  453.               @button.opacity -= 10
  454.               @button.y += 1
  455.            end   
  456.         end  
  457.         @wp[@wp_page].contents_opacity -= 15
  458.         @info.contents_opacity -= 15
  459.         @background.opacity -= 15
  460.         @cursor1.opacity -= 15
  461.         @cursor2.opacity -= 15
  462.      else  
  463.         @picture.opacity -= 10
  464.         @button.opacity -= 15
  465.         @wp[@wp_page].contents_opacity += 15
  466.         @info.contents_opacity += 15
  467.         @background.opacity += 15
  468.         @cursor1.opacity += 15
  469.         @cursor2.opacity += 15        
  470.      end  
  471. end

  472. #------------------------------------------------------------------------------
  473. # ● Refresh Info Window
  474. #------------------------------------------------------------------------------      
  475. def refresh_info_window(starting = false)
  476.      return if @image_active
  477.      return if @wp_page_old == @wp_page and starting == false   
  478.      @wp_page_old = @wp_page
  479.      page = @wp_page + 1
  480.      @picture_id = (9 * @wp_page) + @wp[@wp_page].index  + 1
  481.      p_pages = "页数 - " + page.to_s + " / " + @max_pages.to_s
  482.      comp  = "   收集程度 " + (@picures_enabled.to_f / @max_pictures.to_f * 100).truncate.to_s + "%"
  483.      p_number = "   已收集 " + @picures_enabled.to_s + " / " + @max_pictures.to_s
  484.      @info.set_text("            " + p_pages + comp + p_number)
  485. end   

  486. #------------------------------------------------------------------------------
  487. # ● Update Slide
  488. #------------------------------------------------------------------------------      
  489. def update_slide
  490.      @background2.ox += 1
  491.      if @loading != nil
  492.         @loading.opacity -= 5
  493.         if @loading.opacity <= 0
  494.            @loading.bitmap.dispose
  495.            @loading.dispose
  496.            @loading = nil
  497.          end  
  498.      end   
  499.      return if @wp[@wp_page].x == 0  
  500.      slide_speed = 25
  501.      @picture.opacity = 0
  502.      @background.opacity = 255
  503.      if @slide_type == 1     
  504.         if @wp[@wp_page].x < 0
  505.            @wp[@wp_page].x += slide_speed
  506.            if @wp[@wp_page].x >= 0
  507.               @wp[@wp_page].x = 0
  508.            end
  509.          end
  510.         if @wp[@page_old].x < 640
  511.            @wp[@page_old].x += slide_speed
  512.            if @wp[@page_old].x >= 544
  513.               @wp[@page_old].x = 544
  514.            end
  515.          end         
  516.        else     
  517.          if @wp[@wp_page].x > 0
  518.             @wp[@wp_page].x -= slide_speed
  519.             if @wp[@wp_page].x <= 0  
  520.                @wp[@wp_page].x = 0
  521.             end   
  522.          end
  523.          if @wp[@page_old].x > -544
  524.             @wp[@page_old].x -= slide_speed
  525.             if @wp[@page_old].x <= -544
  526.                @wp[@page_old].x = -544
  527.             end
  528.          end           
  529.        end
  530.        if @slide_type == 0   
  531.           @wp[@wp_page].x = 0 if @wp[@wp_page].x <= 0  
  532.        else
  533.            @wp[@wp_page].x = 0 if @wp[@wp_page].x >= 0
  534.        end  
  535. end

  536. #------------------------------------------------------------------------------
  537. # ● Check_limite
  538. #------------------------------------------------------------------------------        
  539. def check_limit
  540.      if @wp_page < 0
  541.         @wp_page = @max_pages - 1
  542.      elsif @wp_page >= @max_pages   
  543.         @wp_page = 0   
  544.      end
  545.      check_active_window
  546. end  

  547. #------------------------------------------------------------------------------
  548. # ● Update Command Image
  549. #------------------------------------------------------------------------------        
  550. def update_command_image
  551.      if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  552.         Sound.play_cursor
  553.         @image_active = false
  554.         @wp[@wp_page].active = true
  555.         return
  556.      end   
  557.      if Input.trigger?(Input::R) or Input.trigger?(Input::L)
  558.         Sound.play_cursor
  559.         execute_zoom      
  560.      end  
  561.      if Input.press?(Input::RIGHT)
  562.         @ex += 4
  563.      elsif Input.press?(Input::LEFT)
  564.         @ex -= 4
  565.      elsif Input.press?(Input::DOWN)
  566.         @ey += 4
  567.      elsif Input.press?(Input::UP)   
  568.         @ey -= 4
  569.      end  
  570.      @ex = @ex_max + @ex_max_zoom if @ex > @ex_max + @ex_max_zoom
  571.      @ex = 0 if @ex < 0
  572.      @ey = @ey_max + @ey_max_zoom if @ey > @ey_max + @ey_max_zoom
  573.      @ey = 0 if @ey < 0        
  574.      @picture.x = -@ex
  575.      @picture.y = -@ey
  576. end  

  577. #------------------------------------------------------------------------------
  578. # ● Execute Zoom
  579. #------------------------------------------------------------------------------         
  580. def execute_zoom
  581.      if @picture.zoom_x == 1.0
  582.         @picture.zoom_x = 1.5
  583.         @picture.zoom_y = 1.5
  584.         refresh_button(1)
  585.         @ex_max_zoom = (@picture.bitmap.width / 2)
  586.         if @ex != @ex_max
  587.            @ex += @ex_max_zoom / 2         
  588.         else   
  589.            if @ex_max != 0   
  590.               @ex += @ex_max_zoom
  591.            else   
  592.               @ex += @ex_max_zoom / 2
  593.            end  
  594.         end  
  595.         @ey_max_zoom = (@picture.bitmap.height / 2)
  596.         if @ey != @ey_max
  597.            @ey += @ey_max_zoom / 2         
  598.         else   
  599.            if @ey_max != 0   
  600.               @ey += @ey_max_zoom
  601.            else   
  602.               @ey += @ey_max_zoom / 2
  603.            end  
  604.          end  
  605.       else
  606.         if @picture.bitmap.width > 640 or
  607.            @picture.bitmap.height > 480
  608.            refresh_button(1)
  609.         else
  610.            refresh_button(0)
  611.         end           
  612.         @ex -= @ex_max_zoom / 2
  613.         @ey -= @ey_max_zoom / 2           
  614.         @picture.zoom_x = 1.0
  615.         @picture.zoom_y = 1.0   
  616.         @ex_max_zoom = 0
  617.         @ey_max_zoom = 0
  618.      end     
  619. end   

  620. #------------------------------------------------------------------------------
  621. # ● check_avaliable_picture?
  622. #------------------------------------------------------------------------------        
  623. def check_avaliable_picture?
  624.      @picture_id = (9 * @wp_page) + @wp[@wp_page].index  + 1
  625.      return false if $game_system.gallery[@picture_id] == nil
  626.      return true
  627. end  

  628. #------------------------------------------------------------------------------
  629. # ● create_bitmap
  630. #------------------------------------------------------------------------------        
  631. def create_bitmap
  632.      @picture.opacity = 0
  633.      @picture.bitmap.dispose
  634.      @picture.bitmap = Cache.gallery(@picture_id.to_s) rescue nil
  635.      @ex = 0
  636.      @ey = 0
  637.      @ex_max_zoom = 0
  638.      @ey_max_zoom = 0
  639.      @picture.zoom_x = 1.0
  640.      @picture.zoom_y = 1.0      
  641.      if @picture.bitmap == nil
  642.         @picture.bitmap = Cache.gallery("")
  643.         refresh_button(0)
  644.         return
  645.      end  
  646.      if @picture.bitmap.width > 544
  647.         @ex_max = @picture.bitmap.width - 544
  648.      else
  649.         @ex_max = 0
  650.      end
  651.      if @picture.bitmap.height > 416
  652.         @ey_max = @picture.bitmap.height - 416
  653.      else
  654.         @ey_max = 0
  655.      end   
  656.      if @picture.bitmap.width > 544 or
  657.         @picture.bitmap.height > 416
  658.         refresh_button(1)
  659.      else
  660.         refresh_button(0)
  661.      end
  662. end


  663. #------------------------------------------------------------------------------
  664. # ● Refresh Button
  665. #------------------------------------------------------------------------------        
  666. def refresh_button(type = 0)
  667.      @button.bitmap.clear
  668.      if type == 0
  669.         src_rect = Rect.new(0, 0, @cw, @ch)
  670.      else
  671.         src_rect = Rect.new(0, @ch, @cw, @ch)
  672.      end  
  673.      @button_bitmap .blt(0,0, @button_image, src_rect)  
  674.      @button.y = 379
  675.      @button_fade_time = 120
  676.      @button.opacity = 0 unless @button.y == 379
  677. end   

  678. #------------------------------------------------------------------------------
  679. # ● Update Command
  680. #------------------------------------------------------------------------------      
  681. def update_command
  682.      return if @wp[@wp_page].x != 0
  683.      if Input.trigger?(Input::B)
  684.         Sound.play_cancel
  685.         SceneManager.return
  686.         return
  687.      end
  688.      if Input.trigger?(Input::C)
  689.         if check_avaliable_picture?
  690.            Sound.play_ok
  691.            @image_active = true
  692.            @wp[@wp_page].active = false
  693.            create_bitmap
  694.         else
  695.           Sound.play_buzzer
  696.         end
  697.         return
  698.      end  
  699.      if Input.trigger?(Input::L) and @max_pages != 1
  700.         Sound.play_cursor
  701.         @page_old = @wp_page
  702.         @wp_page -= 1
  703.         @slide_type = 1
  704.         check_limit
  705.         return
  706.      elsif Input.trigger?(Input::R) and @max_pages != 1   
  707.         Sound.play_cursor
  708.         @page_old = @wp_page
  709.         @wp_page += 1
  710.         @slide_type = 0
  711.         check_limit
  712.         return
  713.      end  
  714. end  
  715. end  

  716. if MOG_PICTURE_GALLERY::PICTURE_GALLERY_MENU_COMMAND
  717. #==============================================================================
  718. # ■ Window Menu Command
  719. #==============================================================================
  720. # class Window_MenuCommand < Window_Command  
  721.   
  722. #------------------------------------------------------------------------------
  723. # ● Add Main Commands
  724. #------------------------------------------------------------------------------     
  725. #   alias mog_picture_gallery_add_main_commands add_main_commands
  726. #   def add_main_commands
  727. #       mog_picture_gallery_add_main_commands
  728. #       add_command(MOG_PICTURE_GALLERY::PICTURE_GALLERY_COMMAND_NAME, :picture, main_commands_enabled)
  729. #   end
  730. # end   

  731. #==============================================================================
  732. # ■ Scene Menu
  733. #==============================================================================
  734. class Scene_Menu < Scene_MenuBase
  735.   
  736. #------------------------------------------------------------------------------
  737. # ● Create Command Windows
  738. #------------------------------------------------------------------------------      
  739.    alias mog_picture_gallery_create_command_window create_command_window
  740.    def create_command_window
  741.        mog_picture_gallery_create_command_window
  742.        @command_window.set_handler(:picture,     method(:Picture_Gallery))
  743.    end
  744.    
  745. #------------------------------------------------------------------------------
  746. # ● Picture Gallery
  747. #------------------------------------------------------------------------------        
  748.    def Picture_Gallery
  749.        SceneManager.call(Scene_Picture_Gallery)
  750.    end

  751. end   
  752. #  
  753. end

  754. $mog_rgss3_picture_gallery = true
复制代码

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2015-5-23 19:59:29 | 只看该作者
本帖最后由 taroxd 于 2015-5-23 20:01 编辑

把 $game_system.gallery 中的数据存到一个公用的存档中。开启游戏时读取这个公用存档。

另外,最好不要使用 $game_system,因为标题界面下该变量很可能没有初始化。

对于“公用存档”的做法,可以参考这个脚本:
https://rpg.blue/home.php?mod=sp ... o=blog&id=11794
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
110
在线时间
39 小时
注册时间
2007-2-1
帖子
31
3
 楼主| 发表于 2015-5-23 22:11:56 | 只看该作者
taroxd 发表于 2015-5-23 19:59
把 $game_system.gallery 中的数据存到一个公用的存档中。开启游戏时读取这个公用存档。

另外,最好不要使 ...

谢大神指点,我看了一下那个脚本保存的是变量的值,可是这个脚本使用的是$game_system,怎么才能把这个脚本里面解锁CG的方法改成用变量控制呢?

点评

脚本里搜索 $game_system ,然后全部改成对应的变量就行。另外还是不建议用变量(因为开始游戏前有可能未初始化),所以只能参考那个脚本的做法。  发表于 2015-5-24 06:59
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
110
在线时间
39 小时
注册时间
2007-2-1
帖子
31
4
 楼主| 发表于 2015-5-24 10:37:32 | 只看该作者
taroxd 发表于 2015-5-23 19:59
把 $game_system.gallery 中的数据存到一个公用的存档中。开启游戏时读取这个公用存档。

另外,最好不要使 ...

我又研究了一下QAQ,试了几个方法还是不理想,这个是全局变量脚本,有没有全局开关的,我是脚本渣...研究了半天也没弄明白。。

点评

判断全局变量的值是否是1不就可以把全局变量当成一个开关来使用了  发表于 2015-6-6 21:11
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
110
在线时间
39 小时
注册时间
2007-2-1
帖子
31
5
 楼主| 发表于 2015-5-24 11:00:00 | 只看该作者
taroxd 发表于 2015-5-23 19:59
把 $game_system.gallery 中的数据存到一个公用的存档中。开启游戏时读取这个公用存档。

另外,最好不要使 ...

另外我用的不是事件标题QAQ,如何才能在标题界面执行公共事件

点评

个人建议用这个脚本跳转到一张专门的地图,然后在该地图执行公共事件 http://rm.66rpg.com/home.php?mod=space&uid=291206&do=blog&id=12643  发表于 2015-6-6 21:12
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21140
在线时间
9351 小时
注册时间
2012-6-19
帖子
7107

开拓者短篇九导演组冠军

6
发表于 2015-6-6 21:08:37 | 只看该作者
本帖最后由 喵呜喵5 于 2015-6-7 22:15 编辑

2015.6.7 更新

补上一个范例工程 https://rpg.blue/thread-379779-1-1.html


==========================================================================


插入我的全局变量脚本(就是2楼的那个),然后在CG图鉴脚本后面插入下面这段代码
  1. class Game_Interpreter
  2.   alias m5_20150606_enable_picture enable_picture
  3.   def enable_picture *args   
  4.     m5_20150606_enable_picture *args
  5.     ( M5GV20140811.get_ext )[:M5Gallery20150606] = $game_system.gallery.clone
  6.     M5GV20140811.save_ext
  7.   end
  8.   alias m5_20150606_disable_picture disable_picture
  9.   def disable_picture *args
  10.     args[1] = nil # BUG修正
  11.     m5_20150606_disable_picture *args
  12.     ( M5GV20140811.get_ext )[:M5Gallery20150606] = $game_system.gallery.clone
  13.     M5GV20140811.save_ext   
  14.   end
  15. end
  16. class Scene_Picture_Gallery
  17.   alias m5_20150606_main main
  18.   def main
  19.     ext = (M5GV20140811.get_ext)[:M5Gallery20150606]
  20.     $game_system.gallery = ext.clone if ext
  21.     m5_20150606_main
  22.   end
  23. end
  24. class Game_System
  25.   alias m5_20150606_initialize initialize
  26.   def initialize
  27.     m5_20150606_initialize
  28.     ext = (M5GV20140811.get_ext)[:M5Gallery20150606]
  29.     @gallery = ext.clone if ext
  30.   end  
  31. end
复制代码
CG的收集情况便会完全通用了


另外,以上的改动只适用于该脚本的2.0版(http://www.atelier-rgss.com/RGSS/System/ACE_SYS01.html),2.0版存在一个囧的不行的BUG会导致无法删除已经获得的CG,所以在我的代码第十行顺手加上了修正该BUG的代码

附上2.0版的脚本,2.0版获取CG的方式从 $game_system.gallery[ID] = true 变为了 enable_picture(ID)
  1. #==============================================================================
  2. # +++ MOG - Picture Gallery ACE (v2.0) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # http://www.atelier-rgss.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. $imported = {} if $imported.nil?
  71. $imported[:mog_picture_gallery] = true

  72. #==============================================================================
  73. # ■ Game_System
  74. #==============================================================================
  75. class Game_System
  76.   
  77. attr_accessor :gallery

  78. #------------------------------------------------------------------------------
  79. # ● Initialize
  80. #------------------------------------------------------------------------------   
  81. alias art_picture_initialize initialize
  82. def initialize
  83.       art_picture_initialize
  84.       @gallery = []
  85. end  
  86. end

  87. #==============================================================================
  88. # ■ Game Interpreter
  89. #==============================================================================
  90. class Game_Interpreter
  91.   
  92. #------------------------------------------------------------------------------
  93. # ● Picture Gallery
  94. #------------------------------------------------------------------------------   
  95. def picture_gallery
  96.      SceneManager.call(Scene_Picture_Gallery)
  97. end
  98.   
  99. #------------------------------------------------------------------------------
  100. # ● Enable Picture
  101. #------------------------------------------------------------------------------   
  102. def enable_picture(id, value = true)
  103.      $game_system.gallery[id] = value
  104. end
  105.   
  106. #------------------------------------------------------------------------------
  107. # ● Disable Picture
  108. #------------------------------------------------------------------------------   
  109. def disable_picture(id, value = false)
  110.      $game_system.gallery[id] = value
  111. end

  112. end

  113. #==============================================================================
  114. # ■ RPG
  115. #==============================================================================
  116. module Cache   
  117.   
  118. #------------------------------------------------------------------------------
  119. # ● Gallery
  120. #------------------------------------------------------------------------------   
  121. def self.gallery(filename)
  122.      load_bitmap("Graphics/Gallery/", filename)
  123. end
  124.      
  125. end


  126. #==============================================================================
  127. # ■ Window_Base
  128. #==============================================================================
  129. class Window_Base < Window
  130.   
  131.   #--------------------------------------------------------------------------
  132.   # ● Draw_Thumbnail
  133.   #--------------------------------------------------------------------------  
  134.   def draw_thumbnail(x,y,id)
  135.       bitmap = Cache.gallery(id.to_s) rescue nil
  136.       return if bitmap == nil
  137.       src_rect = Rect.new(0, 0, bitmap.width , bitmap.height )
  138.       src_rect2 = Rect.new(x, y, 118, 59)  
  139.       self.contents.stretch_blt(src_rect2, bitmap, src_rect)
  140.       bitmap.dispose
  141.   end
  142.   
  143. end  

  144. #==============================================================================
  145. # ■ Window_Picture
  146. #==============================================================================
  147. class Window_Picture < Window_Selectable
  148.   
  149. #------------------------------------------------------------------------------
  150. # ● Initialize
  151. #------------------------------------------------------------------------------   
  152.   def initialize(page)
  153.       super(0, 64, Graphics.width, Graphics.height - 32)
  154.       self.opacity = 0
  155.       @index = -1
  156.       @page = page
  157.       @pic_max = MOG_PICTURE_GALLERY::MAX_PICTURES
  158.       @pic_max = 1 if @pic_max <= 0
  159.       @pag_max = @pic_max / 9
  160.       if @pag_max == page
  161.          o = @pag_max * 9
  162.          o2 =  @pic_max - o
  163.          @item_max = o2
  164.       else
  165.          @item_max = 9
  166.       end
  167.       @i_max =  @item_max
  168.       refresh(page)
  169.       select(0)
  170.       activate
  171.   end

  172. #------------------------------------------------------------------------------
  173. # ● Refresh
  174. #------------------------------------------------------------------------------   
  175.   def refresh(page = 0)
  176.       if self.contents != nil
  177.          self.contents.dispose
  178.          self.contents = nil
  179.       end
  180.       if @item_max > 0
  181.          self.contents = Bitmap.new(width - 32, 6 * 89)
  182.          for i in 0...@item_max
  183.             draw_item(i,page)
  184.          end
  185.       end
  186.   end
  187.   
  188. #------------------------------------------------------------------------------
  189. # ● WX
  190. #------------------------------------------------------------------------------   
  191.   def wx
  192.       (Graphics.width ) / 3
  193.   end
  194.   
  195. #------------------------------------------------------------------------------
  196. # ● WY
  197. #------------------------------------------------------------------------------   
  198.   def wy
  199.       (Graphics.height + 64) / 5
  200.   end
  201.   
  202. #------------------------------------------------------------------------------
  203. # ● SX
  204. #------------------------------------------------------------------------------   
  205.   def sx
  206.       (Graphics.width / 96).truncate
  207.   end
  208.   
  209. #------------------------------------------------------------------------------
  210. # ● SY
  211. #------------------------------------------------------------------------------   
  212.   def sy
  213.      (Graphics.height - 416) / 12
  214.   end  
  215.   
  216. #------------------------------------------------------------------------------
  217. # ● draw_item
  218. #------------------------------------------------------------------------------   
  219.   def draw_item(index,page)
  220.       np = 9 * page
  221.       picture_number = index + 1 + np
  222.       x = sx + 16 + index % 3 * wx
  223.       y = sy + 12 + index / 3 * wy
  224.       s = picture_number
  225.       s = 0 if $game_system.gallery[picture_number] == nil
  226.       draw_thumbnail(x,y,s)
  227.       self.contents.draw_text(x + 30,y + 49, 64, 32, "N - " + picture_number.to_s,1)
  228.   end
  229.   
  230. #------------------------------------------------------------------------------
  231. # ● item_rect
  232. #------------------------------------------------------------------------------     
  233.   def item_rect(index)
  234.       rect = Rect.new(0, 0, 0, 0)
  235.       rect.width = 150
  236.       rect.height = 90
  237.       rect.x = sx + (@index % col_max * wx)
  238.       rect.y = sy + (@index / col_max * wy)
  239.       return rect
  240.   end  
  241.    
  242. #------------------------------------------------------------------------------
  243. # ● Col Max
  244. #------------------------------------------------------------------------------      
  245.   def col_max
  246.       return 3
  247.   end
  248.    
  249. #------------------------------------------------------------------------------
  250. # ● Item Max
  251. #------------------------------------------------------------------------------         
  252.   def item_max
  253.       return @item_max == nil ? 0 : @item_max
  254.   end  
  255.   
  256. end

  257. #==============================================================================
  258. # ■ Window Help
  259. #==============================================================================
  260. class Window_Help < Window_Base
  261.   
  262.   #--------------------------------------------------------------------------
  263.   # * Set Text
  264.   #--------------------------------------------------------------------------
  265.   def set_text_pic(text)
  266.     if text != @text
  267.       @text = text
  268.       refresh_pic
  269.     end
  270.   end

  271.   #--------------------------------------------------------------------------
  272.   # * Refresh
  273.   #--------------------------------------------------------------------------
  274.   def refresh_pic
  275.     contents.clear
  276.     draw_text_ex_pic(4, 0, @text)
  277.   end

  278.   #--------------------------------------------------------------------------
  279.   # * Draw Text with Control Characters
  280.   #--------------------------------------------------------------------------
  281.   def draw_text_ex_pic(x, y, text)
  282.     reset_font_settings
  283.     text = convert_escape_characters(text)
  284.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  285.     contents.font.size = MOG_PICTURE_GALLERY::HELP_FONT_SIZE
  286.     contents.font.name = MOG_PICTURE_GALLERY::HELP_FONT_NAME
  287.     contents.font.bold = MOG_PICTURE_GALLERY::HELP_FONT_BOLD
  288.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  289.   end  
  290.   
  291. end


  292. #==============================================================================
  293. # ■ Scene_Picture Gallery
  294. #==============================================================================
  295. class Scene_Picture_Gallery
  296. include MOG_PICTURE_GALLERY
  297.   
  298. #------------------------------------------------------------------------------
  299. # ● Main
  300. #------------------------------------------------------------------------------     
  301. def main
  302.      setup
  303.      execute_dispose
  304.      create_image     
  305.      create_background     
  306.      create_loading_text         
  307.      create_window
  308.      create_cursor
  309.      create_button
  310.      execute_loop
  311.      execute_dispose
  312. end

  313. #------------------------------------------------------------------------------
  314. # ● Create_Loading
  315. #------------------------------------------------------------------------------      
  316. def create_loading_text
  317.      @loading = Sprite.new
  318.      @loading.bitmap = Bitmap.new(100,32)
  319.      @loading.z = 300
  320.      @loading.bitmap.font.size = 20
  321.      @loading.bitmap.font.bold = true
  322.      @loading.bitmap.font.name = "Georgia"  
  323.      @loading.bitmap.draw_text(0,0, 100, 32, "Loading...",1)
  324.      @loading.x = (Graphics.width / 2) - 50
  325.      @loading.y = (Graphics.height / 2)
  326.      Graphics.transition(20)
  327. end  

  328. #------------------------------------------------------------------------------
  329. # ● Setup
  330. #------------------------------------------------------------------------------      
  331. def setup
  332.      @max_pictures = MAX_PICTURES
  333.      @max_pictures = 1 if @max_pictures <= 0
  334.      v = (@max_pictures / 9)
  335.      v2 = (v - 1) * 9
  336.      v3 = (@max_pictures - v2) - 9
  337.      if v3 != 0
  338.         @max_pages = (@max_pictures / 9) + 1
  339.      else
  340.         @max_pages = (@max_pictures / 9)
  341.      end  
  342.      @max_pages = 1 if @max_pages == 0
  343.      @aw_center = 0
  344.      @aw_left = 0
  345.      @aw_right = 0
  346.      @slide_type = 0
  347.      @page_old = 0
  348.      @picture_id = 0
  349.      @image_active = false
  350.      @old_index = 0
  351.      @picures_enabled = 0
  352.      @comp = 0
  353.      @ex = 0
  354.      @ey = 0
  355.      @ex_max = 0
  356.      @ey_max = 0
  357.      @ex_max_zoom = 0
  358.      @ey_max_zoom = 0
  359.      @move_hor = true
  360.      @move_ver = true
  361.      @scroll_speed = [0,0]
  362.      @pic_center_pos = [0,0]   
  363.      for i in 0..MAX_PICTURES
  364.          @picures_enabled += 1 if $game_system.gallery[i]
  365.      end  
  366. end  
  367.    
  368. #------------------------------------------------------------------------------
  369. # ● create_background
  370. #------------------------------------------------------------------------------        
  371. def create_background
  372.      @background = Sprite.new
  373.      @background.bitmap = Cache.gallery("Background")  
  374.      @background.z = 0
  375.      @background2 = Plane.new
  376.      @background2.bitmap = Cache.gallery("Background2")      
  377.      @background2.z = -1
  378. end

  379. #------------------------------------------------------------------------------
  380. # ● Create Window
  381. #------------------------------------------------------------------------------      
  382. def create_window
  383.      @info = Window_Help.new
  384.      @info.x = HELP_POSITION[0]
  385.      @info.y = (Graphics.height - 48) + HELP_POSITION[1]
  386.      @info.opacity = 0
  387.      @wp_page = 0
  388.      @wp_page_old = @wp_page
  389.      @wp_index = 0
  390.      @wp =[]
  391.      for i in 0...@max_pages
  392.          @wp[i] = Window_Picture.new(i)
  393.      end  
  394.      check_active_window(true)
  395.      refresh_info_window(true)
  396. end

  397. #------------------------------------------------------------------------------
  398. # ● Create_image
  399. #------------------------------------------------------------------------------        
  400. def create_image
  401.      @picture = Sprite.new
  402.      @picture.bitmap = Cache.gallery("")
  403.      @picture.z = 100
  404.      @picture.opacity = 0
  405. end

  406. #------------------------------------------------------------------------------
  407. # ● Check Active Window
  408. #------------------------------------------------------------------------------      
  409. def check_active_window(starting = false)
  410.      for i in 0...@max_pages
  411.         if i == @wp_page
  412.             @wp[@wp_page].active = true
  413.             @wp[@wp_page].visible = true
  414.             if @slide_type == 0   
  415.                @wp[@wp_page].x = Graphics.width
  416.             else
  417.                @wp[@wp_page].x = -Graphics.width
  418.             end   
  419.          elsif i == @page_old  and starting == false
  420.             @wp[@page_old].active = false
  421.             @wp[@page_old].visible = true
  422.             @wp[@page_old].visible = false if starting
  423.             @wp[@page_old].x = 0     
  424.          else   
  425.             @wp[i].active = false
  426.             @wp[i].visible = false
  427.          end   
  428.      end  
  429. end

  430. #------------------------------------------------------------------------------
  431. # ● Create Button
  432. #------------------------------------------------------------------------------      
  433. def create_button
  434.      @button_image = Cache.gallery("Button")
  435.      @button_bitmap =  Bitmap.new(@button_image.width, @button_image.height)
  436.      @cw = @button_image.width
  437.      @ch = @button_image.height / 2
  438.      src_rect = Rect.new(0, 0, @cw, @ch)
  439.      @button_bitmap .blt(0,0, @button_image, src_rect)           
  440.      @button = Sprite.new
  441.      @button.bitmap = @button_bitmap
  442.      @button.x = 2
  443.      @button.y = Graphics.height - @ch
  444.      @button.z = 250
  445.      @button.opacity = 0
  446.      @button_fade_time = 0
  447. end

  448. #------------------------------------------------------------------------------
  449. # ● Create Cursor
  450. #------------------------------------------------------------------------------      
  451. def create_cursor
  452.      @cx1 = 0
  453.      @cx2 = 0     
  454.      @cursor_speed = 0
  455.      image = Cache.gallery("Cursor")
  456.      @bitmap = Bitmap.new(image.width, image.height)
  457.      cw = image.width / 2
  458.      ch = image.height
  459.      src_rect = Rect.new(cw, 0, cw, ch)
  460.      @bitmap.blt(0,0, image, src_rect)   
  461.      @cx3 = Graphics.width - cw
  462.      @cx_pos = [PAGE_CURSOR_POSITION[0],
  463.                 PAGE_CURSOR_POSITION[1] - (ch / 2),
  464.                 PAGE_CURSOR_POSITION[2] + Graphics.width - cw,
  465.                 PAGE_CURSOR_POSITION[3] - (ch / 2)
  466.                 ]
  467.      @cursor1 = Sprite.new
  468.      @cursor1.bitmap = @bitmap
  469.      @cursor1.x = @cx_pos[0] + @cx1
  470.      @cursor1.y = @cx_pos[1] + Graphics.height / 2
  471.      @cursor1.z = 200
  472.      @bitmap2 = Bitmap.new(image.width, image.height)
  473.      src_rect2 = Rect.new(0, 0, cw, ch)
  474.      @bitmap2.blt(0,0, image, src_rect2)         
  475.      @cursor2 = Sprite.new
  476.      @cursor2.bitmap = @bitmap2
  477.      @cursor2.x = @cx_pos[2] + @cx2
  478.      @cursor2.y = @cx_pos[3] + Graphics.height / 2
  479.      @cursor2.z = 200
  480.      image.dispose
  481.      if @max_pages == 1
  482.         @cursor1.visible = false
  483.         @cursor2.visible = false
  484.      end   
  485. end

  486. #------------------------------------------------------------------------------
  487. # ● Execute Loop
  488. #------------------------------------------------------------------------------     
  489. def execute_loop
  490.      loop do
  491.           Graphics.update
  492.           Input.update
  493.           update
  494.           if SceneManager.scene != self
  495.               break
  496.           end
  497.      end
  498. end

  499. #------------------------------------------------------------------------------
  500. # ● Execute Dispose
  501. #------------------------------------------------------------------------------      
  502. def execute_dispose
  503.      return if @background == nil
  504.      Graphics.freeze
  505.      for i in 0...@max_pages
  506.          @wp[i].dispose
  507.      end   
  508.      @info.dispose
  509.      if @picture.bitmap != nil
  510.         @picture.bitmap.dispose
  511.      end
  512.      @picture.dispose
  513.      @background.bitmap.dispose
  514.      @background.dispose
  515.      @background = nil
  516.      @background2.bitmap.dispose
  517.      @background2.dispose     
  518.      @bitmap.dispose
  519.      @bitmap2.dispose
  520.      @cursor1.bitmap.dispose
  521.      @cursor1.dispose     
  522.      @cursor2.bitmap.dispose
  523.      @cursor2.dispose
  524.      @button_bitmap.dispose
  525.      @button.bitmap.dispose
  526.      @button.dispose
  527.      @button_image.dispose
  528.      if @loading != nil
  529.         @loading.bitmap.dispose
  530.         @loading.dispose
  531.      end   
  532. end

  533. #------------------------------------------------------------------------------
  534. # ● Update
  535. #------------------------------------------------------------------------------      
  536. def update
  537.      @wp.each {|wid| wid.update}
  538.      @info.update
  539.      if @image_active  
  540.         update_command_image
  541.      else   
  542.         update_command
  543.      end   
  544.      update_slide
  545.      update_image_effect
  546.      update_cursor_animation
  547.      refresh_info_window
  548. end  
  549.   
  550. #------------------------------------------------------------------------------
  551. # ● update_cursor_animation
  552. #------------------------------------------------------------------------------        
  553. def update_cursor_animation
  554.      @cursor_speed += 1
  555.      case @cursor_speed
  556.         when 1..20
  557.            @cx1 += 1
  558.            @cx2 -= 1
  559.         when 21..40
  560.            @cx1 -= 1
  561.            @cx2 += 1         
  562.         else
  563.         @cursor_speed = 0
  564.         @cx1 = 0
  565.         @cx2 = 0
  566.      end
  567.      @cursor1.x = @cx_pos[0] + @cx1
  568.      @cursor2.x = @cx_pos[2] + @cx2
  569. end
  570.    
  571. #------------------------------------------------------------------------------
  572. # ● Update Image Effect
  573. #------------------------------------------------------------------------------      
  574. def update_image_effect
  575.      return if @wp[@wp_page].x != 0
  576.      @button_fade_time -= 1 if @button_fade_time > 0
  577.      if @image_active
  578.         @picture.opacity += 15
  579.         if @button_fade_time != 0
  580.            @button.opacity += 5
  581.         else   
  582.            if @button.y < Graphics.height  
  583.               @button.opacity -= 10
  584.               @button.y += 1
  585.            end   
  586.         end  
  587.         @wp[@wp_page].contents_opacity -= 15
  588.         @info.contents_opacity -= 15
  589.         @background.opacity -= 15
  590.         @cursor1.opacity -= 15
  591.         @cursor2.opacity -= 15
  592.      else  
  593.         @picture.opacity -= 10
  594.         @button.opacity -= 15
  595.         @wp[@wp_page].contents_opacity += 15
  596.         @info.contents_opacity += 15
  597.         @background.opacity += 15
  598.         @cursor1.opacity += 15
  599.         @cursor2.opacity += 15        
  600.      end  
  601. end

  602. #------------------------------------------------------------------------------
  603. # ● Refresh Info Window
  604. #------------------------------------------------------------------------------      
  605. def refresh_info_window(starting = false)
  606.      return if @image_active
  607.      return if @wp_page_old == @wp_page and starting == false   
  608.      @wp_page_old = @wp_page
  609.      page = @wp_page + 1
  610.      @picture_id = (9 * @wp_page) + @wp[@wp_page].index  + 1
  611.      p_pages =  "         " + HELP_TEXT[0] + page.to_s + " / " + @max_pages.to_s
  612.      comp  = "   " + "(" +(@picures_enabled.to_f / @max_pictures.to_f * 100).truncate.to_s + "%)"
  613.      p_number = "        " + HELP_TEXT[1] + " " + @picures_enabled.to_s + " / " + @max_pictures.to_s
  614.      @info.set_text_pic(p_pages + p_number + comp)
  615. end   

  616. #------------------------------------------------------------------------------
  617. # ● Update Slide
  618. #------------------------------------------------------------------------------      
  619. def update_slide
  620.      @background2.ox += 1
  621.      if @loading != nil
  622.         @loading.opacity -= 5
  623.         if @loading.opacity <= 0
  624.            @loading.bitmap.dispose
  625.            @loading.dispose
  626.            @loading = nil
  627.          end  
  628.      end   
  629.      return if @wp[@wp_page].x == 0  
  630.      slide_speed = 25
  631.      @picture.opacity = 0
  632.      @background.opacity = 255
  633.      if @slide_type == 1     
  634.         if @wp[@wp_page].x < 0
  635.            @wp[@wp_page].x += slide_speed
  636.            if @wp[@wp_page].x >= 0
  637.               @wp[@wp_page].x = 0
  638.            end
  639.          end
  640.         if @wp[@page_old].x < Graphics.width
  641.            @wp[@page_old].x += slide_speed
  642.            if @wp[@page_old].x >= Graphics.width
  643.               @wp[@page_old].x = Graphics.width
  644.            end
  645.          end         
  646.        else     
  647.          if @wp[@wp_page].x > 0
  648.             @wp[@wp_page].x -= slide_speed
  649.             if @wp[@wp_page].x <= 0  
  650.                @wp[@wp_page].x = 0
  651.             end   
  652.          end
  653.          if @wp[@page_old].x > -Graphics.width
  654.             @wp[@page_old].x -= slide_speed
  655.             if @wp[@page_old].x <= -Graphics.width
  656.                @wp[@page_old].x = -Graphics.width
  657.             end
  658.          end           
  659.        end
  660.        if @slide_type == 0   
  661.           @wp[@wp_page].x = 0 if @wp[@wp_page].x <= 0  
  662.        else
  663.            @wp[@wp_page].x = 0 if @wp[@wp_page].x >= 0
  664.        end  
  665. end

  666. #------------------------------------------------------------------------------
  667. # ● Check_limite
  668. #------------------------------------------------------------------------------        
  669. def check_limit
  670.      if @wp_page < 0
  671.         @wp_page = @max_pages - 1
  672.      elsif @wp_page >= @max_pages   
  673.         @wp_page = 0   
  674.      end
  675.      check_active_window
  676. end  

  677. #------------------------------------------------------------------------------
  678. # ● Update Command Image
  679. #------------------------------------------------------------------------------        
  680. def update_command_image
  681.      if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  682.         Sound.play_cursor
  683.         @image_active = false
  684.         @wp[@wp_page].active = true
  685.         return
  686.      end   
  687.      if Input.trigger?(Input::R) or Input.trigger?(Input::L)
  688.         Sound.play_cursor
  689.         execute_zoom      
  690.      end  
  691.      update_move_image_hor
  692.      update_move_image_ver     
  693. end  

  694. #------------------------------------------------------------------------------
  695. # ● Update Move Image Hor
  696. #------------------------------------------------------------------------------        
  697. def update_move_image_hor
  698.      if !@move_hor
  699.         @picture.x = @pic_center_pos[0]
  700.      else
  701.         @ex += @scroll_speed[0] if Input.press?(Input::RIGHT)
  702.         @ex -= @scroll_speed[0] if Input.press?(Input::LEFT)
  703.         @ex = @ex_max + @ex_max_zoom if @ex > @ex_max + @ex_max_zoom
  704.         @ex = 0 if @ex < 0
  705.         @picture.x = -@ex
  706.      end
  707. end

  708. #------------------------------------------------------------------------------
  709. # ● Update Move Image Ver
  710. #------------------------------------------------------------------------------        
  711. def update_move_image_ver
  712.      if !@move_ver
  713.         @picture.y = @pic_center_pos[1]
  714.      else
  715.         @ey += @scroll_speed[1] if Input.press?(Input::DOWN)
  716.         @ey -= @scroll_speed[1] if Input.press?(Input::UP)  
  717.         @ey = @ey_max + @ey_max_zoom if @ey > @ey_max + @ey_max_zoom
  718.         @ey = 0 if @ey < 0     
  719.         @picture.y = -@ey
  720.      end
  721. end

  722. #------------------------------------------------------------------------------
  723. # ● Execute Zoom
  724. #------------------------------------------------------------------------------         
  725. def execute_zoom
  726.      if @picture.zoom_x == 1.0
  727.         execute_zoom_in
  728.       else
  729.         cancel_zoom
  730.      end     
  731. end   

  732. #------------------------------------------------------------------------------
  733. # ● Cancel Zoom
  734. #------------------------------------------------------------------------------         
  735. def cancel_zoom         
  736.      @ex -= @ex_max_zoom / 2
  737.      @ey -= @ey_max_zoom / 2           
  738.      @picture.zoom_x = 1.0
  739.      @picture.zoom_y = 1.0   
  740.      @ex_max_zoom = 0
  741.      @ey_max_zoom = 0   
  742.      @move_hor = @picture.bitmap.width > Graphics.width ? true : false
  743.      @move_ver = @picture.bitmap.height > Graphics.height ? true : false
  744.      @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width / 2),
  745.                         Graphics.height / 2 - (@picture.bitmap.height / 2)]
  746.      refresh_button
  747. end

  748. #------------------------------------------------------------------------------
  749. # ● Execute Zoom In
  750. #------------------------------------------------------------------------------         
  751. def execute_zoom_in
  752.      @picture.zoom_x = 1.5
  753.      @picture.zoom_y = 1.5
  754.      zoom_width = (@picture.bitmap.width + (@picture.bitmap.width / 2)) - Graphics.width
  755.      if zoom_width.abs < Graphics.width
  756.         @ex_max_zoom = zoom_width > 0 ? zoom_width : 0
  757.         @move_hor = @ex_max_zoom > 0 ? true : false
  758.         @picture.x = Graphics.width / 2 - (@picture.bitmap.width + (@picture.bitmap.width / 2)) if !@move_hor
  759.      else
  760.         @ex_max_zoom = (@picture.bitmap.width / 2)
  761.         @move_hor = true
  762.      end
  763.         if @ex != @ex_max
  764.            @ex += @ex_max_zoom / 2         
  765.         else   
  766.            if @ex_max != 0   
  767.               @ex += @ex_max_zoom
  768.            else   
  769.               @ex += @ex_max_zoom / 2
  770.            end  
  771.      end  
  772.      zoom_height = (@picture.bitmap.height + (@picture.bitmap.height / 2)) - Graphics.height
  773.      if zoom_height.abs < Graphics.height
  774.         @ey_max_zoom = zoom_height > 0 ? zoom_height : 0
  775.         @move_ver = @ey_max_zoom > 0 ? true : false
  776.      else
  777.         @ey_max_zoom = (@picture.bitmap.height / 2)
  778.         @move_ver = true
  779.      end      
  780.      if @ey != @ey_max
  781.         @ey += @ey_max_zoom / 2         
  782.      else   
  783.         if @ey_max != 0   
  784.            @ey += @ey_max_zoom
  785.         else   
  786.            @ey += @ey_max_zoom / 2
  787.         end  
  788.     end     
  789.     @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width) + (@picture.bitmap.width / 4) ,
  790.                       Graphics.height / 2 - (@picture.bitmap.height) + (@picture.bitmap.height / 4)]   
  791.     refresh_button
  792. end

  793. #------------------------------------------------------------------------------
  794. # ● check_avaliable_picture?
  795. #------------------------------------------------------------------------------        
  796. def check_avaliable_picture?
  797.      @picture_id = (9 * @wp_page) + @wp[@wp_page].index  + 1
  798.      return false if $game_system.gallery[@picture_id] == nil
  799.      return true
  800. end  

  801. #------------------------------------------------------------------------------
  802. # ● create_bitmap
  803. #------------------------------------------------------------------------------        
  804. def create_bitmap
  805.      @picture.opacity = 0
  806.      @picture.bitmap.dispose
  807.      @picture.bitmap = Cache.gallery(@picture_id.to_s) rescue nil
  808.      @ex = 0
  809.      @ey = 0
  810.      @ex_max_zoom = 0
  811.      @ey_max_zoom = 0
  812.      @picture.zoom_x = 1.0
  813.      @picture.zoom_y = 1.0   
  814.      if @picture.bitmap == nil
  815.         @picture.bitmap = Cache.gallery("")   
  816.         return
  817.      end  
  818.      if @picture.bitmap.width > Graphics.width
  819.         @ex_max = @picture.bitmap.width - Graphics.width
  820.         @move_hor = true
  821.      else
  822.         @ex_max = 0
  823.         @move_hor = false
  824.      end
  825.      if @picture.bitmap.height > Graphics.height
  826.         @ey_max = @picture.bitmap.height - Graphics.height
  827.         @move_ver = true
  828.      else
  829.         @ey_max = 0
  830.         @move_ver = false
  831.      end   
  832.     refresh_button
  833.     @pic_center_pos = [Graphics.width / 2 - (@picture.bitmap.width / 2),
  834.                        Graphics.height / 2 - (@picture.bitmap.height / 2)]
  835.     im_size_x = @picture.bitmap.width
  836.     im_size_y = @picture.bitmap.height
  837.     @scroll_speed[0] = (im_size_x / 240) + SCROLL_SPEED[0]
  838.     @scroll_speed[1] = (im_size_y / 240) + SCROLL_SPEED[1]
  839.     @scroll_speed[0] = 1 if @scroll_speed[0] < 0
  840.     @scroll_speed[1] = 1 if @scroll_speed[1] < 0
  841. end


  842. #------------------------------------------------------------------------------
  843. # ● Refresh Button
  844. #------------------------------------------------------------------------------        
  845. def refresh_button(type = 0)
  846.      @button.bitmap.clear
  847.      if @move_hor or @move_ver
  848.         src_rect = Rect.new(0, @ch, @cw, @ch)
  849.      else        
  850.         src_rect = Rect.new(0, 0, @cw, @ch)
  851.      end  
  852.      @button_bitmap .blt(0,0, @button_image, src_rect)  
  853.      @button.y = Graphics.height - (@ch + 2)
  854.      @button_fade_time = 120
  855.      @button.opacity = 0 unless @button.y == Graphics.height - (@ch + 2)
  856. end   

  857. #------------------------------------------------------------------------------
  858. # ● Update Command
  859. #------------------------------------------------------------------------------      
  860. def update_command
  861.      return if @wp[@wp_page].x != 0
  862.      if Input.trigger?(Input::B)
  863.         Sound.play_cancel
  864.         SceneManager.return
  865.         return
  866.      end
  867.      if Input.trigger?(Input::C)
  868.         if check_avaliable_picture?
  869.            Sound.play_ok
  870.            @image_active = true
  871.            @wp[@wp_page].active = false
  872.            create_bitmap
  873.         else
  874.           Sound.play_buzzer
  875.         end
  876.         return
  877.      end  
  878.      if Input.trigger?(Input::L) and @max_pages != 1
  879.         Sound.play_cursor
  880.         @page_old = @wp_page
  881.         @wp_page -= 1
  882.         @slide_type = 1
  883.         check_limit
  884.         return
  885.      elsif Input.trigger?(Input::R) and @max_pages != 1   
  886.         Sound.play_cursor
  887.         @page_old = @wp_page
  888.         @wp_page += 1
  889.         @slide_type = 0
  890.         check_limit
  891.         return
  892.      end  
  893.   end  
  894.    
  895. end  

  896. if MOG_PICTURE_GALLERY::PICTURE_GALLERY_MENU_COMMAND
  897. #==============================================================================
  898. # ■ Window Menu Command
  899. #==============================================================================
  900. class Window_MenuCommand < Window_Command  
  901.   
  902. #------------------------------------------------------------------------------
  903. # ● Add Main Commands
  904. #------------------------------------------------------------------------------     
  905.   alias mog_picture_gallery_add_main_commands add_main_commands
  906.   def add_main_commands
  907.       mog_picture_gallery_add_main_commands
  908.       add_command(MOG_PICTURE_GALLERY::PICTURE_GALLERY_COMMAND_NAME, :picture, main_commands_enabled)
  909.   end
  910. end   

  911. #==============================================================================
  912. # ■ Scene Menu
  913. #==============================================================================
  914. class Scene_Menu < Scene_MenuBase
  915.   
  916. #------------------------------------------------------------------------------
  917. # ● Create Command Windows
  918. #------------------------------------------------------------------------------      
  919.    alias mog_picture_gallery_create_command_window create_command_window
  920.    def create_command_window
  921.        mog_picture_gallery_create_command_window
  922.        @command_window.set_handler(:picture,     method(:Picture_Gallery))
  923.    end
  924.    
  925. #------------------------------------------------------------------------------
  926. # ● Picture Gallery
  927. #------------------------------------------------------------------------------        
  928.    def Picture_Gallery
  929.        SceneManager.call(Scene_Picture_Gallery)
  930.    end

  931. end   

  932. end
复制代码

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22189
在线时间
8585 小时
注册时间
2011-12-31
帖子
3363
7
发表于 2015-6-6 21:44:03 | 只看该作者
夢工場的
フィルター付きCGギャラリー画面
フィルター付きシーン回想画面
http://hime.be/rgss.html
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-6-14 14:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表