I made this script for a request by Punk. But now he doesn't need it... so I can post it for anyone else who wants it. It makes a scene that holds all the pictures in a certain directory, which you can then click on and it shows them full size.
Features
Allows you view lots of pictures in game.
Screenshots
I don't have any good pictures to make a screenshot (I used the transitions to test mine... xD )
Script
Script
Code:
#==============================================================================
# ** Image_Gallery
#------------------------------------------------------------------------------
# by Syvkal
# Version 1.0
# 05-03-08
#==============================================================================
#
# --Disabling Pictures--
#
# To disable any pictures use:
#
# Gallery.disable(x)
#
# To enable any pictures use:
#
# Gallery.enable(x)
#
# The 'x' is the picture index, starting with 0
#
# --Return Scene--
#
# To edit where this scene returns to search:
#
# ##RETURN SCENE##
#
#==============================================================================
#=================================================#
# ** C O N F I G U R A T I O N ** #
#=================================================#
# This is where you can change the custom directory
module Pictures
DIR = 'Graphics/Gallery/'
# This is where you add your pictures types
NAMES = Dir.glob(DIR+'*.{jpg,jpeg,bmp,png}')
for i in 0...NAMES.size
NAMES[i].slice!(DIR)
NAMES[i].slice!('.png')
NAMES[i].slice!('.jpg')
NAMES[i].slice!('.jpeg')
NAMES[i].slice!('.bmp')
end
end
def main
# Make window
@gallery_window = Window_Gallery.new
@picture = 0
@picture_window = Window_Picture.new(@picture)
@picture_window.active = false
@picture_window.visible = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@gallery_window.dispose
@picture_window.dispose
end
#--------------------------------------------------------------------------
def update
# Update windows
@gallery_window.update
@picture = @gallery_window.index
@picture_window.update
if @gallery_window.active
update_gallery
return
end
if @picture_window.active
update_picture
return
end
end
#--------------------------------------------------------------------------
def update_gallery
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
##RETURN SCENE##
$scene = Scene_Menu.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
if $game_system.disable[@gallery_window.index] == true
$game_system.se_play($data_system.buzzer_se)
return
else
$game_system.se_play($data_system.decision_se)
@picture_window = Window_Picture.new(@picture)
@gallery_window.active = false
@gallery_window.visible = false
return
end
end
end
#--------------------------------------------------------------------------
def update_picture
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@picture_window.active = false
@picture_window.visible = false
@gallery_window.active = true
@gallery_window.visible = true
return
end
end
end
class Game_System
attr_accessor :disable
alias initialize_original initialize
def initialize
initialize_original
@disable = []
for i in 0...Gallery::PICS.size
@disable[i] = false
end
end
end
module Gallery
PICS = []
for i in 0...Pictures::NAMES.size - 1
PICS.push(RPG::Cache.gallery(Pictures::NAMES[i]))
end
def self.disable(i)
$game_system.disable[i] = true
end
def self.enable(i)
$game_system.disable[i] = nil
end
end
class Window_Picture < Window_Base
#--------------------------------------------------------------------------
def initialize(picture)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@pic = Gallery::PICS
@pics = @pic[picture]
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = (640 - @pics.width) / 2
y = (480 - @pics.height) / 2
rect = Rect.new(0, 0, @pics.width, @pics.height)
rect2 = Rect.new(x, y, @pics.width>608 ? 608 : @pics.width, @pics.height>448 ? 448 : @pics.height)
self.contents.stretch_blt(rect2, @pics, rect)
end
end
Instructions
Put it above Main.
Further instructions can be found in the script header.
Compatibility
Not sure what it's compatible with.... Should be pretty much everything...
Author's Notes
I am willing to make this for VX aswell, but only if someone wants it. It probably already works for VX, but VX allows you cut out lots of unnecessary coding, so I still count this as a XP script...