Main Menu
  • Welcome to The RPG Maker Resource Kit.

Deity Gallery

Started by modern algebra, January 11, 2010, 11:28:23 PM

0 Members and 1 Guest are viewing this topic.

modern algebra

Gallery
Version: 1.0
Author: Deity
Date: January 11, 2010

Description



This script opens a gallery with pictures from the Pictures folder that the player can view. It allows you to add as many pictures as you like to as many galleries as you like, so you can, for instance, have the player unlock them as bonus achievements or use them as photo journal for the game, or do both in separate galleries!

Features


  • Allows you to setup a collection of pictures as a gallery that can be viewed by the player
  • Can have multiple galleries with different purposes
  • Can create new galleries or add pictures to existing ones at any time during the game
  • Tons of customization options, right down to the size and colour of the title and description texts
  • Can set it so that exiting the gallery can take you either to the menu or to the map, depending on how you want it accessed

Screenshots


You can change the size, color, position, and window opacity of everything there. Further, you may set it so that when the player presses SHIFT, all of that data goes away

Instructions

Place this script above Main and below the default scripts.

To open the script from a call script on the map, use: $scene = Scene_Gallery.new (1)
To open the script from an item common event or from the menu, use: $scene = Scene_Gallery.new (2)

See the header of the script for more detailed instructions

Script




#????????????????????????????????????????????????????????????????#
# Script:  Deity's Gallery                                       #
# by Ðeity [translated to English by modern algebra (rmrk.net)]  #
# Big Thanks: MelekTaus for helping me.                          #
#????????????????????????????????????????????????????????????????#
#  Description:                                       #
#                                                                #
#  This script opens a gallery with pictures from the Pictures   #
# folder that the player can view. It allows you to add as many  #
# pictures as you like to as many galleries as you like, so you  #
# can, for instance, have the player unlock them or use them as  #
# photo journal for the game.
#????????????????????????????????????????????????????????????????#
#  Instructions:                                                 #
#                                                                #
#  In order to open the gallery, you need to put the following   #
# code into a call script (or into a scene):                     #
#     $scene = Scene_Gallery.new (last_scene)                    #
#       last_scene : which scene to open upon exiting gallery:   #
#         1 => returns to Map                                    #
#         2 => returns to Menu                                   #
#                                                                #
#  If you want to call the script from the title screen, then    #
# you must choose the savefile you want first. To call the load  #
# screen and have the selected file go immediately to gallery,   #
# you need to use this code:                                     #
#    $scene = Scene_File.new (false, true, false, true)          #
#                                                                #
#  You can set up the initial galleries at line 129. You must     #
# read the settings at line 65 very carefully for optimal        #
# configuration.                                                 #
#                                                                #
#  Now, you also need to know how to add galleries in-game and   #
# how to add pictures to those galleries. To add a new gallery,  #
# all you need to do is use the code:                            #
#    $game_gallery.add_gallery (gallery_name)                    #
#      gallery_name : a String with whatever you want the name   #
#        of the gallery to be. You must put it within quotations #
#    Example =>                                                  #
#  $game_gallery.add_gallery ("Gallery 1")                       #
#                                                                #
#  To add a picture to an existing gallery, use the code:        #
#    $game_gallery.add_picture(gallery_name, pic_name, pic_desc) #
#      gallery_name : the name of the gallery you are adding the #
#        picture to. Must be in quotations.                      #
#      pic_name : the name of the picture (in Graphics/Pictures  #
#        folder) that you are adding to the gallery. Must be in  #
#        quotations.                                             #
#      pic_desc : a short description of the picture that will   #
#        show up when viewing. Must be in quotations.            #
#    Example =>                                                  #
#  $game_gallery.add_picture ("Gallery 1", "Fig. 1", "1st pic")  #
#                                                                #
#  Since that is likely too long for a simple call script box,   #
# keep in mind that you can first save the names of the items to #
# local variables, like this for instance:                       #
#    a = "Gallery 1"                                             #
#    b = "Fig. 1"                                                #
#    c = "This is the 1st picture"                               #
#    $game_gallery.add_picture (a, b, c)                         #
#?????????????????????????? Settings ????????????????????????????#
#               true = yes | false = no                                                                     #
module D_GALLERY
#    GENERAL                                                                                    #
 BGM_GAL = "Scene7" # Background Music for the Gallery
 KEY_GAL = "Key" # Sound Effect to play when switching pictures
 WINSTYLE = "Window" # The windowskin of the windows in the scene
 SAVE_FILE = 2 # The graphics folder in which you have the pictures:
               # 1 => System; 2 => Pictures
 MENU_INDEX = 0  # When returning to the menu from the Gallery, what
                 # index to return to.
#     WINDOWS                                                                                   #
 # Top Window #
 HEAD = "Select Gallery" # Text in the top window of the gallery
 HEAD_X = 0 # X-coordinate for this window
 HEAD_Y = 0 # Y-coordinate for this window
 HEAD_WIDTH = 544 # Width of the window
 HEAD_HEIGHT = 62 # Height of the window
 SIZE_HEAD = 24 # Size of the text in this window
 # Gallery Selection Window #
 KIND = 2 # Placement of Selection Window. [1 => Central; 2 => User defined]
 SPLIT = false # Use multiple columns of commands in this window or just one?
 ROWS = 0 # If SPLIT is true, how many columns for this window
 COMMAND_X = 0 # X-coordinate of this window
 COMMAND_Y = 0 # Y-coordinate for this window.
 COMMAND_WIDTH = 160 # Width of the window
 COMMAND_OPACITY = 255  # Opacity of window. [0 => transparent; 255 => opaque]
 # Gallery Name Window #
 GN_X = 0 # X-coordinate of this window
 GN_Y = 0 # Y-coordinate of this window
 GN_WIDTH = 544 # Width of window
 GN_HEIGHT = 62 # Height of window
 GN_SIZE = 24 # Size of Text in window
 GN_OPACITY = 0  # Opacity of window. [0 => transpatent; 255 => opaque]
 GN_COLOR = Color.new(255,255,255,255) # Color of Gallery name (r, g, b, a)
 GN_SWITCH = true # Should name window disappear when SHIFT pressed?
 # Picture Title Window
 TITLE = "Title:" # Text before name of the picture
 TITLE_X = 0 # X-coordinate of the window
 TITLE_Y = 62 # Y-coordinate of the window.
 TITLE_HEIGHT = 62 # Height of the Picture title window
 TITLE_WIDTH = 544 # Width of the Picture title window
 SIZE_TITLE = 24 # Size of text in the picture title window
 COLOR_TITLE = Color.new(255,255,0,255) # Color of text in window (r, g, b, a)
 TITLE_OPACITY = 0 # Opacity of window. [0 => transparent; 255 => opaque]
 TITLE_SWITCH = false # Should title window disappear when SHIFT pressed?
 # Picture Description Window #
 DIS_X = 0 # X-coordinate of the window.
 DIS_Y = 124 # Y-coordinate of the window.
 DIS_HEIGHT = 62 # Height of the window
 DIS_WIDTH = 544 # Width of the window
 SIZE_DIS = 24 # Size of text in this window
 COLOR_DIS = Color.new(0,255,100,255) # Color of text in this window (r, g, b, a)
 DIS_OPACITY = 0 # Opacity of window. [0 => transparent; 255 => opaque]
 DIS_SWITCH = true # Should description window disappear when SHIFT pressed?
 # Help Window #
 HELP = "Shift: Info  |  L/R: Previous / Next  |  ESC: Exit" # Hilfestellung für den Benutzer,
                                                                                                             # um durch die Gallerie zu navigieren.
 HELP_X = 0 # X-coordinate of this window
 HELP_Y = 416-62 # Y-coordinate of this window
 HELP_HEIGHT = 62 # Height of this window
 HELP_WIDTH = 544 # Width of this window
 SIZE_HELP = 18 # Size of text in this window
 COLOR_HELP = Color.new(255,255,255,255) # Color of text in this window
 HELP_OPACITY = 0    # Opacity of window. [0 => transparent; 255 => opaque]
 HELP_SWITCH = true # Should help window disappear when SHIFT pressed?
#     GALLERY
 GALERIEN = {                                                                                            #
 #  Here you can define the initial state of the gallery. I.e. what pictures
 # and galleries are unlocked at beginning of game. Set them up in the
 # following manner:
 #   "Name of Gallery 1" => [
 # ["Name of first picture","Description of 1st Picture"],
 # ["Name of second picture","Description of 2nd picture"],
 # ["Name of nth picture", "Description of nth picture"]   # <- no comma for last picture!
 # ], # <- comma for all but last gallery
 #
 #  And the same process for all subsequent galleries.
 # EXAMPLE::
 #  
 #    "System" => [
 #  ["Title", "The title screen"],
 #  ["GameOver", "The GameOver Screen"]
 #  ],
 #
 #  NB: Pictures are taken from System folder only if you have set KIND to
 # be 1 at line 82. If KIND is 2, pictures are taken from Pictures folder
 "Gallery 1" => [
   ["", ""],
   ["", ""],
   ["", ""]
   ]
 }
end
# Do not touch anything else in the script unless you are a
# scripter yourself and know what you're doing.
#???????????????????????????????????????????????????????????????#
#????????????????????????????????????????????#
include D_GALLERY
class Game_Gallery
 def initialize
   @data = GALERIEN
 end
 def add_gallery(gallery_name)
   @data[gallery_name] = []
 end
 def add_picture(gallery_name,picture_name,picture_discription)
   @data[gallery_name] = [] if @data[gallery_name] == nil
   @data[gallery_name].push([picture_name, picture_discription])
 end
 def [](pic_name)
   return @data[pic_name]
 end
 def gallery_name(id)
   return @data.keys[id]
 end
 def value_from_id(id)
   return @data.values[id]
 end
 def galleries
   return @data.keys
 end
end
class Scene_Title
 alias create_game_objects_new create_game_objects
 def create_game_objects
   create_game_objects_new
   $game_gallery          = Game_Gallery.new
 end
end
class Scene_File
   alias initialize_new initialize
  def initialize(saving, from_title, from_event,gallery = false)
   @saving = saving
   @from_title = from_title
   @from_event = from_event
   @gallery = gallery
 end
 alias determine_savefile_new determine_savefile
 def determine_savefile
   determine_savefile_new
   if @saving
     Sound.play_save
     do_save
   else
     if @savefile_windows[@index].file_exist
       Sound.play_load
       if @gallery == false
         do_load
       else
         read_gallery
       end
     else
       Sound.play_buzzer
       return
     end
   end
   $game_temp.last_file_index = @index
 end
 def read_gallery
   file = File.open(@savefile_windows[@index].filename, "rb")
   characters           = Marshal.load(file)
   Graphics.frame_count = Marshal.load(file)
   @last_bgm            = Marshal.load(file)
   @last_bgs            = Marshal.load(file)
   $game_system         = Marshal.load(file)
   $game_message        = Marshal.load(file)
   $game_switches       = Marshal.load(file)
   $game_variables      = Marshal.load(file)
   $game_self_switches  = Marshal.load(file)
   $game_actors         = Marshal.load(file)
   $game_party          = Marshal.load(file)
   $game_troop          = Marshal.load(file)
   $game_map            = Marshal.load(file)
   $game_player         = Marshal.load(file)
   $game_gallery          = Marshal.load(file)
   file.close
   $scene = Scene_Gallery.new(3)
 end
 alias write_save_data_new write_save_data
 def write_save_data(file)
   write_save_data_new(file)
   Marshal.dump($game_gallery,       file)
 end
 alias read_save_data_new read_save_data
 def read_save_data(file)
   read_save_data_new(file)
   $game_gallery          = Marshal.load(file)
 end
end
class Window_Gallery_Name < Window_Base
 def initialize
   super(GN_X,GN_Y,GN_WIDTH,GN_HEIGHT)
   self.windowskin = Cache.system(WINSTYLE)
   self.opacity = GN_OPACITY
   self.contents.font.color = GN_COLOR
   self.contents.font.size = GN_SIZE
 end
 def refresh(gal_id)
   self.contents.clear
   self.contents.draw_text(0, 0, GN_WIDTH, GN_SIZE,$game_gallery.gallery_name(gal_id),1)
 end
end
class Window_Gallery_Head < Window_Base
 def initialize
   super(HEAD_X,HEAD_Y,HEAD_WIDTH,HEAD_HEIGHT)
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.draw_text(0,0,self.contents.width,SIZE_HEAD,HEAD)
 end
end
class Window_Gallery_Title < Window_Base
 def initialize
   super(TITLE_X,TITLE_Y,TITLE_WIDTH,TITLE_HEIGHT)
   self.windowskin = Cache.system(WINSTYLE)
   self.opacity = TITLE_OPACITY
   self.contents.font.color = COLOR_TITLE
   self.contents.font.size = SIZE_TITLE
 end
 def refresh(title)
   self.contents.clear
   @title = title
   self.contents.draw_text(0, 0, 544, SIZE_TITLE,TITLE+"  "+@title)
 end
end
class Window_Gallery_Dis < Window_Base
 def initialize
   super(DIS_X,DIS_Y,DIS_WIDTH,DIS_HEIGHT)
   self.windowskin = Cache.system(WINSTYLE)
   self.opacity = DIS_OPACITY
   self.contents.font.color = COLOR_DIS
   self.contents.font.size = SIZE_DIS
 end
 def refresh(gallery_index,picture_index)
   self.contents.clear
   self.contents.draw_text(0, 0, 544, SIZE_DIS,$game_gallery.value_from_id(gallery_index)[picture_index][1])
 end
end
class Window_Gallery_Help < Window_Base
 def initialize
   super(HELP_X,HELP_Y,HELP_WIDTH,HELP_HEIGHT)
   self.windowskin = Cache.system(WINSTYLE)
   self.opacity = HELP_OPACITY
   self.contents.font.color = COLOR_HELP
   self.contents.font.size = SIZE_HELP
 end
 def refresh
   self.contents.clear
   self.contents.draw_text(0, 0, 544, SIZE_HELP,HELP, 1)
 end
end
class Scene_Gallery < Scene_Base
 def initialize(last_scene)
   @last_scene = last_scene
   Audio.bgs_stop
   Audio.bgm_stop
   Audio.bgm_play("Audio/BGM/"+BGM_GAL.to_s, 100, 100)
   @picture_index = 0
   @hiden = false
 end
 def start
   create_menu_background
   create_command_window
   create_windows
 end
 def create_command_window
    if SPLIT == true
     @command_window = Window_Command.new(COMMAND_WIDTH,$game_gallery.galleries,ROWS)
   end
   if SPLIT != true
     @command_window = Window_Command.new(COMMAND_WIDTH,$game_gallery.galleries)
   end
   case KIND
   when 1
     @command_window.x = (544 - @command_window.width) / 2
     @command_window.y = (544 - @command_window.height) / 2
   when 2
     @command_window.x = COMMAND_X
     @command_window.y = COMMAND_Y
   end
   @head_window = Window_Gallery_Head.new
   @command_window.opacity = COMMAND_OPACITY
   @command_window.active = true
   @command_window_index = @command_window.index
 end
 def create_windows
   @help_window = Window_Gallery_Help.new
   @help_window.visible = false
   @title_window = Window_Gallery_Title.new
   @title_window.visible = false
   @des_window = Window_Gallery_Dis.new
   @des_window.visible = false
   @gn_window = Window_Gallery_Name.new
   @gn_window.visible = false
 end
 def draw_picture(command_window_index1,picture_index1)
   @pic = Sprite.new()
   case SAVE_FILE
   when 1
       @pic.bitmap = Cache.system($game_gallery.value_from_id(command_window_index1)[picture_index1][0].to_s)
   when 2
       @pic.bitmap = Cache.picture($game_gallery.value_from_id(command_window_index1)[picture_index1][0].to_s)
   end
   @pic.x = (544-@pic.width)/2
   @pic.y = (416-@pic.height)/2
   if @menuback_sprite != nil
     @pic.z = @menuback_sprite.z + 1
   end
 end
 def delete_picture
   @pic.dispose if @pic != nil
 end
 def close_windows
   @command_window.dispose if @command_window != nil
   @help_window.dispose if @help_window != nil
   @title_window.dispose if @title_window != nil
   @des_window.dispose if @des_window != nil
   @head_window.dispose if @head_window != nil
   @gn_window.dispose if @gn_window != nil
   dispose_menu_background
 end
 def hide_windows(kind)
   case kind
   when 1
     @help_window.visible = false
     @title_window.visible = false
     @des_window.visible = false
     @gn_window.visible = false
   when 2
     if @hiden == false && @hiden != nil
       @help_window.visible = false if HELP_SWITCH == true
       @title_window.visible = false if TITLE_SWITCH == true
       @des_window.visible = false if DIS_SWITCH == true
       @gn_window.visible = false if GN_SWITCH == true
       @hiden = true
     elsif @hiden == true && @hiden != nil
       @help_window.visible = true if HELP_SWITCH == true
       @title_window.visible = true if TITLE_SWITCH == true
       @des_window.visible = true if DIS_SWITCH == true
       @gn_window.visible = true if GN_SWITCH == true
       @hiden = false
     end
   end
 end
 def show_windows
     @help_window.visible = true
     @title_window.visible = true
     @des_window.visible = true
     @gn_window.visible = true
 end
 def refresh_windows
   @title_window.refresh($game_gallery.value_from_id(@command_window_index)[@picture_index][0].to_s) if @title_window != nil
   @des_window.refresh(@command_window_index,@picture_index)
   @help_window.refresh
   @gn_window.refresh(@command_window_index)
 end
 def update_command
    if @command_window != nil
     if @command_window.active == true
       @command_window.update
       @command_window_index = @command_window.index
       if Input.trigger?(Input::C)
         @command_window.active = false
         @command_window.visible = false
         @head_window.visible = false
         show_windows
       end
       if Input.trigger?(Input::B)
         Sound.play_cancel
         Audio.bgm_stop
         close_windows
         case @last_scene
         when 1
           $scene = Scene_Map.new
         when 2
           $scene = Scene_Menu.new(MENU_INDEX)
         when 3
           $scene = Scene_File.new(false,true,false,true)
         end
       end
     end
   end
 end
 def update_gallery
   if @command_window != nil
         if @command_window.active == false
           if Input.trigger?(Input::LEFT)
             Audio.se_play("Audio/SE/"+KEY_GAL.to_s, 100, 100)
             @picture_index -= 1
             if @picture_index < 0
               @picture_index = $game_gallery.value_from_id(@command_window_index).size - 1
             end
           end
           if Input.trigger?(Input::RIGHT)
             Audio.se_play("Audio/SE/"+KEY_GAL.to_s, 100, 100)
             @picture_index += 1
             if @picture_index > $game_gallery.value_from_id(@command_window_index).size - 1
               @picture_index = 0
             end
           end
           if Input.trigger?(Input::A)
               hide_windows(2)
           end
           delete_picture
           draw_picture(@command_window_index,@picture_index)
           refresh_windows
           if Input.trigger?(Input::B)
             Sound.play_cancel
             @picture_index = 0
             hide_windows(1)
             delete_picture
             @command_window.active = true if @command_window != nil
             @command_window.visible = true if @command_window != nil
             @head_window.visible = true if @head_window != nil
         end
       end
     end
 end
 def update
   update_menu_background
   if @command_window.active == true
     update_command
   else
     update_gallery
   end
 end
end


Credit




  • Deity

Thanks


  • MelekTaus

Support



Please post in this topic at rmrk.net and I will either try to help you with the problem or refer you to the author.

Known Compatibility Issues

No currently known compatibility issues.

Demo



A demo isn't all that helpful for this script, I don't think. If you guys want one, I can make one.

Translator's Notes



I didn't touch the coding on this script at all - all I translated were the comments. All credit goes to Deity.

Eternal

pretty neat, might use it ;)