05-05-2006, 01:00 PM
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Well, I've been scripting for quite a while now but I've never really released any of my
scripts, mainly because I don't think they'll be any use to you or got destroyed when I
had to wipe my hardrive, I hope some of you put this to use.
The Art Gallery
by datriot
May 5 2006
What it does:
This script allows you to put art in your game and view them
in this art gallery. (This is based of the Final Fantasy: Origins Art Gallery)
Features:
1) Allows you to put art in the game and view it in the art gallery.
2) Has an unlock feature, so you have to unlock the art before viewing it.
3) Has "new tags" so it will say *New* when you haven't vied it yet.
4) You can move your pictures, zoom in & out.
5) Toggle windows and background on & off.
And that's about it.
What's to come:
I might make it so you can rotate the images, and maybe change the hue of them,
but I can't really think of anything major to add.
How to use:
Making pieces of art:
Go to the gallery module and then into the constant ART_LIST, there are already some
examples, but here's a blank template:
Art.new(ID, Name of Art, Name of File,
Description (Store in an array, up to two lines), Author, unlocked, new)
e.g
Art.new(1, "Example", "Example"
["Woot! First line!" "OMG! It's the second line!"], "Some Guy", false, false)
Gain Art:
$game_party.gain_art(art_id)
Lose Art:
$game_party.lose_art(art_id)
Put all the art in a folder named "Art" in your Graphics/Pictures folder.
And that's about it....oh and go to this line:
@background.bitmap = RPG::Cache.picture("Art/Background")
And replace the "Background" with the name of your background file. (Which goes in the art folder too)
The Script
Code:
#====================================================================#==========
# ** Art Gallery
#------------------------------------------------------------------------------
# A list full of the art you have aquired during the game.
#====================================================================#==========
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Art Gallery', 'Datriot', 1, '5.4.06')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Art Gallery') == true
class Art
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :id
attr_accessor :name
attr_accessor :file_name
attr_accessor :description
attr_accessor :author
attr_accessor :new
attr_accessor :unlocked
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(id, name = '????', file_name = '', description = ['', '???????', ''], author = 'Unknown',
new = true, unlocked = false)
# Sets Parameters
@id, @name, @file_name, @description, @author, @new, @unlocked =
id, name, file_name, description, author, new, unlocked
end
end
module Gallery
#--------------------------------------------------------------------------
# * Gallery Constants
#--------------------------------------------------------------------------
ART_LIST = [nil,
# Art List Begin
Art.new(1, 'Arshes', 'Arshes',
['Is Arshes a woman? Maybe this can help you reach your conclusion...', '*whistles*'], 'Enterbrain', true, true),
Art.new(2, 'Quina As Selphie', 'Quina As Selphie',
['I know what you are thinking...', 'WTF!?'], 'Guillaume Chartier', false, false)
] # End of Art List
end # End of Module
class Scene_Title
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias datriot_gallery_scenetitle_commandnewgame command_new_game
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def command_new_game
# Orginal Main Method
datriot_gallery_scenetitle_commandnewgame
# Creates Gallery Data List
$data_gallery = Gallery::ART_LIST
end
end
class Scene_Save
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias datriot_gallery_scenesave_writesavedata write_save_data
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def write_save_data(file)
# Orginal Main Method
datriot_gallery_scenesave_writesavedata(file)
# Writes Gallery Data List
Marshal.dump($data_gallery, file)
end
end
class Scene_Load
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias datriot_gallery_sceneload_readsavedata read_save_data
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def read_save_data(file)
# Orginal Main Method
datriot_gallery_sceneload_readsavedata(file)
# Reads Gallery Data List
$data_gallery = Marshal.load(file)
end
end
class Game_Party
#--------------------------------------------------------------------------
# * Gain Art
#--------------------------------------------------------------------------
def gain_art(art_id)
# Adds the art and gives it a new tag
$data_gallery[art_id].unlocked = true
$data_gallery[art_id].new = true
end
#--------------------------------------------------------------------------
# * Lose Art
#--------------------------------------------------------------------------
def lose_art(art_id)
# Adds the art and gives it a new tag
$data_gallery[art_id].unlocked = false
$data_gallery[art_id].new = false
end
end
#--------------------------------------------------------------------------
# * Art Show Window
#--------------------------------------------------------------------------
class Window_Art < Window_Base
#--------------------------------------------------------------------------
# * Intial Processing
#--------------------------------------------------------------------------
def initialize(name = "????", description = ["???"], author = "??????")
super(0, 480 - 96, 640, 96)
self.contents = Bitmap.new(width - 32, height - 32)
@name, @description, @author = name, description, author
refresh
end
#--------------------------------------------------------------------------
# * Item Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.name = Font.default_name
# Draws Description
for i in 0...@description.size
self.contents.draw_text(0, 32 * i + 2, 640, 32, @description[i])
end
end
end
#--------------------------------------------------------------------------
# * Art Show Window
#--------------------------------------------------------------------------
class Window_ArtName < Window_Base
#--------------------------------------------------------------------------
# * Intial Processing
#--------------------------------------------------------------------------
def initialize(name = "????", author = "??????")
super(0, 0, 640, 50)
self.contents = Bitmap.new(width - 32, height - 32)
@name, @author = name, author
refresh
end
#--------------------------------------------------------------------------
# * Item Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.name = Font.default_name
# Draws Art Name
self.contents.draw_text(0, -8, 400, 32, "#{@name}")
# Draws Author Name
self.contents.draw_text(300, -8, 240, 32, "Author: #{@author}", 2)
end
end
#--------------------------------------------------------------------------
# * Art Key
#--------------------------------------------------------------------------
class Window_ArtKey < Window_Base
#--------------------------------------------------------------------------
# * Intial Processing
#--------------------------------------------------------------------------
def initialize
super(0, 0, 280, 175)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Item Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Change font size
self.contents.font.name = Font.default_name
self.contents.font.size = 18
# Draws Key
self.contents.draw_text(0, -8 + 25 * 0, 400, 32, 'Return to previous menu: X or ESC', 0)
self.contents.draw_text(0, -8 + 25 * 1, 400, 32, 'Toggle Windows: Shift', 0)
self.contents.draw_text(0, -8 + 25 * 2, 400, 32, 'Toggle Background: Q', 0)
self.contents.draw_text(0, -8 + 25 * 3, 400, 32, 'Move: Directional Keys', 0)
self.contents.draw_text(0, -8 + 25 * 4, 400, 32, 'Zoom In: A', 0)
self.contents.draw_text(0, -8 + 25 * 5, 400, 32, 'Zoom Out: S', 0)
end
end
#--------------------------------------------------------------------------
# * Art Gallery Scene
#--------------------------------------------------------------------------
class Scene_ArtGallery
#--------------------------------------------------------------------------
# * Intial Processing
#--------------------------------------------------------------------------
def initialize
# Stores all art unlocked and locked into array.
@items = []
for i in 1...$data_gallery.size
if $data_gallery[i].unlocked == true
if $data_gallery[i].new == true
@items.push("#{$data_gallery[i].name} *NEW*")
else
@items.push($data_gallery[i].name)
end
else
@items.push("????")
end
end
# Adds the exit command
@items.push("Exit")
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Creates background image
@background = Sprite.new
@background.bitmap = RPG::Cache.picture("Background")
@background.z = -1000
# Creates art gallery window
@gallery_list_window = Window_Command.new(320, @items)
@gallery_list_window.z = -999
# Creates Art Display Window
@display_window = Window_Art.new
@display_window.visible = false
@display_window.back_opacity = 125
# Creates Art Name and Author Window
@name_window = Window_ArtName.new
@name_window.y = @display_window.y - 50
@name_window.back_opacity = 125; @name_window.visible = false
# Creates Art Key Window
@key_window = Window_ArtKey.new
@key_window.x, @key_window.y = 360, 0
@key_window.opacity, @key_window.visible = 125, false
# Creates blank art variable
@art = Sprite.new; @art.bitmap == ""
# 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 and Images
@gallery_list_window.dispose
@display_window.dispose
@name_window.dispose
@key_window.dispose
@background.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update Windows and Images
@gallery_list_window.update
@display_window.update
@name_window.update
@key_window.update
@background.update
# Checks if gallery list window is active
if @gallery_list_window.active == true
update_gallery_list
end
if @art.bitmap != ""
update_art_display
end
end
#--------------------------------------------------------------------------
# * Gallery List Frame Update
#--------------------------------------------------------------------------
def update_gallery_list
# If B button was pressed
if Input.trigger?(Input::B)
exit_scene
end
# If C button was pressed
if Input.trigger?(Input::C)
@choice = @items[@gallery_list_window.index]
if @choice != '????'
# Checks if highlighted option in exit
if @choice == 'Exit'
# Exits scene
exit_scene
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Makes the id variable the same as the picture you want to view
id = @gallery_list_window.index + 1
# Disables the currently selected art "new" tag
$data_gallery[id].new = false
# Recreates gallery list window
gallery_list_refresh
# Activates art display window with desired art
display_window_active($data_gallery[id].name, $data_gallery[id].description, $data_gallery[id].author,
$data_gallery[id].file_name)
else
# Play buzzer se
$game_system.se_play($data_system.buzzer_se)
end
end
end
#--------------------------------------------------------------------------
# * Art Display Frame Update
#--------------------------------------------------------------------------
def update_art_display
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Return to art select
@display_window.visible = false
@name_window.visible = false
@key_window.visible = false
@gallery_list_window.visible = true
@gallery_list_window.active = true
@background.visible = true
# Delete art image
@c_art = ""; @art.dispose
@art = Sprite.new; @art.bitmap = RPG::Cache.picture(@c_art)
end
# If SHIFT button pressed
if Input.trigger?(Input::SHIFT)
# Plays decision SE
$game_system.se_play($data_system.decision_se)
# Toggles the windows on and off
toggle_windows
end
# If L button pressed
if Input.trigger?(Input::L)
# Plays decision SE
$game_system.se_play($data_system.decision_se)
# Toggles the background on and off
toggle_background
end
# If LEFT button pressed
if Input.press?(Input::LEFT)
# Move art by one pixel to the left
@art.x -= 1
end
# If RIGHT button pressed
if Input.press?(Input::RIGHT)
# Move art by one pixel to the right
@art.x += 1
end
# If UP button pressed
if Input.press?(Input::UP)
# Move art by one pixel up
@art.y -= 1
end
# If DOWN button pressed
if Input.press?(Input::DOWN)
# Move art by one pixel down
@art.y += 1
end
# If X button is pressed
if Input.press?(Input::X)
# If art isn't zoomed in more than four times
if @art.zoom_x < 4
# Make art larger by one percent
@art.zoom_x += 0.05
@art.zoom_y += 0.05
end
end
# If Y button is pressed
if Input.press?(Input::Y)
# If art isn't zoomed in more than four times
if @art.zoom_x > 0.3
# Make art smaller by one percent
@art.zoom_x -= 0.05
@art.zoom_y -= 0.05
end
end
end
#--------------------------------------------------------------------------
# * Art Window Activate
#--------------------------------------------------------------------------
def display_window_active(name, description, author, file_name)
# Disposes art display window
@display_window.dispose
# Recreates art display window using new information
@display_window = Window_Art.new(name, description, author)
@display_window.back_opacity = 125
# Disposes art name window
@name_window.dispose
# Recreates art name window using new information
@name_window = Window_ArtName.new(name, author)
@name_window.y = @display_window.y - 50
@name_window.back_opacity = 125
# Makes the art display window visible
@display_window.visible = true
# Makes the name window visible
@name_window.visible = true
# Makes the key window visible
@key_window.visible = true
# Deactivates art gallery window
@gallery_list_window.active = false
@gallery_list_window.visible = false
# Recreates art image
@c_art = "#{file_name}"
if @art != nil; @art.dispose; end
@art = Sprite.new; @art.bitmap = RPG::Cache.picture("Art/#{@c_art}")
end
#--------------------------------------------------------------------------
# * Toggle Windows
#--------------------------------------------------------------------------
def toggle_windows
# Checks if the display window is visible
if @display_window.visible == true
# Deactivates dispay window
@display_window.visible = false
else
# Activates dispay window
@display_window.visible = true
end
# Checks if the name window is visible
if @name_window.visible == true
# Deactivates name window
@name_window.visible = false
else
# Activates name window
@name_window.visible = true
end
# Checks if the key window is visible
if @key_window.visible == true
# Deactivates key window
@key_window.visible = false
else
# Activates key window
@key_window.visible = true
end
end
#--------------------------------------------------------------------------
# * Toggle Background
#--------------------------------------------------------------------------
def toggle_background
# Checks if the background is visible
if @background.visible == true
# Deactivates background
@background.visible = false
else
# Activates background
@background.visible = true
end
end
#--------------------------------------------------------------------------
# * Gallery List Refresh
#--------------------------------------------------------------------------
def gallery_list_refresh
# Stores all art unlocked and locked into array.
@items = []
for i in 1...$data_gallery.size
if $data_gallery[i].unlocked == true
if $data_gallery[i].new == true
@items.push("#{$data_gallery[i].name} *NEW*")
else
@items.push($data_gallery[i].name)
end
else
@items.push('????')
end
end
# Adds the exit command
@items.push('Exit')
# Disposes of gallery list window
@gallery_list_window.dispose
# Creates art gallery window
@gallery_list_window = Window_Command.new(320, @items)
@gallery_list_window.z = -999
@gallery_list_window.visible = false; @gallery_list_window.active = false
# Returns to previous method
return
end
#--------------------------------------------------------------------------
# * Exit Scene Method
#--------------------------------------------------------------------------
def exit_scene
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Exits to map scene
$scene = Scene_Map.new
end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end
Art_Gallery.rar (Size: 671.39 KB / Downloads: 2)