#--------------------------------------------------------------------------
# Window
#--------------------------------------------------------------------------
class Window_PreMenu < Window_Selectable
def initialize(x, y, w, h)
super(x, y, w, h)
@item_max = 3
@column_max = 3
@index = 0
self.active = true
update_cursor_rect
end
#--------------------------------------------------------------------------
def update_cursor_rect
super
tx = self.cursor_rect.x - 8
ty = self.cursor_rect.y - 8
tw = self.cursor_rect.width + 16
th = 32
self.cursor_rect.set(tx, ty, tw, th)
end
end
#--------------------------------------------------------------------------
# Scene
#--------------------------------------------------------------------------
class Scene_PreMenu
# Initialize it with the variable ID and the Common Event ID.
# You can even define the font and the color used to draw
# the texts.
def initialize(var_id=0,ce_id=0, font=Font.new("Tahoma",16), color=Color.new(0,0,0))
@variable_id = var_id
@common_event_id = ce_id
@font = font
@font.color = color
@font.bold = true
end
#--------------------------------------------------------------------------
def main
@effect_close = false
@common_event = nil
@effect_resize_progress = 1
@effect_resize_rate = 4
@spriteset = Spriteset_Map.new
iw, ih = 320, 100
iy = $game_player.screen_y - (ih + 32)
ix = $game_player.screen_x - (iw / 2)
ix = 0 if ix < 0
ix = 640-iw if ix+iw > 640
iy = 0 if iy < 0
iy = 480-ih if iy+ih > 480
@info_window = Window_Base.new(ix, iy, iw, 1)
@command_window = Window_PreMenu.new(ix, iy+52, iw, 1)
@info_window.contents = Bitmap.new(iw-32,16)
@info_window.contents.font = @font
@info_window.contents.draw_text(0,0,iw-32,16,"Gold: " + $game_party.gold.to_s)
@info_window.contents.draw_text(0,0,iw-32,16,"Level: " + $game_variables[@variable_id].to_s, 2)
@command_window.contents = Bitmap.new(iw-32,16)
@command_window.contents.font = @font
@command_window.contents.draw_text(-8,0,96,16,"Items",1)
@command_window.contents.draw_text(96,0,96,16,"Roster",1)
@command_window.contents.draw_text(200,0,96,16,"Exit",1)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@info_window.dispose
@command_window.dispose
end
#--------------------------------------------------------------------------
def update
@spriteset.update
@info_window.update
@command_window.update
update_command
update_effects
end
#--------------------------------------------------------------------------
def update_effects
if @effect_resize_progress == 1
if @info_window.height >= 48
@info_window.height = 48
@effect_resize_progress = 0
@command_window.height = @info_window.height
$scene = Scene_Map.new if @effect_close
else
@info_window.height += 48 / (Graphics.frame_rate/@effect_resize_rate)
@command_window.height = @info_window.height
end
elsif @effect_resize_progress == -1
if @info_window.height <= 0
@effect_resize_progress = 0
@command_window.height = @info_window.height
$scene = Scene_Map.new if @effect_close
else
@info_window.height -= 48 / (Graphics.frame_rate/@effect_resize_rate)
@command_window.height = @info_window.height
end
end
end
#--------------------------------------------------------------------------
def update_command
return if @effect_close
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# Taken off the effect for skipping with the ESC key.
# If you want it dis-comment the below lines and define
# $scene = Scene_Map.new
#@effect_resize_progress = -1
#@effect_close = true
$scene = Scene_Menu.new
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # Action taken when: Items
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new(1)
when 1 # Action taken when: Roster
$game_system.se_play($data_system.decision_se)
$game_temp.common_event_id = @common_event_id
@effect_resize_progress = -1
@effect_close = true
when 2 # Action taken when: Back
$game_system.se_play($data_system.cancel_se)
@effect_resize_progress = -1
@effect_close = true
end
return
end
end
end
#--------------------------------------------------------------------------
# Updates (Just for testing issues)
#--------------------------------------------------------------------------
class Scene_Map
def call_menu
$game_temp.menu_calling = false
if $game_temp.menu_beep
$game_system.se_play($data_system.decision_se)
$game_temp.menu_beep = false
end
$game_player.straighten
$scene = Scene_PreMenu.new
end
end
#--------------------------------------------------------------------------
# Updates (Just for testing issues)
#--------------------------------------------------------------------------
class Scene_Item
def initialize(last=0)
@last_scene = last
end
#--------------------------------------------------------------------------
def update_item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
if @last_scene == 0
$scene = Scene_Menu.new(0)
else
$scene = Scene_PreMenu.new
end
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
unless @item.is_a?(RPG::Item)
$game_system.se_play($data_system.buzzer_se)
return
end
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
if @item.scope >= 3
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
else
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
$scene = Scene_Map.new
return
end
end
return
end
end
end