-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile_scroll.rb
97 lines (96 loc) · 3.96 KB
/
profile_scroll.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#==============================================================================
# ■ プロフィールをスクロール RGSS3 v2.0 MIT License; see git.io/tic
#------------------------------------------------------------------------------
# 3行以上のプロフィールに対応(\nで改行)し、上下スクロールを可能にします。
#==============================================================================
class Window_Description < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, window_height)
self.opacity = 0
end
#--------------------------------------------------------------------------
# ● ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
#--------------------------------------------------------------------------
# ● 表示行数の取得
#--------------------------------------------------------------------------
def visible_line_number
return 2
end
#--------------------------------------------------------------------------
# ● アクターの設定
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@actor ? @actor.description.gsub(/\\n/i, "\r\n").lines.count : 0
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
create_contents
draw_description
end
#--------------------------------------------------------------------------
# ● 説明の描画
#--------------------------------------------------------------------------
def draw_description
draw_text_ex(4, 0, @actor.description.gsub(/\\n/i, "\r\n"))
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
process_scroll
end
#--------------------------------------------------------------------------
# ● スクロール処理
#--------------------------------------------------------------------------
def process_scroll
row = top_row
row -= 1 if Input.repeat?(:UP) && row > 0
row += 1 if Input.repeat?(:DOWN) && row < item_max - visible_line_number
Sound.play_cursor if row != top_row
self.top_row = row
end
end
#------------------------------------------------------------------------------
class Window_Status
#--------------------------------------------------------------------------
# ● 解放【エイリアス】
#--------------------------------------------------------------------------
alias toruic_dispose dispose
def dispose
@description_window.dispose unless disposed?
toruic_dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新【エイリアス】
#--------------------------------------------------------------------------
alias toruic_update update
def update
toruic_update
@description_window.update
end
#--------------------------------------------------------------------------
# ● 説明の描画【※再定義※】
#--------------------------------------------------------------------------
def draw_description(x, y)
@description_window ||= Window_Description.new(x - 4, y, width - (x - 4))
@description_window.actor = @actor
end
end