class Scene_Map
#--------------------------------------------------------------------------
# ● 生成所有窗口
#--------------------------------------------------------------------------
alias create_all_windows_cld99 create_all_windows
def create_all_windows
create_all_windows_cld99
create_itemget_window
end
def create_itemget_window
@itemget_window = Window_Itemget.new
end
def itemget_set_text(string)
@itemget_window.set_text(string)
end
end
# Window_Itemget 大部分方法来自Window_Help
class Window_Itemget < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(line_number = 1)
@line_number = line_number
super(window_x, window_y, window_width, window_height)
end
def window_x
0
end
def window_y
Graphics.height - window_height
end
def window_width
Graphics.width / 2
end
def window_height
fitting_height(@line_number)
end
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
def update
super
if Time.should_clear_text?
self.clear
Time.text_cleared
end
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● 增加/减少物品
# include_equip : 是否包括装备
#--------------------------------------------------------------------------
alias gain_item_cld99 gain_item
def gain_item(item, amount, include_equip = false)
gain_item_cld99(item, amount, include_equip)
if SceneManager.scene_is?(Scene_Map)
text = make_text_item(item, amount)
SceneManager.scene.itemget_set_text(text)
Time.clear_text_reserve
end
end
def make_text_item(item, amount)
gain_lose = amount > 0 ? "获得" : "失去"
sprintf("%s了%d个%s", gain_lose, amount.abs, item.name)
end
#--------------------------------------------------------------------------
# ● 增加/减少持有金钱
#--------------------------------------------------------------------------
alias gain_gold_cld99 gain_gold
def gain_gold(amount)
gain_gold_cld99(amount)
if SceneManager.scene_is?(Scene_Map)
text = make_text_gold(amount)
SceneManager.scene.itemget_set_text(text)
Time.clear_text_reserve
end
end
def make_text_gold(amount)
gain_lose = amount > 0 ? "获得" : "失去"
sprintf("%s了%d%s", gain_lose, amount.abs, Vocab.currency_unit)
end
end
class Time
def self.clear_text_reserve
@now = Time.now
end
def self.should_clear_text?
return false unless @now
(Time.now - @now).to_i >= 1
end
def self.text_cleared
@now = nil
end
end