#========================================
#标题添加设定脚本v.1.0
#脚本的想法来自于月光奏鸣曲
#作者为Elamed,使用时请保留以上信息。
#========================================
class Game_System
attr_accessor :bgm_volume
attr_accessor :se_volume
attr_accessor :moniter_mode
def initialize
@bgm_volume = 80
@se_volume = 80
@moniter_mode = 0
end
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, @bgm_volume, bgm.pitch)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil and bgs.name != ""
Audio.bgs_play("Audio/BGS/" + bgs.name, @bgm.volume, bgs.pitch)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
def me_play(me)
if me != nil and me.name != ""
Audio.me_play("Audio/ME/" + me.name, @se.volume, me.pitch)
else
Audio.me_stop
end
Graphics.frame_reset
end
def se_play(se)
if se != nil and se.name != ""
Audio.se_play("Audio/SE/" + se.name, @se_volume, se.pitch)
end
end
end
class Scene_Title
def main
if $BTEST
battle_test
return
end
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
if FileTest.exist?("SettingData.rxdata")
file = File.open("SettingData.rxdata", "r")
$data_system_set = load_data("SettingData.rxdata")
$game_system = Marshal.load(file)
file.close
else
file = File.open("SettingData.rxdata", "w")
Marshal.dump($game_system, file)
file.close
end
if $game_system.moniter_mode == 1
unless $keybd
$keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
$keybd.call 0xA4, 0, 0, 0
$keybd.call 13, 0, 0, 0
$keybd.call 13, 0, 2, 0
$keybd.call 0xA4, 0, 2, 0
end
end
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# 生成命令窗口
s1 = "新游戏"
s2 = "读取"
s3 = "设定"
s4 = "退出"
@command_window = Window_Command.new(200, [s1, s2, s3, s4])
@command_window.x = 400
@command_window.y = 205
# 判定继续的有效性
# 存档文件一个也不存在的时候也调查
# 有効为 @continue_enabled 为 true、無効为 false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
if @continue_enabled
@command_window.index = 1
end
# 演奏标题 BGM
$game_system.bgm_play($data_system.title_bgm)
# 停止演奏 ME、BGS
Audio.me_stop
Audio.bgs_stop
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放命令窗口
@command_window.dispose
# 释放标题图形
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新命令窗口
@command_window.update
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置的分支
case @command_window.index
when 0 # 新游戏
command_new_game
when 1 # 继续
command_continue
when 2
command_option
when 3 # 退出
command_shutdown
end
end
end
def command_option
$game_system.se_play($data_system.decision_se)
$scene = Scene_Option.new
end
end
class Window_System < Window_Selectable
def initialize
super(160, 100, 300, 32 * 4)
@settings = $game_system
@item_max = 3
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
def refresh(bgm_volume = @settings.bgm_volume, se_volume = @settings.se_volume, moniter_mode = @settings.moniter_mode)
self.contents.clear
self.contents.font.size = 16
@settings.bgm_volume = bgm_volume
@settings.se_volume = se_volume
@settings.moniter_mode = moniter_mode
rect = Rect.new(4, 32 * 0, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
text = "BGM: "
blocknum = @settings.bgm_volume / 10
for i in 2..blocknum
case i
when 2
text = text + " "
when 3
text = text + "▁" # 30
when 4
text = text + "▂" # 40
when 5
text = text + "▃" # 50
when 6
text = text + "▄" # 60
when 7
text = text + "▅" # 70
when 8
text = text + "▆" # 80
when 9
text = text + "▇" # 90
when 10
text = text + "█" # 100
end
end
self.contents.draw_text(rect, text)
rect = Rect.new(4, 32 * 1, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
blocknum = @settings.se_volume / 10
text = "SE: "
for i in 2..blocknum
case i
when 2
text = text + " "
when 3
text = text + "▁" # 30
when 4
text = text + "▂" # 40
when 5
text = text + "▃" # 50
when 6
text = text + "▄" # 60
when 7
text = text + "▅" # 70
when 8
text = text + "▆" # 80
when 9
text = text + "▇" # 90
when 10
text = text + "█" # 100
end
end
self.contents.draw_text(rect, text)
rect = Rect.new(4, 32 * 2, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
text = "模式(需要重新启动游戏):"
case @settings.moniter_mode
when 0
text = text + " 窗口"
when 1
text = text + " 全屏"
end
self.contents.draw_text(rect, text)
end
end
class Scene_Option
def initialize
@bgm_volume = $game_system.bgm_volume
@se_volume = $game_system.se_volume
@moniter_mode = $game_system.moniter_mode
end
def main
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
@sprite.opacity = 180
@system_window = Window_System.new
@system_window.opacity = 180
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@system_window.dispose
@sprite.dispose
end
def update
@system_window.update
@sprite.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
$game_system.bgm_volume = @bgm_volume
$game_system.se_volume = @se_volume
$game_system.moniter_mode = @moniter_mode
file = File.open("SettingData.rxdata", "w")
Marshal.dump($game_system, file)
file.close
# 切换到菜单画面
$scene = Scene_Title.new
return
end
if Input.trigger?(Input::RIGHT)
if @system_window.index == 0
if @bgm_volume < 100
$game_system.se_play($data_system.cursor_se)
@bgm_volume = @bgm_volume + 10
$game_system.bgm_play($data_system.title_bgm)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.cancel_se)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
elsif @system_window.index == 1
if @se_volume < 100
$game_system.se_play($data_system.cursor_se)
@se_volume = @se_volume + 10
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.cancel_se)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
elsif @system_window.index == 2
if @moniter_mode == 0
$game_system.se_play($data_system.decision_se)
@moniter_mode = 1
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.decision_se)
@moniter_mode = 0
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
end
return
end
if Input.trigger?(Input::LEFT)
if @system_window.index == 0
if @bgm_volume > 20
$game_system.se_play($data_system.cursor_se)
@bgm_volume = @bgm_volume - 10
$game_system.bgm_play($data_system.title_bgm)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.cancel_se)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
elsif @system_window.index == 1
if @se_volume > 20
$game_system.se_play($data_system.cursor_se)
@se_volume = @se_volume - 10
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.cancel_se)
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
elsif @system_window.index == 2
if @moniter_mode == 0
$game_system.se_play($data_system.decision_se)
@moniter_mode = 1
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
else
$game_system.se_play($data_system.decision_se)
@moniter_mode = 0
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
end
return
end
@system_window.refresh(@bgm_volume, @se_volume, @moniter_mode)
end
end