#==============================================================================
# ★ RGSS3_荣誉系统 Ver1.00
#==============================================================================
=begin
作者:tomoaky (伪)汉化:快乐之源
请运行以下命令事件“脚本”
使用方法:gain_dedal(0)
请运行以下命令事件“脚本”
gain_dedal(1) #括号内的数字对应几号荣誉
例如:gain_dedal(1)
在游戏里获得一号荣誉
=end
#==============================================================================
# □ 设定项目
#==============================================================================
module TMDEDAL
# COMMAND_DEDAL = "荣誉" # 菜单中的名字
# 一个荣誉也没有时隐藏菜单(true隐藏;false不隐藏)
HIDE_COMMAND = false
# 荣誉获得时的效果音
SE_GAIN_DEDAL = RPG::SE.new("Powerup", 90, 140)
# 荣誉名称及简介的设置
#例如:DEDAL_DATA[0] = ["名字", 1, "简介"]
dEDAL_DATA = {}
dEDAL_DATA[1] = ["荣誉1", 1, "简介1"]
dEDAL_DATA[2] = ["荣誉2", 2, "简介2"]
dEDAL_DATA[3] = ["荣誉3", 3, "简介3"]
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 变量
#--------------------------------------------------------------------------
attr_reader :Dedals # 已获得荣誉
attr_reader :new_dedals # 获得新荣誉
attr_accessor :dedal_info_count # 荣誉总数
attr_accessor :dedal_info_opacity # 不透明度
#--------------------------------------------------------------------------
# ● 荣誉初始化
#--------------------------------------------------------------------------
alias tmdedal_game_party_initialize initialize
def initialize
tmdedal_game_party_initialize
@Dedals = []
@new_dedals = []
@dedal_info_count = 0
@dedal_info_opacity = 0
end
#--------------------------------------------------------------------------
# ○ 荣誉获得
#--------------------------------------------------------------------------
def gain_dedal(dedal_id)
return if @dedals.any? {|dedal| dedal[0] == dedal_id }
t = Time.now.strftime(" (%Y/%m/%d %H:%M)")
@dedals.push([dedal_id, t])
@new_dedals.push([dedal_id, t])
end
#--------------------------------------------------------------------------
# ○ 荣誉界面退出
#--------------------------------------------------------------------------
def delete_new_dedal
@new_dedals.shift
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ 已获得的荣誉
#--------------------------------------------------------------------------
def gain_dedal(dedal_id)
$game_party.gain_dedal(dedal_id)
end
end
#==============================================================================
# ■ Window_MenuCommand
#==============================================================================
class Window_MenuCommand
#--------------------------------------------------------------------------
# ● 独自指令的追加
#--------------------------------------------------------------------------
alias tmdedal_window_menucommand_add_original_commands add_original_commands
def add_original_commands
tmdedal_window_menucommand_add_original_commands
unless TMDEDAL::HIDE_COMMAND && !dedal_enabled
# add_command(TMDEDAL::COMMAND_DEDAL, :dedal, dedal_enabled)
end
end
#--------------------------------------------------------------------------
# ○取得荣誉的状态
#--------------------------------------------------------------------------
def dedal_enabled
!$game_party.dedals.empty?
end
end
#==============================================================================
# □ Window_DedalInfo
#==============================================================================
class Window_DedalInfo < Window_Base
#--------------------------------------------------------------------------
# ● 对象初期化
#--------------------------------------------------------------------------
def initialize
super(Graphics.width - window_width, 0, window_width, fitting_height(1))
self.opacity = 0
self.contents_opacity = $game_party.dedal_info_opacity
refresh
end
#--------------------------------------------------------------------------
# ● 窗口宽度
#--------------------------------------------------------------------------
def window_width
return 240
end
#--------------------------------------------------------------------------
# ● 框架更新
#--------------------------------------------------------------------------
def update
super
if $game_party.dedal_info_count > 0
self.contents_opacity += 16
$game_party.dedal_info_count -= 1
$game_party.delete_new_dedal if $game_party.dedal_info_count == 0
else
self.contents_opacity -= 16
if self.contents_opacity == 0
open unless $game_party.new_dedals.empty?
end
end
$game_party.dedal_info_opacity = self.contents_opacity
end
#--------------------------------------------------------------------------
# ● 打开窗口
#--------------------------------------------------------------------------
def open
refresh
TMDEDAL::SE_GAIN_DEDAL.play
$game_party.dedal_info_count = 150
self.contents_opacity = 0
self
end
#--------------------------------------------------------------------------
# ○ 恢复精神
#--------------------------------------------------------------------------
def refresh
contents.clear
unless $game_party.new_dedals.empty?
draw_background(contents.rect)
dedal = TMDEDAL::DEDAL_DATA[$game_party.new_Dedals[0][0]]
rect = contents.rect.clone
draw_icon(Dedal[1], rect.x, rect.y)
rect.x += 24
rect.width -= 24
draw_text(rect, dedal[0])
end
end
#--------------------------------------------------------------------------
# ○ 背景
#--------------------------------------------------------------------------
def draw_background(rect)
temp_rect = rect.clone
temp_rect.width /= 2
contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
temp_rect.x = temp_rect.width
contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
end
#--------------------------------------------------------------------------
# ○ 背景色1
#--------------------------------------------------------------------------
def back_color1
Color.new(0, 0, 0, 192)
end
#--------------------------------------------------------------------------
# ○ 背景色2
#--------------------------------------------------------------------------
def back_color2
Color.new(0, 0, 0, 0)
end
end
#==============================================================================
# □ Window_Dedal
#==============================================================================
class Window_Dedal < Window_Selectable
#--------------------------------------------------------------------------
# ● 对象初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
refresh
select(0)
activate
end
#--------------------------------------------------------------------------
# ● 位数的取得
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# ● 荣誉数取得
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● 物品获得
#--------------------------------------------------------------------------
def item
@data && index >= 0 ? @data[index] : nil
end
#--------------------------------------------------------------------------
# ● 荣誉清单
#--------------------------------------------------------------------------
def make_item_list
@data = $game_party.Dedals
end
#--------------------------------------------------------------------------
# ● 荣誉的描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
dedal = TMDEDAL::DEDAL_DATA[item[0]]
rect = item_rect(index)
draw_icon(dedal[1], rect.x, rect.y)
rect.x += 24
rect.width -= 216
draw_text(rect, dedal[0])
rect.x = contents.width - 192
rect.width = 192
draw_text(rect, item[1], 2)
end
#--------------------------------------------------------------------------
# ● 帮助更新
#--------------------------------------------------------------------------
def update_help
if item
dedal = TMDEDAL::DEDAL_DATA[item[0]]
text = dedal[2]
@help_window.set_text(text)
end
end
#--------------------------------------------------------------------------
# ● 恢复精神
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● 全窗口
#--------------------------------------------------------------------------
alias tmdedal_scene_map_create_all_windows create_all_windows
def create_all_windows
tmdedal_scene_map_create_all_windows
create_dedal_window
end
#--------------------------------------------------------------------------
# ○荣誉窗口
#--------------------------------------------------------------------------
def create_dedal_window
@dedal_window = Window_DedalInfo.new
end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 指令窗口
#--------------------------------------------------------------------------
alias tmdedal_scene_menu_create_command_window create_command_window
def create_command_window
tmdedal_scene_menu_create_command_window
# @command_window.set_handler(:dedal, method(:command_dedal))
end
#--------------------------------------------------------------------------
# ○ 指令[奖牌]
#--------------------------------------------------------------------------
def command_Dedal
SceneManager.call(Scene_dedal)
end
end
#==============================================================================
# □ Scene_Dedal
#==============================================================================
class Scene_Dedal < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_item_window
end
#--------------------------------------------------------------------------
# ○ 物品窗口
#--------------------------------------------------------------------------
def create_item_window
wy = @help_window.height
wh = Graphics.height - wy
@item_window = Window_Dedal.new(0, wy, Graphics.width, wh)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:cancel, method(:return_scene))
end
end