module HB
module MENU
ITEM = "Предметы"
STAT = "Статус"
SAVE = "Сохранить"
LOAD = "Загрузка"
EXIT = "Выйти"
BCKG = :map # nil - убрать фон, :map - карта
end
end
class Scene_Menu
def main
s1 = HB::MENU::ITEM
s2 = HB::MENU::STAT
s3 = HB::MENU::SAVE
s4 = HB::MENU::LOAD
s5 = HB::MENU::EXIT
if HB::MENU::BCKG != nil && HB::MENU::BCKG != :map
@bg = Plane.new
@bg.bitmap = RPG::Cache.picture(HB::MENU::BCKG)
elsif HB::MENU::BCKG == :map
@bg = Spriteset_Map.new
end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.x = 64
@command_window.y = 144
@command_window.index = @menu_index
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
end
if $game_system.save_disabled
@command_window.disable_item(2)
end
@location_window = Window_Location.new
@location_window.x = 224
@location_window.y = 272
@steps_window = Window_Steps.new
@steps_window.x = 400
@steps_window.y = 272
@status_window = Window_M_Status.new
@status_window.x = 224
@status_window.y = 144
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@location_window.dispose
@steps_window.dispose
@status_window.dispose
end
def update
@command_window.update
@location_window.update
@steps_window.update
@status_window.update
if @command_window.active
update_command
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new
when 2
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 3
$game_system.se_play($data_system.decision_se)
$scene = Scene_LoadMenu.new
when 4
$game_system.se_play($data_system.decision_se)
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
$scene = nil
end
return
end
end
end
class Scene_Status
def main
if HB::MENU::BCKG != nil && HB::MENU::BCKG != :map
@bg = Plane.new
@bg.bitmap = RPG::Cache.picture(HB::MENU::BCKG)
elsif HB::MENU::BCKG == :map
@bg = Spriteset_Map.new
end
@location_window = Window_Location.new
@location_window.x = 144
@location_window.y = 272
@steps_window = Window_Steps.new
@steps_window.x = 320
@steps_window.y = 272
@status_window = Window_M_Status.new
@status_window.x = 144
@status_window.y = 144
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@location_window.dispose
@steps_window.dispose
@status_window.dispose
end
def update
@location_window.update
@steps_window.update
@status_window.update
end
def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(1)
return
end
end
end
class Scene_Save < Scene_File
def on_decision(filename)
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(2)
end
def on_cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(2)
end
end
class Scene_LoadMenu < Scene_File
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Which file would you like to load?")
end
def on_decision(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
def on_cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(3)
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
class Window_Base < Window
def draw_actor_hp(actor, x, y, width = 208)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 100, 32, "Здоровье: ")
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(x + 100, y, 48, 32, actor.hp.to_s, 2)
self.contents.font.color = normal_color
self.contents.draw_text(x + 148, y, 12, 32, "/", 1)
self.contents.draw_text(x + 160, y, 48, 32, actor.maxhp.to_s)
end
end
class Window_M_Status < Window_Base
def initialize
super(0, 0, 352, 128)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
actor = $game_party.actors[0]
draw_actor_graphic(actor, 20, 58)
draw_actor_class(actor, x + 48, y)
draw_actor_name(actor, x + 48, y + 32)
draw_actor_hp(actor, x, y + 64)
end
end
class Window_Location < Window_Base
def initialize
super(0, 0, 176, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
map = load_data("Data/MapInfos.rxdata")[$game_map.map_id].name
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 144, 32, "#{map}", 1)
end
end
class Window_Steps < Window_Base
def initialize
super(0, 0, 176, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 72, 32, "Шагов: ", 2)
self.contents.font.color = normal_color
self.contents.draw_text(72, 0, 72, 32, $game_party.steps.to_s)
end
end