#===============================================================================
# MOG Gallery - Customize Layout
# Author: Mobius XVI
# Version: 1.0
# Date: 31 Aug 2018
#===============================================================================
#
# Introduction:
#
# The purpose of this script is to allow you to modify the layout of MOG's
# picture gallery script.
#
# Instructions:
#
# - Place this script below the MOG Gallery script but above main
#
# Issues/Bugs/Possible Bugs:
#
# - None yet.
#
# Credits/Thanks:
# - Mobius XVI, author
# - MOG, author, original script:
# https://atelierrgss.wordpress.com/scripts/rpg-maker-xp/
#
# License
#
# The MIT License (MIT)
#
# Copyright (c) 2018 darmes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#==============================================================================
# CUSTOMIZATION START
#==============================================================================
module MOG_PICTURE_GALLERY
X_start = 15
Y_start = 12
Thumbnail_Width = 150
Thumbnail_Height = 80
Number_Columns = 3
Vertical_Spacing = 30
Horizontal_Spacing = 65
Cursor_Padding = 12
Font_Name = "MS PGothic"
Font_Color = Color.new(0,0,0)
end
#==============================================================================
# CUSTOMIZATION END -- DON'T EDIT BELOW THIS LINE!!!
#==============================================================================
#==============================================================================
# * Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# Draw_Thumbnail
#--------------------------------------------------------------------------
def draw_thumbnail(x,y,id)
image = RPG::Cache.gallery(id.to_s) rescue nil
return if image == nil
cw = image.width
ch = image.height
src_rect = Rect.new(0, 0, cw , ch)
tw = MOG_PICTURE_GALLERY::Thumbnail_Width
th = MOG_PICTURE_GALLERY::Thumbnail_Height
src_rect2 = Rect.new(x, y, tw, th)
self.contents.stretch_blt(src_rect2, image, src_rect)
end
end
#==============================================================================
# * Window_Picture
#==============================================================================
class Window_Picture < Window_Selectable
#------------------------------------------------------------------------------
# * Initialize
#------------------------------------------------------------------------------
def initialize(page)
super(0, 64, 640, 365)
self.opacity = 0
@column_max = MOG_PICTURE_GALLERY::Number_Columns
@page = page
@pic_max = MOG_PICTURE_GALLERY::MAX_PICTURES
@pic_max = 1 if @pic_max <= 0
@item_max = MOG_PICTURE_GALLERY::Number_Columns * page_row_max
@pag_max = @pic_max / @item_max
if @pag_max == page
o = @pag_max * @item_max
o2 = @pic_max - o
@item_max = o2
end
refresh(page)
self.index = 0
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
# Subtract a frame height of 32 from the window height, and divide it by
# 1 row height of 32
return ((self.height - 32) + MOG_PICTURE_GALLERY::Vertical_Spacing) / \
(80 + MOG_PICTURE_GALLERY::Vertical_Spacing)
end
#--------------------------------------------------------------------------
# * Get horizontal spacing
#--------------------------------------------------------------------------
def horizontal_spacing
MOG_PICTURE_GALLERY::Thumbnail_Width + MOG_PICTURE_GALLERY::Horizontal_Spacing
end
#--------------------------------------------------------------------------
# * Get vertical spacing
#--------------------------------------------------------------------------
def vertical_spacing
MOG_PICTURE_GALLERY::Thumbnail_Height + MOG_PICTURE_GALLERY::Vertical_Spacing
end
#------------------------------------------------------------------------------
# * draw_item
#------------------------------------------------------------------------------
def draw_item(index,page)
np = @item_max * page
picture_number = index + 1 + np
#x = 15 + index % 3 * 215
x = MOG_PICTURE_GALLERY::X_start + \
((index % @column_max) * horizontal_spacing)
#y = 12 + index / 3 *110
y = MOG_PICTURE_GALLERY::Y_start + \
((index / @column_max) * vertical_spacing)
s = picture_number
s = 0 if $game_system.gallery[picture_number] == nil
draw_thumbnail(x,y,s)
self.contents.font.name = MOG_PICTURE_GALLERY::Font_Name
self.contents.font.color = MOG_PICTURE_GALLERY::Font_Color
self.contents.draw_text(x + 45,y + 70, 64, 32, "N - " + picture_number.to_s,1)
self.contents.font.name = Font.default_name
self.contents.font.color = normal_color
end
#------------------------------------------------------------------------------
# * update_cursor_rect
#------------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
if row < self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
cursor_width = MOG_PICTURE_GALLERY::Thumbnail_Width + \
(2 * MOG_PICTURE_GALLERY::Cursor_Padding)
cursor_height = MOG_PICTURE_GALLERY::Thumbnail_Height + \
(2 * MOG_PICTURE_GALLERY::Cursor_Padding)
#x = index % 3 * 215
x = MOG_PICTURE_GALLERY::X_start - \
MOG_PICTURE_GALLERY::Cursor_Padding + \
(index % @column_max) * horizontal_spacing
#y = index / 3 *110
y = MOG_PICTURE_GALLERY::Y_start - \
MOG_PICTURE_GALLERY::Cursor_Padding + \
(index / @column_max) * vertical_spacing
self.cursor_rect.set(x, y, cursor_width, cursor_height)
end
end
#==============================================================================
# * Window_Picture_Help
#==============================================================================
class Window_Picture_Help < Window_Help
#--------------------------------------------------------------------------
# * Set Text
# text : text string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# If at least one part of text and alignment differ from last time
if text != @text or align != @align
# Redraw text
self.contents.clear
self.contents.font.name = MOG_PICTURE_GALLERY::Font_Name
self.contents.font.color = MOG_PICTURE_GALLERY::Font_Color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#==============================================================================
# * Scene_ArtPictures
#==============================================================================
class Scene_Picture_Gallery
#------------------------------------------------------------------------------
# * Create Window
#------------------------------------------------------------------------------
def create_window
@info = Window_Picture_Help.new
@info.y = 416
@info.opacity = 0
@wp_page = 0
@wp_page_old = @wp_page
@wp_index = 0
@wp =[]
for i in 0...@max_pages
@wp[i] = Window_Picture.new(i)
@wp[i].x = 32 * i
end
check_active_window(true)
refresh_info_window(true)
end
end