#------------------------------------------------------------------------------
# ● Check Active Window
#------------------------------------------------------------------------------
def check_active_window(starting = false)
for i in 0...@max_pages
if i == @wp_page
@wp[@wp_page].active = true
@wp[@wp_page].visible = true
if @slide_type == 0
@wp[@wp_page].x = 544
else
@wp[@wp_page].x = -544
end
elsif i == @page_old and starting == false
@wp[@page_old].active = false
@wp[@page_old].visible = true
@wp[@page_old].visible = false if starting
@wp[@page_old].x = 0
else
@wp[i].active = false
@wp[i].visible = false
end
end
end
#------------------------------------------------------------------------------
# ● Execute Loop
#------------------------------------------------------------------------------
def execute_loop
loop do
Graphics.update
Input.update
update
if SceneManager.scene != self
break
end
end
end
#------------------------------------------------------------------------------
# ● Execute Dispose
#------------------------------------------------------------------------------
def execute_dispose
Graphics.freeze
for i in 0...@max_pages
@wp[i].dispose
end
@info.dispose
if @picture.bitmap != nil
@picture.bitmap.dispose
end
@picture.dispose
@background.bitmap.dispose
@background.dispose
@background2.bitmap.dispose
@background2.dispose
@bitmap.dispose
@bitmap2.dispose
@cursor1.bitmap.dispose
@cursor1.dispose
@cursor2.bitmap.dispose
@cursor2.dispose
@button_bitmap.dispose
@button.bitmap.dispose
@button.dispose
@button_image.dispose
if @loading != nil
@loading.bitmap.dispose
@loading.dispose
end
end
#------------------------------------------------------------------------------
# ● Update
#------------------------------------------------------------------------------
def update
@wp.each {|wid| wid.update}
@info.update
if @image_active
update_command_image
else
update_command
end
update_slide
update_image_effect
update_cursor_animation
refresh_info_window
end
#------------------------------------------------------------------------------
# ● update_cursor_animation
#------------------------------------------------------------------------------
def update_cursor_animation
@cursor_speed += 1
case @cursor_speed
when 1..20
@cx1 += 1
@cx2 -= 1
when 21..40
@cx1 -= 1
@cx2 += 1
else
@cursor_speed = 0
@cx1 = 0
@cx2 = 0
end
@cursor1.x = 0 + @cx1
@cursor2.x = 514 + @cx2
end
#------------------------------------------------------------------------------
# ● Update Image Effect
#------------------------------------------------------------------------------
def update_image_effect
return if @wp[@wp_page].x != 0
@button_fade_time -= 1 if @button_fade_time > 0
if @image_active
@picture.opacity += 15
if @button_fade_time != 0
@button.opacity += 5
else
if @button.y < 416
@button.opacity -= 10
@button.y += 1
end
end
@wp[@wp_page].contents_opacity -= 15
@info.contents_opacity -= 15
@background.opacity -= 15
@cursor1.opacity -= 15
@cursor2.opacity -= 15
else
@picture.opacity -= 10
@button.opacity -= 15
@wp[@wp_page].contents_opacity += 15
@info.contents_opacity += 15
@background.opacity += 15
@cursor1.opacity += 15
@cursor2.opacity += 15
end
end
#------------------------------------------------------------------------------
# ● Update Slide
#------------------------------------------------------------------------------
def update_slide
@background2.ox += 1
if @loading != nil
@loading.opacity -= 5
if @loading.opacity <= 0
@loading.bitmap.dispose
@loading.dispose
@loading = nil
end
end
return if @wp[@wp_page].x == 0
slide_speed = 25
@picture.opacity = 0
@background.opacity = 255
if @slide_type == 1
if @wp[@wp_page].x < 0
@wp[@wp_page].x += slide_speed
if @wp[@wp_page].x >= 0
@wp[@wp_page].x = 0
end
end
if @wp[@page_old].x < 640
@wp[@page_old].x += slide_speed
if @wp[@page_old].x >= 544
@wp[@page_old].x = 544
end
end
else
if @wp[@wp_page].x > 0
@wp[@wp_page].x -= slide_speed
if @wp[@wp_page].x <= 0
@wp[@wp_page].x = 0
end
end
if @wp[@page_old].x > -544
@wp[@page_old].x -= slide_speed
if @wp[@page_old].x <= -544
@wp[@page_old].x = -544
end
end
end
if @slide_type == 0
@wp[@wp_page].x = 0 if @wp[@wp_page].x <= 0
else
@wp[@wp_page].x = 0 if @wp[@wp_page].x >= 0
end
end
#------------------------------------------------------------------------------
# ● Check_limite
#------------------------------------------------------------------------------
def check_limit
if @wp_page < 0
@wp_page = @max_pages - 1
elsif @wp_page >= @max_pages
@wp_page = 0
end
check_active_window
end
#------------------------------------------------------------------------------
# ● Update Command Image
#------------------------------------------------------------------------------
def update_command_image
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
Sound.play_cursor
@image_active = false
@wp[@wp_page].active = true
return
end
if Input.trigger?(Input::R) or Input.trigger?(Input::L)
Sound.play_cursor
execute_zoom
end
if Input.press?(Input::RIGHT)
@ex += 4
elsif Input.press?(Input::LEFT)
@ex -= 4
elsif Input.press?(Input::DOWN)
@ey += 4
elsif Input.press?(Input::UP)
@ey -= 4
end
@ex = @ex_max + @ex_max_zoom if @ex > @ex_max + @ex_max_zoom
@ex = 0 if @ex < 0
@ey = @ey_max + @ey_max_zoom if @ey > @ey_max + @ey_max_zoom
@ey = 0 if @ey < 0
@picture.x = -@ex
@picture.y = -@ey
end
#------------------------------------------------------------------------------
# ● Execute Zoom
#------------------------------------------------------------------------------
def execute_zoom
if @picture.zoom_x == 1.0
@picture.zoom_x = 1.5
@picture.zoom_y = 1.5
refresh_button(1)
@ex_max_zoom = (@picture.bitmap.width / 2)
if @ex != @ex_max
@ex += @ex_max_zoom / 2
else
if @ex_max != 0
@ex += @ex_max_zoom
else
@ex += @ex_max_zoom / 2
end
end
@ey_max_zoom = (@picture.bitmap.height / 2)
if @ey != @ey_max
@ey += @ey_max_zoom / 2
else
if @ey_max != 0
@ey += @ey_max_zoom
else
@ey += @ey_max_zoom / 2
end
end
else
if @picture.bitmap.width > 640 or
@picture.bitmap.height > 480
refresh_button(1)
else
refresh_button(0)
end
@ex -= @ex_max_zoom / 2
@ey -= @ey_max_zoom / 2
@picture.zoom_x = 1.0
@picture.zoom_y = 1.0
@ex_max_zoom = 0
@ey_max_zoom = 0
end
end
#------------------------------------------------------------------------------
# ● Update Command
#------------------------------------------------------------------------------
def update_command
return if @wp[@wp_page].x != 0
if Input.trigger?(Input::B)
Sound.play_cancel
SceneManager.return
return
end
if Input.trigger?(Input::C)
if check_avaliable_picture?
Sound.play_ok
@image_active = true
@wp[@wp_page].active = false
create_bitmap
else
Sound.play_buzzer
end
return
end
if Input.trigger?(Input::L) and @max_pages != 1
Sound.play_cursor
@page_old = @wp_page
@wp_page -= 1
@slide_type = 1
check_limit
return
elsif Input.trigger?(Input::R) and @max_pages != 1
Sound.play_cursor
@page_old = @wp_page
@wp_page += 1
@slide_type = 0
check_limit
return
end
end
end
if MOG_PICTURE_GALLERY::PICTURE_GALLERY_MENU_COMMAND
#==============================================================================
# ■ Window Menu Command
#==============================================================================
class Window_MenuCommand < Window_Command
#------------------------------------------------------------------------------
# ● Add Main Commands
#------------------------------------------------------------------------------
alias mog_picture_gallery_add_main_commands add_main_commands
def add_main_commands
mog_picture_gallery_add_main_commands
add_command(MOG_PICTURE_GALLERY::PICTURE_GALLERY_COMMAND_NAME, :picture, main_commands_enabled)
end
end
#==============================================================================
# ■ Scene Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#------------------------------------------------------------------------------
# ● Create Command Windows
#------------------------------------------------------------------------------
alias mog_picture_gallery_create_command_window create_command_window
def create_command_window
mog_picture_gallery_create_command_window
@command_window.set_handler(:picture, method(:Picture_Gallery))
end
#------------------------------------------------------------------------------
# ● Picture Gallery
#------------------------------------------------------------------------------
def Picture_Gallery
SceneManager.call(Scene_Picture_Gallery)
end