#==============================================================================
# ** Window_Map
#------------------------------------------------------------------------------
class Window_MapMenu < Window_Base
MAP_TABLE =
[
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","","",
]
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Text Character Acquisition
#--------------------------------------------------------------------------
def grid
return MAP_TABLE[@index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...237
x = 32 + i / 17 / 14 * 160 + i % 17 * 32
y = 0 + i / 17 % 14 * 32
self.contents.draw_text(x, y, 32, 32, MAP_TABLE[i], 1)
end
@bitmap = RPG::Cache.picture("kantomap.png")
self.contents.blt(32, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
x = 32 + @index / 17 / 14 * 160 + @index % 17 * 32
y = 0 + @index / 17 % 14 * 32
self.cursor_rect.set(x, y, 32, 32)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
if @index == 0
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
end
if @index == 1
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Skill.new
end
end
# If right directional button is pushed
if Input.repeat?(Input::RIGHT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the right edge
if Input.trigger?(Input::RIGHT) or
@index % 17 < 16
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % 17 < 16
@index += 1
end
end
end
# If left directional button is pushed
if Input.repeat?(Input::LEFT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the left edge
if Input.trigger?(Input::LEFT) or
@index % 17 > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % 17 > 0
@index -= 1
end
end
end
# If down directional button is pushed
if Input.repeat?(Input::DOWN)
# Move cursor down
$game_system.se_play($data_system.cursor_se)
if @index % 237 < 237
@index += 17
end
end
# If up directional button is pushed
if Input.repeat?(Input::UP)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the upper edge
if Input.trigger?(Input::UP)
# Move cursor up
$game_system.se_play($data_system.cursor_se)
if @index % 237 >= 17
@index -= 17
end
end
end
update_cursor_rect
end
end
#---------------------------------------------------------------------------
# * class Window_Town
#---------------------------------------------------------------------------
class Window_Town < Window_Base
#-------------------------------------------------------------------------
# * Object Initialization
#-------------------------------------------------------------------------
def initialize
super(0, 0, 416, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#-------------------------------------------------------------------------
# * refresh
#-------------------------------------------------------------------------
def refresh
@bitmap = RPG::Cache.picture("pallettown.png")
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
end
end
#---------------------------------------------------------------------------
# * Scene Map_Menu
#---------------------------------------------------------------------------
class Scene_MapMenu
def initialize(index = 0)
@index = index
end
#-------------------------------------------------------------------------
# * MAIN
#-------------------------------------------------------------------------
def main
@mapmenu_window = Window_MapMenu.new
@mapmenu_window.index = @index
# 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
@mapmenu_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mapmenu_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Menu screen
$scene = Scene_Menu.new
return
end
end
end
#---------------------------------------------------------------------------
# * Scene_Town
#---------------------------------------------------------------------------
class Scene_Town
#-------------------------------------------------------------------------
# * Main
#-------------------------------------------------------------------------
def main
@town_window = Window_Town.new
# 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
@town_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@town_window.update
# if mapmenu is active call update_map
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_MapMenu.new(172)
return
end
end
end