Advertisement
roninator2

Picture Gallery

Dec 11th, 2024 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.46 KB | None | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Picture Gallery                        ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║                                               ╠════════════════════╣
  7. # ║ Show an image gallery in menu                 ║    06 Oct 2021     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires:                                                          ║
  11. # ║        Global save system by TheLeech                              ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║   Allows to display pictures for the player to view                ║
  16. # ║   Requires Global save system by theleech                          ║
  17. # ╚════════════════════════════════════════════════════════════════════╝
  18. # ╔════════════════════════════════════════════════════════════════════╗
  19. # ║ Instructions:                                                      ║
  20. # ║   Specify the settings for each image in the array                 ║
  21. # ║     {                                                              ║
  22. # ║     :name => "P1", # image name                                    ║
  23. # ║     :opacity => 255, # opacity of image                            ║
  24. # ║     :x => 0, # x position                                          ║
  25. # ║     :y => 0, # y position                                          ║
  26. # ║     :visible => true, # picture visible                            ║
  27. # ║     :mcmd => false, # commands visible                             ║
  28. # ║     :wait => 180,  # how long to display image                     ║
  29. # ║     :command => "Picture 1", # Command in menu                     ║
  30. # ║     },                                                             ║
  31. # ║                                                                    ║
  32. # ║  Add or remove sections to accomdate your game.                    ║
  33. # ║                                                                    ║
  34. # ║  If you want to block access to the Gallery in title               ║
  35. # ║  you will need to use a global data script                         ║
  36. # ║                                                                    ║
  37. # ╚════════════════════════════════════════════════════════════════════╝
  38. # ╔════════════════════════════════════════════════════════════════════╗
  39. # ║ Updates:                                                           ║
  40. # ║ 1.00 - 06 Oct 2021 - Script finished                               ║
  41. # ║                                                                    ║
  42. # ╚════════════════════════════════════════════════════════════════════╝
  43. # ╔════════════════════════════════════════════════════════════════════╗
  44. # ║ Credits and Thanks:                                                ║
  45. # ║   Roninator2                                                       ║
  46. # ║                                                                    ║
  47. # ╚════════════════════════════════════════════════════════════════════╝
  48. # ╔════════════════════════════════════════════════════════════════════╗
  49. # ║ Terms of use:                                                      ║
  50. # ║  Follow the original Authors terms of use where applicable         ║
  51. # ║    - When not made by me (Roninator2)                              ║
  52. # ║  Free for all uses in RPG Maker except nudity                      ║
  53. # ║  Anyone using this script in their project before these terms      ║
  54. # ║  were changed are allowed to use this script even if it conflicts  ║
  55. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  56. # ║  No part of this code can be used with AI programs or tools        ║
  57. # ║  Credit must be given                                              ║
  58. # ╚════════════════════════════════════════════════════════════════════╝
  59.  
  60. module R2_Gallery_Title
  61.   Switch = 2 # switch to determine if in menu or title screen
  62.   Stop_Music = true # stops background music if true
  63.   Gallery_Music = "Battle1" # music to play while viewing gallery
  64.   Play_Music = false # play music while viewing gallery
  65.   Return_Text = "Back to Menu" # text to show for returning to menu
  66.   Background_Image = "Gallery_Background" # image to show for the background
  67.   Global_Switch = 5 # variable used with global variables
  68.   # requires a global variable script
  69.  
  70.   Picture_Gallery = [
  71.   {
  72.     :name => "P1", # image name
  73.     :opacity => 255, # opacity of image
  74.     :x => 0, # x position
  75.     :y => 0, # y position
  76.     :visible => true, # picture visible
  77.     :mcmd => false, # commands visible
  78.     :wait => 180,
  79.     :command => "Picture 1",
  80.     },
  81.   {
  82.     :name => "P2", # image name
  83.     :opacity => 255, # opacity of image
  84.     :x => 0, # x position
  85.     :y => 0, # y position
  86.     :visible => true, # picture visible
  87.     :mcmd => false, # commands visible
  88.     :wait => 180,
  89.     :command => "Picture 2",
  90.     },
  91.   {
  92.     :name => "P3", # image name
  93.     :opacity => 255, # opacity of image
  94.     :x => 0, # x position
  95.     :y => 0, # y position
  96.     :visible => true, # picture visible
  97.     :mcmd => false, # commands visible
  98.     :wait => 180,
  99.     :command => "Picture 3",
  100.     },
  101.   {
  102.     :name => "P4", # image name
  103.     :opacity => 255, # opacity of image
  104.     :x => 0, # x position
  105.     :y => 0, # y position
  106.     :visible => true, # picture visible
  107.     :mcmd => false, # commands visible
  108.     :wait => 180,
  109.     :command => "Picture 4",
  110.     },
  111.   {
  112.     :name => "P5", # image name
  113.     :opacity => 255, # opacity of image
  114.     :x => 0, # x position
  115.     :y => 0, # y position
  116.     :visible => true, # picture visible
  117.     :mcmd => false, # commands visible
  118.     :wait => 180,
  119.     :command => "Picture 5",
  120.     },
  121.   {
  122.     :name => "P6", # image name
  123.     :opacity => 255, # opacity of image
  124.     :x => 0, # x position
  125.     :y => 0, # y position
  126.     :visible => true, # picture visible
  127.     :mcmd => false, # commands visible
  128.     :wait => 180,
  129.     :command => "Picture 6",
  130.     },
  131.   {
  132.     :name => "P7", # image name
  133.     :opacity => 255, # opacity of image
  134.     :x => 0, # x position
  135.     :y => 0, # y position
  136.     :visible => true, # picture visible
  137.     :mcmd => false, # commands visible
  138.     :wait => 180,
  139.     :command => "Picture 7",
  140.     },
  141.   {
  142.     :name => "P8", # image name
  143.     :opacity => 255, # opacity of image
  144.     :x => 0, # x position
  145.     :y => 0, # y position
  146.     :visible => true, # picture visible
  147.     :mcmd => false, # commands visible
  148.     :wait => 180,
  149.     :command => "Picture 8",
  150.     },
  151.   {
  152.     :name => "P9", # image name
  153.     :opacity => 255, # opacity of image
  154.     :x => 0, # x position
  155.     :y => 0, # y position
  156.     :visible => true, # picture visible
  157.     :mcmd => false, # commands visible
  158.     :wait => 180,
  159.     :command => "Picture 9",
  160.     },
  161.   {
  162.     :name => "P10", # image name
  163.     :opacity => 255, # opacity of image
  164.     :x => 0, # x position
  165.     :y => 0, # y position
  166.     :visible => true, # picture visible
  167.     :mcmd => false, # commands visible
  168.     :wait => 180,
  169.     :command => "Picture 10",
  170.     },
  171.   ]
  172.  
  173. end
  174. # ╔══════════════════════════════════════════════════════════╗
  175. # ║ End of configuration                                     ║
  176. # ╚══════════════════════════════════════════════════════════╝
  177.  
  178. class Window_Gallery < Window_Command
  179.   def make_command_list
  180.     add_command(R2_Gallery_Title::Return_Text, :menu)
  181.     for cmd in R2_Gallery_Title::Picture_Gallery
  182.       add_command(cmd[:command], cmd[:command])
  183.     end
  184.   end
  185. end
  186.  
  187. class Scene_Gallery < Scene_MenuBase
  188.   def start
  189.     super
  190.     @last_bgm = RPG::BGM.last
  191.     RPG::BGM.stop if R2_Gallery_Title::Stop_Music
  192.     msc = RPG::BGM.new(R2_Gallery_Title::Gallery_Music, 100, 100) if R2_Gallery_Title::Play_Music
  193.     msc.play if R2_Gallery_Title::Play_Music
  194.     create_background
  195.     create_commands
  196.   end
  197.   def create_background
  198.     @background_sprite = Sprite.new
  199.     @background_sprite.bitmap = Cache.system(R2_Gallery_Title::Background_Image)
  200.     @background_sprite.color.set(0, 0, 0, 0)
  201.   end
  202.   def create_commands
  203.     @cmd = Window_Gallery.new(0,0) #(x,y)
  204.     @cmd.width = 244
  205.     @cmd.height = 416
  206.     @cmd.opacity = 0
  207.     @cmd.set_handler(:menu, method(:cmd_menu))
  208.     for cmd in R2_Gallery_Title::Picture_Gallery
  209.       @cmd.set_handler(cmd[:command], method(:sh_pic))
  210.     end
  211.   end
  212.   def cmd_menu
  213.     if $game_switches[R2_Gallery_Title::Switch]
  214.       return_scene
  215.       @last_bgm.play(@last_bgm.pos) if R2_Gallery_Title::Stop_Music
  216.       $game_switches[R2_Gallery_Title::Switch] = false
  217.     else
  218.       SceneManager.goto(Scene_Title)
  219.     end
  220.   end
  221.   def sh_pic
  222.     index = @cmd.index - 1
  223.     R2_Gallery_Title::Picture_Gallery.each_with_index { |cmd, i|
  224.       next if index != i
  225.       @pic = Sprite.new
  226.       @pic.bitmap = Cache.picture(cmd[:name])
  227.       @pic.opacity = cmd[:opacity]
  228.       @pic.x = cmd[:x]
  229.       @pic.y = cmd[:y]
  230.       @pic.visible = cmd[:visible]
  231.       @cmd.visible = cmd[:mcmd]
  232.       Graphics.wait(cmd[:wait])
  233.     }
  234.       @pic.visible = false
  235.       @cmd.visible = true
  236.       @cmd.activate
  237.   end
  238. end
  239.  
  240. class Window_MenuCommand < Window_Command
  241.   def add_original_commands
  242.     add_command("Gallery", :gallery)
  243.   end
  244. end
  245.  
  246. class Scene_Menu < Scene_MenuBase
  247.   alias r2_handler_command_gallery  create_command_window
  248.   def create_command_window
  249.     r2_handler_command_gallery
  250.     @command_window.set_handler(:gallery,   method(:command_gallery))
  251.   end
  252.   def command_gallery
  253.     $game_switches[R2_Gallery_Title::Switch] = true
  254.     SceneManager.call(Scene_Gallery)
  255.   end
  256. end
  257.  
  258. # ╔══════════════════════════════════════════════════════════╗
  259. # ║ Title Screen command                                     ║
  260. # ║ Requires Global save system by theleech                  ║
  261. # ╚══════════════════════════════════════════════════════════╝
  262.  
  263. class Scene_Title < Scene_Base
  264.   alias r2_gallery_title  create_command_window
  265.   def create_command_window
  266.     r2_gallery_title
  267.     @command_window.set_handler(:gallery, method(:command_gallery))
  268.   end
  269.   def command_gallery
  270.     close_command_window
  271.     SceneManager.call(Scene_Gallery)
  272.   end
  273. end
  274.  
  275. class Window_TitleCommand < Window_Command
  276.   alias r2_command_gallery_title  make_command_list
  277.   def make_command_list
  278.     r2_command_gallery_title
  279.     if $imported[:lglobal_save]
  280.       LGlobalSave.load
  281.       add_command("Gallery", :gallery) if $game_switches[R2_Gallery_Title::Global_Switch] == true
  282.     end
  283.   end
  284. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement